babylon.max.js 7.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs", [], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs"] = factory();
  8. else
  9. root["BABYLON"] = factory();
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./Legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../node_modules/tslib/tslib.es6.js":
  99. /*!******************************************!*\
  100. !*** ../node_modules/tslib/tslib.es6.js ***!
  101. \******************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../node_modules/webpack/buildin/global.js":
  291. /*!*************************************************!*\
  292. !*** ../node_modules/webpack/buildin/global.js ***!
  293. \*************************************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./Actions/abstractActionManager.ts":
  314. /*!******************************************!*\
  315. !*** ./Actions/abstractActionManager.ts ***!
  316. \******************************************/
  317. /*! exports provided: AbstractActionManager */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractActionManager", function() { return AbstractActionManager; });
  322. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  323. /**
  324. * Abstract class used to decouple action Manager from scene and meshes.
  325. * Do not instantiate.
  326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  327. */
  328. var AbstractActionManager = /** @class */ (function () {
  329. function AbstractActionManager() {
  330. /** Gets the cursor to use when hovering items */
  331. this.hoverCursor = '';
  332. /** Gets the list of actions */
  333. this.actions = new Array();
  334. /**
  335. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  336. */
  337. this.isRecursive = false;
  338. }
  339. Object.defineProperty(AbstractActionManager, "HasTriggers", {
  340. /**
  341. * Does exist one action manager with at least one trigger
  342. **/
  343. get: function () {
  344. for (var t in AbstractActionManager.Triggers) {
  345. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  346. return true;
  347. }
  348. }
  349. return false;
  350. },
  351. enumerable: true,
  352. configurable: true
  353. });
  354. Object.defineProperty(AbstractActionManager, "HasPickTriggers", {
  355. /**
  356. * Does exist one action manager with at least one pick trigger
  357. **/
  358. get: function () {
  359. for (var t in AbstractActionManager.Triggers) {
  360. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  361. var t_int = parseInt(t);
  362. if (t_int >= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickTrigger && t_int <= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickUpTrigger) {
  363. return true;
  364. }
  365. }
  366. }
  367. return false;
  368. },
  369. enumerable: true,
  370. configurable: true
  371. });
  372. /**
  373. * Does exist one action manager that handles actions of a given trigger
  374. * @param trigger defines the trigger to be tested
  375. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  376. **/
  377. AbstractActionManager.HasSpecificTrigger = function (trigger) {
  378. for (var t in AbstractActionManager.Triggers) {
  379. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  380. var t_int = parseInt(t);
  381. if (t_int === trigger) {
  382. return true;
  383. }
  384. }
  385. }
  386. return false;
  387. };
  388. /** Gets the list of active triggers */
  389. AbstractActionManager.Triggers = {};
  390. return AbstractActionManager;
  391. }());
  392. /***/ }),
  393. /***/ "./Actions/action.ts":
  394. /*!***************************!*\
  395. !*** ./Actions/action.ts ***!
  396. \***************************/
  397. /*! exports provided: Action */
  398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  399. "use strict";
  400. __webpack_require__.r(__webpack_exports__);
  401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return Action; });
  402. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  403. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  404. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  405. /**
  406. * The action to be carried out following a trigger
  407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  408. */
  409. var Action = /** @class */ (function () {
  410. /**
  411. * Creates a new Action
  412. * @param triggerOptions the trigger, with or without parameters, for the action
  413. * @param condition an optional determinant of action
  414. */
  415. function Action(
  416. /** the trigger, with or without parameters, for the action */
  417. triggerOptions, condition) {
  418. this.triggerOptions = triggerOptions;
  419. /**
  420. * An event triggered prior to action being executed.
  421. */
  422. this.onBeforeExecuteObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  423. if (triggerOptions.parameter) {
  424. this.trigger = triggerOptions.trigger;
  425. this._triggerParameter = triggerOptions.parameter;
  426. }
  427. else if (triggerOptions.trigger) {
  428. this.trigger = triggerOptions.trigger;
  429. }
  430. else {
  431. this.trigger = triggerOptions;
  432. }
  433. this._nextActiveAction = this;
  434. this._condition = condition;
  435. }
  436. /**
  437. * Internal only
  438. * @hidden
  439. */
  440. Action.prototype._prepare = function () {
  441. };
  442. /**
  443. * Gets the trigger parameters
  444. * @returns the trigger parameters
  445. */
  446. Action.prototype.getTriggerParameter = function () {
  447. return this._triggerParameter;
  448. };
  449. /**
  450. * Internal only - executes current action event
  451. * @hidden
  452. */
  453. Action.prototype._executeCurrent = function (evt) {
  454. if (this._nextActiveAction._condition) {
  455. var condition = this._nextActiveAction._condition;
  456. var currentRenderId = this._actionManager.getScene().getRenderId();
  457. // We cache the current evaluation for the current frame
  458. if (condition._evaluationId === currentRenderId) {
  459. if (!condition._currentResult) {
  460. return;
  461. }
  462. }
  463. else {
  464. condition._evaluationId = currentRenderId;
  465. if (!condition.isValid()) {
  466. condition._currentResult = false;
  467. return;
  468. }
  469. condition._currentResult = true;
  470. }
  471. }
  472. this.onBeforeExecuteObservable.notifyObservers(this);
  473. this._nextActiveAction.execute(evt);
  474. this.skipToNextActiveAction();
  475. };
  476. /**
  477. * Execute placeholder for child classes
  478. * @param evt optional action event
  479. */
  480. Action.prototype.execute = function (evt) {
  481. };
  482. /**
  483. * Skips to next active action
  484. */
  485. Action.prototype.skipToNextActiveAction = function () {
  486. if (this._nextActiveAction._child) {
  487. if (!this._nextActiveAction._child._actionManager) {
  488. this._nextActiveAction._child._actionManager = this._actionManager;
  489. }
  490. this._nextActiveAction = this._nextActiveAction._child;
  491. }
  492. else {
  493. this._nextActiveAction = this;
  494. }
  495. };
  496. /**
  497. * Adds action to chain of actions, may be a DoNothingAction
  498. * @param action defines the next action to execute
  499. * @returns The action passed in
  500. * @see https://www.babylonjs-playground.com/#1T30HR#0
  501. */
  502. Action.prototype.then = function (action) {
  503. this._child = action;
  504. action._actionManager = this._actionManager;
  505. action._prepare();
  506. return action;
  507. };
  508. /**
  509. * Internal only
  510. * @hidden
  511. */
  512. Action.prototype._getProperty = function (propertyPath) {
  513. return this._actionManager._getProperty(propertyPath);
  514. };
  515. /**
  516. * Internal only
  517. * @hidden
  518. */
  519. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  520. return this._actionManager._getEffectiveTarget(target, propertyPath);
  521. };
  522. /**
  523. * Serialize placeholder for child classes
  524. * @param parent of child
  525. * @returns the serialized object
  526. */
  527. Action.prototype.serialize = function (parent) {
  528. };
  529. /**
  530. * Internal only called by serialize
  531. * @hidden
  532. */
  533. Action.prototype._serialize = function (serializedAction, parent) {
  534. var serializationObject = {
  535. type: 1,
  536. children: [],
  537. name: serializedAction.name,
  538. properties: serializedAction.properties || []
  539. };
  540. // Serialize child
  541. if (this._child) {
  542. this._child.serialize(serializationObject);
  543. }
  544. // Check if "this" has a condition
  545. if (this._condition) {
  546. var serializedCondition = this._condition.serialize();
  547. serializedCondition.children.push(serializationObject);
  548. if (parent) {
  549. parent.children.push(serializedCondition);
  550. }
  551. return serializedCondition;
  552. }
  553. if (parent) {
  554. parent.children.push(serializationObject);
  555. }
  556. return serializationObject;
  557. };
  558. /**
  559. * Internal only
  560. * @hidden
  561. */
  562. Action._SerializeValueAsString = function (value) {
  563. if (typeof value === "number") {
  564. return value.toString();
  565. }
  566. if (typeof value === "boolean") {
  567. return value ? "true" : "false";
  568. }
  569. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]) {
  570. return value.x + ", " + value.y;
  571. }
  572. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  573. return value.x + ", " + value.y + ", " + value.z;
  574. }
  575. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  576. return value.r + ", " + value.g + ", " + value.b;
  577. }
  578. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  579. return value.r + ", " + value.g + ", " + value.b + ", " + value.a;
  580. }
  581. return value; // string
  582. };
  583. /**
  584. * Internal only
  585. * @hidden
  586. */
  587. Action._GetTargetProperty = function (target) {
  588. return {
  589. name: "target",
  590. targetType: target._isMesh ? "MeshProperties"
  591. : target._isLight ? "LightProperties"
  592. : target._isCamera ? "CameraProperties"
  593. : "SceneProperties",
  594. value: target._isScene ? "Scene" : target.name
  595. };
  596. };
  597. return Action;
  598. }());
  599. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.Action"] = Action;
  600. /***/ }),
  601. /***/ "./Actions/actionEvent.ts":
  602. /*!********************************!*\
  603. !*** ./Actions/actionEvent.ts ***!
  604. \********************************/
  605. /*! exports provided: ActionEvent */
  606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  607. "use strict";
  608. __webpack_require__.r(__webpack_exports__);
  609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return ActionEvent; });
  610. /**
  611. * ActionEvent is the event being sent when an action is triggered.
  612. */
  613. var ActionEvent = /** @class */ (function () {
  614. /**
  615. * Creates a new ActionEvent
  616. * @param source The mesh or sprite that triggered the action
  617. * @param pointerX The X mouse cursor position at the time of the event
  618. * @param pointerY The Y mouse cursor position at the time of the event
  619. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  620. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  621. * @param additionalData additional data for the event
  622. */
  623. function ActionEvent(
  624. /** The mesh or sprite that triggered the action */
  625. source,
  626. /** The X mouse cursor position at the time of the event */
  627. pointerX,
  628. /** The Y mouse cursor position at the time of the event */
  629. pointerY,
  630. /** The mesh that is currently pointed at (can be null) */
  631. meshUnderPointer,
  632. /** the original (browser) event that triggered the ActionEvent */
  633. sourceEvent,
  634. /** additional data for the event */
  635. additionalData) {
  636. this.source = source;
  637. this.pointerX = pointerX;
  638. this.pointerY = pointerY;
  639. this.meshUnderPointer = meshUnderPointer;
  640. this.sourceEvent = sourceEvent;
  641. this.additionalData = additionalData;
  642. }
  643. /**
  644. * Helper function to auto-create an ActionEvent from a source mesh.
  645. * @param source The source mesh that triggered the event
  646. * @param evt The original (browser) event
  647. * @param additionalData additional data for the event
  648. * @returns the new ActionEvent
  649. */
  650. ActionEvent.CreateNew = function (source, evt, additionalData) {
  651. var scene = source.getScene();
  652. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer || source, evt, additionalData);
  653. };
  654. /**
  655. * Helper function to auto-create an ActionEvent from a source sprite
  656. * @param source The source sprite that triggered the event
  657. * @param scene Scene associated with the sprite
  658. * @param evt The original (browser) event
  659. * @param additionalData additional data for the event
  660. * @returns the new ActionEvent
  661. */
  662. ActionEvent.CreateNewFromSprite = function (source, scene, evt, additionalData) {
  663. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  664. };
  665. /**
  666. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  667. * @param scene the scene where the event occurred
  668. * @param evt The original (browser) event
  669. * @returns the new ActionEvent
  670. */
  671. ActionEvent.CreateNewFromScene = function (scene, evt) {
  672. return new ActionEvent(null, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt);
  673. };
  674. /**
  675. * Helper function to auto-create an ActionEvent from a primitive
  676. * @param prim defines the target primitive
  677. * @param pointerPos defines the pointer position
  678. * @param evt The original (browser) event
  679. * @param additionalData additional data for the event
  680. * @returns the new ActionEvent
  681. */
  682. ActionEvent.CreateNewFromPrimitive = function (prim, pointerPos, evt, additionalData) {
  683. return new ActionEvent(prim, pointerPos.x, pointerPos.y, null, evt, additionalData);
  684. };
  685. return ActionEvent;
  686. }());
  687. /***/ }),
  688. /***/ "./Actions/actionManager.ts":
  689. /*!**********************************!*\
  690. !*** ./Actions/actionManager.ts ***!
  691. \**********************************/
  692. /*! exports provided: ActionManager */
  693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  694. "use strict";
  695. __webpack_require__.r(__webpack_exports__);
  696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return ActionManager; });
  697. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  698. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  699. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  700. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  701. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  702. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  703. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  704. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  705. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  706. /* harmony import */ var _abstractActionManager__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./abstractActionManager */ "./Actions/abstractActionManager.ts");
  707. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  708. /**
  709. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  710. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  712. */
  713. var ActionManager = /** @class */ (function (_super) {
  714. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ActionManager, _super);
  715. /**
  716. * Creates a new action manager
  717. * @param scene defines the hosting scene
  718. */
  719. function ActionManager(scene) {
  720. var _this = _super.call(this) || this;
  721. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  722. scene.actionManagers.push(_this);
  723. return _this;
  724. }
  725. // Methods
  726. /**
  727. * Releases all associated resources
  728. */
  729. ActionManager.prototype.dispose = function () {
  730. var index = this._scene.actionManagers.indexOf(this);
  731. for (var i = 0; i < this.actions.length; i++) {
  732. var action = this.actions[i];
  733. ActionManager.Triggers[action.trigger]--;
  734. if (ActionManager.Triggers[action.trigger] === 0) {
  735. delete ActionManager.Triggers[action.trigger];
  736. }
  737. }
  738. if (index > -1) {
  739. this._scene.actionManagers.splice(index, 1);
  740. }
  741. };
  742. /**
  743. * Gets hosting scene
  744. * @returns the hosting scene
  745. */
  746. ActionManager.prototype.getScene = function () {
  747. return this._scene;
  748. };
  749. /**
  750. * Does this action manager handles actions of any of the given triggers
  751. * @param triggers defines the triggers to be tested
  752. * @return a boolean indicating whether one (or more) of the triggers is handled
  753. */
  754. ActionManager.prototype.hasSpecificTriggers = function (triggers) {
  755. for (var index = 0; index < this.actions.length; index++) {
  756. var action = this.actions[index];
  757. if (triggers.indexOf(action.trigger) > -1) {
  758. return true;
  759. }
  760. }
  761. return false;
  762. };
  763. /**
  764. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  765. * speed.
  766. * @param triggerA defines the trigger to be tested
  767. * @param triggerB defines the trigger to be tested
  768. * @return a boolean indicating whether one (or more) of the triggers is handled
  769. */
  770. ActionManager.prototype.hasSpecificTriggers2 = function (triggerA, triggerB) {
  771. for (var index = 0; index < this.actions.length; index++) {
  772. var action = this.actions[index];
  773. if (triggerA == action.trigger || triggerB == action.trigger) {
  774. return true;
  775. }
  776. }
  777. return false;
  778. };
  779. /**
  780. * Does this action manager handles actions of a given trigger
  781. * @param trigger defines the trigger to be tested
  782. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  783. * @return whether the trigger is handled
  784. */
  785. ActionManager.prototype.hasSpecificTrigger = function (trigger, parameterPredicate) {
  786. for (var index = 0; index < this.actions.length; index++) {
  787. var action = this.actions[index];
  788. if (action.trigger === trigger) {
  789. if (parameterPredicate) {
  790. if (parameterPredicate(action.getTriggerParameter())) {
  791. return true;
  792. }
  793. }
  794. else {
  795. return true;
  796. }
  797. }
  798. }
  799. return false;
  800. };
  801. Object.defineProperty(ActionManager.prototype, "hasPointerTriggers", {
  802. /**
  803. * Does this action manager has pointer triggers
  804. */
  805. get: function () {
  806. for (var index = 0; index < this.actions.length; index++) {
  807. var action = this.actions[index];
  808. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPointerOutTrigger) {
  809. return true;
  810. }
  811. }
  812. return false;
  813. },
  814. enumerable: true,
  815. configurable: true
  816. });
  817. Object.defineProperty(ActionManager.prototype, "hasPickTriggers", {
  818. /**
  819. * Does this action manager has pick triggers
  820. */
  821. get: function () {
  822. for (var index = 0; index < this.actions.length; index++) {
  823. var action = this.actions[index];
  824. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPickUpTrigger) {
  825. return true;
  826. }
  827. }
  828. return false;
  829. },
  830. enumerable: true,
  831. configurable: true
  832. });
  833. /**
  834. * Registers an action to this action manager
  835. * @param action defines the action to be registered
  836. * @return the action amended (prepared) after registration
  837. */
  838. ActionManager.prototype.registerAction = function (action) {
  839. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  840. if (this.getScene().actionManager !== this) {
  841. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  842. return null;
  843. }
  844. }
  845. this.actions.push(action);
  846. if (ActionManager.Triggers[action.trigger]) {
  847. ActionManager.Triggers[action.trigger]++;
  848. }
  849. else {
  850. ActionManager.Triggers[action.trigger] = 1;
  851. }
  852. action._actionManager = this;
  853. action._prepare();
  854. return action;
  855. };
  856. /**
  857. * Unregisters an action to this action manager
  858. * @param action defines the action to be unregistered
  859. * @return a boolean indicating whether the action has been unregistered
  860. */
  861. ActionManager.prototype.unregisterAction = function (action) {
  862. var index = this.actions.indexOf(action);
  863. if (index !== -1) {
  864. this.actions.splice(index, 1);
  865. ActionManager.Triggers[action.trigger] -= 1;
  866. if (ActionManager.Triggers[action.trigger] === 0) {
  867. delete ActionManager.Triggers[action.trigger];
  868. }
  869. delete action._actionManager;
  870. return true;
  871. }
  872. return false;
  873. };
  874. /**
  875. * Process a specific trigger
  876. * @param trigger defines the trigger to process
  877. * @param evt defines the event details to be processed
  878. */
  879. ActionManager.prototype.processTrigger = function (trigger, evt) {
  880. for (var index = 0; index < this.actions.length; index++) {
  881. var action = this.actions[index];
  882. if (action.trigger === trigger) {
  883. if (evt) {
  884. if (trigger === ActionManager.OnKeyUpTrigger
  885. || trigger === ActionManager.OnKeyDownTrigger) {
  886. var parameter = action.getTriggerParameter();
  887. if (parameter && parameter !== evt.sourceEvent.keyCode) {
  888. if (!parameter.toLowerCase) {
  889. continue;
  890. }
  891. var lowerCase = parameter.toLowerCase();
  892. if (lowerCase !== evt.sourceEvent.key) {
  893. var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;
  894. var actualkey = String.fromCharCode(unicode).toLowerCase();
  895. if (actualkey !== lowerCase) {
  896. continue;
  897. }
  898. }
  899. }
  900. }
  901. }
  902. action._executeCurrent(evt);
  903. }
  904. }
  905. };
  906. /** @hidden */
  907. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  908. var properties = propertyPath.split(".");
  909. for (var index = 0; index < properties.length - 1; index++) {
  910. target = target[properties[index]];
  911. }
  912. return target;
  913. };
  914. /** @hidden */
  915. ActionManager.prototype._getProperty = function (propertyPath) {
  916. var properties = propertyPath.split(".");
  917. return properties[properties.length - 1];
  918. };
  919. /**
  920. * Serialize this manager to a JSON object
  921. * @param name defines the property name to store this manager
  922. * @returns a JSON representation of this manager
  923. */
  924. ActionManager.prototype.serialize = function (name) {
  925. var root = {
  926. children: new Array(),
  927. name: name,
  928. type: 3,
  929. properties: new Array() // Empty for root but required
  930. };
  931. for (var i = 0; i < this.actions.length; i++) {
  932. var triggerObject = {
  933. type: 0,
  934. children: new Array(),
  935. name: ActionManager.GetTriggerName(this.actions[i].trigger),
  936. properties: new Array()
  937. };
  938. var triggerOptions = this.actions[i].triggerOptions;
  939. if (triggerOptions && typeof triggerOptions !== "number") {
  940. if (triggerOptions.parameter instanceof Node) {
  941. triggerObject.properties.push(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(triggerOptions.parameter));
  942. }
  943. else {
  944. var parameter = {};
  945. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__["DeepCopier"].DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
  946. if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
  947. parameter._meshId = triggerOptions.parameter.mesh.id;
  948. }
  949. triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
  950. }
  951. }
  952. // Serialize child action, recursively
  953. this.actions[i].serialize(triggerObject);
  954. // Add serialized trigger
  955. root.children.push(triggerObject);
  956. }
  957. return root;
  958. };
  959. /**
  960. * Creates a new ActionManager from a JSON data
  961. * @param parsedActions defines the JSON data to read from
  962. * @param object defines the hosting mesh
  963. * @param scene defines the hosting scene
  964. */
  965. ActionManager.Parse = function (parsedActions, object, scene) {
  966. var actionManager = new ActionManager(scene);
  967. if (object === null) {
  968. scene.actionManager = actionManager;
  969. }
  970. else {
  971. object.actionManager = actionManager;
  972. }
  973. // instanciate a new object
  974. var instanciate = function (name, params) {
  975. var internalClassType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON." + name);
  976. if (internalClassType) {
  977. var newInstance = Object.create(internalClassType.prototype);
  978. newInstance.constructor.apply(newInstance, params);
  979. return newInstance;
  980. }
  981. };
  982. var parseParameter = function (name, value, target, propertyPath) {
  983. if (propertyPath === null) {
  984. // String, boolean or float
  985. var floatValue = parseFloat(value);
  986. if (value === "true" || value === "false") {
  987. return value === "true";
  988. }
  989. else {
  990. return isNaN(floatValue) ? value : floatValue;
  991. }
  992. }
  993. var effectiveTarget = propertyPath.split(".");
  994. var values = value.split(",");
  995. // Get effective Target
  996. for (var i = 0; i < effectiveTarget.length; i++) {
  997. target = target[effectiveTarget[i]];
  998. }
  999. // Return appropriate value with its type
  1000. if (typeof (target) === "boolean") {
  1001. return values[0] === "true";
  1002. }
  1003. if (typeof (target) === "string") {
  1004. return values[0];
  1005. }
  1006. // Parameters with multiple values such as Vector3 etc.
  1007. var split = new Array();
  1008. for (var i = 0; i < values.length; i++) {
  1009. split.push(parseFloat(values[i]));
  1010. }
  1011. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  1012. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(split);
  1013. }
  1014. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]) {
  1015. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"].FromArray(split);
  1016. }
  1017. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  1018. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(split);
  1019. }
  1020. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  1021. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(split);
  1022. }
  1023. return parseFloat(values[0]);
  1024. };
  1025. // traverse graph per trigger
  1026. var traverse = function (parsedAction, trigger, condition, action, combineArray) {
  1027. if (combineArray === void 0) { combineArray = null; }
  1028. if (parsedAction.detached) {
  1029. return;
  1030. }
  1031. var parameters = new Array();
  1032. var target = null;
  1033. var propertyPath = null;
  1034. var combine = parsedAction.combine && parsedAction.combine.length > 0;
  1035. // Parameters
  1036. if (parsedAction.type === 2) {
  1037. parameters.push(actionManager);
  1038. }
  1039. else {
  1040. parameters.push(trigger);
  1041. }
  1042. if (combine) {
  1043. var actions = new Array();
  1044. for (var j = 0; j < parsedAction.combine.length; j++) {
  1045. traverse(parsedAction.combine[j], ActionManager.NothingTrigger, condition, action, actions);
  1046. }
  1047. parameters.push(actions);
  1048. }
  1049. else {
  1050. for (var i = 0; i < parsedAction.properties.length; i++) {
  1051. var value = parsedAction.properties[i].value;
  1052. var name = parsedAction.properties[i].name;
  1053. var targetType = parsedAction.properties[i].targetType;
  1054. if (name === "target") {
  1055. if (targetType !== null && targetType === "SceneProperties") {
  1056. value = target = scene;
  1057. }
  1058. else {
  1059. value = target = scene.getNodeByName(value);
  1060. }
  1061. }
  1062. else if (name === "parent") {
  1063. value = scene.getNodeByName(value);
  1064. }
  1065. else if (name === "sound") {
  1066. // Can not externalize to component, so only checks for the presence off the API.
  1067. if (scene.getSoundByName) {
  1068. value = scene.getSoundByName(value);
  1069. }
  1070. }
  1071. else if (name !== "propertyPath") {
  1072. if (parsedAction.type === 2 && name === "operator") {
  1073. value = _condition__WEBPACK_IMPORTED_MODULE_2__["ValueCondition"][value];
  1074. }
  1075. else {
  1076. value = parseParameter(name, value, target, name === "value" ? propertyPath : null);
  1077. }
  1078. }
  1079. else {
  1080. propertyPath = value;
  1081. }
  1082. parameters.push(value);
  1083. }
  1084. }
  1085. if (combineArray === null) {
  1086. parameters.push(condition);
  1087. }
  1088. else {
  1089. parameters.push(null);
  1090. }
  1091. // If interpolate value action
  1092. if (parsedAction.name === "InterpolateValueAction") {
  1093. var param = parameters[parameters.length - 2];
  1094. parameters[parameters.length - 1] = param;
  1095. parameters[parameters.length - 2] = condition;
  1096. }
  1097. // Action or condition(s) and not CombineAction
  1098. var newAction = instanciate(parsedAction.name, parameters);
  1099. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"] && condition !== null) {
  1100. var nothing = new _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"](trigger, condition);
  1101. if (action) {
  1102. action.then(nothing);
  1103. }
  1104. else {
  1105. actionManager.registerAction(nothing);
  1106. }
  1107. action = nothing;
  1108. }
  1109. if (combineArray === null) {
  1110. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"]) {
  1111. condition = newAction;
  1112. newAction = action;
  1113. }
  1114. else {
  1115. condition = null;
  1116. if (action) {
  1117. action.then(newAction);
  1118. }
  1119. else {
  1120. actionManager.registerAction(newAction);
  1121. }
  1122. }
  1123. }
  1124. else {
  1125. combineArray.push(newAction);
  1126. }
  1127. for (var i = 0; i < parsedAction.children.length; i++) {
  1128. traverse(parsedAction.children[i], trigger, condition, newAction, null);
  1129. }
  1130. };
  1131. // triggers
  1132. for (var i = 0; i < parsedActions.children.length; i++) {
  1133. var triggerParams;
  1134. var trigger = parsedActions.children[i];
  1135. if (trigger.properties.length > 0) {
  1136. var param = trigger.properties[0].value;
  1137. var value = trigger.properties[0].targetType === null ? param : scene.getMeshByName(param);
  1138. if (value._meshId) {
  1139. value.mesh = scene.getMeshByID(value._meshId);
  1140. }
  1141. triggerParams = { trigger: ActionManager[trigger.name], parameter: value };
  1142. }
  1143. else {
  1144. triggerParams = ActionManager[trigger.name];
  1145. }
  1146. for (var j = 0; j < trigger.children.length; j++) {
  1147. if (!trigger.detached) {
  1148. traverse(trigger.children[j], triggerParams, null, null);
  1149. }
  1150. }
  1151. }
  1152. };
  1153. /**
  1154. * Get a trigger name by index
  1155. * @param trigger defines the trigger index
  1156. * @returns a trigger name
  1157. */
  1158. ActionManager.GetTriggerName = function (trigger) {
  1159. switch (trigger) {
  1160. case 0: return "NothingTrigger";
  1161. case 1: return "OnPickTrigger";
  1162. case 2: return "OnLeftPickTrigger";
  1163. case 3: return "OnRightPickTrigger";
  1164. case 4: return "OnCenterPickTrigger";
  1165. case 5: return "OnPickDownTrigger";
  1166. case 6: return "OnPickUpTrigger";
  1167. case 7: return "OnLongPressTrigger";
  1168. case 8: return "OnPointerOverTrigger";
  1169. case 9: return "OnPointerOutTrigger";
  1170. case 10: return "OnEveryFrameTrigger";
  1171. case 11: return "OnIntersectionEnterTrigger";
  1172. case 12: return "OnIntersectionExitTrigger";
  1173. case 13: return "OnKeyDownTrigger";
  1174. case 14: return "OnKeyUpTrigger";
  1175. case 15: return "OnPickOutTrigger";
  1176. default: return "";
  1177. }
  1178. };
  1179. /**
  1180. * Nothing
  1181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1182. */
  1183. ActionManager.NothingTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_NothingTrigger;
  1184. /**
  1185. * On pick
  1186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1187. */
  1188. ActionManager.OnPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickTrigger;
  1189. /**
  1190. * On left pick
  1191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1192. */
  1193. ActionManager.OnLeftPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLeftPickTrigger;
  1194. /**
  1195. * On right pick
  1196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1197. */
  1198. ActionManager.OnRightPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnRightPickTrigger;
  1199. /**
  1200. * On center pick
  1201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1202. */
  1203. ActionManager.OnCenterPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnCenterPickTrigger;
  1204. /**
  1205. * On pick down
  1206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1207. */
  1208. ActionManager.OnPickDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickDownTrigger;
  1209. /**
  1210. * On double pick
  1211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1212. */
  1213. ActionManager.OnDoublePickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnDoublePickTrigger;
  1214. /**
  1215. * On pick up
  1216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1217. */
  1218. ActionManager.OnPickUpTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickUpTrigger;
  1219. /**
  1220. * On pick out.
  1221. * This trigger will only be raised if you also declared a OnPickDown
  1222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1223. */
  1224. ActionManager.OnPickOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickOutTrigger;
  1225. /**
  1226. * On long press
  1227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1228. */
  1229. ActionManager.OnLongPressTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLongPressTrigger;
  1230. /**
  1231. * On pointer over
  1232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1233. */
  1234. ActionManager.OnPointerOverTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOverTrigger;
  1235. /**
  1236. * On pointer out
  1237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1238. */
  1239. ActionManager.OnPointerOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOutTrigger;
  1240. /**
  1241. * On every frame
  1242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1243. */
  1244. ActionManager.OnEveryFrameTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnEveryFrameTrigger;
  1245. /**
  1246. * On intersection enter
  1247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1248. */
  1249. ActionManager.OnIntersectionEnterTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionEnterTrigger;
  1250. /**
  1251. * On intersection exit
  1252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1253. */
  1254. ActionManager.OnIntersectionExitTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionExitTrigger;
  1255. /**
  1256. * On key down
  1257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1258. */
  1259. ActionManager.OnKeyDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnKeyDownTrigger;
  1260. /**
  1261. * On key up
  1262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1263. */
  1264. ActionManager.OnKeyUpTrigger = 15;
  1265. return ActionManager;
  1266. }(_abstractActionManager__WEBPACK_IMPORTED_MODULE_9__["AbstractActionManager"]));
  1267. /***/ }),
  1268. /***/ "./Actions/condition.ts":
  1269. /*!******************************!*\
  1270. !*** ./Actions/condition.ts ***!
  1271. \******************************/
  1272. /*! exports provided: Condition, ValueCondition, PredicateCondition, StateCondition */
  1273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1274. "use strict";
  1275. __webpack_require__.r(__webpack_exports__);
  1276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return Condition; });
  1277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return ValueCondition; });
  1278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return PredicateCondition; });
  1279. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return StateCondition; });
  1280. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1281. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1282. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1283. /**
  1284. * A Condition applied to an Action
  1285. */
  1286. var Condition = /** @class */ (function () {
  1287. /**
  1288. * Creates a new Condition
  1289. * @param actionManager the manager of the action the condition is applied to
  1290. */
  1291. function Condition(actionManager) {
  1292. this._actionManager = actionManager;
  1293. }
  1294. /**
  1295. * Check if the current condition is valid
  1296. * @returns a boolean
  1297. */
  1298. Condition.prototype.isValid = function () {
  1299. return true;
  1300. };
  1301. /**
  1302. * Internal only
  1303. * @hidden
  1304. */
  1305. Condition.prototype._getProperty = function (propertyPath) {
  1306. return this._actionManager._getProperty(propertyPath);
  1307. };
  1308. /**
  1309. * Internal only
  1310. * @hidden
  1311. */
  1312. Condition.prototype._getEffectiveTarget = function (target, propertyPath) {
  1313. return this._actionManager._getEffectiveTarget(target, propertyPath);
  1314. };
  1315. /**
  1316. * Serialize placeholder for child classes
  1317. * @returns the serialized object
  1318. */
  1319. Condition.prototype.serialize = function () {
  1320. };
  1321. /**
  1322. * Internal only
  1323. * @hidden
  1324. */
  1325. Condition.prototype._serialize = function (serializedCondition) {
  1326. return {
  1327. type: 2,
  1328. children: [],
  1329. name: serializedCondition.name,
  1330. properties: serializedCondition.properties
  1331. };
  1332. };
  1333. return Condition;
  1334. }());
  1335. /**
  1336. * Defines specific conditional operators as extensions of Condition
  1337. */
  1338. var ValueCondition = /** @class */ (function (_super) {
  1339. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ValueCondition, _super);
  1340. /**
  1341. * Creates a new ValueCondition
  1342. * @param actionManager manager for the action the condition applies to
  1343. * @param target for the action
  1344. * @param propertyPath path to specify the property of the target the conditional operator uses
  1345. * @param value the value compared by the conditional operator against the current value of the property
  1346. * @param operator the conditional operator, default ValueCondition.IsEqual
  1347. */
  1348. function ValueCondition(actionManager, target,
  1349. /** path to specify the property of the target the conditional operator uses */
  1350. propertyPath,
  1351. /** the value compared by the conditional operator against the current value of the property */
  1352. value,
  1353. /** the conditional operator, default ValueCondition.IsEqual */
  1354. operator) {
  1355. if (operator === void 0) { operator = ValueCondition.IsEqual; }
  1356. var _this = _super.call(this, actionManager) || this;
  1357. _this.propertyPath = propertyPath;
  1358. _this.value = value;
  1359. _this.operator = operator;
  1360. _this._target = target;
  1361. _this._effectiveTarget = _this._getEffectiveTarget(target, _this.propertyPath);
  1362. _this._property = _this._getProperty(_this.propertyPath);
  1363. return _this;
  1364. }
  1365. Object.defineProperty(ValueCondition, "IsEqual", {
  1366. /**
  1367. * returns the number for IsEqual
  1368. */
  1369. get: function () {
  1370. return ValueCondition._IsEqual;
  1371. },
  1372. enumerable: true,
  1373. configurable: true
  1374. });
  1375. Object.defineProperty(ValueCondition, "IsDifferent", {
  1376. /**
  1377. * Returns the number for IsDifferent
  1378. */
  1379. get: function () {
  1380. return ValueCondition._IsDifferent;
  1381. },
  1382. enumerable: true,
  1383. configurable: true
  1384. });
  1385. Object.defineProperty(ValueCondition, "IsGreater", {
  1386. /**
  1387. * Returns the number for IsGreater
  1388. */
  1389. get: function () {
  1390. return ValueCondition._IsGreater;
  1391. },
  1392. enumerable: true,
  1393. configurable: true
  1394. });
  1395. Object.defineProperty(ValueCondition, "IsLesser", {
  1396. /**
  1397. * Returns the number for IsLesser
  1398. */
  1399. get: function () {
  1400. return ValueCondition._IsLesser;
  1401. },
  1402. enumerable: true,
  1403. configurable: true
  1404. });
  1405. /**
  1406. * Compares the given value with the property value for the specified conditional operator
  1407. * @returns the result of the comparison
  1408. */
  1409. ValueCondition.prototype.isValid = function () {
  1410. switch (this.operator) {
  1411. case ValueCondition.IsGreater:
  1412. return this._effectiveTarget[this._property] > this.value;
  1413. case ValueCondition.IsLesser:
  1414. return this._effectiveTarget[this._property] < this.value;
  1415. case ValueCondition.IsEqual:
  1416. case ValueCondition.IsDifferent:
  1417. var check;
  1418. if (this.value.equals) {
  1419. check = this.value.equals(this._effectiveTarget[this._property]);
  1420. }
  1421. else {
  1422. check = this.value === this._effectiveTarget[this._property];
  1423. }
  1424. return this.operator === ValueCondition.IsEqual ? check : !check;
  1425. }
  1426. return false;
  1427. };
  1428. /**
  1429. * Serialize the ValueCondition into a JSON compatible object
  1430. * @returns serialization object
  1431. */
  1432. ValueCondition.prototype.serialize = function () {
  1433. return this._serialize({
  1434. name: "ValueCondition",
  1435. properties: [
  1436. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1437. { name: "propertyPath", value: this.propertyPath },
  1438. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  1439. { name: "operator", value: ValueCondition.GetOperatorName(this.operator) }
  1440. ]
  1441. });
  1442. };
  1443. /**
  1444. * Gets the name of the conditional operator for the ValueCondition
  1445. * @param operator the conditional operator
  1446. * @returns the name
  1447. */
  1448. ValueCondition.GetOperatorName = function (operator) {
  1449. switch (operator) {
  1450. case ValueCondition._IsEqual: return "IsEqual";
  1451. case ValueCondition._IsDifferent: return "IsDifferent";
  1452. case ValueCondition._IsGreater: return "IsGreater";
  1453. case ValueCondition._IsLesser: return "IsLesser";
  1454. default: return "";
  1455. }
  1456. };
  1457. /**
  1458. * Internal only
  1459. * @hidden
  1460. */
  1461. ValueCondition._IsEqual = 0;
  1462. /**
  1463. * Internal only
  1464. * @hidden
  1465. */
  1466. ValueCondition._IsDifferent = 1;
  1467. /**
  1468. * Internal only
  1469. * @hidden
  1470. */
  1471. ValueCondition._IsGreater = 2;
  1472. /**
  1473. * Internal only
  1474. * @hidden
  1475. */
  1476. ValueCondition._IsLesser = 3;
  1477. return ValueCondition;
  1478. }(Condition));
  1479. /**
  1480. * Defines a predicate condition as an extension of Condition
  1481. */
  1482. var PredicateCondition = /** @class */ (function (_super) {
  1483. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PredicateCondition, _super);
  1484. /**
  1485. * Creates a new PredicateCondition
  1486. * @param actionManager manager for the action the condition applies to
  1487. * @param predicate defines the predicate function used to validate the condition
  1488. */
  1489. function PredicateCondition(actionManager,
  1490. /** defines the predicate function used to validate the condition */
  1491. predicate) {
  1492. var _this = _super.call(this, actionManager) || this;
  1493. _this.predicate = predicate;
  1494. return _this;
  1495. }
  1496. /**
  1497. * @returns the validity of the predicate condition
  1498. */
  1499. PredicateCondition.prototype.isValid = function () {
  1500. return this.predicate();
  1501. };
  1502. return PredicateCondition;
  1503. }(Condition));
  1504. /**
  1505. * Defines a state condition as an extension of Condition
  1506. */
  1507. var StateCondition = /** @class */ (function (_super) {
  1508. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StateCondition, _super);
  1509. /**
  1510. * Creates a new StateCondition
  1511. * @param actionManager manager for the action the condition applies to
  1512. * @param target of the condition
  1513. * @param value to compare with target state
  1514. */
  1515. function StateCondition(actionManager, target,
  1516. /** Value to compare with target state */
  1517. value) {
  1518. var _this = _super.call(this, actionManager) || this;
  1519. _this.value = value;
  1520. _this._target = target;
  1521. return _this;
  1522. }
  1523. /**
  1524. * Gets a boolean indicating if the current condition is met
  1525. * @returns the validity of the state
  1526. */
  1527. StateCondition.prototype.isValid = function () {
  1528. return this._target.state === this.value;
  1529. };
  1530. /**
  1531. * Serialize the StateCondition into a JSON compatible object
  1532. * @returns serialization object
  1533. */
  1534. StateCondition.prototype.serialize = function () {
  1535. return this._serialize({
  1536. name: "StateCondition",
  1537. properties: [
  1538. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1539. { name: "value", value: this.value }
  1540. ]
  1541. });
  1542. };
  1543. return StateCondition;
  1544. }(Condition));
  1545. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.ValueCondition"] = ValueCondition;
  1546. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PredicateCondition"] = PredicateCondition;
  1547. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StateCondition"] = StateCondition;
  1548. /***/ }),
  1549. /***/ "./Actions/directActions.ts":
  1550. /*!**********************************!*\
  1551. !*** ./Actions/directActions.ts ***!
  1552. \**********************************/
  1553. /*! exports provided: SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction */
  1554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1555. "use strict";
  1556. __webpack_require__.r(__webpack_exports__);
  1557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return SwitchBooleanAction; });
  1558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return SetStateAction; });
  1559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return SetValueAction; });
  1560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return IncrementValueAction; });
  1561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return PlayAnimationAction; });
  1562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return StopAnimationAction; });
  1563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return DoNothingAction; });
  1564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return CombineAction; });
  1565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return ExecuteCodeAction; });
  1566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return SetParentAction; });
  1567. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1568. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  1569. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  1570. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1571. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  1572. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1573. /**
  1574. * This defines an action responsible to toggle a boolean once triggered.
  1575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1576. */
  1577. var SwitchBooleanAction = /** @class */ (function (_super) {
  1578. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SwitchBooleanAction, _super);
  1579. /**
  1580. * Instantiate the action
  1581. * @param triggerOptions defines the trigger options
  1582. * @param target defines the object containing the boolean
  1583. * @param propertyPath defines the path to the boolean property in the target object
  1584. * @param condition defines the trigger related conditions
  1585. */
  1586. function SwitchBooleanAction(triggerOptions, target, propertyPath, condition) {
  1587. var _this = _super.call(this, triggerOptions, condition) || this;
  1588. _this.propertyPath = propertyPath;
  1589. _this._target = _this._effectiveTarget = target;
  1590. return _this;
  1591. }
  1592. /** @hidden */
  1593. SwitchBooleanAction.prototype._prepare = function () {
  1594. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1595. this._property = this._getProperty(this.propertyPath);
  1596. };
  1597. /**
  1598. * Execute the action toggle the boolean value.
  1599. */
  1600. SwitchBooleanAction.prototype.execute = function () {
  1601. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
  1602. };
  1603. /**
  1604. * Serializes the actions and its related information.
  1605. * @param parent defines the object to serialize in
  1606. * @returns the serialized object
  1607. */
  1608. SwitchBooleanAction.prototype.serialize = function (parent) {
  1609. return _super.prototype._serialize.call(this, {
  1610. name: "SwitchBooleanAction",
  1611. properties: [
  1612. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1613. { name: "propertyPath", value: this.propertyPath }
  1614. ]
  1615. }, parent);
  1616. };
  1617. return SwitchBooleanAction;
  1618. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1619. /**
  1620. * This defines an action responsible to set a the state field of the target
  1621. * to a desired value once triggered.
  1622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1623. */
  1624. var SetStateAction = /** @class */ (function (_super) {
  1625. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetStateAction, _super);
  1626. /**
  1627. * Instantiate the action
  1628. * @param triggerOptions defines the trigger options
  1629. * @param target defines the object containing the state property
  1630. * @param value defines the value to store in the state field
  1631. * @param condition defines the trigger related conditions
  1632. */
  1633. function SetStateAction(triggerOptions, target, value, condition) {
  1634. var _this = _super.call(this, triggerOptions, condition) || this;
  1635. _this.value = value;
  1636. _this._target = target;
  1637. return _this;
  1638. }
  1639. /**
  1640. * Execute the action and store the value on the target state property.
  1641. */
  1642. SetStateAction.prototype.execute = function () {
  1643. this._target.state = this.value;
  1644. };
  1645. /**
  1646. * Serializes the actions and its related information.
  1647. * @param parent defines the object to serialize in
  1648. * @returns the serialized object
  1649. */
  1650. SetStateAction.prototype.serialize = function (parent) {
  1651. return _super.prototype._serialize.call(this, {
  1652. name: "SetStateAction",
  1653. properties: [
  1654. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1655. { name: "value", value: this.value }
  1656. ]
  1657. }, parent);
  1658. };
  1659. return SetStateAction;
  1660. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1661. /**
  1662. * This defines an action responsible to set a property of the target
  1663. * to a desired value once triggered.
  1664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1665. */
  1666. var SetValueAction = /** @class */ (function (_super) {
  1667. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetValueAction, _super);
  1668. /**
  1669. * Instantiate the action
  1670. * @param triggerOptions defines the trigger options
  1671. * @param target defines the object containing the property
  1672. * @param propertyPath defines the path of the property to set in the target
  1673. * @param value defines the value to set in the property
  1674. * @param condition defines the trigger related conditions
  1675. */
  1676. function SetValueAction(triggerOptions, target, propertyPath, value, condition) {
  1677. var _this = _super.call(this, triggerOptions, condition) || this;
  1678. _this.propertyPath = propertyPath;
  1679. _this.value = value;
  1680. _this._target = _this._effectiveTarget = target;
  1681. return _this;
  1682. }
  1683. /** @hidden */
  1684. SetValueAction.prototype._prepare = function () {
  1685. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1686. this._property = this._getProperty(this.propertyPath);
  1687. };
  1688. /**
  1689. * Execute the action and set the targetted property to the desired value.
  1690. */
  1691. SetValueAction.prototype.execute = function () {
  1692. this._effectiveTarget[this._property] = this.value;
  1693. if (this._target.markAsDirty) {
  1694. this._target.markAsDirty(this._property);
  1695. }
  1696. };
  1697. /**
  1698. * Serializes the actions and its related information.
  1699. * @param parent defines the object to serialize in
  1700. * @returns the serialized object
  1701. */
  1702. SetValueAction.prototype.serialize = function (parent) {
  1703. return _super.prototype._serialize.call(this, {
  1704. name: "SetValueAction",
  1705. properties: [
  1706. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1707. { name: "propertyPath", value: this.propertyPath },
  1708. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1709. ]
  1710. }, parent);
  1711. };
  1712. return SetValueAction;
  1713. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1714. /**
  1715. * This defines an action responsible to increment the target value
  1716. * to a desired value once triggered.
  1717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1718. */
  1719. var IncrementValueAction = /** @class */ (function (_super) {
  1720. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IncrementValueAction, _super);
  1721. /**
  1722. * Instantiate the action
  1723. * @param triggerOptions defines the trigger options
  1724. * @param target defines the object containing the property
  1725. * @param propertyPath defines the path of the property to increment in the target
  1726. * @param value defines the value value we should increment the property by
  1727. * @param condition defines the trigger related conditions
  1728. */
  1729. function IncrementValueAction(triggerOptions, target, propertyPath, value, condition) {
  1730. var _this = _super.call(this, triggerOptions, condition) || this;
  1731. _this.propertyPath = propertyPath;
  1732. _this.value = value;
  1733. _this._target = _this._effectiveTarget = target;
  1734. return _this;
  1735. }
  1736. /** @hidden */
  1737. IncrementValueAction.prototype._prepare = function () {
  1738. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1739. this._property = this._getProperty(this.propertyPath);
  1740. if (typeof this._effectiveTarget[this._property] !== "number") {
  1741. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Warning: IncrementValueAction can only be used with number values");
  1742. }
  1743. };
  1744. /**
  1745. * Execute the action and increment the target of the value amount.
  1746. */
  1747. IncrementValueAction.prototype.execute = function () {
  1748. this._effectiveTarget[this._property] += this.value;
  1749. if (this._target.markAsDirty) {
  1750. this._target.markAsDirty(this._property);
  1751. }
  1752. };
  1753. /**
  1754. * Serializes the actions and its related information.
  1755. * @param parent defines the object to serialize in
  1756. * @returns the serialized object
  1757. */
  1758. IncrementValueAction.prototype.serialize = function (parent) {
  1759. return _super.prototype._serialize.call(this, {
  1760. name: "IncrementValueAction",
  1761. properties: [
  1762. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1763. { name: "propertyPath", value: this.propertyPath },
  1764. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1765. ]
  1766. }, parent);
  1767. };
  1768. return IncrementValueAction;
  1769. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1770. /**
  1771. * This defines an action responsible to start an animation once triggered.
  1772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1773. */
  1774. var PlayAnimationAction = /** @class */ (function (_super) {
  1775. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlayAnimationAction, _super);
  1776. /**
  1777. * Instantiate the action
  1778. * @param triggerOptions defines the trigger options
  1779. * @param target defines the target animation or animation name
  1780. * @param from defines from where the animation should start (animation frame)
  1781. * @param end defines where the animation should stop (animation frame)
  1782. * @param loop defines if the animation should loop or stop after the first play
  1783. * @param condition defines the trigger related conditions
  1784. */
  1785. function PlayAnimationAction(triggerOptions, target, from, to, loop, condition) {
  1786. var _this = _super.call(this, triggerOptions, condition) || this;
  1787. _this.from = from;
  1788. _this.to = to;
  1789. _this.loop = loop;
  1790. _this._target = target;
  1791. return _this;
  1792. }
  1793. /** @hidden */
  1794. PlayAnimationAction.prototype._prepare = function () {
  1795. };
  1796. /**
  1797. * Execute the action and play the animation.
  1798. */
  1799. PlayAnimationAction.prototype.execute = function () {
  1800. var scene = this._actionManager.getScene();
  1801. scene.beginAnimation(this._target, this.from, this.to, this.loop);
  1802. };
  1803. /**
  1804. * Serializes the actions and its related information.
  1805. * @param parent defines the object to serialize in
  1806. * @returns the serialized object
  1807. */
  1808. PlayAnimationAction.prototype.serialize = function (parent) {
  1809. return _super.prototype._serialize.call(this, {
  1810. name: "PlayAnimationAction",
  1811. properties: [
  1812. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1813. { name: "from", value: String(this.from) },
  1814. { name: "to", value: String(this.to) },
  1815. { name: "loop", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.loop) || false }
  1816. ]
  1817. }, parent);
  1818. };
  1819. return PlayAnimationAction;
  1820. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1821. /**
  1822. * This defines an action responsible to stop an animation once triggered.
  1823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1824. */
  1825. var StopAnimationAction = /** @class */ (function (_super) {
  1826. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopAnimationAction, _super);
  1827. /**
  1828. * Instantiate the action
  1829. * @param triggerOptions defines the trigger options
  1830. * @param target defines the target animation or animation name
  1831. * @param condition defines the trigger related conditions
  1832. */
  1833. function StopAnimationAction(triggerOptions, target, condition) {
  1834. var _this = _super.call(this, triggerOptions, condition) || this;
  1835. _this._target = target;
  1836. return _this;
  1837. }
  1838. /** @hidden */
  1839. StopAnimationAction.prototype._prepare = function () {
  1840. };
  1841. /**
  1842. * Execute the action and stop the animation.
  1843. */
  1844. StopAnimationAction.prototype.execute = function () {
  1845. var scene = this._actionManager.getScene();
  1846. scene.stopAnimation(this._target);
  1847. };
  1848. /**
  1849. * Serializes the actions and its related information.
  1850. * @param parent defines the object to serialize in
  1851. * @returns the serialized object
  1852. */
  1853. StopAnimationAction.prototype.serialize = function (parent) {
  1854. return _super.prototype._serialize.call(this, {
  1855. name: "StopAnimationAction",
  1856. properties: [_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target)]
  1857. }, parent);
  1858. };
  1859. return StopAnimationAction;
  1860. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1861. /**
  1862. * This defines an action responsible that does nothing once triggered.
  1863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1864. */
  1865. var DoNothingAction = /** @class */ (function (_super) {
  1866. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DoNothingAction, _super);
  1867. /**
  1868. * Instantiate the action
  1869. * @param triggerOptions defines the trigger options
  1870. * @param condition defines the trigger related conditions
  1871. */
  1872. function DoNothingAction(triggerOptions, condition) {
  1873. if (triggerOptions === void 0) { triggerOptions = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger; }
  1874. return _super.call(this, triggerOptions, condition) || this;
  1875. }
  1876. /**
  1877. * Execute the action and do nothing.
  1878. */
  1879. DoNothingAction.prototype.execute = function () {
  1880. };
  1881. /**
  1882. * Serializes the actions and its related information.
  1883. * @param parent defines the object to serialize in
  1884. * @returns the serialized object
  1885. */
  1886. DoNothingAction.prototype.serialize = function (parent) {
  1887. return _super.prototype._serialize.call(this, {
  1888. name: "DoNothingAction",
  1889. properties: []
  1890. }, parent);
  1891. };
  1892. return DoNothingAction;
  1893. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1894. /**
  1895. * This defines an action responsible to trigger several actions once triggered.
  1896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1897. */
  1898. var CombineAction = /** @class */ (function (_super) {
  1899. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CombineAction, _super);
  1900. /**
  1901. * Instantiate the action
  1902. * @param triggerOptions defines the trigger options
  1903. * @param children defines the list of aggregated animations to run
  1904. * @param condition defines the trigger related conditions
  1905. */
  1906. function CombineAction(triggerOptions, children, condition) {
  1907. var _this = _super.call(this, triggerOptions, condition) || this;
  1908. _this.children = children;
  1909. return _this;
  1910. }
  1911. /** @hidden */
  1912. CombineAction.prototype._prepare = function () {
  1913. for (var index = 0; index < this.children.length; index++) {
  1914. this.children[index]._actionManager = this._actionManager;
  1915. this.children[index]._prepare();
  1916. }
  1917. };
  1918. /**
  1919. * Execute the action and executes all the aggregated actions.
  1920. */
  1921. CombineAction.prototype.execute = function (evt) {
  1922. for (var index = 0; index < this.children.length; index++) {
  1923. this.children[index].execute(evt);
  1924. }
  1925. };
  1926. /**
  1927. * Serializes the actions and its related information.
  1928. * @param parent defines the object to serialize in
  1929. * @returns the serialized object
  1930. */
  1931. CombineAction.prototype.serialize = function (parent) {
  1932. var serializationObject = _super.prototype._serialize.call(this, {
  1933. name: "CombineAction",
  1934. properties: [],
  1935. combine: []
  1936. }, parent);
  1937. for (var i = 0; i < this.children.length; i++) {
  1938. serializationObject.combine.push(this.children[i].serialize(null));
  1939. }
  1940. return serializationObject;
  1941. };
  1942. return CombineAction;
  1943. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1944. /**
  1945. * This defines an action responsible to run code (external event) once triggered.
  1946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1947. */
  1948. var ExecuteCodeAction = /** @class */ (function (_super) {
  1949. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExecuteCodeAction, _super);
  1950. /**
  1951. * Instantiate the action
  1952. * @param triggerOptions defines the trigger options
  1953. * @param func defines the callback function to run
  1954. * @param condition defines the trigger related conditions
  1955. */
  1956. function ExecuteCodeAction(triggerOptions, func, condition) {
  1957. var _this = _super.call(this, triggerOptions, condition) || this;
  1958. _this.func = func;
  1959. return _this;
  1960. }
  1961. /**
  1962. * Execute the action and run the attached code.
  1963. */
  1964. ExecuteCodeAction.prototype.execute = function (evt) {
  1965. this.func(evt);
  1966. };
  1967. return ExecuteCodeAction;
  1968. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1969. /**
  1970. * This defines an action responsible to set the parent property of the target once triggered.
  1971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1972. */
  1973. var SetParentAction = /** @class */ (function (_super) {
  1974. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetParentAction, _super);
  1975. /**
  1976. * Instantiate the action
  1977. * @param triggerOptions defines the trigger options
  1978. * @param target defines the target containing the parent property
  1979. * @param parent defines from where the animation should start (animation frame)
  1980. * @param condition defines the trigger related conditions
  1981. */
  1982. function SetParentAction(triggerOptions, target, parent, condition) {
  1983. var _this = _super.call(this, triggerOptions, condition) || this;
  1984. _this._target = target;
  1985. _this._parent = parent;
  1986. return _this;
  1987. }
  1988. /** @hidden */
  1989. SetParentAction.prototype._prepare = function () {
  1990. };
  1991. /**
  1992. * Execute the action and set the parent property.
  1993. */
  1994. SetParentAction.prototype.execute = function () {
  1995. if (this._target.parent === this._parent) {
  1996. return;
  1997. }
  1998. var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
  1999. invertParentWorldMatrix.invert();
  2000. this._target.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this._target.position, invertParentWorldMatrix);
  2001. this._target.parent = this._parent;
  2002. };
  2003. /**
  2004. * Serializes the actions and its related information.
  2005. * @param parent defines the object to serialize in
  2006. * @returns the serialized object
  2007. */
  2008. SetParentAction.prototype.serialize = function (parent) {
  2009. return _super.prototype._serialize.call(this, {
  2010. name: "SetParentAction",
  2011. properties: [
  2012. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  2013. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._parent),
  2014. ]
  2015. }, parent);
  2016. };
  2017. return SetParentAction;
  2018. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  2019. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2020. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.ExecuteCodeAction"] = ExecuteCodeAction;
  2021. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.DoNothingAction"] = DoNothingAction;
  2022. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.StopAnimationAction"] = StopAnimationAction;
  2023. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PlayAnimationAction"] = PlayAnimationAction;
  2024. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.IncrementValueAction"] = IncrementValueAction;
  2025. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetValueAction"] = SetValueAction;
  2026. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetStateAction"] = SetStateAction;
  2027. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2028. /***/ }),
  2029. /***/ "./Actions/directAudioActions.ts":
  2030. /*!***************************************!*\
  2031. !*** ./Actions/directAudioActions.ts ***!
  2032. \***************************************/
  2033. /*! exports provided: PlaySoundAction, StopSoundAction */
  2034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2035. "use strict";
  2036. __webpack_require__.r(__webpack_exports__);
  2037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return PlaySoundAction; });
  2038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return StopSoundAction; });
  2039. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2040. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2041. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2042. /**
  2043. * This defines an action helpful to play a defined sound on a triggered action.
  2044. */
  2045. var PlaySoundAction = /** @class */ (function (_super) {
  2046. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaySoundAction, _super);
  2047. /**
  2048. * Instantiate the action
  2049. * @param triggerOptions defines the trigger options
  2050. * @param sound defines the sound to play
  2051. * @param condition defines the trigger related conditions
  2052. */
  2053. function PlaySoundAction(triggerOptions, sound, condition) {
  2054. var _this = _super.call(this, triggerOptions, condition) || this;
  2055. _this._sound = sound;
  2056. return _this;
  2057. }
  2058. /** @hidden */
  2059. PlaySoundAction.prototype._prepare = function () {
  2060. };
  2061. /**
  2062. * Execute the action and play the sound.
  2063. */
  2064. PlaySoundAction.prototype.execute = function () {
  2065. if (this._sound !== undefined) {
  2066. this._sound.play();
  2067. }
  2068. };
  2069. /**
  2070. * Serializes the actions and its related information.
  2071. * @param parent defines the object to serialize in
  2072. * @returns the serialized object
  2073. */
  2074. PlaySoundAction.prototype.serialize = function (parent) {
  2075. return _super.prototype._serialize.call(this, {
  2076. name: "PlaySoundAction",
  2077. properties: [{ name: "sound", value: this._sound.name }]
  2078. }, parent);
  2079. };
  2080. return PlaySoundAction;
  2081. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2082. /**
  2083. * This defines an action helpful to stop a defined sound on a triggered action.
  2084. */
  2085. var StopSoundAction = /** @class */ (function (_super) {
  2086. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopSoundAction, _super);
  2087. /**
  2088. * Instantiate the action
  2089. * @param triggerOptions defines the trigger options
  2090. * @param sound defines the sound to stop
  2091. * @param condition defines the trigger related conditions
  2092. */
  2093. function StopSoundAction(triggerOptions, sound, condition) {
  2094. var _this = _super.call(this, triggerOptions, condition) || this;
  2095. _this._sound = sound;
  2096. return _this;
  2097. }
  2098. /** @hidden */
  2099. StopSoundAction.prototype._prepare = function () {
  2100. };
  2101. /**
  2102. * Execute the action and stop the sound.
  2103. */
  2104. StopSoundAction.prototype.execute = function () {
  2105. if (this._sound !== undefined) {
  2106. this._sound.stop();
  2107. }
  2108. };
  2109. /**
  2110. * Serializes the actions and its related information.
  2111. * @param parent defines the object to serialize in
  2112. * @returns the serialized object
  2113. */
  2114. StopSoundAction.prototype.serialize = function (parent) {
  2115. return _super.prototype._serialize.call(this, {
  2116. name: "StopSoundAction",
  2117. properties: [{ name: "sound", value: this._sound.name }]
  2118. }, parent);
  2119. };
  2120. return StopSoundAction;
  2121. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2122. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PlaySoundAction"] = StopSoundAction;
  2123. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StopSoundAction"] = StopSoundAction;
  2124. /***/ }),
  2125. /***/ "./Actions/index.ts":
  2126. /*!**************************!*\
  2127. !*** ./Actions/index.ts ***!
  2128. \**************************/
  2129. /*! exports provided: Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction */
  2130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2131. "use strict";
  2132. __webpack_require__.r(__webpack_exports__);
  2133. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _action__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  2135. /* harmony import */ var _actionEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionEvent */ "./Actions/actionEvent.ts");
  2136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _actionEvent__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  2137. /* harmony import */ var _actionManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actionManager */ "./Actions/actionManager.ts");
  2138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _actionManager__WEBPACK_IMPORTED_MODULE_2__["ActionManager"]; });
  2139. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  2140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"]; });
  2141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["ValueCondition"]; });
  2142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["PredicateCondition"]; });
  2143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["StateCondition"]; });
  2144. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  2145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SwitchBooleanAction"]; });
  2146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetStateAction"]; });
  2147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetValueAction"]; });
  2148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["IncrementValueAction"]; });
  2149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["PlayAnimationAction"]; });
  2150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["StopAnimationAction"]; });
  2151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"]; });
  2152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["CombineAction"]; });
  2153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["ExecuteCodeAction"]; });
  2154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetParentAction"]; });
  2155. /* harmony import */ var _directAudioActions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./directAudioActions */ "./Actions/directAudioActions.ts");
  2156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["PlaySoundAction"]; });
  2157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["StopSoundAction"]; });
  2158. /* harmony import */ var _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./interpolateValueAction */ "./Actions/interpolateValueAction.ts");
  2159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__["InterpolateValueAction"]; });
  2160. /***/ }),
  2161. /***/ "./Actions/interpolateValueAction.ts":
  2162. /*!*******************************************!*\
  2163. !*** ./Actions/interpolateValueAction.ts ***!
  2164. \*******************************************/
  2165. /*! exports provided: InterpolateValueAction */
  2166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2167. "use strict";
  2168. __webpack_require__.r(__webpack_exports__);
  2169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return InterpolateValueAction; });
  2170. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2171. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2172. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  2173. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2174. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2175. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  2176. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2177. /**
  2178. * This defines an action responsible to change the value of a property
  2179. * by interpolating between its current value and the newly set one once triggered.
  2180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2181. */
  2182. var InterpolateValueAction = /** @class */ (function (_super) {
  2183. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InterpolateValueAction, _super);
  2184. /**
  2185. * Instantiate the action
  2186. * @param triggerOptions defines the trigger options
  2187. * @param target defines the object containing the value to interpolate
  2188. * @param propertyPath defines the path to the property in the target object
  2189. * @param value defines the target value at the end of the interpolation
  2190. * @param duration deines the time it will take for the property to interpolate to the value.
  2191. * @param condition defines the trigger related conditions
  2192. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  2193. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  2194. */
  2195. function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations, onInterpolationDone) {
  2196. if (duration === void 0) { duration = 1000; }
  2197. var _this = _super.call(this, triggerOptions, condition) || this;
  2198. /**
  2199. * Defines the time it will take for the property to interpolate to the value.
  2200. */
  2201. _this.duration = 1000;
  2202. /**
  2203. * Observable triggered once the interpolation animation has been done.
  2204. */
  2205. _this.onInterpolationDoneObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  2206. _this.propertyPath = propertyPath;
  2207. _this.value = value;
  2208. _this.duration = duration;
  2209. _this.stopOtherAnimations = stopOtherAnimations;
  2210. _this.onInterpolationDone = onInterpolationDone;
  2211. _this._target = _this._effectiveTarget = target;
  2212. return _this;
  2213. }
  2214. /** @hidden */
  2215. InterpolateValueAction.prototype._prepare = function () {
  2216. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  2217. this._property = this._getProperty(this.propertyPath);
  2218. };
  2219. /**
  2220. * Execute the action starts the value interpolation.
  2221. */
  2222. InterpolateValueAction.prototype.execute = function () {
  2223. var _this = this;
  2224. var scene = this._actionManager.getScene();
  2225. var keys = [
  2226. {
  2227. frame: 0,
  2228. value: this._effectiveTarget[this._property]
  2229. }, {
  2230. frame: 100,
  2231. value: this.value
  2232. }
  2233. ];
  2234. var dataType;
  2235. if (typeof this.value === "number") {
  2236. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT;
  2237. }
  2238. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"]) {
  2239. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_COLOR3;
  2240. }
  2241. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"]) {
  2242. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3;
  2243. }
  2244. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]) {
  2245. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_MATRIX;
  2246. }
  2247. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]) {
  2248. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_QUATERNION;
  2249. }
  2250. else {
  2251. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  2252. return;
  2253. }
  2254. var animation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"]("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  2255. animation.setKeys(keys);
  2256. if (this.stopOtherAnimations) {
  2257. scene.stopAnimation(this._effectiveTarget);
  2258. }
  2259. var wrapper = function () {
  2260. _this.onInterpolationDoneObservable.notifyObservers(_this);
  2261. if (_this.onInterpolationDone) {
  2262. _this.onInterpolationDone();
  2263. }
  2264. };
  2265. scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);
  2266. };
  2267. /**
  2268. * Serializes the actions and its related information.
  2269. * @param parent defines the object to serialize in
  2270. * @returns the serialized object
  2271. */
  2272. InterpolateValueAction.prototype.serialize = function (parent) {
  2273. return _super.prototype._serialize.call(this, {
  2274. name: "InterpolateValueAction",
  2275. properties: [
  2276. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  2277. { name: "propertyPath", value: this.propertyPath },
  2278. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  2279. { name: "duration", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.duration) },
  2280. { name: "stopOtherAnimations", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.stopOtherAnimations) || false }
  2281. ]
  2282. }, parent);
  2283. };
  2284. return InterpolateValueAction;
  2285. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2286. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].RegisteredTypes["BABYLON.InterpolateValueAction"] = InterpolateValueAction;
  2287. /***/ }),
  2288. /***/ "./Animations/animatable.ts":
  2289. /*!**********************************!*\
  2290. !*** ./Animations/animatable.ts ***!
  2291. \**********************************/
  2292. /*! exports provided: Animatable */
  2293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2294. "use strict";
  2295. __webpack_require__.r(__webpack_exports__);
  2296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return Animatable; });
  2297. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  2298. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  2299. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2300. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  2301. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2302. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/precisionDate */ "./Misc/precisionDate.ts");
  2303. /* harmony import */ var _Bones_bone__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Bones/bone */ "./Bones/bone.ts");
  2304. /**
  2305. * Class used to store an actual running animation
  2306. */
  2307. var Animatable = /** @class */ (function () {
  2308. /**
  2309. * Creates a new Animatable
  2310. * @param scene defines the hosting scene
  2311. * @param target defines the target object
  2312. * @param fromFrame defines the starting frame number (default is 0)
  2313. * @param toFrame defines the ending frame number (default is 100)
  2314. * @param loopAnimation defines if the animation must loop (default is false)
  2315. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2316. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2317. * @param animations defines a group of animation to add to the new Animatable
  2318. * @param onAnimationLoop defines a callback to call when animation loops
  2319. */
  2320. function Animatable(scene,
  2321. /** defines the target object */
  2322. target,
  2323. /** defines the starting frame number (default is 0) */
  2324. fromFrame,
  2325. /** defines the ending frame number (default is 100) */
  2326. toFrame,
  2327. /** defines if the animation must loop (default is false) */
  2328. loopAnimation, speedRatio,
  2329. /** defines a callback to call when animation ends if it is not looping */
  2330. onAnimationEnd, animations,
  2331. /** defines a callback to call when animation loops */
  2332. onAnimationLoop) {
  2333. if (fromFrame === void 0) { fromFrame = 0; }
  2334. if (toFrame === void 0) { toFrame = 100; }
  2335. if (loopAnimation === void 0) { loopAnimation = false; }
  2336. if (speedRatio === void 0) { speedRatio = 1.0; }
  2337. this.target = target;
  2338. this.fromFrame = fromFrame;
  2339. this.toFrame = toFrame;
  2340. this.loopAnimation = loopAnimation;
  2341. this.onAnimationEnd = onAnimationEnd;
  2342. this.onAnimationLoop = onAnimationLoop;
  2343. this._localDelayOffset = null;
  2344. this._pausedDelay = null;
  2345. this._runtimeAnimations = new Array();
  2346. this._paused = false;
  2347. this._speedRatio = 1;
  2348. this._weight = -1.0;
  2349. /**
  2350. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2351. * This will only apply for non looping animation (default is true)
  2352. */
  2353. this.disposeOnEnd = true;
  2354. /**
  2355. * Gets a boolean indicating if the animation has started
  2356. */
  2357. this.animationStarted = false;
  2358. /**
  2359. * Observer raised when the animation ends
  2360. */
  2361. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2362. /**
  2363. * Observer raised when the animation loops
  2364. */
  2365. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2366. this._scene = scene;
  2367. if (animations) {
  2368. this.appendAnimations(target, animations);
  2369. }
  2370. this._speedRatio = speedRatio;
  2371. scene._activeAnimatables.push(this);
  2372. }
  2373. Object.defineProperty(Animatable.prototype, "syncRoot", {
  2374. /**
  2375. * Gets the root Animatable used to synchronize and normalize animations
  2376. */
  2377. get: function () {
  2378. return this._syncRoot;
  2379. },
  2380. enumerable: true,
  2381. configurable: true
  2382. });
  2383. Object.defineProperty(Animatable.prototype, "masterFrame", {
  2384. /**
  2385. * Gets the current frame of the first RuntimeAnimation
  2386. * Used to synchronize Animatables
  2387. */
  2388. get: function () {
  2389. if (this._runtimeAnimations.length === 0) {
  2390. return 0;
  2391. }
  2392. return this._runtimeAnimations[0].currentFrame;
  2393. },
  2394. enumerable: true,
  2395. configurable: true
  2396. });
  2397. Object.defineProperty(Animatable.prototype, "weight", {
  2398. /**
  2399. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2400. */
  2401. get: function () {
  2402. return this._weight;
  2403. },
  2404. set: function (value) {
  2405. if (value === -1) { // -1 is ok and means no weight
  2406. this._weight = -1;
  2407. return;
  2408. }
  2409. // Else weight must be in [0, 1] range
  2410. this._weight = Math.min(Math.max(value, 0), 1.0);
  2411. },
  2412. enumerable: true,
  2413. configurable: true
  2414. });
  2415. Object.defineProperty(Animatable.prototype, "speedRatio", {
  2416. /**
  2417. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2418. */
  2419. get: function () {
  2420. return this._speedRatio;
  2421. },
  2422. set: function (value) {
  2423. for (var index = 0; index < this._runtimeAnimations.length; index++) {
  2424. var animation = this._runtimeAnimations[index];
  2425. animation._prepareForSpeedRatioChange(value);
  2426. }
  2427. this._speedRatio = value;
  2428. },
  2429. enumerable: true,
  2430. configurable: true
  2431. });
  2432. // Methods
  2433. /**
  2434. * Synchronize and normalize current Animatable with a source Animatable
  2435. * This is useful when using animation weights and when animations are not of the same length
  2436. * @param root defines the root Animatable to synchronize with
  2437. * @returns the current Animatable
  2438. */
  2439. Animatable.prototype.syncWith = function (root) {
  2440. this._syncRoot = root;
  2441. if (root) {
  2442. // Make sure this animatable will animate after the root
  2443. var index = this._scene._activeAnimatables.indexOf(this);
  2444. if (index > -1) {
  2445. this._scene._activeAnimatables.splice(index, 1);
  2446. this._scene._activeAnimatables.push(this);
  2447. }
  2448. }
  2449. return this;
  2450. };
  2451. /**
  2452. * Gets the list of runtime animations
  2453. * @returns an array of RuntimeAnimation
  2454. */
  2455. Animatable.prototype.getAnimations = function () {
  2456. return this._runtimeAnimations;
  2457. };
  2458. /**
  2459. * Adds more animations to the current animatable
  2460. * @param target defines the target of the animations
  2461. * @param animations defines the new animations to add
  2462. */
  2463. Animatable.prototype.appendAnimations = function (target, animations) {
  2464. var _this = this;
  2465. for (var index = 0; index < animations.length; index++) {
  2466. var animation = animations[index];
  2467. var newRuntimeAnimation = new _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__["RuntimeAnimation"](target, animation, this._scene, this);
  2468. newRuntimeAnimation._onLoop = function () {
  2469. _this.onAnimationLoopObservable.notifyObservers(_this);
  2470. if (_this.onAnimationLoop) {
  2471. _this.onAnimationLoop();
  2472. }
  2473. };
  2474. this._runtimeAnimations.push(newRuntimeAnimation);
  2475. }
  2476. };
  2477. /**
  2478. * Gets the source animation for a specific property
  2479. * @param property defines the propertyu to look for
  2480. * @returns null or the source animation for the given property
  2481. */
  2482. Animatable.prototype.getAnimationByTargetProperty = function (property) {
  2483. var runtimeAnimations = this._runtimeAnimations;
  2484. for (var index = 0; index < runtimeAnimations.length; index++) {
  2485. if (runtimeAnimations[index].animation.targetProperty === property) {
  2486. return runtimeAnimations[index].animation;
  2487. }
  2488. }
  2489. return null;
  2490. };
  2491. /**
  2492. * Gets the runtime animation for a specific property
  2493. * @param property defines the propertyu to look for
  2494. * @returns null or the runtime animation for the given property
  2495. */
  2496. Animatable.prototype.getRuntimeAnimationByTargetProperty = function (property) {
  2497. var runtimeAnimations = this._runtimeAnimations;
  2498. for (var index = 0; index < runtimeAnimations.length; index++) {
  2499. if (runtimeAnimations[index].animation.targetProperty === property) {
  2500. return runtimeAnimations[index];
  2501. }
  2502. }
  2503. return null;
  2504. };
  2505. /**
  2506. * Resets the animatable to its original state
  2507. */
  2508. Animatable.prototype.reset = function () {
  2509. var runtimeAnimations = this._runtimeAnimations;
  2510. for (var index = 0; index < runtimeAnimations.length; index++) {
  2511. runtimeAnimations[index].reset(true);
  2512. }
  2513. this._localDelayOffset = null;
  2514. this._pausedDelay = null;
  2515. };
  2516. /**
  2517. * Allows the animatable to blend with current running animations
  2518. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2519. * @param blendingSpeed defines the blending speed to use
  2520. */
  2521. Animatable.prototype.enableBlending = function (blendingSpeed) {
  2522. var runtimeAnimations = this._runtimeAnimations;
  2523. for (var index = 0; index < runtimeAnimations.length; index++) {
  2524. runtimeAnimations[index].animation.enableBlending = true;
  2525. runtimeAnimations[index].animation.blendingSpeed = blendingSpeed;
  2526. }
  2527. };
  2528. /**
  2529. * Disable animation blending
  2530. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2531. */
  2532. Animatable.prototype.disableBlending = function () {
  2533. var runtimeAnimations = this._runtimeAnimations;
  2534. for (var index = 0; index < runtimeAnimations.length; index++) {
  2535. runtimeAnimations[index].animation.enableBlending = false;
  2536. }
  2537. };
  2538. /**
  2539. * Jump directly to a given frame
  2540. * @param frame defines the frame to jump to
  2541. */
  2542. Animatable.prototype.goToFrame = function (frame) {
  2543. var runtimeAnimations = this._runtimeAnimations;
  2544. if (runtimeAnimations[0]) {
  2545. var fps = runtimeAnimations[0].animation.framePerSecond;
  2546. var currentFrame = runtimeAnimations[0].currentFrame;
  2547. var adjustTime = frame - currentFrame;
  2548. var delay = this.speedRatio !== 0 ? adjustTime * 1000 / (fps * this.speedRatio) : 0;
  2549. if (this._localDelayOffset === null) {
  2550. this._localDelayOffset = 0;
  2551. }
  2552. this._localDelayOffset -= delay;
  2553. }
  2554. for (var index = 0; index < runtimeAnimations.length; index++) {
  2555. runtimeAnimations[index].goToFrame(frame);
  2556. }
  2557. };
  2558. /**
  2559. * Pause the animation
  2560. */
  2561. Animatable.prototype.pause = function () {
  2562. if (this._paused) {
  2563. return;
  2564. }
  2565. this._paused = true;
  2566. };
  2567. /**
  2568. * Restart the animation
  2569. */
  2570. Animatable.prototype.restart = function () {
  2571. this._paused = false;
  2572. };
  2573. Animatable.prototype._raiseOnAnimationEnd = function () {
  2574. if (this.onAnimationEnd) {
  2575. this.onAnimationEnd();
  2576. }
  2577. this.onAnimationEndObservable.notifyObservers(this);
  2578. };
  2579. /**
  2580. * Stop and delete the current animation
  2581. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2582. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2583. */
  2584. Animatable.prototype.stop = function (animationName, targetMask) {
  2585. if (animationName || targetMask) {
  2586. var idx = this._scene._activeAnimatables.indexOf(this);
  2587. if (idx > -1) {
  2588. var runtimeAnimations = this._runtimeAnimations;
  2589. for (var index = runtimeAnimations.length - 1; index >= 0; index--) {
  2590. var runtimeAnimation = runtimeAnimations[index];
  2591. if (animationName && runtimeAnimation.animation.name != animationName) {
  2592. continue;
  2593. }
  2594. if (targetMask && !targetMask(runtimeAnimation.target)) {
  2595. continue;
  2596. }
  2597. runtimeAnimation.dispose();
  2598. runtimeAnimations.splice(index, 1);
  2599. }
  2600. if (runtimeAnimations.length == 0) {
  2601. this._scene._activeAnimatables.splice(idx, 1);
  2602. this._raiseOnAnimationEnd();
  2603. }
  2604. }
  2605. }
  2606. else {
  2607. var index = this._scene._activeAnimatables.indexOf(this);
  2608. if (index > -1) {
  2609. this._scene._activeAnimatables.splice(index, 1);
  2610. var runtimeAnimations = this._runtimeAnimations;
  2611. for (var index = 0; index < runtimeAnimations.length; index++) {
  2612. runtimeAnimations[index].dispose();
  2613. }
  2614. this._raiseOnAnimationEnd();
  2615. }
  2616. }
  2617. };
  2618. /**
  2619. * Wait asynchronously for the animation to end
  2620. * @returns a promise which will be fullfilled when the animation ends
  2621. */
  2622. Animatable.prototype.waitAsync = function () {
  2623. var _this = this;
  2624. return new Promise(function (resolve, reject) {
  2625. _this.onAnimationEndObservable.add(function () {
  2626. resolve(_this);
  2627. }, undefined, undefined, _this, true);
  2628. });
  2629. };
  2630. /** @hidden */
  2631. Animatable.prototype._animate = function (delay) {
  2632. if (this._paused) {
  2633. this.animationStarted = false;
  2634. if (this._pausedDelay === null) {
  2635. this._pausedDelay = delay;
  2636. }
  2637. return true;
  2638. }
  2639. if (this._localDelayOffset === null) {
  2640. this._localDelayOffset = delay;
  2641. this._pausedDelay = null;
  2642. }
  2643. else if (this._pausedDelay !== null) {
  2644. this._localDelayOffset += delay - this._pausedDelay;
  2645. this._pausedDelay = null;
  2646. }
  2647. if (this._weight === 0) { // We consider that an animation with a weight === 0 is "actively" paused
  2648. return true;
  2649. }
  2650. // Animating
  2651. var running = false;
  2652. var runtimeAnimations = this._runtimeAnimations;
  2653. var index;
  2654. for (index = 0; index < runtimeAnimations.length; index++) {
  2655. var animation = runtimeAnimations[index];
  2656. var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight);
  2657. running = running || isRunning;
  2658. }
  2659. this.animationStarted = running;
  2660. if (!running) {
  2661. if (this.disposeOnEnd) {
  2662. // Remove from active animatables
  2663. index = this._scene._activeAnimatables.indexOf(this);
  2664. this._scene._activeAnimatables.splice(index, 1);
  2665. // Dispose all runtime animations
  2666. for (index = 0; index < runtimeAnimations.length; index++) {
  2667. runtimeAnimations[index].dispose();
  2668. }
  2669. }
  2670. this._raiseOnAnimationEnd();
  2671. if (this.disposeOnEnd) {
  2672. this.onAnimationEnd = null;
  2673. this.onAnimationLoop = null;
  2674. this.onAnimationLoopObservable.clear();
  2675. this.onAnimationEndObservable.clear();
  2676. }
  2677. }
  2678. return running;
  2679. };
  2680. return Animatable;
  2681. }());
  2682. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._animate = function () {
  2683. if (!this.animationsEnabled) {
  2684. return;
  2685. }
  2686. var animatables = this._activeAnimatables;
  2687. if (animatables.length === 0) {
  2688. return;
  2689. }
  2690. // Getting time
  2691. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__["PrecisionDate"].Now;
  2692. if (!this._animationTimeLast) {
  2693. if (this._pendingData.length > 0) {
  2694. return;
  2695. }
  2696. this._animationTimeLast = now;
  2697. }
  2698. var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
  2699. this._animationTime += deltaTime;
  2700. var animationTime = this._animationTime;
  2701. this._animationTimeLast = now;
  2702. for (var index = 0; index < animatables.length; index++) {
  2703. animatables[index]._animate(animationTime);
  2704. }
  2705. // Late animation bindings
  2706. this._processLateAnimationBindings();
  2707. };
  2708. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
  2709. if (weight === void 0) { weight = 1.0; }
  2710. if (speedRatio === void 0) { speedRatio = 1.0; }
  2711. var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
  2712. returnedAnimatable.weight = weight;
  2713. return returnedAnimatable;
  2714. };
  2715. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2716. if (speedRatio === void 0) { speedRatio = 1.0; }
  2717. if (stopCurrent === void 0) { stopCurrent = true; }
  2718. if (from > to && speedRatio > 0) {
  2719. speedRatio *= -1;
  2720. }
  2721. if (stopCurrent) {
  2722. this.stopAnimation(target, undefined, targetMask);
  2723. }
  2724. if (!animatable) {
  2725. animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
  2726. }
  2727. var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
  2728. // Local animations
  2729. if (target.animations && shouldRunTargetAnimations) {
  2730. animatable.appendAnimations(target, target.animations);
  2731. }
  2732. // Children animations
  2733. if (target.getAnimatables) {
  2734. var animatables = target.getAnimatables();
  2735. for (var index = 0; index < animatables.length; index++) {
  2736. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
  2737. }
  2738. }
  2739. animatable.reset();
  2740. return animatable;
  2741. };
  2742. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2743. if (speedRatio === void 0) { speedRatio = 1.0; }
  2744. if (stopCurrent === void 0) { stopCurrent = true; }
  2745. var children = target.getDescendants(directDescendantsOnly);
  2746. var result = [];
  2747. result.push(this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2748. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  2749. var child = children_1[_i];
  2750. result.push(this.beginAnimation(child, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2751. }
  2752. return result;
  2753. };
  2754. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2755. if (speedRatio === undefined) {
  2756. speedRatio = 1.0;
  2757. }
  2758. var animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
  2759. return animatable;
  2760. };
  2761. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2762. var children = target.getDescendants(directDescendantsOnly);
  2763. var result = [];
  2764. result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2765. for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
  2766. var child = children_2[_i];
  2767. result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2768. }
  2769. return result;
  2770. };
  2771. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAnimatableByTarget = function (target) {
  2772. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2773. if (this._activeAnimatables[index].target === target) {
  2774. return this._activeAnimatables[index];
  2775. }
  2776. }
  2777. return null;
  2778. };
  2779. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAllAnimatablesByTarget = function (target) {
  2780. var result = [];
  2781. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2782. if (this._activeAnimatables[index].target === target) {
  2783. result.push(this._activeAnimatables[index]);
  2784. }
  2785. }
  2786. return result;
  2787. };
  2788. /**
  2789. * Will stop the animation of the given target
  2790. * @param target - the target
  2791. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  2792. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2793. */
  2794. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAnimation = function (target, animationName, targetMask) {
  2795. var animatables = this.getAllAnimatablesByTarget(target);
  2796. for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
  2797. var animatable = animatables_1[_i];
  2798. animatable.stop(animationName, targetMask);
  2799. }
  2800. };
  2801. /**
  2802. * Stops and removes all animations that have been applied to the scene
  2803. */
  2804. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAllAnimations = function () {
  2805. if (this._activeAnimatables) {
  2806. for (var i = 0; i < this._activeAnimatables.length; i++) {
  2807. this._activeAnimatables[i].stop();
  2808. }
  2809. this._activeAnimatables = [];
  2810. }
  2811. for (var _i = 0, _a = this.animationGroups; _i < _a.length; _i++) {
  2812. var group = _a[_i];
  2813. group.stop();
  2814. }
  2815. };
  2816. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._registerTargetForLateAnimationBinding = function (runtimeAnimation, originalValue) {
  2817. var target = runtimeAnimation.target;
  2818. this._registeredForLateAnimationBindings.pushNoDuplicate(target);
  2819. if (!target._lateAnimationHolders) {
  2820. target._lateAnimationHolders = {};
  2821. }
  2822. if (!target._lateAnimationHolders[runtimeAnimation.targetPath]) {
  2823. target._lateAnimationHolders[runtimeAnimation.targetPath] = {
  2824. totalWeight: 0,
  2825. animations: [],
  2826. originalValue: originalValue
  2827. };
  2828. }
  2829. target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
  2830. target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
  2831. };
  2832. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForMatrices = function (holder) {
  2833. var normalizer = 1.0;
  2834. var finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  2835. var finalScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  2836. var finalQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  2837. var startIndex = 0;
  2838. var originalAnimation = holder.animations[0];
  2839. var originalValue = holder.originalValue;
  2840. var scale = 1;
  2841. if (holder.totalWeight < 1.0) {
  2842. // We need to mix the original value in
  2843. originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2844. scale = 1.0 - holder.totalWeight;
  2845. }
  2846. else {
  2847. startIndex = 1;
  2848. // We need to normalize the weights
  2849. normalizer = holder.totalWeight;
  2850. originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2851. scale = originalAnimation.weight / normalizer;
  2852. if (scale == 1) {
  2853. return originalAnimation.currentValue;
  2854. }
  2855. }
  2856. finalScaling.scaleInPlace(scale);
  2857. finalPosition.scaleInPlace(scale);
  2858. finalQuaternion.scaleInPlace(scale);
  2859. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2860. var runtimeAnimation = holder.animations[animIndex];
  2861. var scale = runtimeAnimation.weight / normalizer;
  2862. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[2];
  2863. var currentScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[3];
  2864. var currentQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[1];
  2865. runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
  2866. currentScaling.scaleAndAddToRef(scale, finalScaling);
  2867. currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
  2868. currentPosition.scaleAndAddToRef(scale, finalPosition);
  2869. }
  2870. var workValue = originalAnimation._animationState.workValue;
  2871. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(finalScaling, finalQuaternion, finalPosition, workValue);
  2872. return workValue;
  2873. };
  2874. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForQuaternions = function (holder, refQuaternion) {
  2875. var originalAnimation = holder.animations[0];
  2876. var originalValue = holder.originalValue;
  2877. if (holder.animations.length === 1) {
  2878. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(originalValue, originalAnimation.currentValue, Math.min(1.0, holder.totalWeight), refQuaternion);
  2879. return refQuaternion;
  2880. }
  2881. var normalizer = 1.0;
  2882. var quaternions;
  2883. var weights;
  2884. if (holder.totalWeight < 1.0) {
  2885. var scale = 1.0 - holder.totalWeight;
  2886. quaternions = [];
  2887. weights = [];
  2888. quaternions.push(originalValue);
  2889. weights.push(scale);
  2890. }
  2891. else {
  2892. if (holder.animations.length === 2) { // Slerp as soon as we can
  2893. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
  2894. return refQuaternion;
  2895. }
  2896. quaternions = [];
  2897. weights = [];
  2898. normalizer = holder.totalWeight;
  2899. }
  2900. for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
  2901. var runtimeAnimation = holder.animations[animIndex];
  2902. quaternions.push(runtimeAnimation.currentValue);
  2903. weights.push(runtimeAnimation.weight / normalizer);
  2904. }
  2905. // https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
  2906. var cumulativeAmount = 0;
  2907. var cumulativeQuaternion = null;
  2908. for (var index = 0; index < quaternions.length;) {
  2909. if (!cumulativeQuaternion) {
  2910. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(quaternions[index], quaternions[index + 1], weights[index + 1] / (weights[index] + weights[index + 1]), refQuaternion);
  2911. cumulativeQuaternion = refQuaternion;
  2912. cumulativeAmount = weights[index] + weights[index + 1];
  2913. index += 2;
  2914. continue;
  2915. }
  2916. cumulativeAmount += weights[index];
  2917. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(cumulativeQuaternion, quaternions[index], weights[index] / cumulativeAmount, cumulativeQuaternion);
  2918. index++;
  2919. }
  2920. return cumulativeQuaternion;
  2921. };
  2922. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindings = function () {
  2923. if (!this._registeredForLateAnimationBindings.length) {
  2924. return;
  2925. }
  2926. for (var index = 0; index < this._registeredForLateAnimationBindings.length; index++) {
  2927. var target = this._registeredForLateAnimationBindings.data[index];
  2928. for (var path in target._lateAnimationHolders) {
  2929. var holder = target._lateAnimationHolders[path];
  2930. var originalAnimation = holder.animations[0];
  2931. var originalValue = holder.originalValue;
  2932. var matrixDecomposeMode = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
  2933. var finalValue = target[path];
  2934. if (matrixDecomposeMode) {
  2935. finalValue = this._processLateAnimationBindingsForMatrices(holder);
  2936. }
  2937. else {
  2938. var quaternionMode = originalValue.w !== undefined;
  2939. if (quaternionMode) {
  2940. finalValue = this._processLateAnimationBindingsForQuaternions(holder, finalValue || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity());
  2941. }
  2942. else {
  2943. var startIndex = 0;
  2944. var normalizer = 1.0;
  2945. if (holder.totalWeight < 1.0) {
  2946. // We need to mix the original value in
  2947. if (originalValue.scale) {
  2948. finalValue = originalValue.scale(1.0 - holder.totalWeight);
  2949. }
  2950. else {
  2951. finalValue = originalValue * (1.0 - holder.totalWeight);
  2952. }
  2953. }
  2954. else {
  2955. // We need to normalize the weights
  2956. normalizer = holder.totalWeight;
  2957. var scale_1 = originalAnimation.weight / normalizer;
  2958. if (scale_1 !== 1) {
  2959. if (originalAnimation.currentValue.scale) {
  2960. finalValue = originalAnimation.currentValue.scale(scale_1);
  2961. }
  2962. else {
  2963. finalValue = originalAnimation.currentValue * scale_1;
  2964. }
  2965. }
  2966. else {
  2967. finalValue = originalAnimation.currentValue;
  2968. }
  2969. startIndex = 1;
  2970. }
  2971. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2972. var runtimeAnimation = holder.animations[animIndex];
  2973. var scale = runtimeAnimation.weight / normalizer;
  2974. if (runtimeAnimation.currentValue.scaleAndAddToRef) {
  2975. runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
  2976. }
  2977. else {
  2978. finalValue += runtimeAnimation.currentValue * scale;
  2979. }
  2980. }
  2981. }
  2982. }
  2983. target[path] = finalValue;
  2984. }
  2985. target._lateAnimationHolders = {};
  2986. }
  2987. this._registeredForLateAnimationBindings.reset();
  2988. };
  2989. _Bones_bone__WEBPACK_IMPORTED_MODULE_6__["Bone"].prototype.copyAnimationRange = function (source, rangeName, frameOffset, rescaleAsRequired, skelDimensionsRatio) {
  2990. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  2991. if (skelDimensionsRatio === void 0) { skelDimensionsRatio = null; }
  2992. // all animation may be coming from a library skeleton, so may need to create animation
  2993. if (this.animations.length === 0) {
  2994. this.animations.push(new _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"](this.name, "_matrix", source.animations[0].framePerSecond, _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONTYPE_MATRIX, 0));
  2995. this.animations[0].setKeys([]);
  2996. }
  2997. // get animation info / verify there is such a range from the source bone
  2998. var sourceRange = source.animations[0].getRange(rangeName);
  2999. if (!sourceRange) {
  3000. return false;
  3001. }
  3002. var from = sourceRange.from;
  3003. var to = sourceRange.to;
  3004. var sourceKeys = source.animations[0].getKeys();
  3005. // rescaling prep
  3006. var sourceBoneLength = source.length;
  3007. var sourceParent = source.getParent();
  3008. var parent = this.getParent();
  3009. var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
  3010. var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
  3011. var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
  3012. var destKeys = this.animations[0].getKeys();
  3013. // loop vars declaration
  3014. var orig;
  3015. var origTranslation;
  3016. var mat;
  3017. for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
  3018. orig = sourceKeys[key];
  3019. if (orig.frame >= from && orig.frame <= to) {
  3020. if (rescaleAsRequired) {
  3021. mat = orig.value.clone();
  3022. // scale based on parent ratio, when bone has parent
  3023. if (parentScalingReqd) {
  3024. origTranslation = mat.getTranslation();
  3025. mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
  3026. // scale based on skeleton dimension ratio when root bone, and value is passed
  3027. }
  3028. else if (dimensionsScalingReqd && skelDimensionsRatio) {
  3029. origTranslation = mat.getTranslation();
  3030. mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
  3031. // use original when root bone, and no data for skelDimensionsRatio
  3032. }
  3033. else {
  3034. mat = orig.value;
  3035. }
  3036. }
  3037. else {
  3038. mat = orig.value;
  3039. }
  3040. destKeys.push({ frame: orig.frame + frameOffset, value: mat });
  3041. }
  3042. }
  3043. this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
  3044. return true;
  3045. };
  3046. /***/ }),
  3047. /***/ "./Animations/animation.ts":
  3048. /*!*********************************!*\
  3049. !*** ./Animations/animation.ts ***!
  3050. \*********************************/
  3051. /*! exports provided: _IAnimationState, Animation */
  3052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3053. "use strict";
  3054. __webpack_require__.r(__webpack_exports__);
  3055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IAnimationState", function() { return _IAnimationState; });
  3056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
  3057. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  3058. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  3059. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  3060. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  3061. /* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  3062. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  3063. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  3064. /**
  3065. * @hidden
  3066. */
  3067. var _IAnimationState = /** @class */ (function () {
  3068. function _IAnimationState() {
  3069. }
  3070. return _IAnimationState;
  3071. }());
  3072. /**
  3073. * Class used to store any kind of animation
  3074. */
  3075. var Animation = /** @class */ (function () {
  3076. /**
  3077. * Initializes the animation
  3078. * @param name Name of the animation
  3079. * @param targetProperty Property to animate
  3080. * @param framePerSecond The frames per second of the animation
  3081. * @param dataType The data type of the animation
  3082. * @param loopMode The loop mode of the animation
  3083. * @param enableBlending Specifies if blending should be enabled
  3084. */
  3085. function Animation(
  3086. /**Name of the animation */
  3087. name,
  3088. /**Property to animate */
  3089. targetProperty,
  3090. /**The frames per second of the animation */
  3091. framePerSecond,
  3092. /**The data type of the animation */
  3093. dataType,
  3094. /**The loop mode of the animation */
  3095. loopMode,
  3096. /**Specifies if blending should be enabled */
  3097. enableBlending) {
  3098. this.name = name;
  3099. this.targetProperty = targetProperty;
  3100. this.framePerSecond = framePerSecond;
  3101. this.dataType = dataType;
  3102. this.loopMode = loopMode;
  3103. this.enableBlending = enableBlending;
  3104. /**
  3105. * @hidden Internal use only
  3106. */
  3107. this._runtimeAnimations = new Array();
  3108. /**
  3109. * The set of event that will be linked to this animation
  3110. */
  3111. this._events = new Array();
  3112. /**
  3113. * Stores the blending speed of the animation
  3114. */
  3115. this.blendingSpeed = 0.01;
  3116. /**
  3117. * Stores the animation ranges for the animation
  3118. */
  3119. this._ranges = {};
  3120. this.targetPropertyPath = targetProperty.split(".");
  3121. this.dataType = dataType;
  3122. this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
  3123. }
  3124. /**
  3125. * @hidden Internal use
  3126. */
  3127. Animation._PrepareAnimation = function (name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
  3128. var dataType = undefined;
  3129. if (!isNaN(parseFloat(from)) && isFinite(from)) {
  3130. dataType = Animation.ANIMATIONTYPE_FLOAT;
  3131. }
  3132. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]) {
  3133. dataType = Animation.ANIMATIONTYPE_QUATERNION;
  3134. }
  3135. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  3136. dataType = Animation.ANIMATIONTYPE_VECTOR3;
  3137. }
  3138. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"]) {
  3139. dataType = Animation.ANIMATIONTYPE_VECTOR2;
  3140. }
  3141. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  3142. dataType = Animation.ANIMATIONTYPE_COLOR3;
  3143. }
  3144. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"]) {
  3145. dataType = Animation.ANIMATIONTYPE_SIZE;
  3146. }
  3147. if (dataType == undefined) {
  3148. return null;
  3149. }
  3150. var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
  3151. var keys = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
  3152. animation.setKeys(keys);
  3153. if (easingFunction !== undefined) {
  3154. animation.setEasingFunction(easingFunction);
  3155. }
  3156. return animation;
  3157. };
  3158. /**
  3159. * Sets up an animation
  3160. * @param property The property to animate
  3161. * @param animationType The animation type to apply
  3162. * @param framePerSecond The frames per second of the animation
  3163. * @param easingFunction The easing function used in the animation
  3164. * @returns The created animation
  3165. */
  3166. Animation.CreateAnimation = function (property, animationType, framePerSecond, easingFunction) {
  3167. var animation = new Animation(property + "Animation", property, framePerSecond, animationType, Animation.ANIMATIONLOOPMODE_CONSTANT);
  3168. animation.setEasingFunction(easingFunction);
  3169. return animation;
  3170. };
  3171. /**
  3172. * Create and start an animation on a node
  3173. * @param name defines the name of the global animation that will be run on all nodes
  3174. * @param node defines the root node where the animation will take place
  3175. * @param targetProperty defines property to animate
  3176. * @param framePerSecond defines the number of frame per second yo use
  3177. * @param totalFrame defines the number of frames in total
  3178. * @param from defines the initial value
  3179. * @param to defines the final value
  3180. * @param loopMode defines which loop mode you want to use (off by default)
  3181. * @param easingFunction defines the easing function to use (linear by default)
  3182. * @param onAnimationEnd defines the callback to call when animation end
  3183. * @returns the animatable created for this animation
  3184. */
  3185. Animation.CreateAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3186. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3187. if (!animation) {
  3188. return null;
  3189. }
  3190. return node.getScene().beginDirectAnimation(node, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3191. };
  3192. /**
  3193. * Create and start an animation on a node and its descendants
  3194. * @param name defines the name of the global animation that will be run on all nodes
  3195. * @param node defines the root node where the animation will take place
  3196. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  3197. * @param targetProperty defines property to animate
  3198. * @param framePerSecond defines the number of frame per second to use
  3199. * @param totalFrame defines the number of frames in total
  3200. * @param from defines the initial value
  3201. * @param to defines the final value
  3202. * @param loopMode defines which loop mode you want to use (off by default)
  3203. * @param easingFunction defines the easing function to use (linear by default)
  3204. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3205. * @returns the list of animatables created for all nodes
  3206. * @example https://www.babylonjs-playground.com/#MH0VLI
  3207. */
  3208. Animation.CreateAndStartHierarchyAnimation = function (name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3209. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3210. if (!animation) {
  3211. return null;
  3212. }
  3213. var scene = node.getScene();
  3214. return scene.beginDirectHierarchyAnimation(node, directDescendantsOnly, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3215. };
  3216. /**
  3217. * Creates a new animation, merges it with the existing animations and starts it
  3218. * @param name Name of the animation
  3219. * @param node Node which contains the scene that begins the animations
  3220. * @param targetProperty Specifies which property to animate
  3221. * @param framePerSecond The frames per second of the animation
  3222. * @param totalFrame The total number of frames
  3223. * @param from The frame at the beginning of the animation
  3224. * @param to The frame at the end of the animation
  3225. * @param loopMode Specifies the loop mode of the animation
  3226. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3227. * @param onAnimationEnd Callback to run once the animation is complete
  3228. * @returns Nullable animation
  3229. */
  3230. Animation.CreateMergeAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3231. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3232. if (!animation) {
  3233. return null;
  3234. }
  3235. node.animations.push(animation);
  3236. return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3237. };
  3238. /**
  3239. * Transition property of an host to the target Value
  3240. * @param property The property to transition
  3241. * @param targetValue The target Value of the property
  3242. * @param host The object where the property to animate belongs
  3243. * @param scene Scene used to run the animation
  3244. * @param frameRate Framerate (in frame/s) to use
  3245. * @param transition The transition type we want to use
  3246. * @param duration The duration of the animation, in milliseconds
  3247. * @param onAnimationEnd Callback trigger at the end of the animation
  3248. * @returns Nullable animation
  3249. */
  3250. Animation.TransitionTo = function (property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd) {
  3251. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  3252. if (duration <= 0) {
  3253. host[property] = targetValue;
  3254. if (onAnimationEnd) {
  3255. onAnimationEnd();
  3256. }
  3257. return null;
  3258. }
  3259. var endFrame = frameRate * (duration / 1000);
  3260. transition.setKeys([{
  3261. frame: 0,
  3262. value: host[property].clone ? host[property].clone() : host[property]
  3263. },
  3264. {
  3265. frame: endFrame,
  3266. value: targetValue
  3267. }]);
  3268. if (!host.animations) {
  3269. host.animations = [];
  3270. }
  3271. host.animations.push(transition);
  3272. var animation = scene.beginAnimation(host, 0, endFrame, false);
  3273. animation.onAnimationEnd = onAnimationEnd;
  3274. return animation;
  3275. };
  3276. Object.defineProperty(Animation.prototype, "runtimeAnimations", {
  3277. /**
  3278. * Return the array of runtime animations currently using this animation
  3279. */
  3280. get: function () {
  3281. return this._runtimeAnimations;
  3282. },
  3283. enumerable: true,
  3284. configurable: true
  3285. });
  3286. Object.defineProperty(Animation.prototype, "hasRunningRuntimeAnimations", {
  3287. /**
  3288. * Specifies if any of the runtime animations are currently running
  3289. */
  3290. get: function () {
  3291. for (var _i = 0, _a = this._runtimeAnimations; _i < _a.length; _i++) {
  3292. var runtimeAnimation = _a[_i];
  3293. if (!runtimeAnimation.isStopped) {
  3294. return true;
  3295. }
  3296. }
  3297. return false;
  3298. },
  3299. enumerable: true,
  3300. configurable: true
  3301. });
  3302. // Methods
  3303. /**
  3304. * Converts the animation to a string
  3305. * @param fullDetails support for multiple levels of logging within scene loading
  3306. * @returns String form of the animation
  3307. */
  3308. Animation.prototype.toString = function (fullDetails) {
  3309. var ret = "Name: " + this.name + ", property: " + this.targetProperty;
  3310. ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
  3311. ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
  3312. ret += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  3313. if (fullDetails) {
  3314. ret += ", Ranges: {";
  3315. var first = true;
  3316. for (var name in this._ranges) {
  3317. if (first) {
  3318. ret += ", ";
  3319. first = false;
  3320. }
  3321. ret += name;
  3322. }
  3323. ret += "}";
  3324. }
  3325. return ret;
  3326. };
  3327. /**
  3328. * Add an event to this animation
  3329. * @param event Event to add
  3330. */
  3331. Animation.prototype.addEvent = function (event) {
  3332. this._events.push(event);
  3333. };
  3334. /**
  3335. * Remove all events found at the given frame
  3336. * @param frame The frame to remove events from
  3337. */
  3338. Animation.prototype.removeEvents = function (frame) {
  3339. for (var index = 0; index < this._events.length; index++) {
  3340. if (this._events[index].frame === frame) {
  3341. this._events.splice(index, 1);
  3342. index--;
  3343. }
  3344. }
  3345. };
  3346. /**
  3347. * Retrieves all the events from the animation
  3348. * @returns Events from the animation
  3349. */
  3350. Animation.prototype.getEvents = function () {
  3351. return this._events;
  3352. };
  3353. /**
  3354. * Creates an animation range
  3355. * @param name Name of the animation range
  3356. * @param from Starting frame of the animation range
  3357. * @param to Ending frame of the animation
  3358. */
  3359. Animation.prototype.createRange = function (name, from, to) {
  3360. // check name not already in use; could happen for bones after serialized
  3361. if (!this._ranges[name]) {
  3362. this._ranges[name] = new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  3363. }
  3364. };
  3365. /**
  3366. * Deletes an animation range by name
  3367. * @param name Name of the animation range to delete
  3368. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3369. */
  3370. Animation.prototype.deleteRange = function (name, deleteFrames) {
  3371. if (deleteFrames === void 0) { deleteFrames = true; }
  3372. var range = this._ranges[name];
  3373. if (!range) {
  3374. return;
  3375. }
  3376. if (deleteFrames) {
  3377. var from = range.from;
  3378. var to = range.to;
  3379. // this loop MUST go high to low for multiple splices to work
  3380. for (var key = this._keys.length - 1; key >= 0; key--) {
  3381. if (this._keys[key].frame >= from && this._keys[key].frame <= to) {
  3382. this._keys.splice(key, 1);
  3383. }
  3384. }
  3385. }
  3386. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  3387. };
  3388. /**
  3389. * Gets the animation range by name, or null if not defined
  3390. * @param name Name of the animation range
  3391. * @returns Nullable animation range
  3392. */
  3393. Animation.prototype.getRange = function (name) {
  3394. return this._ranges[name];
  3395. };
  3396. /**
  3397. * Gets the key frames from the animation
  3398. * @returns The key frames of the animation
  3399. */
  3400. Animation.prototype.getKeys = function () {
  3401. return this._keys;
  3402. };
  3403. /**
  3404. * Gets the highest frame rate of the animation
  3405. * @returns Highest frame rate of the animation
  3406. */
  3407. Animation.prototype.getHighestFrame = function () {
  3408. var ret = 0;
  3409. for (var key = 0, nKeys = this._keys.length; key < nKeys; key++) {
  3410. if (ret < this._keys[key].frame) {
  3411. ret = this._keys[key].frame;
  3412. }
  3413. }
  3414. return ret;
  3415. };
  3416. /**
  3417. * Gets the easing function of the animation
  3418. * @returns Easing function of the animation
  3419. */
  3420. Animation.prototype.getEasingFunction = function () {
  3421. return this._easingFunction;
  3422. };
  3423. /**
  3424. * Sets the easing function of the animation
  3425. * @param easingFunction A custom mathematical formula for animation
  3426. */
  3427. Animation.prototype.setEasingFunction = function (easingFunction) {
  3428. this._easingFunction = easingFunction;
  3429. };
  3430. /**
  3431. * Interpolates a scalar linearly
  3432. * @param startValue Start value of the animation curve
  3433. * @param endValue End value of the animation curve
  3434. * @param gradient Scalar amount to interpolate
  3435. * @returns Interpolated scalar value
  3436. */
  3437. Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
  3438. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Lerp(startValue, endValue, gradient);
  3439. };
  3440. /**
  3441. * Interpolates a scalar cubically
  3442. * @param startValue Start value of the animation curve
  3443. * @param outTangent End tangent of the animation
  3444. * @param endValue End value of the animation curve
  3445. * @param inTangent Start tangent of the animation curve
  3446. * @param gradient Scalar amount to interpolate
  3447. * @returns Interpolated scalar value
  3448. */
  3449. Animation.prototype.floatInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3450. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3451. };
  3452. /**
  3453. * Interpolates a quaternion using a spherical linear interpolation
  3454. * @param startValue Start value of the animation curve
  3455. * @param endValue End value of the animation curve
  3456. * @param gradient Scalar amount to interpolate
  3457. * @returns Interpolated quaternion value
  3458. */
  3459. Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
  3460. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Slerp(startValue, endValue, gradient);
  3461. };
  3462. /**
  3463. * Interpolates a quaternion cubically
  3464. * @param startValue Start value of the animation curve
  3465. * @param outTangent End tangent of the animation curve
  3466. * @param endValue End value of the animation curve
  3467. * @param inTangent Start tangent of the animation curve
  3468. * @param gradient Scalar amount to interpolate
  3469. * @returns Interpolated quaternion value
  3470. */
  3471. Animation.prototype.quaternionInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3472. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Hermite(startValue, outTangent, endValue, inTangent, gradient).normalize();
  3473. };
  3474. /**
  3475. * Interpolates a Vector3 linearl
  3476. * @param startValue Start value of the animation curve
  3477. * @param endValue End value of the animation curve
  3478. * @param gradient Scalar amount to interpolate
  3479. * @returns Interpolated scalar value
  3480. */
  3481. Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
  3482. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(startValue, endValue, gradient);
  3483. };
  3484. /**
  3485. * Interpolates a Vector3 cubically
  3486. * @param startValue Start value of the animation curve
  3487. * @param outTangent End tangent of the animation
  3488. * @param endValue End value of the animation curve
  3489. * @param inTangent Start tangent of the animation curve
  3490. * @param gradient Scalar amount to interpolate
  3491. * @returns InterpolatedVector3 value
  3492. */
  3493. Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3494. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3495. };
  3496. /**
  3497. * Interpolates a Vector2 linearly
  3498. * @param startValue Start value of the animation curve
  3499. * @param endValue End value of the animation curve
  3500. * @param gradient Scalar amount to interpolate
  3501. * @returns Interpolated Vector2 value
  3502. */
  3503. Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
  3504. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(startValue, endValue, gradient);
  3505. };
  3506. /**
  3507. * Interpolates a Vector2 cubically
  3508. * @param startValue Start value of the animation curve
  3509. * @param outTangent End tangent of the animation
  3510. * @param endValue End value of the animation curve
  3511. * @param inTangent Start tangent of the animation curve
  3512. * @param gradient Scalar amount to interpolate
  3513. * @returns Interpolated Vector2 value
  3514. */
  3515. Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3516. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3517. };
  3518. /**
  3519. * Interpolates a size linearly
  3520. * @param startValue Start value of the animation curve
  3521. * @param endValue End value of the animation curve
  3522. * @param gradient Scalar amount to interpolate
  3523. * @returns Interpolated Size value
  3524. */
  3525. Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
  3526. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Lerp(startValue, endValue, gradient);
  3527. };
  3528. /**
  3529. * Interpolates a Color3 linearly
  3530. * @param startValue Start value of the animation curve
  3531. * @param endValue End value of the animation curve
  3532. * @param gradient Scalar amount to interpolate
  3533. * @returns Interpolated Color3 value
  3534. */
  3535. Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
  3536. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Lerp(startValue, endValue, gradient);
  3537. };
  3538. /**
  3539. * @hidden Internal use only
  3540. */
  3541. Animation.prototype._getKeyValue = function (value) {
  3542. if (typeof value === "function") {
  3543. return value();
  3544. }
  3545. return value;
  3546. };
  3547. /**
  3548. * @hidden Internal use only
  3549. */
  3550. Animation.prototype._interpolate = function (currentFrame, state) {
  3551. if (state.loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && state.repeatCount > 0) {
  3552. return state.highLimitValue.clone ? state.highLimitValue.clone() : state.highLimitValue;
  3553. }
  3554. var keys = this._keys;
  3555. if (keys.length === 1) {
  3556. return this._getKeyValue(keys[0].value);
  3557. }
  3558. var startKeyIndex = state.key;
  3559. if (keys[startKeyIndex].frame >= currentFrame) {
  3560. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3561. startKeyIndex--;
  3562. }
  3563. }
  3564. for (var key = startKeyIndex; key < keys.length; key++) {
  3565. var endKey = keys[key + 1];
  3566. if (endKey.frame >= currentFrame) {
  3567. state.key = key;
  3568. var startKey = keys[key];
  3569. var startValue = this._getKeyValue(startKey.value);
  3570. if (startKey.interpolation === _animationKey__WEBPACK_IMPORTED_MODULE_4__["AnimationKeyInterpolation"].STEP) {
  3571. return startValue;
  3572. }
  3573. var endValue = this._getKeyValue(endKey.value);
  3574. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3575. var frameDelta = endKey.frame - startKey.frame;
  3576. // gradient : percent of currentFrame between the frame inf and the frame sup
  3577. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3578. // check for easingFunction and correction of gradient
  3579. var easingFunction = this.getEasingFunction();
  3580. if (easingFunction != null) {
  3581. gradient = easingFunction.ease(gradient);
  3582. }
  3583. switch (this.dataType) {
  3584. // Float
  3585. case Animation.ANIMATIONTYPE_FLOAT:
  3586. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3587. switch (state.loopMode) {
  3588. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3589. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3590. return floatValue;
  3591. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3592. return state.offsetValue * state.repeatCount + floatValue;
  3593. }
  3594. break;
  3595. // Quaternion
  3596. case Animation.ANIMATIONTYPE_QUATERNION:
  3597. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3598. switch (state.loopMode) {
  3599. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3600. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3601. return quatValue;
  3602. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3603. return quatValue.addInPlace(state.offsetValue.scale(state.repeatCount));
  3604. }
  3605. return quatValue;
  3606. // Vector3
  3607. case Animation.ANIMATIONTYPE_VECTOR3:
  3608. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3609. switch (state.loopMode) {
  3610. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3611. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3612. return vec3Value;
  3613. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3614. return vec3Value.add(state.offsetValue.scale(state.repeatCount));
  3615. }
  3616. // Vector2
  3617. case Animation.ANIMATIONTYPE_VECTOR2:
  3618. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3619. switch (state.loopMode) {
  3620. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3621. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3622. return vec2Value;
  3623. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3624. return vec2Value.add(state.offsetValue.scale(state.repeatCount));
  3625. }
  3626. // Size
  3627. case Animation.ANIMATIONTYPE_SIZE:
  3628. switch (state.loopMode) {
  3629. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3630. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3631. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3632. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3633. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(state.offsetValue.scale(state.repeatCount));
  3634. }
  3635. // Color3
  3636. case Animation.ANIMATIONTYPE_COLOR3:
  3637. switch (state.loopMode) {
  3638. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3639. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3640. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3641. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3642. return this.color3InterpolateFunction(startValue, endValue, gradient).add(state.offsetValue.scale(state.repeatCount));
  3643. }
  3644. // Matrix
  3645. case Animation.ANIMATIONTYPE_MATRIX:
  3646. switch (state.loopMode) {
  3647. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3648. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3649. if (Animation.AllowMatricesInterpolation) {
  3650. return this.matrixInterpolateFunction(startValue, endValue, gradient, state.workValue);
  3651. }
  3652. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3653. return startValue;
  3654. }
  3655. default:
  3656. break;
  3657. }
  3658. break;
  3659. }
  3660. }
  3661. return this._getKeyValue(keys[keys.length - 1].value);
  3662. };
  3663. /**
  3664. * Defines the function to use to interpolate matrices
  3665. * @param startValue defines the start matrix
  3666. * @param endValue defines the end matrix
  3667. * @param gradient defines the gradient between both matrices
  3668. * @param result defines an optional target matrix where to store the interpolation
  3669. * @returns the interpolated matrix
  3670. */
  3671. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3672. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3673. if (result) {
  3674. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3675. return result;
  3676. }
  3677. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3678. }
  3679. if (result) {
  3680. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3681. return result;
  3682. }
  3683. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3684. };
  3685. /**
  3686. * Makes a copy of the animation
  3687. * @returns Cloned animation
  3688. */
  3689. Animation.prototype.clone = function () {
  3690. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3691. clone.enableBlending = this.enableBlending;
  3692. clone.blendingSpeed = this.blendingSpeed;
  3693. if (this._keys) {
  3694. clone.setKeys(this._keys);
  3695. }
  3696. if (this._ranges) {
  3697. clone._ranges = {};
  3698. for (var name in this._ranges) {
  3699. var range = this._ranges[name];
  3700. if (!range) {
  3701. continue;
  3702. }
  3703. clone._ranges[name] = range.clone();
  3704. }
  3705. }
  3706. return clone;
  3707. };
  3708. /**
  3709. * Sets the key frames of the animation
  3710. * @param values The animation key frames to set
  3711. */
  3712. Animation.prototype.setKeys = function (values) {
  3713. this._keys = values.slice(0);
  3714. };
  3715. /**
  3716. * Serializes the animation to an object
  3717. * @returns Serialized object
  3718. */
  3719. Animation.prototype.serialize = function () {
  3720. var serializationObject = {};
  3721. serializationObject.name = this.name;
  3722. serializationObject.property = this.targetProperty;
  3723. serializationObject.framePerSecond = this.framePerSecond;
  3724. serializationObject.dataType = this.dataType;
  3725. serializationObject.loopBehavior = this.loopMode;
  3726. serializationObject.enableBlending = this.enableBlending;
  3727. serializationObject.blendingSpeed = this.blendingSpeed;
  3728. var dataType = this.dataType;
  3729. serializationObject.keys = [];
  3730. var keys = this.getKeys();
  3731. for (var index = 0; index < keys.length; index++) {
  3732. var animationKey = keys[index];
  3733. var key = {};
  3734. key.frame = animationKey.frame;
  3735. switch (dataType) {
  3736. case Animation.ANIMATIONTYPE_FLOAT:
  3737. key.values = [animationKey.value];
  3738. break;
  3739. case Animation.ANIMATIONTYPE_QUATERNION:
  3740. case Animation.ANIMATIONTYPE_MATRIX:
  3741. case Animation.ANIMATIONTYPE_VECTOR3:
  3742. case Animation.ANIMATIONTYPE_COLOR3:
  3743. key.values = animationKey.value.asArray();
  3744. break;
  3745. }
  3746. serializationObject.keys.push(key);
  3747. }
  3748. serializationObject.ranges = [];
  3749. for (var name in this._ranges) {
  3750. var source = this._ranges[name];
  3751. if (!source) {
  3752. continue;
  3753. }
  3754. var range = {};
  3755. range.name = name;
  3756. range.from = source.from;
  3757. range.to = source.to;
  3758. serializationObject.ranges.push(range);
  3759. }
  3760. return serializationObject;
  3761. };
  3762. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3763. /**
  3764. * Get the float animation type
  3765. */
  3766. get: function () {
  3767. return Animation._ANIMATIONTYPE_FLOAT;
  3768. },
  3769. enumerable: true,
  3770. configurable: true
  3771. });
  3772. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3773. /**
  3774. * Get the Vector3 animation type
  3775. */
  3776. get: function () {
  3777. return Animation._ANIMATIONTYPE_VECTOR3;
  3778. },
  3779. enumerable: true,
  3780. configurable: true
  3781. });
  3782. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3783. /**
  3784. * Get the Vector2 animation type
  3785. */
  3786. get: function () {
  3787. return Animation._ANIMATIONTYPE_VECTOR2;
  3788. },
  3789. enumerable: true,
  3790. configurable: true
  3791. });
  3792. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3793. /**
  3794. * Get the Size animation type
  3795. */
  3796. get: function () {
  3797. return Animation._ANIMATIONTYPE_SIZE;
  3798. },
  3799. enumerable: true,
  3800. configurable: true
  3801. });
  3802. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3803. /**
  3804. * Get the Quaternion animation type
  3805. */
  3806. get: function () {
  3807. return Animation._ANIMATIONTYPE_QUATERNION;
  3808. },
  3809. enumerable: true,
  3810. configurable: true
  3811. });
  3812. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3813. /**
  3814. * Get the Matrix animation type
  3815. */
  3816. get: function () {
  3817. return Animation._ANIMATIONTYPE_MATRIX;
  3818. },
  3819. enumerable: true,
  3820. configurable: true
  3821. });
  3822. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3823. /**
  3824. * Get the Color3 animation type
  3825. */
  3826. get: function () {
  3827. return Animation._ANIMATIONTYPE_COLOR3;
  3828. },
  3829. enumerable: true,
  3830. configurable: true
  3831. });
  3832. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3833. /**
  3834. * Get the Relative Loop Mode
  3835. */
  3836. get: function () {
  3837. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3838. },
  3839. enumerable: true,
  3840. configurable: true
  3841. });
  3842. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3843. /**
  3844. * Get the Cycle Loop Mode
  3845. */
  3846. get: function () {
  3847. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3848. },
  3849. enumerable: true,
  3850. configurable: true
  3851. });
  3852. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3853. /**
  3854. * Get the Constant Loop Mode
  3855. */
  3856. get: function () {
  3857. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3858. },
  3859. enumerable: true,
  3860. configurable: true
  3861. });
  3862. /** @hidden */
  3863. Animation._UniversalLerp = function (left, right, amount) {
  3864. var constructor = left.constructor;
  3865. if (constructor.Lerp) { // Lerp supported
  3866. return constructor.Lerp(left, right, amount);
  3867. }
  3868. else if (constructor.Slerp) { // Slerp supported
  3869. return constructor.Slerp(left, right, amount);
  3870. }
  3871. else if (left.toFixed) { // Number
  3872. return left * (1.0 - amount) + amount * right;
  3873. }
  3874. else { // Blending not supported
  3875. return right;
  3876. }
  3877. };
  3878. /**
  3879. * Parses an animation object and creates an animation
  3880. * @param parsedAnimation Parsed animation object
  3881. * @returns Animation object
  3882. */
  3883. Animation.Parse = function (parsedAnimation) {
  3884. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3885. var dataType = parsedAnimation.dataType;
  3886. var keys = [];
  3887. var data;
  3888. var index;
  3889. if (parsedAnimation.enableBlending) {
  3890. animation.enableBlending = parsedAnimation.enableBlending;
  3891. }
  3892. if (parsedAnimation.blendingSpeed) {
  3893. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3894. }
  3895. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3896. var key = parsedAnimation.keys[index];
  3897. var inTangent;
  3898. var outTangent;
  3899. switch (dataType) {
  3900. case Animation.ANIMATIONTYPE_FLOAT:
  3901. data = key.values[0];
  3902. if (key.values.length >= 1) {
  3903. inTangent = key.values[1];
  3904. }
  3905. if (key.values.length >= 2) {
  3906. outTangent = key.values[2];
  3907. }
  3908. break;
  3909. case Animation.ANIMATIONTYPE_QUATERNION:
  3910. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3911. if (key.values.length >= 8) {
  3912. var _inTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3913. if (!_inTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3914. inTangent = _inTangent;
  3915. }
  3916. }
  3917. if (key.values.length >= 12) {
  3918. var _outTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3919. if (!_outTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3920. outTangent = _outTangent;
  3921. }
  3922. }
  3923. break;
  3924. case Animation.ANIMATIONTYPE_MATRIX:
  3925. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3926. break;
  3927. case Animation.ANIMATIONTYPE_COLOR3:
  3928. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(key.values);
  3929. break;
  3930. case Animation.ANIMATIONTYPE_VECTOR3:
  3931. default:
  3932. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3933. break;
  3934. }
  3935. var keyData = {};
  3936. keyData.frame = key.frame;
  3937. keyData.value = data;
  3938. if (inTangent != undefined) {
  3939. keyData.inTangent = inTangent;
  3940. }
  3941. if (outTangent != undefined) {
  3942. keyData.outTangent = outTangent;
  3943. }
  3944. keys.push(keyData);
  3945. }
  3946. animation.setKeys(keys);
  3947. if (parsedAnimation.ranges) {
  3948. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3949. data = parsedAnimation.ranges[index];
  3950. animation.createRange(data.name, data.from, data.to);
  3951. }
  3952. }
  3953. return animation;
  3954. };
  3955. /**
  3956. * Appends the serialized animations from the source animations
  3957. * @param source Source containing the animations
  3958. * @param destination Target to store the animations
  3959. */
  3960. Animation.AppendSerializedAnimations = function (source, destination) {
  3961. _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3962. };
  3963. /**
  3964. * Use matrix interpolation instead of using direct key value when animating matrices
  3965. */
  3966. Animation.AllowMatricesInterpolation = false;
  3967. /**
  3968. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3969. */
  3970. Animation.AllowMatrixDecomposeForInterpolation = true;
  3971. // Statics
  3972. /**
  3973. * Float animation type
  3974. */
  3975. Animation._ANIMATIONTYPE_FLOAT = 0;
  3976. /**
  3977. * Vector3 animation type
  3978. */
  3979. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3980. /**
  3981. * Quaternion animation type
  3982. */
  3983. Animation._ANIMATIONTYPE_QUATERNION = 2;
  3984. /**
  3985. * Matrix animation type
  3986. */
  3987. Animation._ANIMATIONTYPE_MATRIX = 3;
  3988. /**
  3989. * Color3 animation type
  3990. */
  3991. Animation._ANIMATIONTYPE_COLOR3 = 4;
  3992. /**
  3993. * Vector2 animation type
  3994. */
  3995. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  3996. /**
  3997. * Size animation type
  3998. */
  3999. Animation._ANIMATIONTYPE_SIZE = 6;
  4000. /**
  4001. * Relative Loop Mode
  4002. */
  4003. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  4004. /**
  4005. * Cycle Loop Mode
  4006. */
  4007. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  4008. /**
  4009. * Constant Loop Mode
  4010. */
  4011. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  4012. return Animation;
  4013. }());
  4014. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Animation"] = Animation;
  4015. _node__WEBPACK_IMPORTED_MODULE_6__["Node"]._AnimationRangeFactory = function (name, from, to) { return new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to); };
  4016. /***/ }),
  4017. /***/ "./Animations/animationEvent.ts":
  4018. /*!**************************************!*\
  4019. !*** ./Animations/animationEvent.ts ***!
  4020. \**************************************/
  4021. /*! exports provided: AnimationEvent */
  4022. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4023. "use strict";
  4024. __webpack_require__.r(__webpack_exports__);
  4025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  4026. /**
  4027. * Composed of a frame, and an action function
  4028. */
  4029. var AnimationEvent = /** @class */ (function () {
  4030. /**
  4031. * Initializes the animation event
  4032. * @param frame The frame for which the event is triggered
  4033. * @param action The event to perform when triggered
  4034. * @param onlyOnce Specifies if the event should be triggered only once
  4035. */
  4036. function AnimationEvent(
  4037. /** The frame for which the event is triggered **/
  4038. frame,
  4039. /** The event to perform when triggered **/
  4040. action,
  4041. /** Specifies if the event should be triggered only once**/
  4042. onlyOnce) {
  4043. this.frame = frame;
  4044. this.action = action;
  4045. this.onlyOnce = onlyOnce;
  4046. /**
  4047. * Specifies if the animation event is done
  4048. */
  4049. this.isDone = false;
  4050. }
  4051. /** @hidden */
  4052. AnimationEvent.prototype._clone = function () {
  4053. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  4054. };
  4055. return AnimationEvent;
  4056. }());
  4057. /***/ }),
  4058. /***/ "./Animations/animationGroup.ts":
  4059. /*!**************************************!*\
  4060. !*** ./Animations/animationGroup.ts ***!
  4061. \**************************************/
  4062. /*! exports provided: TargetedAnimation, AnimationGroup */
  4063. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4064. "use strict";
  4065. __webpack_require__.r(__webpack_exports__);
  4066. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  4067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  4068. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4069. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  4070. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  4071. /**
  4072. * This class defines the direct association between an animation and a target
  4073. */
  4074. var TargetedAnimation = /** @class */ (function () {
  4075. function TargetedAnimation() {
  4076. }
  4077. return TargetedAnimation;
  4078. }());
  4079. /**
  4080. * Use this class to create coordinated animations on multiple targets
  4081. */
  4082. var AnimationGroup = /** @class */ (function () {
  4083. /**
  4084. * Instantiates a new Animation Group.
  4085. * This helps managing several animations at once.
  4086. * @see http://doc.babylonjs.com/how_to/group
  4087. * @param name Defines the name of the group
  4088. * @param scene Defines the scene the group belongs to
  4089. */
  4090. function AnimationGroup(
  4091. /** The name of the animation group */
  4092. name, scene) {
  4093. if (scene === void 0) { scene = null; }
  4094. this.name = name;
  4095. this._targetedAnimations = new Array();
  4096. this._animatables = new Array();
  4097. this._from = Number.MAX_VALUE;
  4098. this._to = -Number.MAX_VALUE;
  4099. this._speedRatio = 1;
  4100. /**
  4101. * This observable will notify when one animation have ended
  4102. */
  4103. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4104. /**
  4105. * Observer raised when one animation loops
  4106. */
  4107. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4108. /**
  4109. * This observable will notify when all animations have ended.
  4110. */
  4111. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4112. /**
  4113. * This observable will notify when all animations have paused.
  4114. */
  4115. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4116. /**
  4117. * This observable will notify when all animations are playing.
  4118. */
  4119. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4120. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  4121. this.uniqueId = this._scene.getUniqueId();
  4122. this._scene.animationGroups.push(this);
  4123. }
  4124. Object.defineProperty(AnimationGroup.prototype, "from", {
  4125. /**
  4126. * Gets the first frame
  4127. */
  4128. get: function () {
  4129. return this._from;
  4130. },
  4131. enumerable: true,
  4132. configurable: true
  4133. });
  4134. Object.defineProperty(AnimationGroup.prototype, "to", {
  4135. /**
  4136. * Gets the last frame
  4137. */
  4138. get: function () {
  4139. return this._to;
  4140. },
  4141. enumerable: true,
  4142. configurable: true
  4143. });
  4144. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  4145. /**
  4146. * Define if the animations are started
  4147. */
  4148. get: function () {
  4149. return this._isStarted;
  4150. },
  4151. enumerable: true,
  4152. configurable: true
  4153. });
  4154. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  4155. /**
  4156. * Gets a value indicating that the current group is playing
  4157. */
  4158. get: function () {
  4159. return this._isStarted && !this._isPaused;
  4160. },
  4161. enumerable: true,
  4162. configurable: true
  4163. });
  4164. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  4165. /**
  4166. * Gets or sets the speed ratio to use for all animations
  4167. */
  4168. get: function () {
  4169. return this._speedRatio;
  4170. },
  4171. /**
  4172. * Gets or sets the speed ratio to use for all animations
  4173. */
  4174. set: function (value) {
  4175. if (this._speedRatio === value) {
  4176. return;
  4177. }
  4178. this._speedRatio = value;
  4179. for (var index = 0; index < this._animatables.length; index++) {
  4180. var animatable = this._animatables[index];
  4181. animatable.speedRatio = this._speedRatio;
  4182. }
  4183. },
  4184. enumerable: true,
  4185. configurable: true
  4186. });
  4187. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  4188. /**
  4189. * Gets the targeted animations for this animation group
  4190. */
  4191. get: function () {
  4192. return this._targetedAnimations;
  4193. },
  4194. enumerable: true,
  4195. configurable: true
  4196. });
  4197. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  4198. /**
  4199. * returning the list of animatables controlled by this animation group.
  4200. */
  4201. get: function () {
  4202. return this._animatables;
  4203. },
  4204. enumerable: true,
  4205. configurable: true
  4206. });
  4207. /**
  4208. * Add an animation (with its target) in the group
  4209. * @param animation defines the animation we want to add
  4210. * @param target defines the target of the animation
  4211. * @returns the TargetedAnimation object
  4212. */
  4213. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  4214. var targetedAnimation = {
  4215. animation: animation,
  4216. target: target
  4217. };
  4218. var keys = animation.getKeys();
  4219. if (this._from > keys[0].frame) {
  4220. this._from = keys[0].frame;
  4221. }
  4222. if (this._to < keys[keys.length - 1].frame) {
  4223. this._to = keys[keys.length - 1].frame;
  4224. }
  4225. this._targetedAnimations.push(targetedAnimation);
  4226. return targetedAnimation;
  4227. };
  4228. /**
  4229. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4230. * It can add constant keys at begin or end
  4231. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4232. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4233. * @returns the animation group
  4234. */
  4235. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  4236. if (beginFrame === void 0) { beginFrame = null; }
  4237. if (endFrame === void 0) { endFrame = null; }
  4238. if (beginFrame == null) {
  4239. beginFrame = this._from;
  4240. }
  4241. if (endFrame == null) {
  4242. endFrame = this._to;
  4243. }
  4244. for (var index = 0; index < this._targetedAnimations.length; index++) {
  4245. var targetedAnimation = this._targetedAnimations[index];
  4246. var keys = targetedAnimation.animation.getKeys();
  4247. var startKey = keys[0];
  4248. var endKey = keys[keys.length - 1];
  4249. if (startKey.frame > beginFrame) {
  4250. var newKey = {
  4251. frame: beginFrame,
  4252. value: startKey.value,
  4253. inTangent: startKey.inTangent,
  4254. outTangent: startKey.outTangent,
  4255. interpolation: startKey.interpolation
  4256. };
  4257. keys.splice(0, 0, newKey);
  4258. }
  4259. if (endKey.frame < endFrame) {
  4260. var newKey = {
  4261. frame: endFrame,
  4262. value: endKey.value,
  4263. inTangent: endKey.outTangent,
  4264. outTangent: endKey.outTangent,
  4265. interpolation: endKey.interpolation
  4266. };
  4267. keys.push(newKey);
  4268. }
  4269. }
  4270. this._from = beginFrame;
  4271. this._to = endFrame;
  4272. return this;
  4273. };
  4274. /**
  4275. * Start all animations on given targets
  4276. * @param loop defines if animations must loop
  4277. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4278. * @param from defines the from key (optional)
  4279. * @param to defines the to key (optional)
  4280. * @returns the current animation group
  4281. */
  4282. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4283. var _this = this;
  4284. if (loop === void 0) { loop = false; }
  4285. if (speedRatio === void 0) { speedRatio = 1; }
  4286. if (this._isStarted || this._targetedAnimations.length === 0) {
  4287. return this;
  4288. }
  4289. var _loop_1 = function (targetedAnimation) {
  4290. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4291. animatable.onAnimationEnd = function () {
  4292. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4293. _this._checkAnimationGroupEnded(animatable);
  4294. };
  4295. animatable.onAnimationLoop = function () {
  4296. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4297. };
  4298. this_1._animatables.push(animatable);
  4299. };
  4300. var this_1 = this;
  4301. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4302. var targetedAnimation = _a[_i];
  4303. _loop_1(targetedAnimation);
  4304. }
  4305. this._speedRatio = speedRatio;
  4306. if (from !== undefined && to !== undefined && from > to && this._speedRatio > 0) {
  4307. this._speedRatio = -speedRatio;
  4308. }
  4309. this._isStarted = true;
  4310. this._isPaused = false;
  4311. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4312. return this;
  4313. };
  4314. /**
  4315. * Pause all animations
  4316. * @returns the animation group
  4317. */
  4318. AnimationGroup.prototype.pause = function () {
  4319. if (!this._isStarted) {
  4320. return this;
  4321. }
  4322. this._isPaused = true;
  4323. for (var index = 0; index < this._animatables.length; index++) {
  4324. var animatable = this._animatables[index];
  4325. animatable.pause();
  4326. }
  4327. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4328. return this;
  4329. };
  4330. /**
  4331. * Play all animations to initial state
  4332. * This function will start() the animations if they were not started or will restart() them if they were paused
  4333. * @param loop defines if animations must loop
  4334. * @returns the animation group
  4335. */
  4336. AnimationGroup.prototype.play = function (loop) {
  4337. // only if all animatables are ready and exist
  4338. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4339. if (loop !== undefined) {
  4340. for (var index = 0; index < this._animatables.length; index++) {
  4341. var animatable = this._animatables[index];
  4342. animatable.loopAnimation = loop;
  4343. }
  4344. }
  4345. this.restart();
  4346. }
  4347. else {
  4348. this.stop();
  4349. this.start(loop, this._speedRatio);
  4350. }
  4351. this._isPaused = false;
  4352. return this;
  4353. };
  4354. /**
  4355. * Reset all animations to initial state
  4356. * @returns the animation group
  4357. */
  4358. AnimationGroup.prototype.reset = function () {
  4359. if (!this._isStarted) {
  4360. return this;
  4361. }
  4362. for (var index = 0; index < this._animatables.length; index++) {
  4363. var animatable = this._animatables[index];
  4364. animatable.reset();
  4365. }
  4366. return this;
  4367. };
  4368. /**
  4369. * Restart animations from key 0
  4370. * @returns the animation group
  4371. */
  4372. AnimationGroup.prototype.restart = function () {
  4373. if (!this._isStarted) {
  4374. return this;
  4375. }
  4376. for (var index = 0; index < this._animatables.length; index++) {
  4377. var animatable = this._animatables[index];
  4378. animatable.restart();
  4379. }
  4380. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4381. return this;
  4382. };
  4383. /**
  4384. * Stop all animations
  4385. * @returns the animation group
  4386. */
  4387. AnimationGroup.prototype.stop = function () {
  4388. if (!this._isStarted) {
  4389. return this;
  4390. }
  4391. var list = this._animatables.slice();
  4392. for (var index = 0; index < list.length; index++) {
  4393. list[index].stop();
  4394. }
  4395. this._isStarted = false;
  4396. return this;
  4397. };
  4398. /**
  4399. * Set animation weight for all animatables
  4400. * @param weight defines the weight to use
  4401. * @return the animationGroup
  4402. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4403. */
  4404. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4405. for (var index = 0; index < this._animatables.length; index++) {
  4406. var animatable = this._animatables[index];
  4407. animatable.weight = weight;
  4408. }
  4409. return this;
  4410. };
  4411. /**
  4412. * Synchronize and normalize all animatables with a source animatable
  4413. * @param root defines the root animatable to synchronize with
  4414. * @return the animationGroup
  4415. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4416. */
  4417. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4418. for (var index = 0; index < this._animatables.length; index++) {
  4419. var animatable = this._animatables[index];
  4420. animatable.syncWith(root);
  4421. }
  4422. return this;
  4423. };
  4424. /**
  4425. * Goes to a specific frame in this animation group
  4426. * @param frame the frame number to go to
  4427. * @return the animationGroup
  4428. */
  4429. AnimationGroup.prototype.goToFrame = function (frame) {
  4430. if (!this._isStarted) {
  4431. return this;
  4432. }
  4433. for (var index = 0; index < this._animatables.length; index++) {
  4434. var animatable = this._animatables[index];
  4435. animatable.goToFrame(frame);
  4436. }
  4437. return this;
  4438. };
  4439. /**
  4440. * Dispose all associated resources
  4441. */
  4442. AnimationGroup.prototype.dispose = function () {
  4443. this._targetedAnimations = [];
  4444. this._animatables = [];
  4445. var index = this._scene.animationGroups.indexOf(this);
  4446. if (index > -1) {
  4447. this._scene.animationGroups.splice(index, 1);
  4448. }
  4449. this.onAnimationEndObservable.clear();
  4450. this.onAnimationGroupEndObservable.clear();
  4451. this.onAnimationGroupPauseObservable.clear();
  4452. this.onAnimationGroupPlayObservable.clear();
  4453. this.onAnimationLoopObservable.clear();
  4454. };
  4455. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4456. // animatable should be taken out of the array
  4457. var idx = this._animatables.indexOf(animatable);
  4458. if (idx > -1) {
  4459. this._animatables.splice(idx, 1);
  4460. }
  4461. // all animatables were removed? animation group ended!
  4462. if (this._animatables.length === 0) {
  4463. this._isStarted = false;
  4464. this.onAnimationGroupEndObservable.notifyObservers(this);
  4465. }
  4466. };
  4467. /**
  4468. * Clone the current animation group and returns a copy
  4469. * @param newName defines the name of the new group
  4470. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  4471. * @returns the new aniamtion group
  4472. */
  4473. AnimationGroup.prototype.clone = function (newName, targetConverter) {
  4474. var newGroup = new AnimationGroup(newName || this.name, this._scene);
  4475. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4476. var targetAnimation = _a[_i];
  4477. newGroup.addTargetedAnimation(targetAnimation.animation.clone(), targetConverter ? targetConverter(targetAnimation.target) : targetAnimation.target);
  4478. }
  4479. return newGroup;
  4480. };
  4481. // Statics
  4482. /**
  4483. * Returns a new AnimationGroup object parsed from the source provided.
  4484. * @param parsedAnimationGroup defines the source
  4485. * @param scene defines the scene that will receive the animationGroup
  4486. * @returns a new AnimationGroup
  4487. */
  4488. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4489. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4490. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4491. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4492. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4493. var id = targetedAnimation.targetId;
  4494. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4495. var morphTarget = scene.getMorphTargetById(id);
  4496. if (morphTarget) {
  4497. animationGroup.addTargetedAnimation(animation, morphTarget);
  4498. }
  4499. }
  4500. else {
  4501. var targetNode = scene.getNodeByID(id);
  4502. if (targetNode != null) {
  4503. animationGroup.addTargetedAnimation(animation, targetNode);
  4504. }
  4505. }
  4506. }
  4507. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4508. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4509. }
  4510. return animationGroup;
  4511. };
  4512. /**
  4513. * Returns the string "AnimationGroup"
  4514. * @returns "AnimationGroup"
  4515. */
  4516. AnimationGroup.prototype.getClassName = function () {
  4517. return "AnimationGroup";
  4518. };
  4519. /**
  4520. * Creates a detailled string about the object
  4521. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4522. * @returns a string representing the object
  4523. */
  4524. AnimationGroup.prototype.toString = function (fullDetails) {
  4525. var ret = "Name: " + this.name;
  4526. ret += ", type: " + this.getClassName();
  4527. if (fullDetails) {
  4528. ret += ", from: " + this._from;
  4529. ret += ", to: " + this._to;
  4530. ret += ", isStarted: " + this._isStarted;
  4531. ret += ", speedRatio: " + this._speedRatio;
  4532. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4533. ret += ", animatables length: " + this._animatables;
  4534. }
  4535. return ret;
  4536. };
  4537. return AnimationGroup;
  4538. }());
  4539. /***/ }),
  4540. /***/ "./Animations/animationKey.ts":
  4541. /*!************************************!*\
  4542. !*** ./Animations/animationKey.ts ***!
  4543. \************************************/
  4544. /*! exports provided: AnimationKeyInterpolation */
  4545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4546. "use strict";
  4547. __webpack_require__.r(__webpack_exports__);
  4548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  4549. /**
  4550. * Enum for the animation key frame interpolation type
  4551. */
  4552. var AnimationKeyInterpolation;
  4553. (function (AnimationKeyInterpolation) {
  4554. /**
  4555. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4556. */
  4557. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  4558. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  4559. /***/ }),
  4560. /***/ "./Animations/animationPropertiesOverride.ts":
  4561. /*!***************************************************!*\
  4562. !*** ./Animations/animationPropertiesOverride.ts ***!
  4563. \***************************************************/
  4564. /*! exports provided: AnimationPropertiesOverride */
  4565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4566. "use strict";
  4567. __webpack_require__.r(__webpack_exports__);
  4568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4569. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4570. /**
  4571. * Class used to override all child animations of a given target
  4572. */
  4573. var AnimationPropertiesOverride = /** @class */ (function () {
  4574. function AnimationPropertiesOverride() {
  4575. /**
  4576. * Gets or sets a value indicating if animation blending must be used
  4577. */
  4578. this.enableBlending = false;
  4579. /**
  4580. * Gets or sets the blending speed to use when enableBlending is true
  4581. */
  4582. this.blendingSpeed = 0.01;
  4583. /**
  4584. * Gets or sets the default loop mode to use
  4585. */
  4586. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4587. }
  4588. return AnimationPropertiesOverride;
  4589. }());
  4590. /***/ }),
  4591. /***/ "./Animations/animationRange.ts":
  4592. /*!**************************************!*\
  4593. !*** ./Animations/animationRange.ts ***!
  4594. \**************************************/
  4595. /*! exports provided: AnimationRange */
  4596. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4597. "use strict";
  4598. __webpack_require__.r(__webpack_exports__);
  4599. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  4600. /**
  4601. * Represents the range of an animation
  4602. */
  4603. var AnimationRange = /** @class */ (function () {
  4604. /**
  4605. * Initializes the range of an animation
  4606. * @param name The name of the animation range
  4607. * @param from The starting frame of the animation
  4608. * @param to The ending frame of the animation
  4609. */
  4610. function AnimationRange(
  4611. /**The name of the animation range**/
  4612. name,
  4613. /**The starting frame of the animation */
  4614. from,
  4615. /**The ending frame of the animation*/
  4616. to) {
  4617. this.name = name;
  4618. this.from = from;
  4619. this.to = to;
  4620. }
  4621. /**
  4622. * Makes a copy of the animation range
  4623. * @returns A copy of the animation range
  4624. */
  4625. AnimationRange.prototype.clone = function () {
  4626. return new AnimationRange(this.name, this.from, this.to);
  4627. };
  4628. return AnimationRange;
  4629. }());
  4630. /***/ }),
  4631. /***/ "./Animations/easing.ts":
  4632. /*!******************************!*\
  4633. !*** ./Animations/easing.ts ***!
  4634. \******************************/
  4635. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4636. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4637. "use strict";
  4638. __webpack_require__.r(__webpack_exports__);
  4639. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4640. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4641. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4644. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4646. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4647. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4650. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4652. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4653. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4654. /**
  4655. * Base class used for every default easing function.
  4656. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4657. */
  4658. var EasingFunction = /** @class */ (function () {
  4659. function EasingFunction() {
  4660. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4661. }
  4662. /**
  4663. * Sets the easing mode of the current function.
  4664. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4665. */
  4666. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4667. var n = Math.min(Math.max(easingMode, 0), 2);
  4668. this._easingMode = n;
  4669. };
  4670. /**
  4671. * Gets the current easing mode.
  4672. * @returns the easing mode
  4673. */
  4674. EasingFunction.prototype.getEasingMode = function () {
  4675. return this._easingMode;
  4676. };
  4677. /**
  4678. * @hidden
  4679. */
  4680. EasingFunction.prototype.easeInCore = function (gradient) {
  4681. throw new Error('You must implement this method');
  4682. };
  4683. /**
  4684. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4685. * of the easing function.
  4686. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4687. * @returns the corresponding value on the curve defined by the easing function
  4688. */
  4689. EasingFunction.prototype.ease = function (gradient) {
  4690. switch (this._easingMode) {
  4691. case EasingFunction.EASINGMODE_EASEIN:
  4692. return this.easeInCore(gradient);
  4693. case EasingFunction.EASINGMODE_EASEOUT:
  4694. return (1 - this.easeInCore(1 - gradient));
  4695. }
  4696. if (gradient >= 0.5) {
  4697. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4698. }
  4699. return (this.easeInCore(gradient * 2) * 0.5);
  4700. };
  4701. /**
  4702. * Interpolation follows the mathematical formula associated with the easing function.
  4703. */
  4704. EasingFunction.EASINGMODE_EASEIN = 0;
  4705. /**
  4706. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4707. */
  4708. EasingFunction.EASINGMODE_EASEOUT = 1;
  4709. /**
  4710. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4711. */
  4712. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4713. return EasingFunction;
  4714. }());
  4715. /**
  4716. * Easing function with a circle shape (see link below).
  4717. * @see https://easings.net/#easeInCirc
  4718. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4719. */
  4720. var CircleEase = /** @class */ (function (_super) {
  4721. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4722. function CircleEase() {
  4723. return _super !== null && _super.apply(this, arguments) || this;
  4724. }
  4725. /** @hidden */
  4726. CircleEase.prototype.easeInCore = function (gradient) {
  4727. gradient = Math.max(0, Math.min(1, gradient));
  4728. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4729. };
  4730. return CircleEase;
  4731. }(EasingFunction));
  4732. /**
  4733. * Easing function with a ease back shape (see link below).
  4734. * @see https://easings.net/#easeInBack
  4735. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4736. */
  4737. var BackEase = /** @class */ (function (_super) {
  4738. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4739. /**
  4740. * Instantiates a back ease easing
  4741. * @see https://easings.net/#easeInBack
  4742. * @param amplitude Defines the amplitude of the function
  4743. */
  4744. function BackEase(
  4745. /** Defines the amplitude of the function */
  4746. amplitude) {
  4747. if (amplitude === void 0) { amplitude = 1; }
  4748. var _this = _super.call(this) || this;
  4749. _this.amplitude = amplitude;
  4750. return _this;
  4751. }
  4752. /** @hidden */
  4753. BackEase.prototype.easeInCore = function (gradient) {
  4754. var num = Math.max(0, this.amplitude);
  4755. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4756. };
  4757. return BackEase;
  4758. }(EasingFunction));
  4759. /**
  4760. * Easing function with a bouncing shape (see link below).
  4761. * @see https://easings.net/#easeInBounce
  4762. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4763. */
  4764. var BounceEase = /** @class */ (function (_super) {
  4765. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4766. /**
  4767. * Instantiates a bounce easing
  4768. * @see https://easings.net/#easeInBounce
  4769. * @param bounces Defines the number of bounces
  4770. * @param bounciness Defines the amplitude of the bounce
  4771. */
  4772. function BounceEase(
  4773. /** Defines the number of bounces */
  4774. bounces,
  4775. /** Defines the amplitude of the bounce */
  4776. bounciness) {
  4777. if (bounces === void 0) { bounces = 3; }
  4778. if (bounciness === void 0) { bounciness = 2; }
  4779. var _this = _super.call(this) || this;
  4780. _this.bounces = bounces;
  4781. _this.bounciness = bounciness;
  4782. return _this;
  4783. }
  4784. /** @hidden */
  4785. BounceEase.prototype.easeInCore = function (gradient) {
  4786. var y = Math.max(0.0, this.bounces);
  4787. var bounciness = this.bounciness;
  4788. if (bounciness <= 1.0) {
  4789. bounciness = 1.001;
  4790. }
  4791. var num9 = Math.pow(bounciness, y);
  4792. var num5 = 1.0 - bounciness;
  4793. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4794. var num15 = gradient * num4;
  4795. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4796. var num3 = Math.floor(num65);
  4797. var num13 = num3 + 1.0;
  4798. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4799. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4800. var num7 = (num8 + num12) * 0.5;
  4801. var num6 = gradient - num7;
  4802. var num2 = num7 - num8;
  4803. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4804. };
  4805. return BounceEase;
  4806. }(EasingFunction));
  4807. /**
  4808. * Easing function with a power of 3 shape (see link below).
  4809. * @see https://easings.net/#easeInCubic
  4810. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4811. */
  4812. var CubicEase = /** @class */ (function (_super) {
  4813. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4814. function CubicEase() {
  4815. return _super !== null && _super.apply(this, arguments) || this;
  4816. }
  4817. /** @hidden */
  4818. CubicEase.prototype.easeInCore = function (gradient) {
  4819. return (gradient * gradient * gradient);
  4820. };
  4821. return CubicEase;
  4822. }(EasingFunction));
  4823. /**
  4824. * Easing function with an elastic shape (see link below).
  4825. * @see https://easings.net/#easeInElastic
  4826. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4827. */
  4828. var ElasticEase = /** @class */ (function (_super) {
  4829. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4830. /**
  4831. * Instantiates an elastic easing function
  4832. * @see https://easings.net/#easeInElastic
  4833. * @param oscillations Defines the number of oscillations
  4834. * @param springiness Defines the amplitude of the oscillations
  4835. */
  4836. function ElasticEase(
  4837. /** Defines the number of oscillations*/
  4838. oscillations,
  4839. /** Defines the amplitude of the oscillations*/
  4840. springiness) {
  4841. if (oscillations === void 0) { oscillations = 3; }
  4842. if (springiness === void 0) { springiness = 3; }
  4843. var _this = _super.call(this) || this;
  4844. _this.oscillations = oscillations;
  4845. _this.springiness = springiness;
  4846. return _this;
  4847. }
  4848. /** @hidden */
  4849. ElasticEase.prototype.easeInCore = function (gradient) {
  4850. var num2;
  4851. var num3 = Math.max(0.0, this.oscillations);
  4852. var num = Math.max(0.0, this.springiness);
  4853. if (num == 0) {
  4854. num2 = gradient;
  4855. }
  4856. else {
  4857. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4858. }
  4859. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4860. };
  4861. return ElasticEase;
  4862. }(EasingFunction));
  4863. /**
  4864. * Easing function with an exponential shape (see link below).
  4865. * @see https://easings.net/#easeInExpo
  4866. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4867. */
  4868. var ExponentialEase = /** @class */ (function (_super) {
  4869. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4870. /**
  4871. * Instantiates an exponential easing function
  4872. * @see https://easings.net/#easeInExpo
  4873. * @param exponent Defines the exponent of the function
  4874. */
  4875. function ExponentialEase(
  4876. /** Defines the exponent of the function */
  4877. exponent) {
  4878. if (exponent === void 0) { exponent = 2; }
  4879. var _this = _super.call(this) || this;
  4880. _this.exponent = exponent;
  4881. return _this;
  4882. }
  4883. /** @hidden */
  4884. ExponentialEase.prototype.easeInCore = function (gradient) {
  4885. if (this.exponent <= 0) {
  4886. return gradient;
  4887. }
  4888. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4889. };
  4890. return ExponentialEase;
  4891. }(EasingFunction));
  4892. /**
  4893. * Easing function with a power shape (see link below).
  4894. * @see https://easings.net/#easeInQuad
  4895. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4896. */
  4897. var PowerEase = /** @class */ (function (_super) {
  4898. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4899. /**
  4900. * Instantiates an power base easing function
  4901. * @see https://easings.net/#easeInQuad
  4902. * @param power Defines the power of the function
  4903. */
  4904. function PowerEase(
  4905. /** Defines the power of the function */
  4906. power) {
  4907. if (power === void 0) { power = 2; }
  4908. var _this = _super.call(this) || this;
  4909. _this.power = power;
  4910. return _this;
  4911. }
  4912. /** @hidden */
  4913. PowerEase.prototype.easeInCore = function (gradient) {
  4914. var y = Math.max(0.0, this.power);
  4915. return Math.pow(gradient, y);
  4916. };
  4917. return PowerEase;
  4918. }(EasingFunction));
  4919. /**
  4920. * Easing function with a power of 2 shape (see link below).
  4921. * @see https://easings.net/#easeInQuad
  4922. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4923. */
  4924. var QuadraticEase = /** @class */ (function (_super) {
  4925. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4926. function QuadraticEase() {
  4927. return _super !== null && _super.apply(this, arguments) || this;
  4928. }
  4929. /** @hidden */
  4930. QuadraticEase.prototype.easeInCore = function (gradient) {
  4931. return (gradient * gradient);
  4932. };
  4933. return QuadraticEase;
  4934. }(EasingFunction));
  4935. /**
  4936. * Easing function with a power of 4 shape (see link below).
  4937. * @see https://easings.net/#easeInQuart
  4938. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4939. */
  4940. var QuarticEase = /** @class */ (function (_super) {
  4941. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4942. function QuarticEase() {
  4943. return _super !== null && _super.apply(this, arguments) || this;
  4944. }
  4945. /** @hidden */
  4946. QuarticEase.prototype.easeInCore = function (gradient) {
  4947. return (gradient * gradient * gradient * gradient);
  4948. };
  4949. return QuarticEase;
  4950. }(EasingFunction));
  4951. /**
  4952. * Easing function with a power of 5 shape (see link below).
  4953. * @see https://easings.net/#easeInQuint
  4954. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4955. */
  4956. var QuinticEase = /** @class */ (function (_super) {
  4957. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4958. function QuinticEase() {
  4959. return _super !== null && _super.apply(this, arguments) || this;
  4960. }
  4961. /** @hidden */
  4962. QuinticEase.prototype.easeInCore = function (gradient) {
  4963. return (gradient * gradient * gradient * gradient * gradient);
  4964. };
  4965. return QuinticEase;
  4966. }(EasingFunction));
  4967. /**
  4968. * Easing function with a sin shape (see link below).
  4969. * @see https://easings.net/#easeInSine
  4970. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4971. */
  4972. var SineEase = /** @class */ (function (_super) {
  4973. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  4974. function SineEase() {
  4975. return _super !== null && _super.apply(this, arguments) || this;
  4976. }
  4977. /** @hidden */
  4978. SineEase.prototype.easeInCore = function (gradient) {
  4979. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  4980. };
  4981. return SineEase;
  4982. }(EasingFunction));
  4983. /**
  4984. * Easing function with a bezier shape (see link below).
  4985. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4986. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4987. */
  4988. var BezierCurveEase = /** @class */ (function (_super) {
  4989. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  4990. /**
  4991. * Instantiates a bezier function
  4992. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4993. * @param x1 Defines the x component of the start tangent in the bezier curve
  4994. * @param y1 Defines the y component of the start tangent in the bezier curve
  4995. * @param x2 Defines the x component of the end tangent in the bezier curve
  4996. * @param y2 Defines the y component of the end tangent in the bezier curve
  4997. */
  4998. function BezierCurveEase(
  4999. /** Defines the x component of the start tangent in the bezier curve */
  5000. x1,
  5001. /** Defines the y component of the start tangent in the bezier curve */
  5002. y1,
  5003. /** Defines the x component of the end tangent in the bezier curve */
  5004. x2,
  5005. /** Defines the y component of the end tangent in the bezier curve */
  5006. y2) {
  5007. if (x1 === void 0) { x1 = 0; }
  5008. if (y1 === void 0) { y1 = 0; }
  5009. if (x2 === void 0) { x2 = 1; }
  5010. if (y2 === void 0) { y2 = 1; }
  5011. var _this = _super.call(this) || this;
  5012. _this.x1 = x1;
  5013. _this.y1 = y1;
  5014. _this.x2 = x2;
  5015. _this.y2 = y2;
  5016. return _this;
  5017. }
  5018. /** @hidden */
  5019. BezierCurveEase.prototype.easeInCore = function (gradient) {
  5020. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  5021. };
  5022. return BezierCurveEase;
  5023. }(EasingFunction));
  5024. /***/ }),
  5025. /***/ "./Animations/index.ts":
  5026. /*!*****************************!*\
  5027. !*** ./Animations/index.ts ***!
  5028. \*****************************/
  5029. /*! exports provided: Animatable, _IAnimationState, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange */
  5030. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5031. "use strict";
  5032. __webpack_require__.r(__webpack_exports__);
  5033. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  5034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  5035. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IAnimationState", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["_IAnimationState"]; });
  5037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  5038. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  5039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  5040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  5041. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  5042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  5043. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  5044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  5045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  5046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  5047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  5048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  5049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  5050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  5051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  5052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  5053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  5054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  5055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  5056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  5057. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  5058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  5059. /* harmony import */ var _animationEvent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationEvent */ "./Animations/animationEvent.ts");
  5060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animationEvent__WEBPACK_IMPORTED_MODULE_6__["AnimationEvent"]; });
  5061. /* empty/unused harmony star reexport *//* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  5062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animationKey__WEBPACK_IMPORTED_MODULE_7__["AnimationKeyInterpolation"]; });
  5063. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  5064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animationRange__WEBPACK_IMPORTED_MODULE_8__["AnimationRange"]; });
  5065. /***/ }),
  5066. /***/ "./Animations/runtimeAnimation.ts":
  5067. /*!****************************************!*\
  5068. !*** ./Animations/runtimeAnimation.ts ***!
  5069. \****************************************/
  5070. /*! exports provided: RuntimeAnimation */
  5071. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5072. "use strict";
  5073. __webpack_require__.r(__webpack_exports__);
  5074. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  5075. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5076. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5077. // Static values to help the garbage collector
  5078. // Quaternion
  5079. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  5080. // Vector3
  5081. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  5082. // Vector2
  5083. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  5084. // Size
  5085. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  5086. // Color3
  5087. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  5088. /**
  5089. * Defines a runtime animation
  5090. */
  5091. var RuntimeAnimation = /** @class */ (function () {
  5092. /**
  5093. * Create a new RuntimeAnimation object
  5094. * @param target defines the target of the animation
  5095. * @param animation defines the source animation object
  5096. * @param scene defines the hosting scene
  5097. * @param host defines the initiating Animatable
  5098. */
  5099. function RuntimeAnimation(target, animation, scene, host) {
  5100. var _this = this;
  5101. this._events = new Array();
  5102. /**
  5103. * The current frame of the runtime animation
  5104. */
  5105. this._currentFrame = 0;
  5106. /**
  5107. * The original value of the runtime animation
  5108. */
  5109. this._originalValue = new Array();
  5110. /**
  5111. * The offsets cache of the runtime animation
  5112. */
  5113. this._offsetsCache = {};
  5114. /**
  5115. * The high limits cache of the runtime animation
  5116. */
  5117. this._highLimitsCache = {};
  5118. /**
  5119. * Specifies if the runtime animation has been stopped
  5120. */
  5121. this._stopped = false;
  5122. /**
  5123. * The blending factor of the runtime animation
  5124. */
  5125. this._blendingFactor = 0;
  5126. /**
  5127. * The target path of the runtime animation
  5128. */
  5129. this._targetPath = "";
  5130. /**
  5131. * The weight of the runtime animation
  5132. */
  5133. this._weight = 1.0;
  5134. /**
  5135. * The ratio offset of the runtime animation
  5136. */
  5137. this._ratioOffset = 0;
  5138. /**
  5139. * The previous delay of the runtime animation
  5140. */
  5141. this._previousDelay = 0;
  5142. /**
  5143. * The previous ratio of the runtime animation
  5144. */
  5145. this._previousRatio = 0;
  5146. this._targetIsArray = false;
  5147. this._animation = animation;
  5148. this._target = target;
  5149. this._scene = scene;
  5150. this._host = host;
  5151. this._activeTargets = [];
  5152. animation._runtimeAnimations.push(this);
  5153. // State
  5154. this._animationState = {
  5155. key: 0,
  5156. repeatCount: 0,
  5157. loopMode: this._getCorrectLoopMode()
  5158. };
  5159. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX) {
  5160. this._animationState.workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  5161. }
  5162. // Limits
  5163. this._keys = this._animation.getKeys();
  5164. this._minFrame = this._keys[0].frame;
  5165. this._maxFrame = this._keys[this._keys.length - 1].frame;
  5166. this._minValue = this._keys[0].value;
  5167. this._maxValue = this._keys[this._keys.length - 1].value;
  5168. // Add a start key at frame 0 if missing
  5169. if (this._minFrame !== 0) {
  5170. var newKey = { frame: 0, value: this._minValue };
  5171. this._keys.splice(0, 0, newKey);
  5172. }
  5173. // Check data
  5174. if (this._target instanceof Array) {
  5175. var index = 0;
  5176. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5177. var target_1 = _a[_i];
  5178. this._preparePath(target_1, index);
  5179. this._getOriginalValues(index);
  5180. index++;
  5181. }
  5182. this._targetIsArray = true;
  5183. }
  5184. else {
  5185. this._preparePath(this._target);
  5186. this._getOriginalValues();
  5187. this._targetIsArray = false;
  5188. this._directTarget = this._activeTargets[0];
  5189. }
  5190. // Cloning events locally
  5191. var events = animation.getEvents();
  5192. if (events && events.length > 0) {
  5193. events.forEach(function (e) {
  5194. _this._events.push(e._clone());
  5195. });
  5196. }
  5197. this._enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  5198. }
  5199. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  5200. /**
  5201. * Gets the current frame of the runtime animation
  5202. */
  5203. get: function () {
  5204. return this._currentFrame;
  5205. },
  5206. enumerable: true,
  5207. configurable: true
  5208. });
  5209. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  5210. /**
  5211. * Gets the weight of the runtime animation
  5212. */
  5213. get: function () {
  5214. return this._weight;
  5215. },
  5216. enumerable: true,
  5217. configurable: true
  5218. });
  5219. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  5220. /**
  5221. * Gets the current value of the runtime animation
  5222. */
  5223. get: function () {
  5224. return this._currentValue;
  5225. },
  5226. enumerable: true,
  5227. configurable: true
  5228. });
  5229. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  5230. /**
  5231. * Gets the target path of the runtime animation
  5232. */
  5233. get: function () {
  5234. return this._targetPath;
  5235. },
  5236. enumerable: true,
  5237. configurable: true
  5238. });
  5239. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  5240. /**
  5241. * Gets the actual target of the runtime animation
  5242. */
  5243. get: function () {
  5244. return this._currentActiveTarget;
  5245. },
  5246. enumerable: true,
  5247. configurable: true
  5248. });
  5249. RuntimeAnimation.prototype._preparePath = function (target, targetIndex) {
  5250. if (targetIndex === void 0) { targetIndex = 0; }
  5251. var targetPropertyPath = this._animation.targetPropertyPath;
  5252. if (targetPropertyPath.length > 1) {
  5253. var property = target[targetPropertyPath[0]];
  5254. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  5255. property = property[targetPropertyPath[index]];
  5256. }
  5257. this._targetPath = targetPropertyPath[targetPropertyPath.length - 1];
  5258. this._activeTargets[targetIndex] = property;
  5259. }
  5260. else {
  5261. this._targetPath = targetPropertyPath[0];
  5262. this._activeTargets[targetIndex] = target;
  5263. }
  5264. };
  5265. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  5266. /**
  5267. * Gets the animation from the runtime animation
  5268. */
  5269. get: function () {
  5270. return this._animation;
  5271. },
  5272. enumerable: true,
  5273. configurable: true
  5274. });
  5275. /**
  5276. * Resets the runtime animation to the beginning
  5277. * @param restoreOriginal defines whether to restore the target property to the original value
  5278. */
  5279. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  5280. if (restoreOriginal === void 0) { restoreOriginal = false; }
  5281. if (restoreOriginal) {
  5282. if (this._target instanceof Array) {
  5283. var index = 0;
  5284. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5285. var target = _a[_i];
  5286. if (this._originalValue[index] !== undefined) {
  5287. this._setValue(target, this._activeTargets[index], this._originalValue[index], -1, index);
  5288. }
  5289. index++;
  5290. }
  5291. }
  5292. else {
  5293. if (this._originalValue[0] !== undefined) {
  5294. this._setValue(this._target, this._directTarget, this._originalValue[0], -1, 0);
  5295. }
  5296. }
  5297. }
  5298. this._offsetsCache = {};
  5299. this._highLimitsCache = {};
  5300. this._currentFrame = 0;
  5301. this._blendingFactor = 0;
  5302. // Events
  5303. for (var index = 0; index < this._events.length; index++) {
  5304. this._events[index].isDone = false;
  5305. }
  5306. };
  5307. /**
  5308. * Specifies if the runtime animation is stopped
  5309. * @returns Boolean specifying if the runtime animation is stopped
  5310. */
  5311. RuntimeAnimation.prototype.isStopped = function () {
  5312. return this._stopped;
  5313. };
  5314. /**
  5315. * Disposes of the runtime animation
  5316. */
  5317. RuntimeAnimation.prototype.dispose = function () {
  5318. var index = this._animation.runtimeAnimations.indexOf(this);
  5319. if (index > -1) {
  5320. this._animation.runtimeAnimations.splice(index, 1);
  5321. }
  5322. };
  5323. /**
  5324. * Apply the interpolated value to the target
  5325. * @param currentValue defines the value computed by the animation
  5326. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5327. */
  5328. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  5329. if (this._targetIsArray) {
  5330. for (var index = 0; index < this._target.length; index++) {
  5331. var target = this._target[index];
  5332. this._setValue(target, this._activeTargets[index], currentValue, weight, index);
  5333. }
  5334. return;
  5335. }
  5336. this._setValue(this._target, this._directTarget, currentValue, weight, 0);
  5337. };
  5338. RuntimeAnimation.prototype._getOriginalValues = function (targetIndex) {
  5339. if (targetIndex === void 0) { targetIndex = 0; }
  5340. var originalValue;
  5341. var target = this._activeTargets[targetIndex];
  5342. if (target.getRestPose && this._targetPath === "_matrix") { // For bones
  5343. originalValue = target.getRestPose();
  5344. }
  5345. else {
  5346. originalValue = target[this._targetPath];
  5347. }
  5348. if (originalValue && originalValue.clone) {
  5349. this._originalValue[targetIndex] = originalValue.clone();
  5350. }
  5351. else {
  5352. this._originalValue[targetIndex] = originalValue;
  5353. }
  5354. };
  5355. RuntimeAnimation.prototype._setValue = function (target, destination, currentValue, weight, targetIndex) {
  5356. // Set value
  5357. this._currentActiveTarget = destination;
  5358. this._weight = weight;
  5359. if (this._enableBlending && this._blendingFactor <= 1.0) {
  5360. if (!this._originalBlendValue) {
  5361. var originalValue = destination[this._targetPath];
  5362. if (originalValue.clone) {
  5363. this._originalBlendValue = originalValue.clone();
  5364. }
  5365. else {
  5366. this._originalBlendValue = originalValue;
  5367. }
  5368. }
  5369. if (this._originalBlendValue.m) { // Matrix
  5370. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  5371. if (this._currentValue) {
  5372. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5373. }
  5374. else {
  5375. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5376. }
  5377. }
  5378. else {
  5379. if (this._currentValue) {
  5380. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5381. }
  5382. else {
  5383. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5384. }
  5385. }
  5386. }
  5387. else {
  5388. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5389. }
  5390. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5391. this._blendingFactor += blendingSpeed;
  5392. }
  5393. else {
  5394. this._currentValue = currentValue;
  5395. }
  5396. if (weight !== -1.0) {
  5397. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5398. }
  5399. else {
  5400. destination[this._targetPath] = this._currentValue;
  5401. }
  5402. if (target.markAsDirty) {
  5403. target.markAsDirty(this._animation.targetProperty);
  5404. }
  5405. };
  5406. /**
  5407. * Gets the loop pmode of the runtime animation
  5408. * @returns Loop Mode
  5409. */
  5410. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5411. if (this._target && this._target.animationPropertiesOverride) {
  5412. return this._target.animationPropertiesOverride.loopMode;
  5413. }
  5414. return this._animation.loopMode;
  5415. };
  5416. /**
  5417. * Move the current animation to a given frame
  5418. * @param frame defines the frame to move to
  5419. */
  5420. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5421. var keys = this._animation.getKeys();
  5422. if (frame < keys[0].frame) {
  5423. frame = keys[0].frame;
  5424. }
  5425. else if (frame > keys[keys.length - 1].frame) {
  5426. frame = keys[keys.length - 1].frame;
  5427. }
  5428. var currentValue = this._animation._interpolate(frame, this._animationState);
  5429. this.setValue(currentValue, -1);
  5430. };
  5431. /**
  5432. * @hidden Internal use only
  5433. */
  5434. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5435. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5436. this._ratioOffset = this._previousRatio - newRatio;
  5437. };
  5438. /**
  5439. * Execute the current animation
  5440. * @param delay defines the delay to add to the current frame
  5441. * @param from defines the lower bound of the animation range
  5442. * @param to defines the upper bound of the animation range
  5443. * @param loop defines if the current animation must loop
  5444. * @param speedRatio defines the current speed ratio
  5445. * @param weight defines the weight of the animation (default is -1 so no weight)
  5446. * @param onLoop optional callback called when animation loops
  5447. * @returns a boolean indicating if the animation is running
  5448. */
  5449. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight) {
  5450. if (weight === void 0) { weight = -1.0; }
  5451. var animation = this._animation;
  5452. var targetPropertyPath = animation.targetPropertyPath;
  5453. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5454. this._stopped = true;
  5455. return false;
  5456. }
  5457. var returnValue = true;
  5458. // Check limits
  5459. if (from < this._minFrame || from > this._maxFrame) {
  5460. from = this._minFrame;
  5461. }
  5462. if (to < this._minFrame || to > this._maxFrame) {
  5463. to = this._maxFrame;
  5464. }
  5465. var range = to - from;
  5466. var offsetValue;
  5467. // Compute ratio which represents the frame delta between from and to
  5468. var ratio = (delay * (animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5469. var highLimitValue = 0;
  5470. this._previousDelay = delay;
  5471. this._previousRatio = ratio;
  5472. if (!loop && (to > from && ratio >= range)) { // If we are out of range and not looping get back to caller
  5473. returnValue = false;
  5474. highLimitValue = animation._getKeyValue(this._maxValue);
  5475. }
  5476. else if (!loop && (from > to && ratio <= range)) {
  5477. returnValue = false;
  5478. highLimitValue = animation._getKeyValue(this._minValue);
  5479. }
  5480. else if (this._animationState.loopMode !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5481. var keyOffset = to.toString() + from.toString();
  5482. if (!this._offsetsCache[keyOffset]) {
  5483. this._animationState.repeatCount = 0;
  5484. this._animationState.loopMode = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  5485. var fromValue = animation._interpolate(from, this._animationState);
  5486. var toValue = animation._interpolate(to, this._animationState);
  5487. this._animationState.loopMode = this._getCorrectLoopMode();
  5488. switch (animation.dataType) {
  5489. // Float
  5490. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5491. this._offsetsCache[keyOffset] = toValue - fromValue;
  5492. break;
  5493. // Quaternion
  5494. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5495. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5496. break;
  5497. // Vector3
  5498. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5499. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5500. // Vector2
  5501. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5502. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5503. // Size
  5504. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5505. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5506. // Color3
  5507. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5508. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5509. default:
  5510. break;
  5511. }
  5512. this._highLimitsCache[keyOffset] = toValue;
  5513. }
  5514. highLimitValue = this._highLimitsCache[keyOffset];
  5515. offsetValue = this._offsetsCache[keyOffset];
  5516. }
  5517. if (offsetValue === undefined) {
  5518. switch (animation.dataType) {
  5519. // Float
  5520. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5521. offsetValue = 0;
  5522. break;
  5523. // Quaternion
  5524. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5525. offsetValue = _staticOffsetValueQuaternion;
  5526. break;
  5527. // Vector3
  5528. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5529. offsetValue = _staticOffsetValueVector3;
  5530. break;
  5531. // Vector2
  5532. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5533. offsetValue = _staticOffsetValueVector2;
  5534. break;
  5535. // Size
  5536. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5537. offsetValue = _staticOffsetValueSize;
  5538. break;
  5539. // Color3
  5540. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5541. offsetValue = _staticOffsetValueColor3;
  5542. }
  5543. }
  5544. // Compute value
  5545. var currentFrame;
  5546. if (this._host && this._host.syncRoot) {
  5547. var syncRoot = this._host.syncRoot;
  5548. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5549. currentFrame = from + (to - from) * hostNormalizedFrame;
  5550. }
  5551. else {
  5552. currentFrame = (returnValue && range !== 0) ? from + ratio % range : to;
  5553. }
  5554. // Reset events if looping
  5555. var events = this._events;
  5556. if (range > 0 && this.currentFrame > currentFrame ||
  5557. range < 0 && this.currentFrame < currentFrame) {
  5558. this._onLoop();
  5559. // Need to reset animation events
  5560. if (events.length) {
  5561. for (var index = 0; index < events.length; index++) {
  5562. if (!events[index].onlyOnce) {
  5563. // reset event, the animation is looping
  5564. events[index].isDone = false;
  5565. }
  5566. }
  5567. }
  5568. }
  5569. this._currentFrame = currentFrame;
  5570. this._animationState.repeatCount = range === 0 ? 0 : (ratio / range) >> 0;
  5571. this._animationState.highLimitValue = highLimitValue;
  5572. this._animationState.offsetValue = offsetValue;
  5573. var currentValue = animation._interpolate(currentFrame, this._animationState);
  5574. // Set value
  5575. this.setValue(currentValue, weight);
  5576. // Check events
  5577. if (events.length) {
  5578. for (var index = 0; index < events.length; index++) {
  5579. // Make sure current frame has passed event frame and that event frame is within the current range
  5580. // Also, handle both forward and reverse animations
  5581. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5582. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5583. var event = events[index];
  5584. if (!event.isDone) {
  5585. // If event should be done only once, remove it.
  5586. if (event.onlyOnce) {
  5587. events.splice(index, 1);
  5588. index--;
  5589. }
  5590. event.isDone = true;
  5591. event.action(currentFrame);
  5592. } // Don't do anything if the event has already be done.
  5593. }
  5594. }
  5595. }
  5596. if (!returnValue) {
  5597. this._stopped = true;
  5598. }
  5599. return returnValue;
  5600. };
  5601. return RuntimeAnimation;
  5602. }());
  5603. /***/ }),
  5604. /***/ "./Audio/analyser.ts":
  5605. /*!***************************!*\
  5606. !*** ./Audio/analyser.ts ***!
  5607. \***************************/
  5608. /*! exports provided: Analyser */
  5609. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5610. "use strict";
  5611. __webpack_require__.r(__webpack_exports__);
  5612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5613. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5614. /**
  5615. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5616. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5617. */
  5618. var Analyser = /** @class */ (function () {
  5619. /**
  5620. * Creates a new analyser
  5621. * @param scene defines hosting scene
  5622. */
  5623. function Analyser(scene) {
  5624. /**
  5625. * Gets or sets the smoothing
  5626. * @ignorenaming
  5627. */
  5628. this.SMOOTHING = 0.75;
  5629. /**
  5630. * Gets or sets the FFT table size
  5631. * @ignorenaming
  5632. */
  5633. this.FFT_SIZE = 512;
  5634. /**
  5635. * Gets or sets the bar graph amplitude
  5636. * @ignorenaming
  5637. */
  5638. this.BARGRAPHAMPLITUDE = 256;
  5639. /**
  5640. * Gets or sets the position of the debug canvas
  5641. * @ignorenaming
  5642. */
  5643. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5644. /**
  5645. * Gets or sets the debug canvas size
  5646. * @ignorenaming
  5647. */
  5648. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5649. this._scene = scene;
  5650. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5651. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5652. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5653. this._webAudioAnalyser.minDecibels = -140;
  5654. this._webAudioAnalyser.maxDecibels = 0;
  5655. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5656. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5657. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5658. }
  5659. }
  5660. /**
  5661. * Get the number of data values you will have to play with for the visualization
  5662. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5663. * @returns a number
  5664. */
  5665. Analyser.prototype.getFrequencyBinCount = function () {
  5666. if (this._audioEngine.canUseWebAudio) {
  5667. return this._webAudioAnalyser.frequencyBinCount;
  5668. }
  5669. else {
  5670. return 0;
  5671. }
  5672. };
  5673. /**
  5674. * Gets the current frequency data as a byte array
  5675. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5676. * @returns a Uint8Array
  5677. */
  5678. Analyser.prototype.getByteFrequencyData = function () {
  5679. if (this._audioEngine.canUseWebAudio) {
  5680. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5681. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5682. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5683. }
  5684. return this._byteFreqs;
  5685. };
  5686. /**
  5687. * Gets the current waveform as a byte array
  5688. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5689. * @returns a Uint8Array
  5690. */
  5691. Analyser.prototype.getByteTimeDomainData = function () {
  5692. if (this._audioEngine.canUseWebAudio) {
  5693. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5694. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5695. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5696. }
  5697. return this._byteTime;
  5698. };
  5699. /**
  5700. * Gets the current frequency data as a float array
  5701. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5702. * @returns a Float32Array
  5703. */
  5704. Analyser.prototype.getFloatFrequencyData = function () {
  5705. if (this._audioEngine.canUseWebAudio) {
  5706. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5707. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5708. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5709. }
  5710. return this._floatFreqs;
  5711. };
  5712. /**
  5713. * Renders the debug canvas
  5714. */
  5715. Analyser.prototype.drawDebugCanvas = function () {
  5716. var _this = this;
  5717. if (this._audioEngine.canUseWebAudio) {
  5718. if (!this._debugCanvas) {
  5719. this._debugCanvas = document.createElement("canvas");
  5720. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5721. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5722. this._debugCanvas.style.position = "absolute";
  5723. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5724. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5725. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5726. document.body.appendChild(this._debugCanvas);
  5727. this._registerFunc = function () {
  5728. _this.drawDebugCanvas();
  5729. };
  5730. this._scene.registerBeforeRender(this._registerFunc);
  5731. }
  5732. if (this._registerFunc && this._debugCanvasContext) {
  5733. var workingArray = this.getByteFrequencyData();
  5734. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5735. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5736. // Draw the frequency domain chart.
  5737. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5738. var value = workingArray[i];
  5739. var percent = value / this.BARGRAPHAMPLITUDE;
  5740. var height = this.DEBUGCANVASSIZE.height * percent;
  5741. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5742. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5743. var hue = i / this.getFrequencyBinCount() * 360;
  5744. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5745. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5746. }
  5747. }
  5748. }
  5749. };
  5750. /**
  5751. * Stops rendering the debug canvas and removes it
  5752. */
  5753. Analyser.prototype.stopDebugCanvas = function () {
  5754. if (this._debugCanvas) {
  5755. if (this._registerFunc) {
  5756. this._scene.unregisterBeforeRender(this._registerFunc);
  5757. this._registerFunc = null;
  5758. }
  5759. document.body.removeChild(this._debugCanvas);
  5760. this._debugCanvas = null;
  5761. this._debugCanvasContext = null;
  5762. }
  5763. };
  5764. /**
  5765. * Connects two audio nodes
  5766. * @param inputAudioNode defines first node to connect
  5767. * @param outputAudioNode defines second node to connect
  5768. */
  5769. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5770. if (this._audioEngine.canUseWebAudio) {
  5771. inputAudioNode.connect(this._webAudioAnalyser);
  5772. this._webAudioAnalyser.connect(outputAudioNode);
  5773. }
  5774. };
  5775. /**
  5776. * Releases all associated resources
  5777. */
  5778. Analyser.prototype.dispose = function () {
  5779. if (this._audioEngine.canUseWebAudio) {
  5780. this._webAudioAnalyser.disconnect();
  5781. }
  5782. };
  5783. return Analyser;
  5784. }());
  5785. /***/ }),
  5786. /***/ "./Audio/audioEngine.ts":
  5787. /*!******************************!*\
  5788. !*** ./Audio/audioEngine.ts ***!
  5789. \******************************/
  5790. /*! exports provided: AudioEngine */
  5791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5792. "use strict";
  5793. __webpack_require__.r(__webpack_exports__);
  5794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5795. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5796. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5797. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5798. // Sets the default audio engine to Babylon.js
  5799. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5800. /**
  5801. * This represents the default audio engine used in babylon.
  5802. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5803. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5804. */
  5805. var AudioEngine = /** @class */ (function () {
  5806. /**
  5807. * Instantiates a new audio engine.
  5808. *
  5809. * There should be only one per page as some browsers restrict the number
  5810. * of audio contexts you can create.
  5811. * @param hostElement defines the host element where to display the mute icon if necessary
  5812. */
  5813. function AudioEngine(hostElement) {
  5814. if (hostElement === void 0) { hostElement = null; }
  5815. var _this = this;
  5816. this._audioContext = null;
  5817. this._audioContextInitialized = false;
  5818. this._muteButton = null;
  5819. /**
  5820. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5821. */
  5822. this.canUseWebAudio = false;
  5823. /**
  5824. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5825. * @ignoreNaming
  5826. */
  5827. this.WarnedWebAudioUnsupported = false;
  5828. /**
  5829. * Gets whether or not mp3 are supported by your browser.
  5830. */
  5831. this.isMP3supported = false;
  5832. /**
  5833. * Gets whether or not ogg are supported by your browser.
  5834. */
  5835. this.isOGGsupported = false;
  5836. /**
  5837. * Gets whether audio has been unlocked on the device.
  5838. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5839. * a user interaction has happened.
  5840. */
  5841. this.unlocked = true;
  5842. /**
  5843. * Defines if the audio engine relies on a custom unlocked button.
  5844. * In this case, the embedded button will not be displayed.
  5845. */
  5846. this.useCustomUnlockedButton = false;
  5847. /**
  5848. * Event raised when audio has been unlocked on the browser.
  5849. */
  5850. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5851. /**
  5852. * Event raised when audio has been locked on the browser.
  5853. */
  5854. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5855. this._tryToRun = false;
  5856. this._onResize = function () {
  5857. _this._moveButtonToTopLeft();
  5858. };
  5859. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5860. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5861. this.canUseWebAudio = true;
  5862. }
  5863. var audioElem = document.createElement('audio');
  5864. this._hostElement = hostElement;
  5865. try {
  5866. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5867. this.isMP3supported = true;
  5868. }
  5869. }
  5870. catch (e) {
  5871. // protect error during capability check.
  5872. }
  5873. try {
  5874. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5875. this.isOGGsupported = true;
  5876. }
  5877. }
  5878. catch (e) {
  5879. // protect error during capability check.
  5880. }
  5881. }
  5882. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5883. /**
  5884. * Gets the current AudioContext if available.
  5885. */
  5886. get: function () {
  5887. if (!this._audioContextInitialized) {
  5888. this._initializeAudioContext();
  5889. }
  5890. else {
  5891. if (!this.unlocked && !this._muteButton) {
  5892. this._displayMuteButton();
  5893. }
  5894. }
  5895. return this._audioContext;
  5896. },
  5897. enumerable: true,
  5898. configurable: true
  5899. });
  5900. /**
  5901. * Flags the audio engine in Locked state.
  5902. * This happens due to new browser policies preventing audio to autoplay.
  5903. */
  5904. AudioEngine.prototype.lock = function () {
  5905. this._triggerSuspendedState();
  5906. };
  5907. /**
  5908. * Unlocks the audio engine once a user action has been done on the dom.
  5909. * This is helpful to resume play once browser policies have been satisfied.
  5910. */
  5911. AudioEngine.prototype.unlock = function () {
  5912. this._triggerRunningState();
  5913. };
  5914. AudioEngine.prototype._resumeAudioContext = function () {
  5915. var result;
  5916. if (this._audioContext.resume) {
  5917. result = this._audioContext.resume();
  5918. }
  5919. return result || Promise.resolve();
  5920. };
  5921. AudioEngine.prototype._initializeAudioContext = function () {
  5922. try {
  5923. if (this.canUseWebAudio) {
  5924. this._audioContext = new AudioContext();
  5925. // create a global volume gain node
  5926. this.masterGain = this._audioContext.createGain();
  5927. this.masterGain.gain.value = 1;
  5928. this.masterGain.connect(this._audioContext.destination);
  5929. this._audioContextInitialized = true;
  5930. if (this._audioContext.state === "running") {
  5931. // Do not wait for the promise to unlock.
  5932. this._triggerRunningState();
  5933. }
  5934. }
  5935. }
  5936. catch (e) {
  5937. this.canUseWebAudio = false;
  5938. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5939. }
  5940. };
  5941. AudioEngine.prototype._triggerRunningState = function () {
  5942. var _this = this;
  5943. if (this._tryToRun) {
  5944. return;
  5945. }
  5946. this._tryToRun = true;
  5947. this._resumeAudioContext()
  5948. .then(function () {
  5949. _this._tryToRun = false;
  5950. if (_this._muteButton) {
  5951. _this._hideMuteButton();
  5952. }
  5953. }).catch(function () {
  5954. _this._tryToRun = false;
  5955. _this.unlocked = false;
  5956. });
  5957. // Notify users that the audio stack is unlocked/unmuted
  5958. this.unlocked = true;
  5959. this.onAudioUnlockedObservable.notifyObservers(this);
  5960. };
  5961. AudioEngine.prototype._triggerSuspendedState = function () {
  5962. this.unlocked = false;
  5963. this.onAudioLockedObservable.notifyObservers(this);
  5964. this._displayMuteButton();
  5965. };
  5966. AudioEngine.prototype._displayMuteButton = function () {
  5967. var _this = this;
  5968. if (this.useCustomUnlockedButton || this._muteButton) {
  5969. return;
  5970. }
  5971. this._muteButton = document.createElement("BUTTON");
  5972. this._muteButton.className = "babylonUnmuteIcon";
  5973. this._muteButton.id = "babylonUnmuteIconBtn";
  5974. this._muteButton.title = "Unmute";
  5975. var css = ".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url(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); 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) }";
  5976. var style = document.createElement('style');
  5977. style.appendChild(document.createTextNode(css));
  5978. document.getElementsByTagName('head')[0].appendChild(style);
  5979. document.body.appendChild(this._muteButton);
  5980. this._moveButtonToTopLeft();
  5981. this._muteButton.addEventListener('touchend', function () {
  5982. _this._triggerRunningState();
  5983. }, true);
  5984. this._muteButton.addEventListener('click', function () {
  5985. _this._triggerRunningState();
  5986. }, true);
  5987. window.addEventListener("resize", this._onResize);
  5988. };
  5989. AudioEngine.prototype._moveButtonToTopLeft = function () {
  5990. if (this._hostElement && this._muteButton) {
  5991. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  5992. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  5993. }
  5994. };
  5995. AudioEngine.prototype._hideMuteButton = function () {
  5996. if (this._muteButton) {
  5997. document.body.removeChild(this._muteButton);
  5998. this._muteButton = null;
  5999. }
  6000. };
  6001. /**
  6002. * Destroy and release the resources associated with the audio ccontext.
  6003. */
  6004. AudioEngine.prototype.dispose = function () {
  6005. if (this.canUseWebAudio && this._audioContextInitialized) {
  6006. if (this._connectedAnalyser && this._audioContext) {
  6007. this._connectedAnalyser.stopDebugCanvas();
  6008. this._connectedAnalyser.dispose();
  6009. this.masterGain.disconnect();
  6010. this.masterGain.connect(this._audioContext.destination);
  6011. this._connectedAnalyser = null;
  6012. }
  6013. this.masterGain.gain.value = 1;
  6014. }
  6015. this.WarnedWebAudioUnsupported = false;
  6016. this._hideMuteButton();
  6017. window.removeEventListener("resize", this._onResize);
  6018. this.onAudioUnlockedObservable.clear();
  6019. this.onAudioLockedObservable.clear();
  6020. };
  6021. /**
  6022. * Gets the global volume sets on the master gain.
  6023. * @returns the global volume if set or -1 otherwise
  6024. */
  6025. AudioEngine.prototype.getGlobalVolume = function () {
  6026. if (this.canUseWebAudio && this._audioContextInitialized) {
  6027. return this.masterGain.gain.value;
  6028. }
  6029. else {
  6030. return -1;
  6031. }
  6032. };
  6033. /**
  6034. * Sets the global volume of your experience (sets on the master gain).
  6035. * @param newVolume Defines the new global volume of the application
  6036. */
  6037. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  6038. if (this.canUseWebAudio && this._audioContextInitialized) {
  6039. this.masterGain.gain.value = newVolume;
  6040. }
  6041. };
  6042. /**
  6043. * Connect the audio engine to an audio analyser allowing some amazing
  6044. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  6045. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  6046. * @param analyser The analyser to connect to the engine
  6047. */
  6048. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  6049. if (this._connectedAnalyser) {
  6050. this._connectedAnalyser.stopDebugCanvas();
  6051. }
  6052. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  6053. this._connectedAnalyser = analyser;
  6054. this.masterGain.disconnect();
  6055. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  6056. }
  6057. };
  6058. return AudioEngine;
  6059. }());
  6060. /***/ }),
  6061. /***/ "./Audio/audioSceneComponent.ts":
  6062. /*!**************************************!*\
  6063. !*** ./Audio/audioSceneComponent.ts ***!
  6064. \**************************************/
  6065. /*! exports provided: AudioSceneComponent */
  6066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6067. "use strict";
  6068. __webpack_require__.r(__webpack_exports__);
  6069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  6070. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6071. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6072. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6073. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6074. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  6075. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  6076. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  6077. // Adds the parser to the scene parsers.
  6078. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  6079. // TODO: add sound
  6080. var loadedSounds = [];
  6081. var loadedSound;
  6082. container.sounds = container.sounds || [];
  6083. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  6084. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  6085. var parsedSound = parsedData.sounds[index];
  6086. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  6087. if (!parsedSound.url) {
  6088. parsedSound.url = parsedSound.name;
  6089. }
  6090. if (!loadedSounds[parsedSound.url]) {
  6091. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  6092. loadedSounds[parsedSound.url] = loadedSound;
  6093. container.sounds.push(loadedSound);
  6094. }
  6095. else {
  6096. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  6097. }
  6098. }
  6099. else {
  6100. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  6101. }
  6102. }
  6103. }
  6104. loadedSounds = [];
  6105. });
  6106. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  6107. get: function () {
  6108. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6109. if (!compo) {
  6110. compo = new AudioSceneComponent(this);
  6111. this._addComponent(compo);
  6112. }
  6113. if (!this._mainSoundTrack) {
  6114. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  6115. }
  6116. return this._mainSoundTrack;
  6117. },
  6118. enumerable: true,
  6119. configurable: true
  6120. });
  6121. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  6122. var index;
  6123. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  6124. if (this.mainSoundTrack.soundCollection[index].name === name) {
  6125. return this.mainSoundTrack.soundCollection[index];
  6126. }
  6127. }
  6128. if (this.soundTracks) {
  6129. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  6130. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  6131. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  6132. return this.soundTracks[sdIndex].soundCollection[index];
  6133. }
  6134. }
  6135. }
  6136. }
  6137. return null;
  6138. };
  6139. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  6140. get: function () {
  6141. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6142. if (!compo) {
  6143. compo = new AudioSceneComponent(this);
  6144. this._addComponent(compo);
  6145. }
  6146. return compo.audioEnabled;
  6147. },
  6148. set: function (value) {
  6149. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6150. if (!compo) {
  6151. compo = new AudioSceneComponent(this);
  6152. this._addComponent(compo);
  6153. }
  6154. if (value) {
  6155. compo.enableAudio();
  6156. }
  6157. else {
  6158. compo.disableAudio();
  6159. }
  6160. },
  6161. enumerable: true,
  6162. configurable: true
  6163. });
  6164. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  6165. get: function () {
  6166. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6167. if (!compo) {
  6168. compo = new AudioSceneComponent(this);
  6169. this._addComponent(compo);
  6170. }
  6171. return compo.headphone;
  6172. },
  6173. set: function (value) {
  6174. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6175. if (!compo) {
  6176. compo = new AudioSceneComponent(this);
  6177. this._addComponent(compo);
  6178. }
  6179. if (value) {
  6180. compo.switchAudioModeForHeadphones();
  6181. }
  6182. else {
  6183. compo.switchAudioModeForNormalSpeakers();
  6184. }
  6185. },
  6186. enumerable: true,
  6187. configurable: true
  6188. });
  6189. /**
  6190. * Defines the sound scene component responsible to manage any sounds
  6191. * in a given scene.
  6192. */
  6193. var AudioSceneComponent = /** @class */ (function () {
  6194. /**
  6195. * Creates a new instance of the component for the given scene
  6196. * @param scene Defines the scene to register the component in
  6197. */
  6198. function AudioSceneComponent(scene) {
  6199. /**
  6200. * The component name helpfull to identify the component in the list of scene components.
  6201. */
  6202. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  6203. this._audioEnabled = true;
  6204. this._headphone = false;
  6205. this.scene = scene;
  6206. scene.soundTracks = new Array();
  6207. scene.sounds = new Array();
  6208. }
  6209. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  6210. /**
  6211. * Gets whether audio is enabled or not.
  6212. * Please use related enable/disable method to switch state.
  6213. */
  6214. get: function () {
  6215. return this._audioEnabled;
  6216. },
  6217. enumerable: true,
  6218. configurable: true
  6219. });
  6220. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  6221. /**
  6222. * Gets whether audio is outputing to headphone or not.
  6223. * Please use the according Switch methods to change output.
  6224. */
  6225. get: function () {
  6226. return this._headphone;
  6227. },
  6228. enumerable: true,
  6229. configurable: true
  6230. });
  6231. /**
  6232. * Registers the component in a given scene
  6233. */
  6234. AudioSceneComponent.prototype.register = function () {
  6235. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  6236. };
  6237. /**
  6238. * Rebuilds the elements related to this component in case of
  6239. * context lost for instance.
  6240. */
  6241. AudioSceneComponent.prototype.rebuild = function () {
  6242. // Nothing to do here. (Not rendering related)
  6243. };
  6244. /**
  6245. * Serializes the component data to the specified json object
  6246. * @param serializationObject The object to serialize to
  6247. */
  6248. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  6249. serializationObject.sounds = [];
  6250. if (this.scene.soundTracks) {
  6251. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  6252. var soundtrack = this.scene.soundTracks[index];
  6253. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  6254. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  6255. }
  6256. }
  6257. }
  6258. };
  6259. /**
  6260. * Adds all the element from the container to the scene
  6261. * @param container the container holding the elements
  6262. */
  6263. AudioSceneComponent.prototype.addFromContainer = function (container) {
  6264. var _this = this;
  6265. if (!container.sounds) {
  6266. return;
  6267. }
  6268. container.sounds.forEach(function (sound) {
  6269. sound.play();
  6270. sound.autoplay = true;
  6271. _this.scene.mainSoundTrack.AddSound(sound);
  6272. });
  6273. };
  6274. /**
  6275. * Removes all the elements in the container from the scene
  6276. * @param container contains the elements to remove
  6277. * @param dispose if the removed element should be disposed (default: false)
  6278. */
  6279. AudioSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  6280. var _this = this;
  6281. if (dispose === void 0) { dispose = false; }
  6282. if (!container.sounds) {
  6283. return;
  6284. }
  6285. container.sounds.forEach(function (sound) {
  6286. sound.stop();
  6287. sound.autoplay = false;
  6288. _this.scene.mainSoundTrack.RemoveSound(sound);
  6289. if (dispose) {
  6290. sound.dispose();
  6291. }
  6292. });
  6293. };
  6294. /**
  6295. * Disposes the component and the associated ressources.
  6296. */
  6297. AudioSceneComponent.prototype.dispose = function () {
  6298. var scene = this.scene;
  6299. if (scene._mainSoundTrack) {
  6300. scene.mainSoundTrack.dispose();
  6301. }
  6302. if (scene.soundTracks) {
  6303. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  6304. scene.soundTracks[scIndex].dispose();
  6305. }
  6306. }
  6307. };
  6308. /**
  6309. * Disables audio in the associated scene.
  6310. */
  6311. AudioSceneComponent.prototype.disableAudio = function () {
  6312. var scene = this.scene;
  6313. this._audioEnabled = false;
  6314. var i;
  6315. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6316. scene.mainSoundTrack.soundCollection[i].pause();
  6317. }
  6318. if (scene.soundTracks) {
  6319. for (i = 0; i < scene.soundTracks.length; i++) {
  6320. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6321. scene.soundTracks[i].soundCollection[j].pause();
  6322. }
  6323. }
  6324. }
  6325. };
  6326. /**
  6327. * Enables audio in the associated scene.
  6328. */
  6329. AudioSceneComponent.prototype.enableAudio = function () {
  6330. var scene = this.scene;
  6331. this._audioEnabled = true;
  6332. var i;
  6333. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6334. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  6335. scene.mainSoundTrack.soundCollection[i].play();
  6336. }
  6337. }
  6338. if (scene.soundTracks) {
  6339. for (i = 0; i < scene.soundTracks.length; i++) {
  6340. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6341. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  6342. scene.soundTracks[i].soundCollection[j].play();
  6343. }
  6344. }
  6345. }
  6346. }
  6347. };
  6348. /**
  6349. * Switch audio to headphone output.
  6350. */
  6351. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  6352. var scene = this.scene;
  6353. this._headphone = true;
  6354. scene.mainSoundTrack.switchPanningModelToHRTF();
  6355. if (scene.soundTracks) {
  6356. for (var i = 0; i < scene.soundTracks.length; i++) {
  6357. scene.soundTracks[i].switchPanningModelToHRTF();
  6358. }
  6359. }
  6360. };
  6361. /**
  6362. * Switch audio to normal speakers.
  6363. */
  6364. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  6365. var scene = this.scene;
  6366. this._headphone = false;
  6367. scene.mainSoundTrack.switchPanningModelToEqualPower();
  6368. if (scene.soundTracks) {
  6369. for (var i = 0; i < scene.soundTracks.length; i++) {
  6370. scene.soundTracks[i].switchPanningModelToEqualPower();
  6371. }
  6372. }
  6373. };
  6374. AudioSceneComponent.prototype._afterRender = function () {
  6375. var scene = this.scene;
  6376. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6377. return;
  6378. }
  6379. var listeningCamera;
  6380. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6381. if (scene.activeCameras.length > 0) {
  6382. listeningCamera = scene.activeCameras[0];
  6383. }
  6384. else {
  6385. listeningCamera = scene.activeCamera;
  6386. }
  6387. if (listeningCamera && audioEngine.audioContext) {
  6388. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6389. // for VR cameras
  6390. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6391. listeningCamera = listeningCamera.rigCameras[0];
  6392. }
  6393. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6394. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6395. cameraDirection.normalize();
  6396. // To avoid some errors on GearVR
  6397. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6398. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6399. }
  6400. var i;
  6401. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6402. var sound = scene.mainSoundTrack.soundCollection[i];
  6403. if (sound.useCustomAttenuation) {
  6404. sound.updateDistanceFromListener();
  6405. }
  6406. }
  6407. if (scene.soundTracks) {
  6408. for (i = 0; i < scene.soundTracks.length; i++) {
  6409. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6410. sound = scene.soundTracks[i].soundCollection[j];
  6411. if (sound.useCustomAttenuation) {
  6412. sound.updateDistanceFromListener();
  6413. }
  6414. }
  6415. }
  6416. }
  6417. }
  6418. };
  6419. return AudioSceneComponent;
  6420. }());
  6421. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6422. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6423. if (!compo) {
  6424. compo = new AudioSceneComponent(scene);
  6425. scene._addComponent(compo);
  6426. }
  6427. };
  6428. /***/ }),
  6429. /***/ "./Audio/index.ts":
  6430. /*!************************!*\
  6431. !*** ./Audio/index.ts ***!
  6432. \************************/
  6433. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6434. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6435. "use strict";
  6436. __webpack_require__.r(__webpack_exports__);
  6437. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6439. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6441. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6443. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6445. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6447. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6449. /***/ }),
  6450. /***/ "./Audio/sound.ts":
  6451. /*!************************!*\
  6452. !*** ./Audio/sound.ts ***!
  6453. \************************/
  6454. /*! exports provided: Sound */
  6455. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6456. "use strict";
  6457. __webpack_require__.r(__webpack_exports__);
  6458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6459. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6460. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6461. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6462. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6463. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6464. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  6465. /**
  6466. * Defines a sound that can be played in the application.
  6467. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6469. */
  6470. var Sound = /** @class */ (function () {
  6471. /**
  6472. * Create a sound and attach it to a scene
  6473. * @param name Name of your sound
  6474. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6475. * @param scene defines the scene the sound belongs to
  6476. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6477. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6478. */
  6479. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6480. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6481. var _this = this;
  6482. /**
  6483. * Does the sound autoplay once loaded.
  6484. */
  6485. this.autoplay = false;
  6486. /**
  6487. * Does the sound loop after it finishes playing once.
  6488. */
  6489. this.loop = false;
  6490. /**
  6491. * Does the sound use a custom attenuation curve to simulate the falloff
  6492. * happening when the source gets further away from the camera.
  6493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6494. */
  6495. this.useCustomAttenuation = false;
  6496. /**
  6497. * Is this sound currently played.
  6498. */
  6499. this.isPlaying = false;
  6500. /**
  6501. * Is this sound currently paused.
  6502. */
  6503. this.isPaused = false;
  6504. /**
  6505. * Does this sound enables spatial sound.
  6506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6507. */
  6508. this.spatialSound = false;
  6509. /**
  6510. * Define the reference distance the sound should be heard perfectly.
  6511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6512. */
  6513. this.refDistance = 1;
  6514. /**
  6515. * Define the roll off factor of spatial sounds.
  6516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6517. */
  6518. this.rolloffFactor = 1;
  6519. /**
  6520. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6522. */
  6523. this.maxDistance = 100;
  6524. /**
  6525. * Define the distance attenuation model the sound will follow.
  6526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6527. */
  6528. this.distanceModel = "linear";
  6529. /**
  6530. * Observable event when the current playing sound finishes.
  6531. */
  6532. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6533. this._panningModel = "equalpower";
  6534. this._playbackRate = 1;
  6535. this._streaming = false;
  6536. this._startTime = 0;
  6537. this._startOffset = 0;
  6538. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6539. /** @hidden */
  6540. this._positionInEmitterSpace = false;
  6541. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6542. this._volume = 1;
  6543. this._isReadyToPlay = false;
  6544. this._isDirectional = false;
  6545. // Used if you'd like to create a directional sound.
  6546. // If not set, the sound will be omnidirectional
  6547. this._coneInnerAngle = 360;
  6548. this._coneOuterAngle = 360;
  6549. this._coneOuterGain = 0;
  6550. this._isOutputConnected = false;
  6551. this._urlType = "Unknown";
  6552. this.name = name;
  6553. this._scene = scene;
  6554. Sound._SceneComponentInitialization(scene);
  6555. this._readyToPlayCallback = readyToPlayCallback;
  6556. // Default custom attenuation function is a linear attenuation
  6557. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6558. if (currentDistance < maxDistance) {
  6559. return currentVolume * (1 - currentDistance / maxDistance);
  6560. }
  6561. else {
  6562. return 0;
  6563. }
  6564. };
  6565. if (options) {
  6566. this.autoplay = options.autoplay || false;
  6567. this.loop = options.loop || false;
  6568. // if volume === 0, we need another way to check this option
  6569. if (options.volume !== undefined) {
  6570. this._volume = options.volume;
  6571. }
  6572. this.spatialSound = options.spatialSound || false;
  6573. this.maxDistance = options.maxDistance || 100;
  6574. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6575. this.rolloffFactor = options.rolloffFactor || 1;
  6576. this.refDistance = options.refDistance || 1;
  6577. this.distanceModel = options.distanceModel || "linear";
  6578. this._playbackRate = options.playbackRate || 1;
  6579. this._streaming = options.streaming || false;
  6580. }
  6581. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6582. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6583. this._soundGain.gain.value = this._volume;
  6584. this._inputAudioNode = this._soundGain;
  6585. this._outputAudioNode = this._soundGain;
  6586. if (this.spatialSound) {
  6587. this._createSpatialParameters();
  6588. }
  6589. this._scene.mainSoundTrack.AddSound(this);
  6590. var validParameter = true;
  6591. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6592. if (urlOrArrayBuffer) {
  6593. try {
  6594. if (typeof (urlOrArrayBuffer) === "string") {
  6595. this._urlType = "String";
  6596. }
  6597. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6598. this._urlType = "ArrayBuffer";
  6599. }
  6600. else if (urlOrArrayBuffer instanceof MediaStream) {
  6601. this._urlType = "MediaStream";
  6602. }
  6603. else if (Array.isArray(urlOrArrayBuffer)) {
  6604. this._urlType = "Array";
  6605. }
  6606. var urls = [];
  6607. var codecSupportedFound = false;
  6608. switch (this._urlType) {
  6609. case "MediaStream":
  6610. this._streaming = true;
  6611. this._isReadyToPlay = true;
  6612. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6613. if (this.autoplay) {
  6614. this.play();
  6615. }
  6616. if (this._readyToPlayCallback) {
  6617. this._readyToPlayCallback();
  6618. }
  6619. break;
  6620. case "ArrayBuffer":
  6621. if (urlOrArrayBuffer.byteLength > 0) {
  6622. codecSupportedFound = true;
  6623. this._soundLoaded(urlOrArrayBuffer);
  6624. }
  6625. break;
  6626. case "String":
  6627. urls.push(urlOrArrayBuffer);
  6628. case "Array":
  6629. if (urls.length === 0) {
  6630. urls = urlOrArrayBuffer;
  6631. }
  6632. // If we found a supported format, we load it immediately and stop the loop
  6633. for (var i = 0; i < urls.length; i++) {
  6634. var url = urls[i];
  6635. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6636. codecSupportedFound = true;
  6637. }
  6638. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6639. codecSupportedFound = true;
  6640. }
  6641. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6642. codecSupportedFound = true;
  6643. }
  6644. if (url.indexOf("blob:") !== -1) {
  6645. codecSupportedFound = true;
  6646. }
  6647. if (codecSupportedFound) {
  6648. // Loading sound using XHR2
  6649. if (!this._streaming) {
  6650. this._scene._loadFile(url, function (data) {
  6651. _this._soundLoaded(data);
  6652. }, undefined, true, true, function (exception) {
  6653. if (exception) {
  6654. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6655. }
  6656. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6657. _this._scene.mainSoundTrack.RemoveSound(_this);
  6658. });
  6659. }
  6660. // Streaming sound using HTML5 Audio tag
  6661. else {
  6662. this._htmlAudioElement = new Audio(url);
  6663. this._htmlAudioElement.controls = false;
  6664. this._htmlAudioElement.loop = this.loop;
  6665. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6666. this._htmlAudioElement.preload = "auto";
  6667. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6668. _this._isReadyToPlay = true;
  6669. if (_this.autoplay) {
  6670. _this.play();
  6671. }
  6672. if (_this._readyToPlayCallback) {
  6673. _this._readyToPlayCallback();
  6674. }
  6675. });
  6676. document.body.appendChild(this._htmlAudioElement);
  6677. this._htmlAudioElement.load();
  6678. }
  6679. break;
  6680. }
  6681. }
  6682. break;
  6683. default:
  6684. validParameter = false;
  6685. break;
  6686. }
  6687. if (!validParameter) {
  6688. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.");
  6689. }
  6690. else {
  6691. if (!codecSupportedFound) {
  6692. this._isReadyToPlay = true;
  6693. // Simulating a ready to play event to avoid breaking code path
  6694. if (this._readyToPlayCallback) {
  6695. window.setTimeout(function () {
  6696. if (_this._readyToPlayCallback) {
  6697. _this._readyToPlayCallback();
  6698. }
  6699. }, 1000);
  6700. }
  6701. }
  6702. }
  6703. }
  6704. catch (ex) {
  6705. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6706. this._scene.mainSoundTrack.RemoveSound(this);
  6707. }
  6708. }
  6709. }
  6710. else {
  6711. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6712. this._scene.mainSoundTrack.AddSound(this);
  6713. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6714. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6715. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6716. }
  6717. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6718. if (this._readyToPlayCallback) {
  6719. window.setTimeout(function () {
  6720. if (_this._readyToPlayCallback) {
  6721. _this._readyToPlayCallback();
  6722. }
  6723. }, 1000);
  6724. }
  6725. }
  6726. }
  6727. /**
  6728. * Release the sound and its associated resources
  6729. */
  6730. Sound.prototype.dispose = function () {
  6731. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6732. if (this.isPlaying) {
  6733. this.stop();
  6734. }
  6735. this._isReadyToPlay = false;
  6736. if (this.soundTrackId === -1) {
  6737. this._scene.mainSoundTrack.RemoveSound(this);
  6738. }
  6739. else if (this._scene.soundTracks) {
  6740. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6741. }
  6742. if (this._soundGain) {
  6743. this._soundGain.disconnect();
  6744. this._soundGain = null;
  6745. }
  6746. if (this._soundPanner) {
  6747. this._soundPanner.disconnect();
  6748. this._soundPanner = null;
  6749. }
  6750. if (this._soundSource) {
  6751. this._soundSource.disconnect();
  6752. this._soundSource = null;
  6753. }
  6754. this._audioBuffer = null;
  6755. if (this._htmlAudioElement) {
  6756. this._htmlAudioElement.pause();
  6757. this._htmlAudioElement.src = "";
  6758. document.body.removeChild(this._htmlAudioElement);
  6759. }
  6760. if (this._streamingSource) {
  6761. this._streamingSource.disconnect();
  6762. }
  6763. if (this._connectedTransformNode && this._registerFunc) {
  6764. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6765. this._connectedTransformNode = null;
  6766. }
  6767. }
  6768. };
  6769. /**
  6770. * Gets if the sounds is ready to be played or not.
  6771. * @returns true if ready, otherwise false
  6772. */
  6773. Sound.prototype.isReady = function () {
  6774. return this._isReadyToPlay;
  6775. };
  6776. Sound.prototype._soundLoaded = function (audioData) {
  6777. var _this = this;
  6778. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6779. return;
  6780. }
  6781. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6782. _this._audioBuffer = buffer;
  6783. _this._isReadyToPlay = true;
  6784. if (_this.autoplay) {
  6785. _this.play();
  6786. }
  6787. if (_this._readyToPlayCallback) {
  6788. _this._readyToPlayCallback();
  6789. }
  6790. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6791. };
  6792. /**
  6793. * Sets the data of the sound from an audiobuffer
  6794. * @param audioBuffer The audioBuffer containing the data
  6795. */
  6796. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6797. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6798. this._audioBuffer = audioBuffer;
  6799. this._isReadyToPlay = true;
  6800. }
  6801. };
  6802. /**
  6803. * Updates the current sounds options such as maxdistance, loop...
  6804. * @param options A JSON object containing values named as the object properties
  6805. */
  6806. Sound.prototype.updateOptions = function (options) {
  6807. if (options) {
  6808. this.loop = options.loop || this.loop;
  6809. this.maxDistance = options.maxDistance || this.maxDistance;
  6810. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6811. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6812. this.refDistance = options.refDistance || this.refDistance;
  6813. this.distanceModel = options.distanceModel || this.distanceModel;
  6814. this._playbackRate = options.playbackRate || this._playbackRate;
  6815. this._updateSpatialParameters();
  6816. if (this.isPlaying) {
  6817. if (this._streaming && this._htmlAudioElement) {
  6818. this._htmlAudioElement.playbackRate = this._playbackRate;
  6819. }
  6820. else {
  6821. if (this._soundSource) {
  6822. this._soundSource.playbackRate.value = this._playbackRate;
  6823. }
  6824. }
  6825. }
  6826. }
  6827. };
  6828. Sound.prototype._createSpatialParameters = function () {
  6829. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6830. if (this._scene.headphone) {
  6831. this._panningModel = "HRTF";
  6832. }
  6833. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6834. this._updateSpatialParameters();
  6835. this._soundPanner.connect(this._outputAudioNode);
  6836. this._inputAudioNode = this._soundPanner;
  6837. }
  6838. };
  6839. Sound.prototype._updateSpatialParameters = function () {
  6840. if (this.spatialSound && this._soundPanner) {
  6841. if (this.useCustomAttenuation) {
  6842. // Tricks to disable in a way embedded Web Audio attenuation
  6843. this._soundPanner.distanceModel = "linear";
  6844. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6845. this._soundPanner.refDistance = 1;
  6846. this._soundPanner.rolloffFactor = 1;
  6847. this._soundPanner.panningModel = this._panningModel;
  6848. }
  6849. else {
  6850. this._soundPanner.distanceModel = this.distanceModel;
  6851. this._soundPanner.maxDistance = this.maxDistance;
  6852. this._soundPanner.refDistance = this.refDistance;
  6853. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6854. this._soundPanner.panningModel = this._panningModel;
  6855. }
  6856. }
  6857. };
  6858. /**
  6859. * Switch the panning model to HRTF:
  6860. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6861. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6862. */
  6863. Sound.prototype.switchPanningModelToHRTF = function () {
  6864. this._panningModel = "HRTF";
  6865. this._switchPanningModel();
  6866. };
  6867. /**
  6868. * Switch the panning model to Equal Power:
  6869. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6871. */
  6872. Sound.prototype.switchPanningModelToEqualPower = function () {
  6873. this._panningModel = "equalpower";
  6874. this._switchPanningModel();
  6875. };
  6876. Sound.prototype._switchPanningModel = function () {
  6877. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6878. this._soundPanner.panningModel = this._panningModel;
  6879. }
  6880. };
  6881. /**
  6882. * Connect this sound to a sound track audio node like gain...
  6883. * @param soundTrackAudioNode the sound track audio node to connect to
  6884. */
  6885. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6886. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6887. if (this._isOutputConnected) {
  6888. this._outputAudioNode.disconnect();
  6889. }
  6890. this._outputAudioNode.connect(soundTrackAudioNode);
  6891. this._isOutputConnected = true;
  6892. }
  6893. };
  6894. /**
  6895. * Transform this sound into a directional source
  6896. * @param coneInnerAngle Size of the inner cone in degree
  6897. * @param coneOuterAngle Size of the outer cone in degree
  6898. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6899. */
  6900. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6901. if (coneOuterAngle < coneInnerAngle) {
  6902. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6903. return;
  6904. }
  6905. this._coneInnerAngle = coneInnerAngle;
  6906. this._coneOuterAngle = coneOuterAngle;
  6907. this._coneOuterGain = coneOuterGain;
  6908. this._isDirectional = true;
  6909. if (this.isPlaying && this.loop) {
  6910. this.stop();
  6911. this.play();
  6912. }
  6913. };
  6914. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6915. /**
  6916. * Gets or sets the inner angle for the directional cone.
  6917. */
  6918. get: function () {
  6919. return this._coneInnerAngle;
  6920. },
  6921. /**
  6922. * Gets or sets the inner angle for the directional cone.
  6923. */
  6924. set: function (value) {
  6925. if (value != this._coneInnerAngle) {
  6926. if (this._coneOuterAngle < value) {
  6927. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6928. return;
  6929. }
  6930. this._coneInnerAngle = value;
  6931. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6932. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6933. }
  6934. }
  6935. },
  6936. enumerable: true,
  6937. configurable: true
  6938. });
  6939. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6940. /**
  6941. * Gets or sets the outer angle for the directional cone.
  6942. */
  6943. get: function () {
  6944. return this._coneOuterAngle;
  6945. },
  6946. /**
  6947. * Gets or sets the outer angle for the directional cone.
  6948. */
  6949. set: function (value) {
  6950. if (value != this._coneOuterAngle) {
  6951. if (value < this._coneInnerAngle) {
  6952. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6953. return;
  6954. }
  6955. this._coneOuterAngle = value;
  6956. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6957. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6958. }
  6959. }
  6960. },
  6961. enumerable: true,
  6962. configurable: true
  6963. });
  6964. /**
  6965. * Sets the position of the emitter if spatial sound is enabled
  6966. * @param newPosition Defines the new posisiton
  6967. */
  6968. Sound.prototype.setPosition = function (newPosition) {
  6969. this._position = newPosition;
  6970. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6971. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6972. }
  6973. };
  6974. /**
  6975. * Sets the local direction of the emitter if spatial sound is enabled
  6976. * @param newLocalDirection Defines the new local direction
  6977. */
  6978. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6979. this._localDirection = newLocalDirection;
  6980. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6981. this._updateDirection();
  6982. }
  6983. };
  6984. Sound.prototype._updateDirection = function () {
  6985. if (!this._connectedTransformNode || !this._soundPanner) {
  6986. return;
  6987. }
  6988. var mat = this._connectedTransformNode.getWorldMatrix();
  6989. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  6990. direction.normalize();
  6991. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  6992. };
  6993. /** @hidden */
  6994. Sound.prototype.updateDistanceFromListener = function () {
  6995. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  6996. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  6997. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  6998. }
  6999. };
  7000. /**
  7001. * Sets a new custom attenuation function for the sound.
  7002. * @param callback Defines the function used for the attenuation
  7003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  7004. */
  7005. Sound.prototype.setAttenuationFunction = function (callback) {
  7006. this._customAttenuationFunction = callback;
  7007. };
  7008. /**
  7009. * Play the sound
  7010. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  7011. * @param offset (optional) Start the sound setting it at a specific time
  7012. */
  7013. Sound.prototype.play = function (time, offset) {
  7014. var _this = this;
  7015. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7016. try {
  7017. if (this._startOffset < 0) {
  7018. time = -this._startOffset;
  7019. this._startOffset = 0;
  7020. }
  7021. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7022. if (!this._soundSource || !this._streamingSource) {
  7023. if (this.spatialSound && this._soundPanner) {
  7024. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  7025. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  7026. }
  7027. if (this._isDirectional) {
  7028. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  7029. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  7030. this._soundPanner.coneOuterGain = this._coneOuterGain;
  7031. if (this._connectedTransformNode) {
  7032. this._updateDirection();
  7033. }
  7034. else {
  7035. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  7036. }
  7037. }
  7038. }
  7039. }
  7040. if (this._streaming) {
  7041. if (!this._streamingSource) {
  7042. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  7043. this._htmlAudioElement.onended = function () { _this._onended(); };
  7044. this._htmlAudioElement.playbackRate = this._playbackRate;
  7045. }
  7046. this._streamingSource.disconnect();
  7047. this._streamingSource.connect(this._inputAudioNode);
  7048. if (this._htmlAudioElement) {
  7049. // required to manage properly the new suspended default state of Chrome
  7050. // When the option 'streaming: true' is used, we need first to wait for
  7051. // the audio engine to be unlocked by a user gesture before trying to play
  7052. // an HTML Audio elememt
  7053. var tryToPlay = function () {
  7054. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  7055. var playPromise = _this._htmlAudioElement.play();
  7056. // In browsers that don’t yet support this functionality,
  7057. // playPromise won’t be defined.
  7058. if (playPromise !== undefined) {
  7059. playPromise.catch(function (error) {
  7060. // Automatic playback failed.
  7061. // Waiting for the audio engine to be unlocked by user click on unmute
  7062. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7063. if (_this.loop || _this.autoplay) {
  7064. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7065. }
  7066. });
  7067. }
  7068. }
  7069. else {
  7070. if (_this.loop || _this.autoplay) {
  7071. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7072. }
  7073. }
  7074. };
  7075. tryToPlay();
  7076. }
  7077. }
  7078. else {
  7079. var tryToPlay = function () {
  7080. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7081. _this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  7082. _this._soundSource.buffer = _this._audioBuffer;
  7083. _this._soundSource.connect(_this._inputAudioNode);
  7084. _this._soundSource.loop = _this.loop;
  7085. _this._soundSource.playbackRate.value = _this._playbackRate;
  7086. _this._soundSource.onended = function () { _this._onended(); };
  7087. startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7088. _this._soundSource.start(startTime, _this.isPaused ? _this._startOffset % _this._soundSource.buffer.duration : offset ? offset : 0);
  7089. }
  7090. };
  7091. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7092. // Wait a bit for FF as context seems late to be ready.
  7093. setTimeout(function () {
  7094. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7095. // Automatic playback failed.
  7096. // Waiting for the audio engine to be unlocked by user click on unmute
  7097. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7098. if (_this.loop || _this.autoplay) {
  7099. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7100. }
  7101. }
  7102. else {
  7103. tryToPlay();
  7104. }
  7105. }, 500);
  7106. }
  7107. else {
  7108. tryToPlay();
  7109. }
  7110. }
  7111. this._startTime = startTime;
  7112. this.isPlaying = true;
  7113. this.isPaused = false;
  7114. }
  7115. catch (ex) {
  7116. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  7117. }
  7118. }
  7119. };
  7120. Sound.prototype._onended = function () {
  7121. this.isPlaying = false;
  7122. if (this.onended) {
  7123. this.onended();
  7124. }
  7125. this.onEndedObservable.notifyObservers(this);
  7126. };
  7127. /**
  7128. * Stop the sound
  7129. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  7130. */
  7131. Sound.prototype.stop = function (time) {
  7132. var _this = this;
  7133. if (this.isPlaying) {
  7134. if (this._streaming) {
  7135. if (this._htmlAudioElement) {
  7136. this._htmlAudioElement.pause();
  7137. // Test needed for Firefox or it will generate an Invalid State Error
  7138. if (this._htmlAudioElement.currentTime > 0) {
  7139. this._htmlAudioElement.currentTime = 0;
  7140. }
  7141. }
  7142. else {
  7143. this._streamingSource.disconnect();
  7144. }
  7145. this.isPlaying = false;
  7146. }
  7147. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  7148. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7149. this._soundSource.stop(stopTime);
  7150. this._soundSource.onended = function () { _this.isPlaying = false; };
  7151. if (!this.isPaused) {
  7152. this._startOffset = 0;
  7153. }
  7154. }
  7155. }
  7156. };
  7157. /**
  7158. * Put the sound in pause
  7159. */
  7160. Sound.prototype.pause = function () {
  7161. if (this.isPlaying) {
  7162. this.isPaused = true;
  7163. if (this._streaming) {
  7164. if (this._htmlAudioElement) {
  7165. this._htmlAudioElement.pause();
  7166. }
  7167. else {
  7168. this._streamingSource.disconnect();
  7169. }
  7170. }
  7171. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7172. this.stop(0);
  7173. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  7174. }
  7175. }
  7176. };
  7177. /**
  7178. * Sets a dedicated volume for this sounds
  7179. * @param newVolume Define the new volume of the sound
  7180. * @param time Define in how long the sound should be at this value
  7181. */
  7182. Sound.prototype.setVolume = function (newVolume, time) {
  7183. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  7184. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7185. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7186. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7187. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  7188. }
  7189. else {
  7190. this._soundGain.gain.value = newVolume;
  7191. }
  7192. }
  7193. this._volume = newVolume;
  7194. };
  7195. /**
  7196. * Set the sound play back rate
  7197. * @param newPlaybackRate Define the playback rate the sound should be played at
  7198. */
  7199. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  7200. this._playbackRate = newPlaybackRate;
  7201. if (this.isPlaying) {
  7202. if (this._streaming && this._htmlAudioElement) {
  7203. this._htmlAudioElement.playbackRate = this._playbackRate;
  7204. }
  7205. else if (this._soundSource) {
  7206. this._soundSource.playbackRate.value = this._playbackRate;
  7207. }
  7208. }
  7209. };
  7210. /**
  7211. * Gets the volume of the sound.
  7212. * @returns the volume of the sound
  7213. */
  7214. Sound.prototype.getVolume = function () {
  7215. return this._volume;
  7216. };
  7217. /**
  7218. * Attach the sound to a dedicated mesh
  7219. * @param transformNode The transform node to connect the sound with
  7220. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7221. */
  7222. Sound.prototype.attachToMesh = function (transformNode) {
  7223. var _this = this;
  7224. if (this._connectedTransformNode && this._registerFunc) {
  7225. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7226. this._registerFunc = null;
  7227. }
  7228. this._connectedTransformNode = transformNode;
  7229. if (!this.spatialSound) {
  7230. this.spatialSound = true;
  7231. this._createSpatialParameters();
  7232. if (this.isPlaying && this.loop) {
  7233. this.stop();
  7234. this.play();
  7235. }
  7236. }
  7237. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  7238. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  7239. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  7240. };
  7241. /**
  7242. * Detach the sound from the previously attached mesh
  7243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7244. */
  7245. Sound.prototype.detachFromMesh = function () {
  7246. if (this._connectedTransformNode && this._registerFunc) {
  7247. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7248. this._registerFunc = null;
  7249. this._connectedTransformNode = null;
  7250. }
  7251. };
  7252. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  7253. if (!node.getBoundingInfo) {
  7254. return;
  7255. }
  7256. var mesh = node;
  7257. if (this._positionInEmitterSpace) {
  7258. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  7259. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  7260. }
  7261. else {
  7262. var boundingInfo = mesh.getBoundingInfo();
  7263. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  7264. }
  7265. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  7266. this._updateDirection();
  7267. }
  7268. };
  7269. /**
  7270. * Clone the current sound in the scene.
  7271. * @returns the new sound clone
  7272. */
  7273. Sound.prototype.clone = function () {
  7274. var _this = this;
  7275. if (!this._streaming) {
  7276. var setBufferAndRun = function () {
  7277. if (_this._isReadyToPlay) {
  7278. clonedSound._audioBuffer = _this.getAudioBuffer();
  7279. clonedSound._isReadyToPlay = true;
  7280. if (clonedSound.autoplay) {
  7281. clonedSound.play();
  7282. }
  7283. }
  7284. else {
  7285. window.setTimeout(setBufferAndRun, 300);
  7286. }
  7287. };
  7288. var currentOptions = {
  7289. autoplay: this.autoplay, loop: this.loop,
  7290. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  7291. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  7292. refDistance: this.refDistance, distanceModel: this.distanceModel
  7293. };
  7294. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  7295. if (this.useCustomAttenuation) {
  7296. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  7297. }
  7298. clonedSound.setPosition(this._position);
  7299. clonedSound.setPlaybackRate(this._playbackRate);
  7300. setBufferAndRun();
  7301. return clonedSound;
  7302. }
  7303. // Can't clone a streaming sound
  7304. else {
  7305. return null;
  7306. }
  7307. };
  7308. /**
  7309. * Gets the current underlying audio buffer containing the data
  7310. * @returns the audio buffer
  7311. */
  7312. Sound.prototype.getAudioBuffer = function () {
  7313. return this._audioBuffer;
  7314. };
  7315. /**
  7316. * Serializes the Sound in a JSON representation
  7317. * @returns the JSON representation of the sound
  7318. */
  7319. Sound.prototype.serialize = function () {
  7320. var serializationObject = {
  7321. name: this.name,
  7322. url: this.name,
  7323. autoplay: this.autoplay,
  7324. loop: this.loop,
  7325. volume: this._volume,
  7326. spatialSound: this.spatialSound,
  7327. maxDistance: this.maxDistance,
  7328. rolloffFactor: this.rolloffFactor,
  7329. refDistance: this.refDistance,
  7330. distanceModel: this.distanceModel,
  7331. playbackRate: this._playbackRate,
  7332. panningModel: this._panningModel,
  7333. soundTrackId: this.soundTrackId
  7334. };
  7335. if (this.spatialSound) {
  7336. if (this._connectedTransformNode) {
  7337. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  7338. }
  7339. serializationObject.position = this._position.asArray();
  7340. serializationObject.refDistance = this.refDistance;
  7341. serializationObject.distanceModel = this.distanceModel;
  7342. serializationObject.isDirectional = this._isDirectional;
  7343. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  7344. serializationObject.coneInnerAngle = this._coneInnerAngle;
  7345. serializationObject.coneOuterAngle = this._coneOuterAngle;
  7346. serializationObject.coneOuterGain = this._coneOuterGain;
  7347. }
  7348. return serializationObject;
  7349. };
  7350. /**
  7351. * Parse a JSON representation of a sound to innstantiate in a given scene
  7352. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  7353. * @param scene Define the scene the new parsed sound should be created in
  7354. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  7355. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  7356. * @returns the newly parsed sound
  7357. */
  7358. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  7359. var soundName = parsedSound.name;
  7360. var soundUrl;
  7361. if (parsedSound.url) {
  7362. soundUrl = rootUrl + parsedSound.url;
  7363. }
  7364. else {
  7365. soundUrl = rootUrl + soundName;
  7366. }
  7367. var options = {
  7368. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  7369. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  7370. rolloffFactor: parsedSound.rolloffFactor,
  7371. refDistance: parsedSound.refDistance,
  7372. distanceModel: parsedSound.distanceModel,
  7373. playbackRate: parsedSound.playbackRate
  7374. };
  7375. var newSound;
  7376. if (!sourceSound) {
  7377. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  7378. scene._addPendingData(newSound);
  7379. }
  7380. else {
  7381. var setBufferAndRun = function () {
  7382. if (sourceSound._isReadyToPlay) {
  7383. newSound._audioBuffer = sourceSound.getAudioBuffer();
  7384. newSound._isReadyToPlay = true;
  7385. if (newSound.autoplay) {
  7386. newSound.play();
  7387. }
  7388. }
  7389. else {
  7390. window.setTimeout(setBufferAndRun, 300);
  7391. }
  7392. };
  7393. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  7394. setBufferAndRun();
  7395. }
  7396. if (parsedSound.position) {
  7397. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  7398. newSound.setPosition(soundPosition);
  7399. }
  7400. if (parsedSound.isDirectional) {
  7401. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7402. if (parsedSound.localDirectionToMesh) {
  7403. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7404. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7405. }
  7406. }
  7407. if (parsedSound.connectedMeshId) {
  7408. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7409. if (connectedMesh) {
  7410. newSound.attachToMesh(connectedMesh);
  7411. }
  7412. }
  7413. return newSound;
  7414. };
  7415. /** @hidden */
  7416. Sound._SceneComponentInitialization = function (_) {
  7417. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AudioSceneComponent");
  7418. };
  7419. return Sound;
  7420. }());
  7421. /***/ }),
  7422. /***/ "./Audio/soundTrack.ts":
  7423. /*!*****************************!*\
  7424. !*** ./Audio/soundTrack.ts ***!
  7425. \*****************************/
  7426. /*! exports provided: SoundTrack */
  7427. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7428. "use strict";
  7429. __webpack_require__.r(__webpack_exports__);
  7430. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7431. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7432. /**
  7433. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7434. * It will be also used in a future release to apply effects on a specific track.
  7435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7436. */
  7437. var SoundTrack = /** @class */ (function () {
  7438. /**
  7439. * Creates a new sound track.
  7440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7441. * @param scene Define the scene the sound track belongs to
  7442. * @param options
  7443. */
  7444. function SoundTrack(scene, options) {
  7445. if (options === void 0) { options = {}; }
  7446. /**
  7447. * The unique identifier of the sound track in the scene.
  7448. */
  7449. this.id = -1;
  7450. this._isMainTrack = false;
  7451. this._isInitialized = false;
  7452. this._scene = scene;
  7453. this.soundCollection = new Array();
  7454. this._options = options;
  7455. if (!this._isMainTrack && this._scene.soundTracks) {
  7456. this._scene.soundTracks.push(this);
  7457. this.id = this._scene.soundTracks.length - 1;
  7458. }
  7459. }
  7460. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7461. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7462. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7463. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7464. if (this._options) {
  7465. if (this._options.volume) {
  7466. this._outputAudioNode.gain.value = this._options.volume;
  7467. }
  7468. if (this._options.mainTrack) {
  7469. this._isMainTrack = this._options.mainTrack;
  7470. }
  7471. }
  7472. this._isInitialized = true;
  7473. }
  7474. };
  7475. /**
  7476. * Release the sound track and its associated resources
  7477. */
  7478. SoundTrack.prototype.dispose = function () {
  7479. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7480. if (this._connectedAnalyser) {
  7481. this._connectedAnalyser.stopDebugCanvas();
  7482. }
  7483. while (this.soundCollection.length) {
  7484. this.soundCollection[0].dispose();
  7485. }
  7486. if (this._outputAudioNode) {
  7487. this._outputAudioNode.disconnect();
  7488. }
  7489. this._outputAudioNode = null;
  7490. }
  7491. };
  7492. /**
  7493. * Adds a sound to this sound track
  7494. * @param sound define the cound to add
  7495. * @ignoreNaming
  7496. */
  7497. SoundTrack.prototype.AddSound = function (sound) {
  7498. if (!this._isInitialized) {
  7499. this._initializeSoundTrackAudioGraph();
  7500. }
  7501. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7502. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7503. }
  7504. if (sound.soundTrackId) {
  7505. if (sound.soundTrackId === -1) {
  7506. this._scene.mainSoundTrack.RemoveSound(sound);
  7507. }
  7508. else if (this._scene.soundTracks) {
  7509. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7510. }
  7511. }
  7512. this.soundCollection.push(sound);
  7513. sound.soundTrackId = this.id;
  7514. };
  7515. /**
  7516. * Removes a sound to this sound track
  7517. * @param sound define the cound to remove
  7518. * @ignoreNaming
  7519. */
  7520. SoundTrack.prototype.RemoveSound = function (sound) {
  7521. var index = this.soundCollection.indexOf(sound);
  7522. if (index !== -1) {
  7523. this.soundCollection.splice(index, 1);
  7524. }
  7525. };
  7526. /**
  7527. * Set a global volume for the full sound track.
  7528. * @param newVolume Define the new volume of the sound track
  7529. */
  7530. SoundTrack.prototype.setVolume = function (newVolume) {
  7531. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7532. this._outputAudioNode.gain.value = newVolume;
  7533. }
  7534. };
  7535. /**
  7536. * Switch the panning model to HRTF:
  7537. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7539. */
  7540. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7541. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7542. for (var i = 0; i < this.soundCollection.length; i++) {
  7543. this.soundCollection[i].switchPanningModelToHRTF();
  7544. }
  7545. }
  7546. };
  7547. /**
  7548. * Switch the panning model to Equal Power:
  7549. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7551. */
  7552. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7553. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7554. for (var i = 0; i < this.soundCollection.length; i++) {
  7555. this.soundCollection[i].switchPanningModelToEqualPower();
  7556. }
  7557. }
  7558. };
  7559. /**
  7560. * Connect the sound track to an audio analyser allowing some amazing
  7561. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7562. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7563. * @param analyser The analyser to connect to the engine
  7564. */
  7565. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7566. if (this._connectedAnalyser) {
  7567. this._connectedAnalyser.stopDebugCanvas();
  7568. }
  7569. this._connectedAnalyser = analyser;
  7570. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7571. this._outputAudioNode.disconnect();
  7572. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7573. }
  7574. };
  7575. return SoundTrack;
  7576. }());
  7577. /***/ }),
  7578. /***/ "./Audio/weightedsound.ts":
  7579. /*!********************************!*\
  7580. !*** ./Audio/weightedsound.ts ***!
  7581. \********************************/
  7582. /*! exports provided: WeightedSound */
  7583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7584. "use strict";
  7585. __webpack_require__.r(__webpack_exports__);
  7586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7587. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7588. /**
  7589. * Wraps one or more Sound objects and selects one with random weight for playback.
  7590. */
  7591. var WeightedSound = /** @class */ (function () {
  7592. /**
  7593. * Creates a new WeightedSound from the list of sounds given.
  7594. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7595. * @param sounds Array of Sounds that will be selected from.
  7596. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7597. */
  7598. function WeightedSound(loop, sounds, weights) {
  7599. var _this = this;
  7600. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7601. this.loop = false;
  7602. this._coneInnerAngle = 360;
  7603. this._coneOuterAngle = 360;
  7604. this._volume = 1;
  7605. /** A Sound is currently playing. */
  7606. this.isPlaying = false;
  7607. /** A Sound is currently paused. */
  7608. this.isPaused = false;
  7609. this._sounds = [];
  7610. this._weights = [];
  7611. if (sounds.length !== weights.length) {
  7612. throw new Error('Sounds length does not equal weights length');
  7613. }
  7614. this.loop = loop;
  7615. this._weights = weights;
  7616. // Normalize the weights
  7617. var weightSum = 0;
  7618. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7619. var weight = weights_1[_i];
  7620. weightSum += weight;
  7621. }
  7622. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7623. for (var i = 0; i < this._weights.length; i++) {
  7624. this._weights[i] *= invWeightSum;
  7625. }
  7626. this._sounds = sounds;
  7627. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7628. var sound = _b[_a];
  7629. sound.onEndedObservable.add(function () { _this._onended(); });
  7630. }
  7631. }
  7632. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7633. /**
  7634. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7635. */
  7636. get: function () {
  7637. return this._coneInnerAngle;
  7638. },
  7639. /**
  7640. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7641. */
  7642. set: function (value) {
  7643. if (value !== this._coneInnerAngle) {
  7644. if (this._coneOuterAngle < value) {
  7645. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7646. return;
  7647. }
  7648. this._coneInnerAngle = value;
  7649. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7650. var sound = _a[_i];
  7651. sound.directionalConeInnerAngle = value;
  7652. }
  7653. }
  7654. },
  7655. enumerable: true,
  7656. configurable: true
  7657. });
  7658. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7659. /**
  7660. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7661. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7662. */
  7663. get: function () {
  7664. return this._coneOuterAngle;
  7665. },
  7666. /**
  7667. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7668. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7669. */
  7670. set: function (value) {
  7671. if (value !== this._coneOuterAngle) {
  7672. if (value < this._coneInnerAngle) {
  7673. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7674. return;
  7675. }
  7676. this._coneOuterAngle = value;
  7677. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7678. var sound = _a[_i];
  7679. sound.directionalConeOuterAngle = value;
  7680. }
  7681. }
  7682. },
  7683. enumerable: true,
  7684. configurable: true
  7685. });
  7686. Object.defineProperty(WeightedSound.prototype, "volume", {
  7687. /**
  7688. * Playback volume.
  7689. */
  7690. get: function () {
  7691. return this._volume;
  7692. },
  7693. /**
  7694. * Playback volume.
  7695. */
  7696. set: function (value) {
  7697. if (value !== this._volume) {
  7698. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7699. var sound = _a[_i];
  7700. sound.setVolume(value);
  7701. }
  7702. }
  7703. },
  7704. enumerable: true,
  7705. configurable: true
  7706. });
  7707. WeightedSound.prototype._onended = function () {
  7708. if (this._currentIndex !== undefined) {
  7709. this._sounds[this._currentIndex].autoplay = false;
  7710. }
  7711. if (this.loop && this.isPlaying) {
  7712. this.play();
  7713. }
  7714. else {
  7715. this.isPlaying = false;
  7716. }
  7717. };
  7718. /**
  7719. * Suspend playback
  7720. */
  7721. WeightedSound.prototype.pause = function () {
  7722. this.isPaused = true;
  7723. if (this._currentIndex !== undefined) {
  7724. this._sounds[this._currentIndex].pause();
  7725. }
  7726. };
  7727. /**
  7728. * Stop playback
  7729. */
  7730. WeightedSound.prototype.stop = function () {
  7731. this.isPlaying = false;
  7732. if (this._currentIndex !== undefined) {
  7733. this._sounds[this._currentIndex].stop();
  7734. }
  7735. };
  7736. /**
  7737. * Start playback.
  7738. * @param startOffset Position the clip head at a specific time in seconds.
  7739. */
  7740. WeightedSound.prototype.play = function (startOffset) {
  7741. if (!this.isPaused) {
  7742. this.stop();
  7743. var randomValue = Math.random();
  7744. var total = 0;
  7745. for (var i = 0; i < this._weights.length; i++) {
  7746. total += this._weights[i];
  7747. if (randomValue <= total) {
  7748. this._currentIndex = i;
  7749. break;
  7750. }
  7751. }
  7752. }
  7753. var sound = this._sounds[this._currentIndex];
  7754. if (sound.isReady()) {
  7755. sound.play(0, this.isPaused ? undefined : startOffset);
  7756. }
  7757. else {
  7758. sound.autoplay = true;
  7759. }
  7760. this.isPlaying = true;
  7761. this.isPaused = false;
  7762. };
  7763. return WeightedSound;
  7764. }());
  7765. /***/ }),
  7766. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7767. /*!***************************************************!*\
  7768. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7769. \***************************************************/
  7770. /*! exports provided: AutoRotationBehavior */
  7771. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7772. "use strict";
  7773. __webpack_require__.r(__webpack_exports__);
  7774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7775. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7776. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7777. /**
  7778. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7779. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7780. */
  7781. var AutoRotationBehavior = /** @class */ (function () {
  7782. function AutoRotationBehavior() {
  7783. this._zoomStopsAnimation = false;
  7784. this._idleRotationSpeed = 0.05;
  7785. this._idleRotationWaitTime = 2000;
  7786. this._idleRotationSpinupTime = 2000;
  7787. this._isPointerDown = false;
  7788. this._lastFrameTime = null;
  7789. this._lastInteractionTime = -Infinity;
  7790. this._cameraRotationSpeed = 0;
  7791. this._lastFrameRadius = 0;
  7792. }
  7793. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7794. /**
  7795. * Gets the name of the behavior.
  7796. */
  7797. get: function () {
  7798. return "AutoRotation";
  7799. },
  7800. enumerable: true,
  7801. configurable: true
  7802. });
  7803. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7804. /**
  7805. * Gets the flag that indicates if user zooming should stop animation.
  7806. */
  7807. get: function () {
  7808. return this._zoomStopsAnimation;
  7809. },
  7810. /**
  7811. * Sets the flag that indicates if user zooming should stop animation.
  7812. */
  7813. set: function (flag) {
  7814. this._zoomStopsAnimation = flag;
  7815. },
  7816. enumerable: true,
  7817. configurable: true
  7818. });
  7819. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7820. /**
  7821. * Gets the default speed at which the camera rotates around the model.
  7822. */
  7823. get: function () {
  7824. return this._idleRotationSpeed;
  7825. },
  7826. /**
  7827. * Sets the default speed at which the camera rotates around the model.
  7828. */
  7829. set: function (speed) {
  7830. this._idleRotationSpeed = speed;
  7831. },
  7832. enumerable: true,
  7833. configurable: true
  7834. });
  7835. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7836. /**
  7837. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7838. */
  7839. get: function () {
  7840. return this._idleRotationWaitTime;
  7841. },
  7842. /**
  7843. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7844. */
  7845. set: function (time) {
  7846. this._idleRotationWaitTime = time;
  7847. },
  7848. enumerable: true,
  7849. configurable: true
  7850. });
  7851. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7852. /**
  7853. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7854. */
  7855. get: function () {
  7856. return this._idleRotationSpinupTime;
  7857. },
  7858. /**
  7859. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7860. */
  7861. set: function (time) {
  7862. this._idleRotationSpinupTime = time;
  7863. },
  7864. enumerable: true,
  7865. configurable: true
  7866. });
  7867. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7868. /**
  7869. * Gets a value indicating if the camera is currently rotating because of this behavior
  7870. */
  7871. get: function () {
  7872. return Math.abs(this._cameraRotationSpeed) > 0;
  7873. },
  7874. enumerable: true,
  7875. configurable: true
  7876. });
  7877. /**
  7878. * Initializes the behavior.
  7879. */
  7880. AutoRotationBehavior.prototype.init = function () {
  7881. // Do notihng
  7882. };
  7883. /**
  7884. * Attaches the behavior to its arc rotate camera.
  7885. * @param camera Defines the camera to attach the behavior to
  7886. */
  7887. AutoRotationBehavior.prototype.attach = function (camera) {
  7888. var _this = this;
  7889. this._attachedCamera = camera;
  7890. var scene = this._attachedCamera.getScene();
  7891. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7892. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7893. _this._isPointerDown = true;
  7894. return;
  7895. }
  7896. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7897. _this._isPointerDown = false;
  7898. }
  7899. });
  7900. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7901. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7902. var dt = 0;
  7903. if (_this._lastFrameTime != null) {
  7904. dt = now - _this._lastFrameTime;
  7905. }
  7906. _this._lastFrameTime = now;
  7907. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7908. _this._applyUserInteraction();
  7909. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7910. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7911. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7912. // Step camera rotation by rotation speed
  7913. if (_this._attachedCamera) {
  7914. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7915. }
  7916. });
  7917. };
  7918. /**
  7919. * Detaches the behavior from its current arc rotate camera.
  7920. */
  7921. AutoRotationBehavior.prototype.detach = function () {
  7922. if (!this._attachedCamera) {
  7923. return;
  7924. }
  7925. var scene = this._attachedCamera.getScene();
  7926. if (this._onPrePointerObservableObserver) {
  7927. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7928. }
  7929. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7930. this._attachedCamera = null;
  7931. };
  7932. /**
  7933. * Returns true if user is scrolling.
  7934. * @return true if user is scrolling.
  7935. */
  7936. AutoRotationBehavior.prototype._userIsZooming = function () {
  7937. if (!this._attachedCamera) {
  7938. return false;
  7939. }
  7940. return this._attachedCamera.inertialRadiusOffset !== 0;
  7941. };
  7942. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7943. if (!this._attachedCamera) {
  7944. return false;
  7945. }
  7946. var zoomHasHitLimit = false;
  7947. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7948. zoomHasHitLimit = true;
  7949. }
  7950. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7951. this._lastFrameRadius = this._attachedCamera.radius;
  7952. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7953. };
  7954. /**
  7955. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7956. */
  7957. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7958. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7959. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7960. }
  7961. };
  7962. // Tools
  7963. AutoRotationBehavior.prototype._userIsMoving = function () {
  7964. if (!this._attachedCamera) {
  7965. return false;
  7966. }
  7967. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  7968. this._attachedCamera.inertialBetaOffset !== 0 ||
  7969. this._attachedCamera.inertialRadiusOffset !== 0 ||
  7970. this._attachedCamera.inertialPanningX !== 0 ||
  7971. this._attachedCamera.inertialPanningY !== 0 ||
  7972. this._isPointerDown;
  7973. };
  7974. return AutoRotationBehavior;
  7975. }());
  7976. /***/ }),
  7977. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  7978. /*!***********************************************!*\
  7979. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  7980. \***********************************************/
  7981. /*! exports provided: BouncingBehavior */
  7982. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7983. "use strict";
  7984. __webpack_require__.r(__webpack_exports__);
  7985. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  7986. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7987. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7988. /**
  7989. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  7990. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7991. */
  7992. var BouncingBehavior = /** @class */ (function () {
  7993. function BouncingBehavior() {
  7994. /**
  7995. * The duration of the animation, in milliseconds
  7996. */
  7997. this.transitionDuration = 450;
  7998. /**
  7999. * Length of the distance animated by the transition when lower radius is reached
  8000. */
  8001. this.lowerRadiusTransitionRange = 2;
  8002. /**
  8003. * Length of the distance animated by the transition when upper radius is reached
  8004. */
  8005. this.upperRadiusTransitionRange = -2;
  8006. this._autoTransitionRange = false;
  8007. // Animations
  8008. this._radiusIsAnimating = false;
  8009. this._radiusBounceTransition = null;
  8010. this._animatables = new Array();
  8011. }
  8012. Object.defineProperty(BouncingBehavior.prototype, "name", {
  8013. /**
  8014. * Gets the name of the behavior.
  8015. */
  8016. get: function () {
  8017. return "Bouncing";
  8018. },
  8019. enumerable: true,
  8020. configurable: true
  8021. });
  8022. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  8023. /**
  8024. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  8025. */
  8026. get: function () {
  8027. return this._autoTransitionRange;
  8028. },
  8029. /**
  8030. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  8031. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  8032. */
  8033. set: function (value) {
  8034. var _this = this;
  8035. if (this._autoTransitionRange === value) {
  8036. return;
  8037. }
  8038. this._autoTransitionRange = value;
  8039. var camera = this._attachedCamera;
  8040. if (!camera) {
  8041. return;
  8042. }
  8043. if (value) {
  8044. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8045. if (!mesh) {
  8046. return;
  8047. }
  8048. mesh.computeWorldMatrix(true);
  8049. var diagonal = mesh.getBoundingInfo().diagonalLength;
  8050. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  8051. _this.upperRadiusTransitionRange = diagonal * 0.05;
  8052. });
  8053. }
  8054. else if (this._onMeshTargetChangedObserver) {
  8055. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8056. }
  8057. },
  8058. enumerable: true,
  8059. configurable: true
  8060. });
  8061. /**
  8062. * Initializes the behavior.
  8063. */
  8064. BouncingBehavior.prototype.init = function () {
  8065. // Do notihng
  8066. };
  8067. /**
  8068. * Attaches the behavior to its arc rotate camera.
  8069. * @param camera Defines the camera to attach the behavior to
  8070. */
  8071. BouncingBehavior.prototype.attach = function (camera) {
  8072. var _this = this;
  8073. this._attachedCamera = camera;
  8074. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8075. if (!_this._attachedCamera) {
  8076. return;
  8077. }
  8078. // Add the bounce animation to the lower radius limit
  8079. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  8080. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  8081. }
  8082. // Add the bounce animation to the upper radius limit
  8083. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  8084. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  8085. }
  8086. });
  8087. };
  8088. /**
  8089. * Detaches the behavior from its current arc rotate camera.
  8090. */
  8091. BouncingBehavior.prototype.detach = function () {
  8092. if (!this._attachedCamera) {
  8093. return;
  8094. }
  8095. if (this._onAfterCheckInputsObserver) {
  8096. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8097. }
  8098. if (this._onMeshTargetChangedObserver) {
  8099. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8100. }
  8101. this._attachedCamera = null;
  8102. };
  8103. /**
  8104. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  8105. * @param radiusLimit The limit to check against.
  8106. * @return Bool to indicate if at limit.
  8107. */
  8108. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  8109. if (!this._attachedCamera) {
  8110. return false;
  8111. }
  8112. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  8113. return true;
  8114. }
  8115. return false;
  8116. };
  8117. /**
  8118. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  8119. * @param radiusDelta The delta by which to animate to. Can be negative.
  8120. */
  8121. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  8122. var _this = this;
  8123. if (!this._attachedCamera) {
  8124. return;
  8125. }
  8126. if (!this._radiusBounceTransition) {
  8127. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  8128. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  8129. }
  8130. // Prevent zoom until bounce has completed
  8131. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  8132. this._attachedCamera.wheelPrecision = Infinity;
  8133. this._attachedCamera.inertialRadiusOffset = 0;
  8134. // Animate to the radius limit
  8135. this.stopAllAnimations();
  8136. this._radiusIsAnimating = true;
  8137. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].TransitionTo("radius", this._attachedCamera.radius + radiusDelta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusBounceTransition, this.transitionDuration, function () { return _this._clearAnimationLocks(); });
  8138. if (animatable) {
  8139. this._animatables.push(animatable);
  8140. }
  8141. };
  8142. /**
  8143. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  8144. */
  8145. BouncingBehavior.prototype._clearAnimationLocks = function () {
  8146. this._radiusIsAnimating = false;
  8147. if (this._attachedCamera) {
  8148. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  8149. }
  8150. };
  8151. /**
  8152. * Stops and removes all animations that have been applied to the camera
  8153. */
  8154. BouncingBehavior.prototype.stopAllAnimations = function () {
  8155. if (this._attachedCamera) {
  8156. this._attachedCamera.animations = [];
  8157. }
  8158. while (this._animatables.length) {
  8159. this._animatables[0].onAnimationEnd = null;
  8160. this._animatables[0].stop();
  8161. this._animatables.shift();
  8162. }
  8163. };
  8164. /**
  8165. * The easing function used by animations
  8166. */
  8167. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  8168. /**
  8169. * The easing mode used by animations
  8170. */
  8171. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  8172. return BouncingBehavior;
  8173. }());
  8174. /***/ }),
  8175. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  8176. /*!**********************************************!*\
  8177. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  8178. \**********************************************/
  8179. /*! exports provided: FramingBehavior */
  8180. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8181. "use strict";
  8182. __webpack_require__.r(__webpack_exports__);
  8183. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  8184. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8185. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8186. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  8187. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  8188. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8189. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8190. /**
  8191. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  8192. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8193. */
  8194. var FramingBehavior = /** @class */ (function () {
  8195. function FramingBehavior() {
  8196. this._mode = FramingBehavior.FitFrustumSidesMode;
  8197. this._radiusScale = 1.0;
  8198. this._positionScale = 0.5;
  8199. this._defaultElevation = 0.3;
  8200. this._elevationReturnTime = 1500;
  8201. this._elevationReturnWaitTime = 1000;
  8202. this._zoomStopsAnimation = false;
  8203. this._framingTime = 1500;
  8204. /**
  8205. * Define if the behavior should automatically change the configured
  8206. * camera limits and sensibilities.
  8207. */
  8208. this.autoCorrectCameraLimitsAndSensibility = true;
  8209. this._isPointerDown = false;
  8210. this._lastInteractionTime = -Infinity;
  8211. // Framing control
  8212. this._animatables = new Array();
  8213. this._betaIsAnimating = false;
  8214. }
  8215. Object.defineProperty(FramingBehavior.prototype, "name", {
  8216. /**
  8217. * Gets the name of the behavior.
  8218. */
  8219. get: function () {
  8220. return "Framing";
  8221. },
  8222. enumerable: true,
  8223. configurable: true
  8224. });
  8225. Object.defineProperty(FramingBehavior.prototype, "mode", {
  8226. /**
  8227. * Gets current mode used by the behavior.
  8228. */
  8229. get: function () {
  8230. return this._mode;
  8231. },
  8232. /**
  8233. * Sets the current mode used by the behavior
  8234. */
  8235. set: function (mode) {
  8236. this._mode = mode;
  8237. },
  8238. enumerable: true,
  8239. configurable: true
  8240. });
  8241. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  8242. /**
  8243. * Gets the scale applied to the radius
  8244. */
  8245. get: function () {
  8246. return this._radiusScale;
  8247. },
  8248. /**
  8249. * Sets the scale applied to the radius (1 by default)
  8250. */
  8251. set: function (radius) {
  8252. this._radiusScale = radius;
  8253. },
  8254. enumerable: true,
  8255. configurable: true
  8256. });
  8257. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  8258. /**
  8259. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8260. */
  8261. get: function () {
  8262. return this._positionScale;
  8263. },
  8264. /**
  8265. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8266. */
  8267. set: function (scale) {
  8268. this._positionScale = scale;
  8269. },
  8270. enumerable: true,
  8271. configurable: true
  8272. });
  8273. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  8274. /**
  8275. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8276. * behaviour is triggered, in radians.
  8277. */
  8278. get: function () {
  8279. return this._defaultElevation;
  8280. },
  8281. /**
  8282. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8283. * behaviour is triggered, in radians.
  8284. */
  8285. set: function (elevation) {
  8286. this._defaultElevation = elevation;
  8287. },
  8288. enumerable: true,
  8289. configurable: true
  8290. });
  8291. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  8292. /**
  8293. * Gets the time (in milliseconds) taken to return to the default beta position.
  8294. * Negative value indicates camera should not return to default.
  8295. */
  8296. get: function () {
  8297. return this._elevationReturnTime;
  8298. },
  8299. /**
  8300. * Sets the time (in milliseconds) taken to return to the default beta position.
  8301. * Negative value indicates camera should not return to default.
  8302. */
  8303. set: function (speed) {
  8304. this._elevationReturnTime = speed;
  8305. },
  8306. enumerable: true,
  8307. configurable: true
  8308. });
  8309. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  8310. /**
  8311. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8312. */
  8313. get: function () {
  8314. return this._elevationReturnWaitTime;
  8315. },
  8316. /**
  8317. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8318. */
  8319. set: function (time) {
  8320. this._elevationReturnWaitTime = time;
  8321. },
  8322. enumerable: true,
  8323. configurable: true
  8324. });
  8325. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  8326. /**
  8327. * Gets the flag that indicates if user zooming should stop animation.
  8328. */
  8329. get: function () {
  8330. return this._zoomStopsAnimation;
  8331. },
  8332. /**
  8333. * Sets the flag that indicates if user zooming should stop animation.
  8334. */
  8335. set: function (flag) {
  8336. this._zoomStopsAnimation = flag;
  8337. },
  8338. enumerable: true,
  8339. configurable: true
  8340. });
  8341. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  8342. /**
  8343. * Gets the transition time when framing the mesh, in milliseconds
  8344. */
  8345. get: function () {
  8346. return this._framingTime;
  8347. },
  8348. /**
  8349. * Sets the transition time when framing the mesh, in milliseconds
  8350. */
  8351. set: function (time) {
  8352. this._framingTime = time;
  8353. },
  8354. enumerable: true,
  8355. configurable: true
  8356. });
  8357. /**
  8358. * Initializes the behavior.
  8359. */
  8360. FramingBehavior.prototype.init = function () {
  8361. // Do notihng
  8362. };
  8363. /**
  8364. * Attaches the behavior to its arc rotate camera.
  8365. * @param camera Defines the camera to attach the behavior to
  8366. */
  8367. FramingBehavior.prototype.attach = function (camera) {
  8368. var _this = this;
  8369. this._attachedCamera = camera;
  8370. var scene = this._attachedCamera.getScene();
  8371. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  8372. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  8373. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  8374. _this._isPointerDown = true;
  8375. return;
  8376. }
  8377. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  8378. _this._isPointerDown = false;
  8379. }
  8380. });
  8381. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8382. if (mesh) {
  8383. _this.zoomOnMesh(mesh);
  8384. }
  8385. });
  8386. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8387. // Stop the animation if there is user interaction and the animation should stop for this interaction
  8388. _this._applyUserInteraction();
  8389. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  8390. // back to the default position after a given timeout
  8391. _this._maintainCameraAboveGround();
  8392. });
  8393. };
  8394. /**
  8395. * Detaches the behavior from its current arc rotate camera.
  8396. */
  8397. FramingBehavior.prototype.detach = function () {
  8398. if (!this._attachedCamera) {
  8399. return;
  8400. }
  8401. var scene = this._attachedCamera.getScene();
  8402. if (this._onPrePointerObservableObserver) {
  8403. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8404. }
  8405. if (this._onAfterCheckInputsObserver) {
  8406. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8407. }
  8408. if (this._onMeshTargetChangedObserver) {
  8409. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8410. }
  8411. this._attachedCamera = null;
  8412. };
  8413. /**
  8414. * Targets the given mesh and updates zoom level accordingly.
  8415. * @param mesh The mesh to target.
  8416. * @param radius Optional. If a cached radius position already exists, overrides default.
  8417. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8418. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8419. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8420. */
  8421. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8422. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8423. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8424. mesh.computeWorldMatrix(true);
  8425. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8426. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8427. };
  8428. /**
  8429. * Targets the given mesh with its children and updates zoom level accordingly.
  8430. * @param mesh The mesh to target.
  8431. * @param radius Optional. If a cached radius position already exists, overrides default.
  8432. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8433. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8434. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8435. */
  8436. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8437. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8438. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8439. mesh.computeWorldMatrix(true);
  8440. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8441. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8442. };
  8443. /**
  8444. * Targets the given meshes with their children and updates zoom level accordingly.
  8445. * @param meshes The mesh to target.
  8446. * @param radius Optional. If a cached radius position already exists, overrides default.
  8447. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8448. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8449. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8450. */
  8451. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8452. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8453. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8454. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8455. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8456. for (var i = 0; i < meshes.length; i++) {
  8457. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8458. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8459. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8460. }
  8461. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8462. };
  8463. /**
  8464. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8465. * @param minimumWorld Determines the smaller position of the bounding box extend
  8466. * @param maximumWorld Determines the bigger position of the bounding box extend
  8467. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8468. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8469. */
  8470. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8471. var _this = this;
  8472. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8473. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8474. var zoomTarget;
  8475. if (!this._attachedCamera) {
  8476. return;
  8477. }
  8478. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8479. var bottom = minimumWorld.y;
  8480. var top = maximumWorld.y;
  8481. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8482. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8483. if (focusOnOriginXZ) {
  8484. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8485. }
  8486. else {
  8487. var centerWorld = minimumWorld.add(radiusWorld);
  8488. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8489. }
  8490. if (!this._vectorTransition) {
  8491. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8492. }
  8493. this._betaIsAnimating = true;
  8494. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8495. if (animatable) {
  8496. this._animatables.push(animatable);
  8497. }
  8498. // sets the radius and lower radius bounds
  8499. // Small delta ensures camera is not always at lower zoom limit.
  8500. var radius = 0;
  8501. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8502. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8503. if (this.autoCorrectCameraLimitsAndSensibility) {
  8504. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8505. }
  8506. radius = position;
  8507. }
  8508. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8509. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8510. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8511. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8512. }
  8513. }
  8514. // Set sensibilities
  8515. if (this.autoCorrectCameraLimitsAndSensibility) {
  8516. var extend = maximumWorld.subtract(minimumWorld).length();
  8517. this._attachedCamera.panningSensibility = 5000 / extend;
  8518. this._attachedCamera.wheelPrecision = 100 / radius;
  8519. }
  8520. // transition to new radius
  8521. if (!this._radiusTransition) {
  8522. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8523. }
  8524. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8525. _this.stopAllAnimations();
  8526. if (onAnimationEnd) {
  8527. onAnimationEnd();
  8528. }
  8529. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8530. _this._attachedCamera.storeState();
  8531. }
  8532. });
  8533. if (animatable) {
  8534. this._animatables.push(animatable);
  8535. }
  8536. };
  8537. /**
  8538. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8539. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8540. * frustum width.
  8541. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8542. * to fully enclose the mesh in the viewing frustum.
  8543. */
  8544. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8545. var size = maximumWorld.subtract(minimumWorld);
  8546. var boxVectorGlobalDiagonal = size.length();
  8547. var frustumSlope = this._getFrustumSlope();
  8548. // Formula for setting distance
  8549. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8550. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8551. // Horizon distance
  8552. var radius = radiusWithoutFraming * this._radiusScale;
  8553. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8554. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8555. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8556. var camera = this._attachedCamera;
  8557. if (!camera) {
  8558. return 0;
  8559. }
  8560. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8561. // Don't exceed the requested limit
  8562. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8563. }
  8564. // Don't exceed the upper radius limit
  8565. if (camera.upperRadiusLimit) {
  8566. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8567. }
  8568. return distance;
  8569. };
  8570. /**
  8571. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8572. * is automatically returned to its default position (expected to be above ground plane).
  8573. */
  8574. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8575. var _this = this;
  8576. if (this._elevationReturnTime < 0) {
  8577. return;
  8578. }
  8579. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8580. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8581. var limitBeta = Math.PI * 0.5;
  8582. // Bring the camera back up if below the ground plane
  8583. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8584. this._betaIsAnimating = true;
  8585. //Transition to new position
  8586. this.stopAllAnimations();
  8587. if (!this._betaTransition) {
  8588. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8589. }
  8590. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8591. _this._clearAnimationLocks();
  8592. _this.stopAllAnimations();
  8593. });
  8594. if (animatabe) {
  8595. this._animatables.push(animatabe);
  8596. }
  8597. }
  8598. };
  8599. /**
  8600. * Returns the frustum slope based on the canvas ratio and camera FOV
  8601. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8602. */
  8603. FramingBehavior.prototype._getFrustumSlope = function () {
  8604. // Calculate the viewport ratio
  8605. // Aspect Ratio is Height/Width.
  8606. var camera = this._attachedCamera;
  8607. if (!camera) {
  8608. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8609. }
  8610. var engine = camera.getScene().getEngine();
  8611. var aspectRatio = engine.getAspectRatio(camera);
  8612. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8613. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8614. var frustumSlopeY = Math.tan(camera.fov / 2);
  8615. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8616. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8617. // along the forward vector.
  8618. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8619. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8620. };
  8621. /**
  8622. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8623. */
  8624. FramingBehavior.prototype._clearAnimationLocks = function () {
  8625. this._betaIsAnimating = false;
  8626. };
  8627. /**
  8628. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8629. */
  8630. FramingBehavior.prototype._applyUserInteraction = function () {
  8631. if (this.isUserIsMoving) {
  8632. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8633. this.stopAllAnimations();
  8634. this._clearAnimationLocks();
  8635. }
  8636. };
  8637. /**
  8638. * Stops and removes all animations that have been applied to the camera
  8639. */
  8640. FramingBehavior.prototype.stopAllAnimations = function () {
  8641. if (this._attachedCamera) {
  8642. this._attachedCamera.animations = [];
  8643. }
  8644. while (this._animatables.length) {
  8645. if (this._animatables[0]) {
  8646. this._animatables[0].onAnimationEnd = null;
  8647. this._animatables[0].stop();
  8648. }
  8649. this._animatables.shift();
  8650. }
  8651. };
  8652. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8653. /**
  8654. * Gets a value indicating if the user is moving the camera
  8655. */
  8656. get: function () {
  8657. if (!this._attachedCamera) {
  8658. return false;
  8659. }
  8660. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8661. this._attachedCamera.inertialBetaOffset !== 0 ||
  8662. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8663. this._attachedCamera.inertialPanningX !== 0 ||
  8664. this._attachedCamera.inertialPanningY !== 0 ||
  8665. this._isPointerDown;
  8666. },
  8667. enumerable: true,
  8668. configurable: true
  8669. });
  8670. /**
  8671. * The easing function used by animations
  8672. */
  8673. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8674. /**
  8675. * The easing mode used by animations
  8676. */
  8677. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8678. // Statics
  8679. /**
  8680. * The camera can move all the way towards the mesh.
  8681. */
  8682. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8683. /**
  8684. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8685. */
  8686. FramingBehavior.FitFrustumSidesMode = 1;
  8687. return FramingBehavior;
  8688. }());
  8689. /***/ }),
  8690. /***/ "./Behaviors/Cameras/index.ts":
  8691. /*!************************************!*\
  8692. !*** ./Behaviors/Cameras/index.ts ***!
  8693. \************************************/
  8694. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8695. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8696. "use strict";
  8697. __webpack_require__.r(__webpack_exports__);
  8698. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8700. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8702. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8704. /***/ }),
  8705. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8706. /*!*************************************************!*\
  8707. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8708. \*************************************************/
  8709. /*! exports provided: AttachToBoxBehavior */
  8710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8711. "use strict";
  8712. __webpack_require__.r(__webpack_exports__);
  8713. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8714. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8715. /**
  8716. * @hidden
  8717. */
  8718. var FaceDirectionInfo = /** @class */ (function () {
  8719. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8720. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8721. if (diff === void 0) { diff = 0; }
  8722. if (ignore === void 0) { ignore = false; }
  8723. this.direction = direction;
  8724. this.rotatedDirection = rotatedDirection;
  8725. this.diff = diff;
  8726. this.ignore = ignore;
  8727. }
  8728. return FaceDirectionInfo;
  8729. }());
  8730. /**
  8731. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8732. */
  8733. var AttachToBoxBehavior = /** @class */ (function () {
  8734. /**
  8735. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8736. * @param ui The transform node that should be attched to the mesh
  8737. */
  8738. function AttachToBoxBehavior(ui) {
  8739. this.ui = ui;
  8740. /**
  8741. * The name of the behavior
  8742. */
  8743. this.name = "AttachToBoxBehavior";
  8744. /**
  8745. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8746. */
  8747. this.distanceAwayFromFace = 0.15;
  8748. /**
  8749. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8750. */
  8751. this.distanceAwayFromBottomOfFace = 0.15;
  8752. this._faceVectors = [new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Down()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Left()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward().scaleInPlace(-1))];
  8753. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8754. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8755. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8756. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8757. /* Does nothing */
  8758. }
  8759. /**
  8760. * Initializes the behavior
  8761. */
  8762. AttachToBoxBehavior.prototype.init = function () {
  8763. /* Does nothing */
  8764. };
  8765. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8766. var _this = this;
  8767. // Go over each face and calculate the angle between the face's normal and targetDirection
  8768. this._faceVectors.forEach(function (v) {
  8769. if (!_this._target.rotationQuaternion) {
  8770. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8771. }
  8772. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8773. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8774. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8775. });
  8776. // Return the face information of the one with the normal closeset to target direction
  8777. return this._faceVectors.reduce(function (min, p) {
  8778. if (min.ignore) {
  8779. return p;
  8780. }
  8781. else if (p.ignore) {
  8782. return min;
  8783. }
  8784. else {
  8785. return min.diff < p.diff ? min : p;
  8786. }
  8787. }, this._faceVectors[0]);
  8788. };
  8789. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8790. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8791. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8792. this._lookAtTmpMatrix.invert();
  8793. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8794. };
  8795. /**
  8796. * Attaches the AttachToBoxBehavior to the passed in mesh
  8797. * @param target The mesh that the specified node will be attached to
  8798. */
  8799. AttachToBoxBehavior.prototype.attach = function (target) {
  8800. var _this = this;
  8801. this._target = target;
  8802. this._scene = this._target.getScene();
  8803. // Every frame, update the app bars position
  8804. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8805. if (!_this._scene.activeCamera) {
  8806. return;
  8807. }
  8808. // Find the face closest to the cameras position
  8809. var cameraPos = _this._scene.activeCamera.position;
  8810. if (_this._scene.activeCamera.devicePosition) {
  8811. cameraPos = _this._scene.activeCamera.devicePosition;
  8812. }
  8813. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8814. if (_this._scene.activeCamera.leftCamera) {
  8815. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8816. }
  8817. else {
  8818. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8819. }
  8820. // Get camera up direction
  8821. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8822. // Ignore faces to not select a parrelel face for the up vector of the UI
  8823. _this._faceVectors.forEach(function (v) {
  8824. if (facing.direction.x && v.direction.x) {
  8825. v.ignore = true;
  8826. }
  8827. if (facing.direction.y && v.direction.y) {
  8828. v.ignore = true;
  8829. }
  8830. if (facing.direction.z && v.direction.z) {
  8831. v.ignore = true;
  8832. }
  8833. });
  8834. var facingUp = _this._closestFace(_this._tmpVector);
  8835. // Unignore faces
  8836. _this._faceVectors.forEach(function (v) {
  8837. v.ignore = false;
  8838. });
  8839. // Position the app bar on that face
  8840. _this.ui.position.copyFrom(target.position);
  8841. if (facing.direction.x) {
  8842. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8843. _this.ui.position.addInPlace(_this._tmpVector);
  8844. }
  8845. if (facing.direction.y) {
  8846. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8847. _this.ui.position.addInPlace(_this._tmpVector);
  8848. }
  8849. if (facing.direction.z) {
  8850. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8851. _this.ui.position.addInPlace(_this._tmpVector);
  8852. }
  8853. // Rotate to be oriented properly to the camera
  8854. if (!_this.ui.rotationQuaternion) {
  8855. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8856. }
  8857. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8858. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8859. // Place ui the correct distance from the bottom of the mesh
  8860. if (facingUp.direction.x) {
  8861. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8862. }
  8863. if (facingUp.direction.y) {
  8864. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8865. }
  8866. if (facingUp.direction.z) {
  8867. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8868. }
  8869. _this.ui.position.addInPlace(_this._tmpVector);
  8870. });
  8871. };
  8872. /**
  8873. * Detaches the behavior from the mesh
  8874. */
  8875. AttachToBoxBehavior.prototype.detach = function () {
  8876. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8877. };
  8878. return AttachToBoxBehavior;
  8879. }());
  8880. /***/ }),
  8881. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8882. /*!***********************************************!*\
  8883. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8884. \***********************************************/
  8885. /*! exports provided: FadeInOutBehavior */
  8886. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8887. "use strict";
  8888. __webpack_require__.r(__webpack_exports__);
  8889. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8890. /**
  8891. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8892. */
  8893. var FadeInOutBehavior = /** @class */ (function () {
  8894. /**
  8895. * Instatiates the FadeInOutBehavior
  8896. */
  8897. function FadeInOutBehavior() {
  8898. var _this = this;
  8899. /**
  8900. * Time in milliseconds to delay before fading in (Default: 0)
  8901. */
  8902. this.delay = 0;
  8903. /**
  8904. * Time in milliseconds for the mesh to fade in (Default: 300)
  8905. */
  8906. this.fadeInTime = 300;
  8907. this._millisecondsPerFrame = 1000 / 60;
  8908. this._hovered = false;
  8909. this._hoverValue = 0;
  8910. this._ownerNode = null;
  8911. this._update = function () {
  8912. if (_this._ownerNode) {
  8913. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8914. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8915. if (_this._ownerNode.visibility > 1) {
  8916. _this._setAllVisibility(_this._ownerNode, 1);
  8917. _this._hoverValue = _this.fadeInTime + _this.delay;
  8918. return;
  8919. }
  8920. else if (_this._ownerNode.visibility < 0) {
  8921. _this._setAllVisibility(_this._ownerNode, 0);
  8922. if (_this._hoverValue < 0) {
  8923. _this._hoverValue = 0;
  8924. return;
  8925. }
  8926. }
  8927. setTimeout(_this._update, _this._millisecondsPerFrame);
  8928. }
  8929. };
  8930. }
  8931. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8932. /**
  8933. * The name of the behavior
  8934. */
  8935. get: function () {
  8936. return "FadeInOut";
  8937. },
  8938. enumerable: true,
  8939. configurable: true
  8940. });
  8941. /**
  8942. * Initializes the behavior
  8943. */
  8944. FadeInOutBehavior.prototype.init = function () {
  8945. };
  8946. /**
  8947. * Attaches the fade behavior on the passed in mesh
  8948. * @param ownerNode The mesh that will be faded in/out once attached
  8949. */
  8950. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8951. this._ownerNode = ownerNode;
  8952. this._setAllVisibility(this._ownerNode, 0);
  8953. };
  8954. /**
  8955. * Detaches the behavior from the mesh
  8956. */
  8957. FadeInOutBehavior.prototype.detach = function () {
  8958. this._ownerNode = null;
  8959. };
  8960. /**
  8961. * Triggers the mesh to begin fading in or out
  8962. * @param value if the object should fade in or out (true to fade in)
  8963. */
  8964. FadeInOutBehavior.prototype.fadeIn = function (value) {
  8965. this._hovered = value;
  8966. this._update();
  8967. };
  8968. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  8969. var _this = this;
  8970. mesh.visibility = value;
  8971. mesh.getChildMeshes().forEach(function (c) {
  8972. _this._setAllVisibility(c, value);
  8973. });
  8974. };
  8975. return FadeInOutBehavior;
  8976. }());
  8977. /***/ }),
  8978. /***/ "./Behaviors/Meshes/index.ts":
  8979. /*!***********************************!*\
  8980. !*** ./Behaviors/Meshes/index.ts ***!
  8981. \***********************************/
  8982. /*! exports provided: AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  8983. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8984. "use strict";
  8985. __webpack_require__.r(__webpack_exports__);
  8986. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  8987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  8988. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  8989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  8990. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  8991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  8992. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  8994. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  8995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  8996. /***/ }),
  8997. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  8998. /*!*******************************************************!*\
  8999. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  9000. \*******************************************************/
  9001. /*! exports provided: MultiPointerScaleBehavior */
  9002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9003. "use strict";
  9004. __webpack_require__.r(__webpack_exports__);
  9005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  9006. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  9007. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9008. /**
  9009. * A behavior that when attached to a mesh will allow the mesh to be scaled
  9010. */
  9011. var MultiPointerScaleBehavior = /** @class */ (function () {
  9012. /**
  9013. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  9014. */
  9015. function MultiPointerScaleBehavior() {
  9016. this._startDistance = 0;
  9017. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  9018. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  9019. this._sceneRenderObserver = null;
  9020. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  9021. this._dragBehaviorA.moveAttached = false;
  9022. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  9023. this._dragBehaviorB.moveAttached = false;
  9024. }
  9025. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  9026. /**
  9027. * The name of the behavior
  9028. */
  9029. get: function () {
  9030. return "MultiPointerScale";
  9031. },
  9032. enumerable: true,
  9033. configurable: true
  9034. });
  9035. /**
  9036. * Initializes the behavior
  9037. */
  9038. MultiPointerScaleBehavior.prototype.init = function () { };
  9039. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  9040. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  9041. };
  9042. /**
  9043. * Attaches the scale behavior the passed in mesh
  9044. * @param ownerNode The mesh that will be scaled around once attached
  9045. */
  9046. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  9047. var _this = this;
  9048. this._ownerNode = ownerNode;
  9049. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  9050. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  9051. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9052. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9053. _this._dragBehaviorA.releaseDrag();
  9054. }
  9055. else {
  9056. _this._initialScale.copyFrom(ownerNode.scaling);
  9057. _this._startDistance = _this._getCurrentDistance();
  9058. }
  9059. }
  9060. });
  9061. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  9062. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9063. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9064. _this._dragBehaviorB.releaseDrag();
  9065. }
  9066. else {
  9067. _this._initialScale.copyFrom(ownerNode.scaling);
  9068. _this._startDistance = _this._getCurrentDistance();
  9069. }
  9070. }
  9071. });
  9072. // Once both drag behaviors are active scale based on the distance between the two pointers
  9073. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9074. behavior.onDragObservable.add(function () {
  9075. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9076. var ratio = _this._getCurrentDistance() / _this._startDistance;
  9077. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  9078. }
  9079. });
  9080. });
  9081. ownerNode.addBehavior(this._dragBehaviorA);
  9082. ownerNode.addBehavior(this._dragBehaviorB);
  9083. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9084. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9085. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9086. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  9087. if (change.length() > 0.01) {
  9088. ownerNode.scaling.addInPlace(change);
  9089. }
  9090. }
  9091. });
  9092. };
  9093. /**
  9094. * Detaches the behavior from the mesh
  9095. */
  9096. MultiPointerScaleBehavior.prototype.detach = function () {
  9097. var _this = this;
  9098. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9099. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9100. behavior.onDragStartObservable.clear();
  9101. behavior.onDragObservable.clear();
  9102. _this._ownerNode.removeBehavior(behavior);
  9103. });
  9104. };
  9105. return MultiPointerScaleBehavior;
  9106. }());
  9107. /***/ }),
  9108. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  9109. /*!*************************************************!*\
  9110. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  9111. \*************************************************/
  9112. /*! exports provided: PointerDragBehavior */
  9113. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9114. "use strict";
  9115. __webpack_require__.r(__webpack_exports__);
  9116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  9117. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  9118. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9119. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9120. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9121. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9122. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  9123. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9124. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  9125. /**
  9126. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  9127. */
  9128. var PointerDragBehavior = /** @class */ (function () {
  9129. /**
  9130. * Creates a pointer drag behavior that can be attached to a mesh
  9131. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  9132. */
  9133. function PointerDragBehavior(options) {
  9134. this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;
  9135. /**
  9136. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  9137. */
  9138. this.maxDragAngle = 0;
  9139. /**
  9140. * @hidden
  9141. */
  9142. this._useAlternatePickedPointAboveMaxDragAngle = false;
  9143. /**
  9144. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9145. */
  9146. this.currentDraggingPointerID = -1;
  9147. /**
  9148. * If the behavior is currently in a dragging state
  9149. */
  9150. this.dragging = false;
  9151. /**
  9152. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  9153. */
  9154. this.dragDeltaRatio = 0.2;
  9155. /**
  9156. * If the drag plane orientation should be updated during the dragging (Default: true)
  9157. */
  9158. this.updateDragPlane = true;
  9159. // Debug mode will display drag planes to help visualize behavior
  9160. this._debugMode = false;
  9161. this._moving = false;
  9162. /**
  9163. * Fires each time the attached mesh is dragged with the pointer
  9164. * * delta between last drag position and current drag position in world space
  9165. * * dragDistance along the drag axis
  9166. * * dragPlaneNormal normal of the current drag plane used during the drag
  9167. * * dragPlanePoint in world space where the drag intersects the drag plane
  9168. */
  9169. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9170. /**
  9171. * Fires each time a drag begins (eg. mouse down on mesh)
  9172. */
  9173. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9174. /**
  9175. * Fires each time a drag ends (eg. mouse release after drag)
  9176. */
  9177. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9178. /**
  9179. * If the attached mesh should be moved when dragged
  9180. */
  9181. this.moveAttached = true;
  9182. /**
  9183. * If the drag behavior will react to drag events (Default: true)
  9184. */
  9185. this.enabled = true;
  9186. /**
  9187. * If camera controls should be detached during the drag
  9188. */
  9189. this.detachCameraControls = true;
  9190. /**
  9191. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  9192. */
  9193. this.useObjectOrienationForDragging = true;
  9194. /**
  9195. * Predicate to determine if it is valid to move the object to a new position when it is moved
  9196. */
  9197. this.validateDrag = function (targetPosition) { return true; };
  9198. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9199. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9200. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9201. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9202. this._attachedElement = null;
  9203. this._startDragRay = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]());
  9204. this._lastPointerRay = {};
  9205. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  9206. // Variables to avoid instantiation in the below method
  9207. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9208. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9209. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9210. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9211. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9212. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9213. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9214. this._options = options ? options : {};
  9215. var optionCount = 0;
  9216. if (this._options.dragAxis) {
  9217. optionCount++;
  9218. }
  9219. if (this._options.dragPlaneNormal) {
  9220. optionCount++;
  9221. }
  9222. if (optionCount > 1) {
  9223. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  9224. }
  9225. }
  9226. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  9227. /**
  9228. * The name of the behavior
  9229. */
  9230. get: function () {
  9231. return "PointerDrag";
  9232. },
  9233. enumerable: true,
  9234. configurable: true
  9235. });
  9236. /**
  9237. * Initializes the behavior
  9238. */
  9239. PointerDragBehavior.prototype.init = function () { };
  9240. /**
  9241. * Attaches the drag behavior the passed in mesh
  9242. * @param ownerNode The mesh that will be dragged around once attached
  9243. */
  9244. PointerDragBehavior.prototype.attach = function (ownerNode) {
  9245. var _this = this;
  9246. this._scene = ownerNode.getScene();
  9247. this._attachedNode = ownerNode;
  9248. // Initialize drag plane to not interfere with existing scene
  9249. if (!PointerDragBehavior._planeScene) {
  9250. if (this._debugMode) {
  9251. PointerDragBehavior._planeScene = this._scene;
  9252. }
  9253. else {
  9254. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9255. PointerDragBehavior._planeScene.detachControl();
  9256. this._scene.getEngine().scenes.pop();
  9257. this._scene.onDisposeObservable.addOnce(function () {
  9258. PointerDragBehavior._planeScene.dispose();
  9259. PointerDragBehavior._planeScene = null;
  9260. });
  9261. }
  9262. }
  9263. this._dragPlane = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane("pointerDragPlane", this._debugMode ? 1 : 10000, PointerDragBehavior._planeScene, false, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].DOUBLESIDE);
  9264. // State of the drag
  9265. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9266. var pickPredicate = function (m) {
  9267. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  9268. };
  9269. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9270. if (!_this.enabled) {
  9271. return;
  9272. }
  9273. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  9274. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9275. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  9276. }
  9277. }
  9278. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  9279. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9280. _this.releaseDrag();
  9281. }
  9282. }
  9283. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  9284. var pointerId = pointerInfo.event.pointerId;
  9285. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  9286. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  9287. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  9288. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  9289. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  9290. }
  9291. _this.currentDraggingPointerID = pointerId;
  9292. }
  9293. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  9294. if (!_this._lastPointerRay[pointerId]) {
  9295. _this._lastPointerRay[pointerId] = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]());
  9296. }
  9297. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  9298. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  9299. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  9300. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  9301. _this._moveDrag(pointerInfo.pickInfo.ray);
  9302. }
  9303. }
  9304. }
  9305. });
  9306. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  9307. if (_this._moving && _this.moveAttached) {
  9308. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  9309. // Slowly move mesh to avoid jitter
  9310. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  9311. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  9312. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  9313. if (_this.validateDrag(_this._tmpVector)) {
  9314. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  9315. }
  9316. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  9317. }
  9318. });
  9319. };
  9320. /**
  9321. * Force relase the drag action by code.
  9322. */
  9323. PointerDragBehavior.prototype.releaseDrag = function () {
  9324. this.dragging = false;
  9325. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  9326. this.currentDraggingPointerID = -1;
  9327. this._moving = false;
  9328. // Reattach camera controls
  9329. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9330. this._scene.activeCamera.attachControl(this._attachedElement, true);
  9331. }
  9332. };
  9333. /**
  9334. * Simulates the start of a pointer drag event on the behavior
  9335. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  9336. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  9337. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  9338. */
  9339. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  9340. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  9341. this._startDrag(pointerId, fromRay, startPickedPoint);
  9342. var lastRay = this._lastPointerRay[pointerId];
  9343. if (pointerId === PointerDragBehavior._AnyMouseID) {
  9344. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  9345. }
  9346. if (lastRay) {
  9347. // if there was a last pointer ray drag the object there
  9348. this._moveDrag(lastRay);
  9349. }
  9350. };
  9351. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  9352. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  9353. return;
  9354. }
  9355. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  9356. // Create start ray from the camera to the object
  9357. if (fromRay) {
  9358. this._startDragRay.direction.copyFrom(fromRay.direction);
  9359. this._startDragRay.origin.copyFrom(fromRay.origin);
  9360. }
  9361. else {
  9362. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  9363. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  9364. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  9365. }
  9366. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  9367. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  9368. if (pickedPoint) {
  9369. this.dragging = true;
  9370. this.currentDraggingPointerID = pointerId;
  9371. this.lastDragPosition.copyFrom(pickedPoint);
  9372. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  9373. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  9374. // Detatch camera controls
  9375. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9376. if (this._scene.activeCamera.inputs.attachedElement) {
  9377. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  9378. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  9379. }
  9380. else {
  9381. this._attachedElement = null;
  9382. }
  9383. }
  9384. }
  9385. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  9386. };
  9387. PointerDragBehavior.prototype._moveDrag = function (ray) {
  9388. this._moving = true;
  9389. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  9390. if (pickedPoint) {
  9391. if (this.updateDragPlane) {
  9392. this._updateDragPlanePosition(ray, pickedPoint);
  9393. }
  9394. var dragLength = 0;
  9395. // depending on the drag mode option drag accordingly
  9396. if (this._options.dragAxis) {
  9397. // Convert local drag axis to world
  9398. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  9399. // Project delta drag from the drag plane onto the drag axis
  9400. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  9401. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  9402. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9403. }
  9404. else {
  9405. dragLength = this._dragDelta.length();
  9406. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9407. }
  9408. this._targetPosition.addInPlace(this._dragDelta);
  9409. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9410. this.lastDragPosition.copyFrom(pickedPoint);
  9411. }
  9412. };
  9413. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9414. var _this = this;
  9415. if (!ray) {
  9416. return null;
  9417. }
  9418. // Calculate angle between plane normal and ray
  9419. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9420. // Correct if ray is casted from oposite side
  9421. if (angle > Math.PI / 2) {
  9422. angle = Math.PI - angle;
  9423. }
  9424. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9425. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9426. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9427. // Invert ray direction along the towards object axis
  9428. this._tmpVector.copyFrom(ray.direction);
  9429. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9430. this._alternatePickedPoint.normalize();
  9431. this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9432. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9433. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9434. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9435. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9436. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9437. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9438. return this._alternatePickedPoint;
  9439. }
  9440. else {
  9441. return null;
  9442. }
  9443. }
  9444. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9445. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9446. return pickResult.pickedPoint;
  9447. }
  9448. else {
  9449. return null;
  9450. }
  9451. };
  9452. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9453. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9454. this._pointA.copyFrom(dragPlanePosition);
  9455. if (this._options.dragAxis) {
  9456. this.useObjectOrienationForDragging ? _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragAxis);
  9457. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9458. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9459. ray.origin.subtractToRef(this._pointA, this._pointC);
  9460. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9461. // Get perpendicular line from direction to camera and drag axis
  9462. this._pointB.subtractToRef(this._pointA, this._lineA);
  9463. this._pointC.subtractToRef(this._pointA, this._lineB);
  9464. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9465. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9466. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9467. this._lookAt.normalize();
  9468. this._dragPlane.position.copyFrom(this._pointA);
  9469. this._pointA.addToRef(this._lookAt, this._lookAt);
  9470. this._dragPlane.lookAt(this._lookAt);
  9471. }
  9472. else if (this._options.dragPlaneNormal) {
  9473. this.useObjectOrienationForDragging ? _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragPlaneNormal, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragPlaneNormal);
  9474. this._dragPlane.position.copyFrom(this._pointA);
  9475. this._pointA.addToRef(this._localAxis, this._lookAt);
  9476. this._dragPlane.lookAt(this._lookAt);
  9477. }
  9478. else {
  9479. this._dragPlane.position.copyFrom(this._pointA);
  9480. this._dragPlane.lookAt(ray.origin);
  9481. }
  9482. // Update the position of the drag plane so it doesn't get out of sync with the node (eg. when moving back and forth quickly)
  9483. this._dragPlane.position.copyFrom(this._attachedNode.absolutePosition);
  9484. this._dragPlane.computeWorldMatrix(true);
  9485. };
  9486. /**
  9487. * Detaches the behavior from the mesh
  9488. */
  9489. PointerDragBehavior.prototype.detach = function () {
  9490. if (this._pointerObserver) {
  9491. this._scene.onPointerObservable.remove(this._pointerObserver);
  9492. }
  9493. if (this._beforeRenderObserver) {
  9494. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9495. }
  9496. this.releaseDrag();
  9497. };
  9498. PointerDragBehavior._AnyMouseID = -2;
  9499. return PointerDragBehavior;
  9500. }());
  9501. /***/ }),
  9502. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9503. /*!************************************************!*\
  9504. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9505. \************************************************/
  9506. /*! exports provided: SixDofDragBehavior */
  9507. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9508. "use strict";
  9509. __webpack_require__.r(__webpack_exports__);
  9510. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9511. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9512. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9513. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9514. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9515. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9516. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9517. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9518. /**
  9519. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  9520. */
  9521. var SixDofDragBehavior = /** @class */ (function () {
  9522. /**
  9523. * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  9524. */
  9525. function SixDofDragBehavior() {
  9526. this._sceneRenderObserver = null;
  9527. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9528. this._moving = false;
  9529. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9530. /**
  9531. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  9532. */
  9533. this.zDragFactor = 3;
  9534. /**
  9535. * If the object should rotate to face the drag origin
  9536. */
  9537. this.rotateDraggedObject = true;
  9538. /**
  9539. * If the behavior is currently in a dragging state
  9540. */
  9541. this.dragging = false;
  9542. /**
  9543. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  9544. */
  9545. this.dragDeltaRatio = 0.2;
  9546. /**
  9547. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9548. */
  9549. this.currentDraggingPointerID = -1;
  9550. /**
  9551. * If camera controls should be detached during the drag
  9552. */
  9553. this.detachCameraControls = true;
  9554. /**
  9555. * Fires each time a drag starts
  9556. */
  9557. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9558. /**
  9559. * Fires each time a drag ends (eg. mouse release after drag)
  9560. */
  9561. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9562. }
  9563. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9564. /**
  9565. * The name of the behavior
  9566. */
  9567. get: function () {
  9568. return "SixDofDrag";
  9569. },
  9570. enumerable: true,
  9571. configurable: true
  9572. });
  9573. /**
  9574. * Initializes the behavior
  9575. */
  9576. SixDofDragBehavior.prototype.init = function () { };
  9577. /**
  9578. * Attaches the scale behavior the passed in mesh
  9579. * @param ownerNode The mesh that will be scaled around once attached
  9580. */
  9581. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9582. var _this = this;
  9583. this._ownerNode = ownerNode;
  9584. this._scene = this._ownerNode.getScene();
  9585. if (!SixDofDragBehavior._virtualScene) {
  9586. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9587. SixDofDragBehavior._virtualScene.detachControl();
  9588. this._scene.getEngine().scenes.pop();
  9589. }
  9590. var pickedMesh = null;
  9591. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9592. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9593. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9594. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9595. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9596. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9597. var pickPredicate = function (m) {
  9598. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9599. };
  9600. var attachedElement = null;
  9601. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9602. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9603. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9604. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9605. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9606. }
  9607. pickedMesh = _this._ownerNode;
  9608. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9609. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9610. // Set position and orientation of the controller
  9611. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9612. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9613. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9614. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9615. pickedMesh.computeWorldMatrix();
  9616. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9617. if (!pickedMesh.rotationQuaternion) {
  9618. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9619. }
  9620. var oldParent = pickedMesh.parent;
  9621. pickedMesh.setParent(null);
  9622. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9623. pickedMesh.setParent(oldParent);
  9624. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9625. // Update state
  9626. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9627. _this.dragging = true;
  9628. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9629. // Detatch camera controls
  9630. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9631. if (_this._scene.activeCamera.inputs.attachedElement) {
  9632. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9633. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9634. }
  9635. else {
  9636. attachedElement = null;
  9637. }
  9638. }
  9639. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9640. _this.onDragStartObservable.notifyObservers({});
  9641. }
  9642. }
  9643. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9644. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9645. _this.dragging = false;
  9646. _this._moving = false;
  9647. _this.currentDraggingPointerID = -1;
  9648. pickedMesh = null;
  9649. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9650. // Reattach camera controls
  9651. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9652. _this._scene.activeCamera.attachControl(attachedElement, true);
  9653. }
  9654. _this.onDragEndObservable.notifyObservers({});
  9655. }
  9656. }
  9657. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9658. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9659. var zDragFactor = _this.zDragFactor;
  9660. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9661. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9662. zDragFactor = 0;
  9663. }
  9664. // Calculate controller drag distance in controller space
  9665. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9666. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9667. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9668. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9669. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9670. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9671. if (_this._virtualDragMesh.position.z < 0) {
  9672. _this._virtualDragMesh.position.z = 0;
  9673. }
  9674. // Update the controller position
  9675. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9676. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9677. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9678. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9679. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9680. if (pickedMesh.parent) {
  9681. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9682. }
  9683. if (!_this._moving) {
  9684. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9685. }
  9686. _this._moving = true;
  9687. }
  9688. }
  9689. });
  9690. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9691. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9692. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9693. if (_this.dragging && _this._moving && pickedMesh) {
  9694. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9695. // Slowly move mesh to avoid jitter
  9696. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9697. if (_this.rotateDraggedObject) {
  9698. // Get change in rotation
  9699. tmpQuaternion.copyFrom(_this._startingOrientation);
  9700. tmpQuaternion.x = -tmpQuaternion.x;
  9701. tmpQuaternion.y = -tmpQuaternion.y;
  9702. tmpQuaternion.z = -tmpQuaternion.z;
  9703. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9704. // Convert change in rotation to only y axis rotation
  9705. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9706. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9707. // Slowly move mesh to avoid jitter
  9708. var oldParent = pickedMesh.parent;
  9709. // Only rotate the mesh if it's parent has uniform scaling
  9710. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9711. pickedMesh.setParent(null);
  9712. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9713. pickedMesh.setParent(oldParent);
  9714. }
  9715. }
  9716. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9717. }
  9718. });
  9719. };
  9720. /**
  9721. * Detaches the behavior from the mesh
  9722. */
  9723. SixDofDragBehavior.prototype.detach = function () {
  9724. if (this._scene) {
  9725. this._scene.onPointerObservable.remove(this._pointerObserver);
  9726. }
  9727. if (this._ownerNode) {
  9728. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9729. }
  9730. if (this._virtualOriginMesh) {
  9731. this._virtualOriginMesh.dispose();
  9732. }
  9733. if (this._virtualDragMesh) {
  9734. this._virtualDragMesh.dispose();
  9735. }
  9736. this.onDragEndObservable.clear();
  9737. this.onDragStartObservable.clear();
  9738. };
  9739. return SixDofDragBehavior;
  9740. }());
  9741. /***/ }),
  9742. /***/ "./Behaviors/index.ts":
  9743. /*!****************************!*\
  9744. !*** ./Behaviors/index.ts ***!
  9745. \****************************/
  9746. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  9747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9748. "use strict";
  9749. __webpack_require__.r(__webpack_exports__);
  9750. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9754. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9760. /***/ }),
  9761. /***/ "./Bones/bone.ts":
  9762. /*!***********************!*\
  9763. !*** ./Bones/bone.ts ***!
  9764. \***********************/
  9765. /*! exports provided: Bone */
  9766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9767. "use strict";
  9768. __webpack_require__.r(__webpack_exports__);
  9769. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9770. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9771. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9772. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9773. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  9774. /**
  9775. * Class used to store bone information
  9776. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9777. */
  9778. var Bone = /** @class */ (function (_super) {
  9779. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9780. /**
  9781. * Create a new bone
  9782. * @param name defines the bone name
  9783. * @param skeleton defines the parent skeleton
  9784. * @param parentBone defines the parent (can be null if the bone is the root)
  9785. * @param localMatrix defines the local matrix
  9786. * @param restPose defines the rest pose matrix
  9787. * @param baseMatrix defines the base matrix
  9788. * @param index defines index of the bone in the hiearchy
  9789. */
  9790. function Bone(
  9791. /**
  9792. * defines the bone name
  9793. */
  9794. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9795. if (parentBone === void 0) { parentBone = null; }
  9796. if (localMatrix === void 0) { localMatrix = null; }
  9797. if (restPose === void 0) { restPose = null; }
  9798. if (baseMatrix === void 0) { baseMatrix = null; }
  9799. if (index === void 0) { index = null; }
  9800. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9801. _this.name = name;
  9802. /**
  9803. * Gets the list of child bones
  9804. */
  9805. _this.children = new Array();
  9806. /** Gets the animations associated with this bone */
  9807. _this.animations = new Array();
  9808. /**
  9809. * @hidden Internal only
  9810. * Set this value to map this bone to a different index in the transform matrices
  9811. * Set this value to -1 to exclude the bone from the transform matrices
  9812. */
  9813. _this._index = null;
  9814. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9815. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9816. _this._scalingDeterminant = 1;
  9817. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9818. _this._needToDecompose = true;
  9819. _this._needToCompose = false;
  9820. /** @hidden */
  9821. _this._linkedTransformNode = null;
  9822. _this._skeleton = skeleton;
  9823. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9824. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9825. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9826. _this._index = index;
  9827. skeleton.bones.push(_this);
  9828. _this.setParent(parentBone, false);
  9829. if (baseMatrix || localMatrix) {
  9830. _this._updateDifferenceMatrix();
  9831. }
  9832. return _this;
  9833. }
  9834. Object.defineProperty(Bone.prototype, "_matrix", {
  9835. /** @hidden */
  9836. get: function () {
  9837. this._compose();
  9838. return this._localMatrix;
  9839. },
  9840. /** @hidden */
  9841. set: function (value) {
  9842. this._localMatrix.copyFrom(value);
  9843. this._needToDecompose = true;
  9844. },
  9845. enumerable: true,
  9846. configurable: true
  9847. });
  9848. /**
  9849. * Gets the current object class name.
  9850. * @return the class name
  9851. */
  9852. Bone.prototype.getClassName = function () {
  9853. return "Bone";
  9854. };
  9855. // Members
  9856. /**
  9857. * Gets the parent skeleton
  9858. * @returns a skeleton
  9859. */
  9860. Bone.prototype.getSkeleton = function () {
  9861. return this._skeleton;
  9862. };
  9863. /**
  9864. * Gets parent bone
  9865. * @returns a bone or null if the bone is the root of the bone hierarchy
  9866. */
  9867. Bone.prototype.getParent = function () {
  9868. return this._parent;
  9869. };
  9870. /**
  9871. * Returns an array containing the root bones
  9872. * @returns an array containing the root bones
  9873. */
  9874. Bone.prototype.getChildren = function () {
  9875. return this.children;
  9876. };
  9877. /**
  9878. * Sets the parent bone
  9879. * @param parent defines the parent (can be null if the bone is the root)
  9880. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9881. */
  9882. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9883. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9884. if (this._parent === parent) {
  9885. return;
  9886. }
  9887. if (this._parent) {
  9888. var index = this._parent.children.indexOf(this);
  9889. if (index !== -1) {
  9890. this._parent.children.splice(index, 1);
  9891. }
  9892. }
  9893. this._parent = parent;
  9894. if (this._parent) {
  9895. this._parent.children.push(this);
  9896. }
  9897. if (updateDifferenceMatrix) {
  9898. this._updateDifferenceMatrix();
  9899. }
  9900. this.markAsDirty();
  9901. };
  9902. /**
  9903. * Gets the local matrix
  9904. * @returns a matrix
  9905. */
  9906. Bone.prototype.getLocalMatrix = function () {
  9907. this._compose();
  9908. return this._localMatrix;
  9909. };
  9910. /**
  9911. * Gets the base matrix (initial matrix which remains unchanged)
  9912. * @returns a matrix
  9913. */
  9914. Bone.prototype.getBaseMatrix = function () {
  9915. return this._baseMatrix;
  9916. };
  9917. /**
  9918. * Gets the rest pose matrix
  9919. * @returns a matrix
  9920. */
  9921. Bone.prototype.getRestPose = function () {
  9922. return this._restPose;
  9923. };
  9924. /**
  9925. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9926. */
  9927. Bone.prototype.getWorldMatrix = function () {
  9928. return this._worldTransform;
  9929. };
  9930. /**
  9931. * Sets the local matrix to rest pose matrix
  9932. */
  9933. Bone.prototype.returnToRest = function () {
  9934. this.updateMatrix(this._restPose.clone());
  9935. };
  9936. /**
  9937. * Gets the inverse of the absolute transform matrix.
  9938. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9939. * @returns a matrix
  9940. */
  9941. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9942. return this._invertedAbsoluteTransform;
  9943. };
  9944. /**
  9945. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9946. * @returns a matrix
  9947. */
  9948. Bone.prototype.getAbsoluteTransform = function () {
  9949. return this._absoluteTransform;
  9950. };
  9951. /**
  9952. * Links with the given transform node.
  9953. * The local matrix of this bone is copied from the transform node every frame.
  9954. * @param transformNode defines the transform node to link to
  9955. */
  9956. Bone.prototype.linkTransformNode = function (transformNode) {
  9957. if (this._linkedTransformNode) {
  9958. this._skeleton._numBonesWithLinkedTransformNode--;
  9959. }
  9960. this._linkedTransformNode = transformNode;
  9961. if (this._linkedTransformNode) {
  9962. this._skeleton._numBonesWithLinkedTransformNode++;
  9963. }
  9964. };
  9965. Object.defineProperty(Bone.prototype, "position", {
  9966. // Properties (matches AbstractMesh properties)
  9967. /** Gets or sets current position (in local space) */
  9968. get: function () {
  9969. this._decompose();
  9970. return this._localPosition;
  9971. },
  9972. set: function (newPosition) {
  9973. this._decompose();
  9974. this._localPosition.copyFrom(newPosition);
  9975. this._markAsDirtyAndCompose();
  9976. },
  9977. enumerable: true,
  9978. configurable: true
  9979. });
  9980. Object.defineProperty(Bone.prototype, "rotation", {
  9981. /** Gets or sets current rotation (in local space) */
  9982. get: function () {
  9983. return this.getRotation();
  9984. },
  9985. set: function (newRotation) {
  9986. this.setRotation(newRotation);
  9987. },
  9988. enumerable: true,
  9989. configurable: true
  9990. });
  9991. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  9992. /** Gets or sets current rotation quaternion (in local space) */
  9993. get: function () {
  9994. this._decompose();
  9995. return this._localRotation;
  9996. },
  9997. set: function (newRotation) {
  9998. this.setRotationQuaternion(newRotation);
  9999. },
  10000. enumerable: true,
  10001. configurable: true
  10002. });
  10003. Object.defineProperty(Bone.prototype, "scaling", {
  10004. /** Gets or sets current scaling (in local space) */
  10005. get: function () {
  10006. return this.getScale();
  10007. },
  10008. set: function (newScaling) {
  10009. this.setScale(newScaling);
  10010. },
  10011. enumerable: true,
  10012. configurable: true
  10013. });
  10014. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  10015. /**
  10016. * Gets the animation properties override
  10017. */
  10018. get: function () {
  10019. return this._skeleton.animationPropertiesOverride;
  10020. },
  10021. enumerable: true,
  10022. configurable: true
  10023. });
  10024. // Methods
  10025. Bone.prototype._decompose = function () {
  10026. if (!this._needToDecompose) {
  10027. return;
  10028. }
  10029. this._needToDecompose = false;
  10030. if (!this._localScaling) {
  10031. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10032. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  10033. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10034. }
  10035. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  10036. };
  10037. Bone.prototype._compose = function () {
  10038. if (!this._needToCompose) {
  10039. return;
  10040. }
  10041. this._needToCompose = false;
  10042. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  10043. };
  10044. /**
  10045. * Update the base and local matrices
  10046. * @param matrix defines the new base or local matrix
  10047. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  10048. * @param updateLocalMatrix defines if the local matrix should be updated
  10049. */
  10050. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  10051. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  10052. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  10053. this._baseMatrix.copyFrom(matrix);
  10054. if (updateDifferenceMatrix) {
  10055. this._updateDifferenceMatrix();
  10056. }
  10057. if (updateLocalMatrix) {
  10058. this._localMatrix.copyFrom(matrix);
  10059. this._markAsDirtyAndDecompose();
  10060. }
  10061. else {
  10062. this.markAsDirty();
  10063. }
  10064. };
  10065. /** @hidden */
  10066. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  10067. if (updateChildren === void 0) { updateChildren = true; }
  10068. if (!rootMatrix) {
  10069. rootMatrix = this._baseMatrix;
  10070. }
  10071. if (this._parent) {
  10072. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10073. }
  10074. else {
  10075. this._absoluteTransform.copyFrom(rootMatrix);
  10076. }
  10077. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  10078. if (updateChildren) {
  10079. for (var index = 0; index < this.children.length; index++) {
  10080. this.children[index]._updateDifferenceMatrix();
  10081. }
  10082. }
  10083. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  10084. };
  10085. /**
  10086. * Flag the bone as dirty (Forcing it to update everything)
  10087. */
  10088. Bone.prototype.markAsDirty = function () {
  10089. this._currentRenderId++;
  10090. this._childUpdateId++;
  10091. this._skeleton._markAsDirty();
  10092. };
  10093. Bone.prototype._markAsDirtyAndCompose = function () {
  10094. this.markAsDirty();
  10095. this._needToCompose = true;
  10096. };
  10097. Bone.prototype._markAsDirtyAndDecompose = function () {
  10098. this.markAsDirty();
  10099. this._needToDecompose = true;
  10100. };
  10101. /**
  10102. * Translate the bone in local or world space
  10103. * @param vec The amount to translate the bone
  10104. * @param space The space that the translation is in
  10105. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10106. */
  10107. Bone.prototype.translate = function (vec, space, mesh) {
  10108. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10109. var lm = this.getLocalMatrix();
  10110. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10111. lm.addAtIndex(12, vec.x);
  10112. lm.addAtIndex(13, vec.y);
  10113. lm.addAtIndex(14, vec.z);
  10114. }
  10115. else {
  10116. var wm = null;
  10117. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10118. if (mesh) {
  10119. wm = mesh.getWorldMatrix();
  10120. }
  10121. this._skeleton.computeAbsoluteTransforms();
  10122. var tmat = Bone._tmpMats[0];
  10123. var tvec = Bone._tmpVecs[0];
  10124. if (this._parent) {
  10125. if (mesh && wm) {
  10126. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10127. tmat.multiplyToRef(wm, tmat);
  10128. }
  10129. else {
  10130. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10131. }
  10132. }
  10133. tmat.setTranslationFromFloats(0, 0, 0);
  10134. tmat.invert();
  10135. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  10136. lm.addAtIndex(12, tvec.x);
  10137. lm.addAtIndex(13, tvec.y);
  10138. lm.addAtIndex(14, tvec.z);
  10139. }
  10140. this._markAsDirtyAndDecompose();
  10141. };
  10142. /**
  10143. * Set the postion of the bone in local or world space
  10144. * @param position The position to set the bone
  10145. * @param space The space that the position is in
  10146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10147. */
  10148. Bone.prototype.setPosition = function (position, space, mesh) {
  10149. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10150. var lm = this.getLocalMatrix();
  10151. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10152. lm.setTranslationFromFloats(position.x, position.y, position.z);
  10153. }
  10154. else {
  10155. var wm = null;
  10156. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10157. if (mesh) {
  10158. wm = mesh.getWorldMatrix();
  10159. }
  10160. this._skeleton.computeAbsoluteTransforms();
  10161. var tmat = Bone._tmpMats[0];
  10162. var vec = Bone._tmpVecs[0];
  10163. if (this._parent) {
  10164. if (mesh && wm) {
  10165. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10166. tmat.multiplyToRef(wm, tmat);
  10167. }
  10168. else {
  10169. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10170. }
  10171. }
  10172. tmat.invert();
  10173. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  10174. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  10175. }
  10176. this._markAsDirtyAndDecompose();
  10177. };
  10178. /**
  10179. * Set the absolute position of the bone (world space)
  10180. * @param position The position to set the bone
  10181. * @param mesh The mesh that this bone is attached to
  10182. */
  10183. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  10184. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  10185. };
  10186. /**
  10187. * Scale the bone on the x, y and z axes (in local space)
  10188. * @param x The amount to scale the bone on the x axis
  10189. * @param y The amount to scale the bone on the y axis
  10190. * @param z The amount to scale the bone on the z axis
  10191. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  10192. */
  10193. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  10194. if (scaleChildren === void 0) { scaleChildren = false; }
  10195. var locMat = this.getLocalMatrix();
  10196. // Apply new scaling on top of current local matrix
  10197. var scaleMat = Bone._tmpMats[0];
  10198. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  10199. scaleMat.multiplyToRef(locMat, locMat);
  10200. // Invert scaling matrix and apply the inverse to all children
  10201. scaleMat.invert();
  10202. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10203. var child = _a[_i];
  10204. var cm = child.getLocalMatrix();
  10205. cm.multiplyToRef(scaleMat, cm);
  10206. cm.multiplyAtIndex(12, x);
  10207. cm.multiplyAtIndex(13, y);
  10208. cm.multiplyAtIndex(14, z);
  10209. child._markAsDirtyAndDecompose();
  10210. }
  10211. this._markAsDirtyAndDecompose();
  10212. if (scaleChildren) {
  10213. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  10214. var child = _c[_b];
  10215. child.scale(x, y, z, scaleChildren);
  10216. }
  10217. }
  10218. };
  10219. /**
  10220. * Set the bone scaling in local space
  10221. * @param scale defines the scaling vector
  10222. */
  10223. Bone.prototype.setScale = function (scale) {
  10224. this._decompose();
  10225. this._localScaling.copyFrom(scale);
  10226. this._markAsDirtyAndCompose();
  10227. };
  10228. /**
  10229. * Gets the current scaling in local space
  10230. * @returns the current scaling vector
  10231. */
  10232. Bone.prototype.getScale = function () {
  10233. this._decompose();
  10234. return this._localScaling;
  10235. };
  10236. /**
  10237. * Gets the current scaling in local space and stores it in a target vector
  10238. * @param result defines the target vector
  10239. */
  10240. Bone.prototype.getScaleToRef = function (result) {
  10241. this._decompose();
  10242. result.copyFrom(this._localScaling);
  10243. };
  10244. /**
  10245. * Set the yaw, pitch, and roll of the bone in local or world space
  10246. * @param yaw The rotation of the bone on the y axis
  10247. * @param pitch The rotation of the bone on the x axis
  10248. * @param roll The rotation of the bone on the z axis
  10249. * @param space The space that the axes of rotation are in
  10250. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10251. */
  10252. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  10253. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10254. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10255. var quat = Bone._tmpQuat;
  10256. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  10257. this.setRotationQuaternion(quat, space, mesh);
  10258. return;
  10259. }
  10260. var rotMatInv = Bone._tmpMats[0];
  10261. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10262. return;
  10263. }
  10264. var rotMat = Bone._tmpMats[1];
  10265. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  10266. rotMatInv.multiplyToRef(rotMat, rotMat);
  10267. this._rotateWithMatrix(rotMat, space, mesh);
  10268. };
  10269. /**
  10270. * Add a rotation to the bone on an axis in local or world space
  10271. * @param axis The axis to rotate the bone on
  10272. * @param amount The amount to rotate the bone
  10273. * @param space The space that the axis is in
  10274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10275. */
  10276. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  10277. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10278. var rmat = Bone._tmpMats[0];
  10279. rmat.setTranslationFromFloats(0, 0, 0);
  10280. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  10281. this._rotateWithMatrix(rmat, space, mesh);
  10282. };
  10283. /**
  10284. * Set the rotation of the bone to a particular axis angle in local or world space
  10285. * @param axis The axis to rotate the bone on
  10286. * @param angle The angle that the bone should be rotated to
  10287. * @param space The space that the axis is in
  10288. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10289. */
  10290. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  10291. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10292. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10293. var quat = Bone._tmpQuat;
  10294. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  10295. this.setRotationQuaternion(quat, space, mesh);
  10296. return;
  10297. }
  10298. var rotMatInv = Bone._tmpMats[0];
  10299. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10300. return;
  10301. }
  10302. var rotMat = Bone._tmpMats[1];
  10303. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  10304. rotMatInv.multiplyToRef(rotMat, rotMat);
  10305. this._rotateWithMatrix(rotMat, space, mesh);
  10306. };
  10307. /**
  10308. * Set the euler rotation of the bone in local of world space
  10309. * @param rotation The euler rotation that the bone should be set to
  10310. * @param space The space that the rotation is in
  10311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10312. */
  10313. Bone.prototype.setRotation = function (rotation, space, mesh) {
  10314. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10315. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  10316. };
  10317. /**
  10318. * Set the quaternion rotation of the bone in local of world space
  10319. * @param quat The quaternion rotation that the bone should be set to
  10320. * @param space The space that the rotation is in
  10321. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10322. */
  10323. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  10324. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10325. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10326. this._decompose();
  10327. this._localRotation.copyFrom(quat);
  10328. this._markAsDirtyAndCompose();
  10329. return;
  10330. }
  10331. var rotMatInv = Bone._tmpMats[0];
  10332. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10333. return;
  10334. }
  10335. var rotMat = Bone._tmpMats[1];
  10336. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  10337. rotMatInv.multiplyToRef(rotMat, rotMat);
  10338. this._rotateWithMatrix(rotMat, space, mesh);
  10339. };
  10340. /**
  10341. * Set the rotation matrix of the bone in local of world space
  10342. * @param rotMat The rotation matrix that the bone should be set to
  10343. * @param space The space that the rotation is in
  10344. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10345. */
  10346. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  10347. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10348. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10349. var quat = Bone._tmpQuat;
  10350. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  10351. this.setRotationQuaternion(quat, space, mesh);
  10352. return;
  10353. }
  10354. var rotMatInv = Bone._tmpMats[0];
  10355. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10356. return;
  10357. }
  10358. var rotMat2 = Bone._tmpMats[1];
  10359. rotMat2.copyFrom(rotMat);
  10360. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10361. this._rotateWithMatrix(rotMat2, space, mesh);
  10362. };
  10363. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10364. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10365. var lmat = this.getLocalMatrix();
  10366. var lx = lmat.m[12];
  10367. var ly = lmat.m[13];
  10368. var lz = lmat.m[14];
  10369. var parent = this.getParent();
  10370. var parentScale = Bone._tmpMats[3];
  10371. var parentScaleInv = Bone._tmpMats[4];
  10372. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10373. if (mesh) {
  10374. parentScale.copyFrom(mesh.getWorldMatrix());
  10375. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10376. }
  10377. else {
  10378. parentScale.copyFrom(parent.getAbsoluteTransform());
  10379. }
  10380. parentScaleInv.copyFrom(parentScale);
  10381. parentScaleInv.invert();
  10382. lmat.multiplyToRef(parentScale, lmat);
  10383. lmat.multiplyToRef(rmat, lmat);
  10384. lmat.multiplyToRef(parentScaleInv, lmat);
  10385. }
  10386. else {
  10387. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10388. parentScale.copyFrom(mesh.getWorldMatrix());
  10389. parentScaleInv.copyFrom(parentScale);
  10390. parentScaleInv.invert();
  10391. lmat.multiplyToRef(parentScale, lmat);
  10392. lmat.multiplyToRef(rmat, lmat);
  10393. lmat.multiplyToRef(parentScaleInv, lmat);
  10394. }
  10395. else {
  10396. lmat.multiplyToRef(rmat, lmat);
  10397. }
  10398. }
  10399. lmat.setTranslationFromFloats(lx, ly, lz);
  10400. this.computeAbsoluteTransforms();
  10401. this._markAsDirtyAndDecompose();
  10402. };
  10403. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10404. var scaleMatrix = Bone._tmpMats[2];
  10405. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10406. if (mesh) {
  10407. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10408. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10409. }
  10410. rotMatInv.invert();
  10411. if (isNaN(rotMatInv.m[0])) {
  10412. // Matrix failed to invert.
  10413. // This can happen if scale is zero for example.
  10414. return false;
  10415. }
  10416. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10417. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10418. return true;
  10419. };
  10420. /**
  10421. * Get the position of the bone in local or world space
  10422. * @param space The space that the returned position is in
  10423. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10424. * @returns The position of the bone
  10425. */
  10426. Bone.prototype.getPosition = function (space, mesh) {
  10427. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10428. if (mesh === void 0) { mesh = null; }
  10429. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10430. this.getPositionToRef(space, mesh, pos);
  10431. return pos;
  10432. };
  10433. /**
  10434. * Copy the position of the bone to a vector3 in local or world space
  10435. * @param space The space that the returned position is in
  10436. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10437. * @param result The vector3 to copy the position to
  10438. */
  10439. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10440. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10441. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10442. var lm = this.getLocalMatrix();
  10443. result.x = lm.m[12];
  10444. result.y = lm.m[13];
  10445. result.z = lm.m[14];
  10446. }
  10447. else {
  10448. var wm = null;
  10449. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10450. if (mesh) {
  10451. wm = mesh.getWorldMatrix();
  10452. }
  10453. this._skeleton.computeAbsoluteTransforms();
  10454. var tmat = Bone._tmpMats[0];
  10455. if (mesh && wm) {
  10456. tmat.copyFrom(this.getAbsoluteTransform());
  10457. tmat.multiplyToRef(wm, tmat);
  10458. }
  10459. else {
  10460. tmat = this.getAbsoluteTransform();
  10461. }
  10462. result.x = tmat.m[12];
  10463. result.y = tmat.m[13];
  10464. result.z = tmat.m[14];
  10465. }
  10466. };
  10467. /**
  10468. * Get the absolute position of the bone (world space)
  10469. * @param mesh The mesh that this bone is attached to
  10470. * @returns The absolute position of the bone
  10471. */
  10472. Bone.prototype.getAbsolutePosition = function (mesh) {
  10473. if (mesh === void 0) { mesh = null; }
  10474. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10475. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10476. return pos;
  10477. };
  10478. /**
  10479. * Copy the absolute position of the bone (world space) to the result param
  10480. * @param mesh The mesh that this bone is attached to
  10481. * @param result The vector3 to copy the absolute position to
  10482. */
  10483. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10484. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10485. };
  10486. /**
  10487. * Compute the absolute transforms of this bone and its children
  10488. */
  10489. Bone.prototype.computeAbsoluteTransforms = function () {
  10490. this._compose();
  10491. if (this._parent) {
  10492. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10493. }
  10494. else {
  10495. this._absoluteTransform.copyFrom(this._localMatrix);
  10496. var poseMatrix = this._skeleton.getPoseMatrix();
  10497. if (poseMatrix) {
  10498. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10499. }
  10500. }
  10501. var children = this.children;
  10502. var len = children.length;
  10503. for (var i = 0; i < len; i++) {
  10504. children[i].computeAbsoluteTransforms();
  10505. }
  10506. };
  10507. /**
  10508. * Get the world direction from an axis that is in the local space of the bone
  10509. * @param localAxis The local direction that is used to compute the world direction
  10510. * @param mesh The mesh that this bone is attached to
  10511. * @returns The world direction
  10512. */
  10513. Bone.prototype.getDirection = function (localAxis, mesh) {
  10514. if (mesh === void 0) { mesh = null; }
  10515. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10516. this.getDirectionToRef(localAxis, mesh, result);
  10517. return result;
  10518. };
  10519. /**
  10520. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10521. * @param localAxis The local direction that is used to compute the world direction
  10522. * @param mesh The mesh that this bone is attached to
  10523. * @param result The vector3 that the world direction will be copied to
  10524. */
  10525. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10526. if (mesh === void 0) { mesh = null; }
  10527. var wm = null;
  10528. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10529. if (mesh) {
  10530. wm = mesh.getWorldMatrix();
  10531. }
  10532. this._skeleton.computeAbsoluteTransforms();
  10533. var mat = Bone._tmpMats[0];
  10534. mat.copyFrom(this.getAbsoluteTransform());
  10535. if (mesh && wm) {
  10536. mat.multiplyToRef(wm, mat);
  10537. }
  10538. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10539. result.normalize();
  10540. };
  10541. /**
  10542. * Get the euler rotation of the bone in local or world space
  10543. * @param space The space that the rotation should be in
  10544. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10545. * @returns The euler rotation
  10546. */
  10547. Bone.prototype.getRotation = function (space, mesh) {
  10548. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10549. if (mesh === void 0) { mesh = null; }
  10550. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10551. this.getRotationToRef(space, mesh, result);
  10552. return result;
  10553. };
  10554. /**
  10555. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10556. * @param space The space that the rotation should be in
  10557. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10558. * @param result The vector3 that the rotation should be copied to
  10559. */
  10560. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10561. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10562. if (mesh === void 0) { mesh = null; }
  10563. var quat = Bone._tmpQuat;
  10564. this.getRotationQuaternionToRef(space, mesh, quat);
  10565. quat.toEulerAnglesToRef(result);
  10566. };
  10567. /**
  10568. * Get the quaternion rotation of the bone in either local or world space
  10569. * @param space The space that the rotation should be in
  10570. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10571. * @returns The quaternion rotation
  10572. */
  10573. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10574. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10575. if (mesh === void 0) { mesh = null; }
  10576. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10577. this.getRotationQuaternionToRef(space, mesh, result);
  10578. return result;
  10579. };
  10580. /**
  10581. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10582. * @param space The space that the rotation should be in
  10583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10584. * @param result The quaternion that the rotation should be copied to
  10585. */
  10586. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10587. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10588. if (mesh === void 0) { mesh = null; }
  10589. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10590. this._decompose();
  10591. result.copyFrom(this._localRotation);
  10592. }
  10593. else {
  10594. var mat = Bone._tmpMats[0];
  10595. var amat = this.getAbsoluteTransform();
  10596. if (mesh) {
  10597. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10598. }
  10599. else {
  10600. mat.copyFrom(amat);
  10601. }
  10602. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10603. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10604. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10605. mat.decompose(undefined, result, undefined);
  10606. }
  10607. };
  10608. /**
  10609. * Get the rotation matrix of the bone in local or world space
  10610. * @param space The space that the rotation should be in
  10611. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10612. * @returns The rotation matrix
  10613. */
  10614. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10615. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10616. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10617. this.getRotationMatrixToRef(space, mesh, result);
  10618. return result;
  10619. };
  10620. /**
  10621. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10622. * @param space The space that the rotation should be in
  10623. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10624. * @param result The quaternion that the rotation should be copied to
  10625. */
  10626. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10627. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10628. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10629. this.getLocalMatrix().getRotationMatrixToRef(result);
  10630. }
  10631. else {
  10632. var mat = Bone._tmpMats[0];
  10633. var amat = this.getAbsoluteTransform();
  10634. if (mesh) {
  10635. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10636. }
  10637. else {
  10638. mat.copyFrom(amat);
  10639. }
  10640. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10641. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10642. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10643. mat.getRotationMatrixToRef(result);
  10644. }
  10645. };
  10646. /**
  10647. * Get the world position of a point that is in the local space of the bone
  10648. * @param position The local position
  10649. * @param mesh The mesh that this bone is attached to
  10650. * @returns The world position
  10651. */
  10652. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10653. if (mesh === void 0) { mesh = null; }
  10654. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10655. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10656. return result;
  10657. };
  10658. /**
  10659. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10660. * @param position The local position
  10661. * @param mesh The mesh that this bone is attached to
  10662. * @param result The vector3 that the world position should be copied to
  10663. */
  10664. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10665. if (mesh === void 0) { mesh = null; }
  10666. var wm = null;
  10667. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10668. if (mesh) {
  10669. wm = mesh.getWorldMatrix();
  10670. }
  10671. this._skeleton.computeAbsoluteTransforms();
  10672. var tmat = Bone._tmpMats[0];
  10673. if (mesh && wm) {
  10674. tmat.copyFrom(this.getAbsoluteTransform());
  10675. tmat.multiplyToRef(wm, tmat);
  10676. }
  10677. else {
  10678. tmat = this.getAbsoluteTransform();
  10679. }
  10680. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10681. };
  10682. /**
  10683. * Get the local position of a point that is in world space
  10684. * @param position The world position
  10685. * @param mesh The mesh that this bone is attached to
  10686. * @returns The local position
  10687. */
  10688. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10689. if (mesh === void 0) { mesh = null; }
  10690. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10691. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10692. return result;
  10693. };
  10694. /**
  10695. * Get the local position of a point that is in world space and copy it to the result param
  10696. * @param position The world position
  10697. * @param mesh The mesh that this bone is attached to
  10698. * @param result The vector3 that the local position should be copied to
  10699. */
  10700. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10701. if (mesh === void 0) { mesh = null; }
  10702. var wm = null;
  10703. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10704. if (mesh) {
  10705. wm = mesh.getWorldMatrix();
  10706. }
  10707. this._skeleton.computeAbsoluteTransforms();
  10708. var tmat = Bone._tmpMats[0];
  10709. tmat.copyFrom(this.getAbsoluteTransform());
  10710. if (mesh && wm) {
  10711. tmat.multiplyToRef(wm, tmat);
  10712. }
  10713. tmat.invert();
  10714. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10715. };
  10716. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10717. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10718. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10719. return Bone;
  10720. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  10721. /***/ }),
  10722. /***/ "./Bones/boneIKController.ts":
  10723. /*!***********************************!*\
  10724. !*** ./Bones/boneIKController.ts ***!
  10725. \***********************************/
  10726. /*! exports provided: BoneIKController */
  10727. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10728. "use strict";
  10729. __webpack_require__.r(__webpack_exports__);
  10730. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10731. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10732. /**
  10733. * Class used to apply inverse kinematics to bones
  10734. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10735. */
  10736. var BoneIKController = /** @class */ (function () {
  10737. /**
  10738. * Creates a new BoneIKController
  10739. * @param mesh defines the mesh to control
  10740. * @param bone defines the bone to control
  10741. * @param options defines options to set up the controller
  10742. */
  10743. function BoneIKController(mesh, bone, options) {
  10744. /**
  10745. * Gets or sets the target position
  10746. */
  10747. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10748. /**
  10749. * Gets or sets the pole target position
  10750. */
  10751. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10752. /**
  10753. * Gets or sets the pole target local offset
  10754. */
  10755. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10756. /**
  10757. * Gets or sets the pole angle
  10758. */
  10759. this.poleAngle = 0;
  10760. /**
  10761. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  10762. */
  10763. this.slerpAmount = 1;
  10764. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10765. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10766. this._bone2Ang = Math.PI;
  10767. this._maxAngle = Math.PI;
  10768. this._rightHandedSystem = false;
  10769. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10770. this._slerping = false;
  10771. this._adjustRoll = 0;
  10772. this._bone2 = bone;
  10773. this._bone1 = bone.getParent();
  10774. if (!this._bone1) {
  10775. return;
  10776. }
  10777. this.mesh = mesh;
  10778. var bonePos = bone.getPosition();
  10779. if (bone.getAbsoluteTransform().determinant() > 0) {
  10780. this._rightHandedSystem = true;
  10781. this._bendAxis.x = 0;
  10782. this._bendAxis.y = 0;
  10783. this._bendAxis.z = -1;
  10784. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10785. this._adjustRoll = Math.PI * .5;
  10786. this._bendAxis.z = 1;
  10787. }
  10788. }
  10789. if (this._bone1.length) {
  10790. var boneScale1 = this._bone1.getScale();
  10791. var boneScale2 = this._bone2.getScale();
  10792. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10793. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10794. }
  10795. else if (this._bone1.children[0]) {
  10796. mesh.computeWorldMatrix(true);
  10797. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10798. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10799. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10800. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10801. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10802. }
  10803. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10804. this.maxAngle = Math.PI;
  10805. if (options) {
  10806. if (options.targetMesh) {
  10807. this.targetMesh = options.targetMesh;
  10808. this.targetMesh.computeWorldMatrix(true);
  10809. }
  10810. if (options.poleTargetMesh) {
  10811. this.poleTargetMesh = options.poleTargetMesh;
  10812. this.poleTargetMesh.computeWorldMatrix(true);
  10813. }
  10814. else if (options.poleTargetBone) {
  10815. this.poleTargetBone = options.poleTargetBone;
  10816. }
  10817. else if (this._bone1.getParent()) {
  10818. this.poleTargetBone = this._bone1.getParent();
  10819. }
  10820. if (options.poleTargetLocalOffset) {
  10821. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10822. }
  10823. if (options.poleAngle) {
  10824. this.poleAngle = options.poleAngle;
  10825. }
  10826. if (options.bendAxis) {
  10827. this._bendAxis.copyFrom(options.bendAxis);
  10828. }
  10829. if (options.maxAngle) {
  10830. this.maxAngle = options.maxAngle;
  10831. }
  10832. if (options.slerpAmount) {
  10833. this.slerpAmount = options.slerpAmount;
  10834. }
  10835. }
  10836. }
  10837. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10838. /**
  10839. * Gets or sets maximum allowed angle
  10840. */
  10841. get: function () {
  10842. return this._maxAngle;
  10843. },
  10844. set: function (value) {
  10845. this._setMaxAngle(value);
  10846. },
  10847. enumerable: true,
  10848. configurable: true
  10849. });
  10850. BoneIKController.prototype._setMaxAngle = function (ang) {
  10851. if (ang < 0) {
  10852. ang = 0;
  10853. }
  10854. if (ang > Math.PI || ang == undefined) {
  10855. ang = Math.PI;
  10856. }
  10857. this._maxAngle = ang;
  10858. var a = this._bone1Length;
  10859. var b = this._bone2Length;
  10860. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10861. };
  10862. /**
  10863. * Force the controller to update the bones
  10864. */
  10865. BoneIKController.prototype.update = function () {
  10866. var bone1 = this._bone1;
  10867. if (!bone1) {
  10868. return;
  10869. }
  10870. var target = this.targetPosition;
  10871. var poleTarget = this.poleTargetPosition;
  10872. var mat1 = BoneIKController._tmpMats[0];
  10873. var mat2 = BoneIKController._tmpMats[1];
  10874. if (this.targetMesh) {
  10875. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10876. }
  10877. if (this.poleTargetBone) {
  10878. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10879. }
  10880. else if (this.poleTargetMesh) {
  10881. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10882. }
  10883. var bonePos = BoneIKController._tmpVecs[0];
  10884. var zaxis = BoneIKController._tmpVecs[1];
  10885. var xaxis = BoneIKController._tmpVecs[2];
  10886. var yaxis = BoneIKController._tmpVecs[3];
  10887. var upAxis = BoneIKController._tmpVecs[4];
  10888. var _tmpQuat = BoneIKController._tmpQuat;
  10889. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10890. poleTarget.subtractToRef(bonePos, upAxis);
  10891. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10892. upAxis.y = 1;
  10893. }
  10894. else {
  10895. upAxis.normalize();
  10896. }
  10897. target.subtractToRef(bonePos, yaxis);
  10898. yaxis.normalize();
  10899. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10900. zaxis.normalize();
  10901. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10902. xaxis.normalize();
  10903. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10904. var a = this._bone1Length;
  10905. var b = this._bone2Length;
  10906. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10907. if (this._maxReach > 0) {
  10908. c = Math.min(this._maxReach, c);
  10909. }
  10910. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10911. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10912. if (acosa > 1) {
  10913. acosa = 1;
  10914. }
  10915. if (acosb > 1) {
  10916. acosb = 1;
  10917. }
  10918. if (acosa < -1) {
  10919. acosa = -1;
  10920. }
  10921. if (acosb < -1) {
  10922. acosb = -1;
  10923. }
  10924. var angA = Math.acos(acosa);
  10925. var angB = Math.acos(acosb);
  10926. var angC = -angA - angB;
  10927. if (this._rightHandedSystem) {
  10928. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10929. mat2.multiplyToRef(mat1, mat1);
  10930. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10931. mat2.multiplyToRef(mat1, mat1);
  10932. }
  10933. else {
  10934. var _tmpVec = BoneIKController._tmpVecs[5];
  10935. _tmpVec.copyFrom(this._bendAxis);
  10936. _tmpVec.x *= -1;
  10937. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10938. mat2.multiplyToRef(mat1, mat1);
  10939. }
  10940. if (this.poleAngle) {
  10941. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10942. mat1.multiplyToRef(mat2, mat1);
  10943. }
  10944. if (this._bone1) {
  10945. if (this.slerpAmount < 1) {
  10946. if (!this._slerping) {
  10947. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10948. }
  10949. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10950. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10951. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10952. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10953. this._slerping = true;
  10954. }
  10955. else {
  10956. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10957. this._bone1Mat.copyFrom(mat1);
  10958. this._slerping = false;
  10959. }
  10960. }
  10961. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10962. this._bone2Ang = angC;
  10963. };
  10964. BoneIKController._tmpVecs = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  10965. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10966. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10967. return BoneIKController;
  10968. }());
  10969. /***/ }),
  10970. /***/ "./Bones/boneLookController.ts":
  10971. /*!*************************************!*\
  10972. !*** ./Bones/boneLookController.ts ***!
  10973. \*************************************/
  10974. /*! exports provided: BoneLookController */
  10975. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10976. "use strict";
  10977. __webpack_require__.r(__webpack_exports__);
  10978. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10979. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10980. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10981. /**
  10982. * Class used to make a bone look toward a point in space
  10983. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10984. */
  10985. var BoneLookController = /** @class */ (function () {
  10986. /**
  10987. * Create a BoneLookController
  10988. * @param mesh the mesh that the bone belongs to
  10989. * @param bone the bone that will be looking to the target
  10990. * @param target the target Vector3 to look at
  10991. * @param options optional settings:
  10992. * * maxYaw: the maximum angle the bone will yaw to
  10993. * * minYaw: the minimum angle the bone will yaw to
  10994. * * maxPitch: the maximum angle the bone will pitch to
  10995. * * minPitch: the minimum angle the bone will yaw to
  10996. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  10997. * * upAxis: the up axis of the coordinate system
  10998. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  10999. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  11000. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  11001. * * adjustYaw: used to make an adjustment to the yaw of the bone
  11002. * * adjustPitch: used to make an adjustment to the pitch of the bone
  11003. * * adjustRoll: used to make an adjustment to the roll of the bone
  11004. **/
  11005. function BoneLookController(mesh, bone, target, options) {
  11006. /**
  11007. * The up axis of the coordinate system that is used when the bone is rotated
  11008. */
  11009. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  11010. /**
  11011. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  11012. */
  11013. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11014. /**
  11015. * Used to make an adjustment to the yaw of the bone
  11016. */
  11017. this.adjustYaw = 0;
  11018. /**
  11019. * Used to make an adjustment to the pitch of the bone
  11020. */
  11021. this.adjustPitch = 0;
  11022. /**
  11023. * Used to make an adjustment to the roll of the bone
  11024. */
  11025. this.adjustRoll = 0;
  11026. /**
  11027. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  11028. */
  11029. this.slerpAmount = 1;
  11030. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11031. this._slerping = false;
  11032. this._firstFrameSkipped = false;
  11033. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  11034. this.mesh = mesh;
  11035. this.bone = bone;
  11036. this.target = target;
  11037. if (options) {
  11038. if (options.adjustYaw) {
  11039. this.adjustYaw = options.adjustYaw;
  11040. }
  11041. if (options.adjustPitch) {
  11042. this.adjustPitch = options.adjustPitch;
  11043. }
  11044. if (options.adjustRoll) {
  11045. this.adjustRoll = options.adjustRoll;
  11046. }
  11047. if (options.maxYaw != null) {
  11048. this.maxYaw = options.maxYaw;
  11049. }
  11050. else {
  11051. this.maxYaw = Math.PI;
  11052. }
  11053. if (options.minYaw != null) {
  11054. this.minYaw = options.minYaw;
  11055. }
  11056. else {
  11057. this.minYaw = -Math.PI;
  11058. }
  11059. if (options.maxPitch != null) {
  11060. this.maxPitch = options.maxPitch;
  11061. }
  11062. else {
  11063. this.maxPitch = Math.PI;
  11064. }
  11065. if (options.minPitch != null) {
  11066. this.minPitch = options.minPitch;
  11067. }
  11068. else {
  11069. this.minPitch = -Math.PI;
  11070. }
  11071. if (options.slerpAmount != null) {
  11072. this.slerpAmount = options.slerpAmount;
  11073. }
  11074. if (options.upAxis != null) {
  11075. this.upAxis = options.upAxis;
  11076. }
  11077. if (options.upAxisSpace != null) {
  11078. this.upAxisSpace = options.upAxisSpace;
  11079. }
  11080. if (options.yawAxis != null || options.pitchAxis != null) {
  11081. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  11082. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  11083. if (options.yawAxis != null) {
  11084. newYawAxis = options.yawAxis.clone();
  11085. newYawAxis.normalize();
  11086. }
  11087. if (options.pitchAxis != null) {
  11088. newPitchAxis = options.pitchAxis.clone();
  11089. newPitchAxis.normalize();
  11090. }
  11091. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  11092. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  11093. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  11094. this._transformYawPitchInv = this._transformYawPitch.clone();
  11095. this._transformYawPitch.invert();
  11096. }
  11097. }
  11098. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  11099. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11100. }
  11101. }
  11102. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  11103. /**
  11104. * Gets or sets the minimum yaw angle that the bone can look to
  11105. */
  11106. get: function () {
  11107. return this._minYaw;
  11108. },
  11109. set: function (value) {
  11110. this._minYaw = value;
  11111. this._minYawSin = Math.sin(value);
  11112. this._minYawCos = Math.cos(value);
  11113. if (this._maxYaw != null) {
  11114. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11115. this._yawRange = this._maxYaw - this._minYaw;
  11116. }
  11117. },
  11118. enumerable: true,
  11119. configurable: true
  11120. });
  11121. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  11122. /**
  11123. * Gets or sets the maximum yaw angle that the bone can look to
  11124. */
  11125. get: function () {
  11126. return this._maxYaw;
  11127. },
  11128. set: function (value) {
  11129. this._maxYaw = value;
  11130. this._maxYawSin = Math.sin(value);
  11131. this._maxYawCos = Math.cos(value);
  11132. if (this._minYaw != null) {
  11133. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11134. this._yawRange = this._maxYaw - this._minYaw;
  11135. }
  11136. },
  11137. enumerable: true,
  11138. configurable: true
  11139. });
  11140. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  11141. /**
  11142. * Gets or sets the minimum pitch angle that the bone can look to
  11143. */
  11144. get: function () {
  11145. return this._minPitch;
  11146. },
  11147. set: function (value) {
  11148. this._minPitch = value;
  11149. this._minPitchTan = Math.tan(value);
  11150. },
  11151. enumerable: true,
  11152. configurable: true
  11153. });
  11154. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  11155. /**
  11156. * Gets or sets the maximum pitch angle that the bone can look to
  11157. */
  11158. get: function () {
  11159. return this._maxPitch;
  11160. },
  11161. set: function (value) {
  11162. this._maxPitch = value;
  11163. this._maxPitchTan = Math.tan(value);
  11164. },
  11165. enumerable: true,
  11166. configurable: true
  11167. });
  11168. /**
  11169. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  11170. */
  11171. BoneLookController.prototype.update = function () {
  11172. //skip the first frame when slerping so that the mesh rotation is correct
  11173. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  11174. this._firstFrameSkipped = true;
  11175. return;
  11176. }
  11177. var bone = this.bone;
  11178. var bonePos = BoneLookController._tmpVecs[0];
  11179. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  11180. var target = this.target;
  11181. var _tmpMat1 = BoneLookController._tmpMats[0];
  11182. var _tmpMat2 = BoneLookController._tmpMats[1];
  11183. var mesh = this.mesh;
  11184. var parentBone = bone.getParent();
  11185. var upAxis = BoneLookController._tmpVecs[1];
  11186. upAxis.copyFrom(this.upAxis);
  11187. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  11188. if (this._transformYawPitch) {
  11189. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  11190. }
  11191. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  11192. }
  11193. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  11194. mesh.getDirectionToRef(upAxis, upAxis);
  11195. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  11196. upAxis.normalize();
  11197. }
  11198. }
  11199. var checkYaw = false;
  11200. var checkPitch = false;
  11201. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  11202. checkYaw = true;
  11203. }
  11204. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  11205. checkPitch = true;
  11206. }
  11207. if (checkYaw || checkPitch) {
  11208. var spaceMat = BoneLookController._tmpMats[2];
  11209. var spaceMatInv = BoneLookController._tmpMats[3];
  11210. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  11211. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  11212. }
  11213. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  11214. spaceMat.copyFrom(mesh.getWorldMatrix());
  11215. }
  11216. else {
  11217. var forwardAxis = BoneLookController._tmpVecs[2];
  11218. forwardAxis.copyFrom(this._fowardAxis);
  11219. if (this._transformYawPitch) {
  11220. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  11221. }
  11222. if (parentBone) {
  11223. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  11224. }
  11225. else {
  11226. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  11227. }
  11228. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  11229. rightAxis.normalize();
  11230. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  11231. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  11232. }
  11233. spaceMat.invertToRef(spaceMatInv);
  11234. var xzlen = null;
  11235. if (checkPitch) {
  11236. var localTarget = BoneLookController._tmpVecs[3];
  11237. target.subtractToRef(bonePos, localTarget);
  11238. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11239. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11240. var pitch = Math.atan2(localTarget.y, xzlen);
  11241. var newPitch = pitch;
  11242. if (pitch > this._maxPitch) {
  11243. localTarget.y = this._maxPitchTan * xzlen;
  11244. newPitch = this._maxPitch;
  11245. }
  11246. else if (pitch < this._minPitch) {
  11247. localTarget.y = this._minPitchTan * xzlen;
  11248. newPitch = this._minPitch;
  11249. }
  11250. if (pitch != newPitch) {
  11251. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11252. localTarget.addInPlace(bonePos);
  11253. target = localTarget;
  11254. }
  11255. }
  11256. if (checkYaw) {
  11257. var localTarget = BoneLookController._tmpVecs[4];
  11258. target.subtractToRef(bonePos, localTarget);
  11259. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11260. var yaw = Math.atan2(localTarget.x, localTarget.z);
  11261. var newYaw = yaw;
  11262. if (yaw > this._maxYaw || yaw < this._minYaw) {
  11263. if (xzlen == null) {
  11264. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11265. }
  11266. if (this._yawRange > Math.PI) {
  11267. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  11268. localTarget.z = this._maxYawCos * xzlen;
  11269. localTarget.x = this._maxYawSin * xzlen;
  11270. newYaw = this._maxYaw;
  11271. }
  11272. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  11273. localTarget.z = this._minYawCos * xzlen;
  11274. localTarget.x = this._minYawSin * xzlen;
  11275. newYaw = this._minYaw;
  11276. }
  11277. }
  11278. else {
  11279. if (yaw > this._maxYaw) {
  11280. localTarget.z = this._maxYawCos * xzlen;
  11281. localTarget.x = this._maxYawSin * xzlen;
  11282. newYaw = this._maxYaw;
  11283. }
  11284. else if (yaw < this._minYaw) {
  11285. localTarget.z = this._minYawCos * xzlen;
  11286. localTarget.x = this._minYawSin * xzlen;
  11287. newYaw = this._minYaw;
  11288. }
  11289. }
  11290. }
  11291. if (this._slerping && this._yawRange > Math.PI) {
  11292. //are we going to be crossing into the min/max region?
  11293. var boneFwd = BoneLookController._tmpVecs[8];
  11294. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  11295. if (this._transformYawPitch) {
  11296. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  11297. }
  11298. var boneRotMat = BoneLookController._tmpMats[4];
  11299. this._boneQuat.toRotationMatrix(boneRotMat);
  11300. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  11301. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  11302. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  11303. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  11304. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  11305. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  11306. if (angBtwTar > angBtwMidYaw) {
  11307. if (xzlen == null) {
  11308. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11309. }
  11310. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  11311. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  11312. if (angBtwMin < angBtwMax) {
  11313. newYaw = boneYaw + Math.PI * .75;
  11314. localTarget.z = Math.cos(newYaw) * xzlen;
  11315. localTarget.x = Math.sin(newYaw) * xzlen;
  11316. }
  11317. else {
  11318. newYaw = boneYaw - Math.PI * .75;
  11319. localTarget.z = Math.cos(newYaw) * xzlen;
  11320. localTarget.x = Math.sin(newYaw) * xzlen;
  11321. }
  11322. }
  11323. }
  11324. if (yaw != newYaw) {
  11325. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11326. localTarget.addInPlace(bonePos);
  11327. target = localTarget;
  11328. }
  11329. }
  11330. }
  11331. var zaxis = BoneLookController._tmpVecs[5];
  11332. var xaxis = BoneLookController._tmpVecs[6];
  11333. var yaxis = BoneLookController._tmpVecs[7];
  11334. var _tmpQuat = BoneLookController._tmpQuat;
  11335. target.subtractToRef(bonePos, zaxis);
  11336. zaxis.normalize();
  11337. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  11338. xaxis.normalize();
  11339. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  11340. yaxis.normalize();
  11341. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  11342. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  11343. return;
  11344. }
  11345. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  11346. return;
  11347. }
  11348. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  11349. return;
  11350. }
  11351. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  11352. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11353. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11354. }
  11355. if (this.slerpAmount < 1) {
  11356. if (!this._slerping) {
  11357. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11358. }
  11359. if (this._transformYawPitch) {
  11360. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11361. }
  11362. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11363. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11364. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11365. this._slerping = true;
  11366. }
  11367. else {
  11368. if (this._transformYawPitch) {
  11369. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11370. }
  11371. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11372. this._slerping = false;
  11373. }
  11374. };
  11375. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11376. var angDiff = ang2 - ang1;
  11377. angDiff %= Math.PI * 2;
  11378. if (angDiff > Math.PI) {
  11379. angDiff -= Math.PI * 2;
  11380. }
  11381. else if (angDiff < -Math.PI) {
  11382. angDiff += Math.PI * 2;
  11383. }
  11384. return angDiff;
  11385. };
  11386. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11387. ang1 %= (2 * Math.PI);
  11388. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11389. ang2 %= (2 * Math.PI);
  11390. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11391. var ab = 0;
  11392. if (ang1 < ang2) {
  11393. ab = ang2 - ang1;
  11394. }
  11395. else {
  11396. ab = ang1 - ang2;
  11397. }
  11398. if (ab > Math.PI) {
  11399. ab = Math.PI * 2 - ab;
  11400. }
  11401. return ab;
  11402. };
  11403. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11404. ang %= (2 * Math.PI);
  11405. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11406. ang1 %= (2 * Math.PI);
  11407. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11408. ang2 %= (2 * Math.PI);
  11409. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11410. if (ang1 < ang2) {
  11411. if (ang > ang1 && ang < ang2) {
  11412. return true;
  11413. }
  11414. }
  11415. else {
  11416. if (ang > ang2 && ang < ang1) {
  11417. return true;
  11418. }
  11419. }
  11420. return false;
  11421. };
  11422. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11423. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11424. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11425. return BoneLookController;
  11426. }());
  11427. /***/ }),
  11428. /***/ "./Bones/index.ts":
  11429. /*!************************!*\
  11430. !*** ./Bones/index.ts ***!
  11431. \************************/
  11432. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11433. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11434. "use strict";
  11435. __webpack_require__.r(__webpack_exports__);
  11436. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11438. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11440. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11442. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11444. /***/ }),
  11445. /***/ "./Bones/skeleton.ts":
  11446. /*!***************************!*\
  11447. !*** ./Bones/skeleton.ts ***!
  11448. \***************************/
  11449. /*! exports provided: Skeleton */
  11450. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11451. "use strict";
  11452. __webpack_require__.r(__webpack_exports__);
  11453. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11454. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11455. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11456. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11457. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11458. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11459. /* harmony import */ var _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animationRange */ "./Animations/animationRange.ts");
  11460. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11461. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11462. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11463. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11464. /**
  11465. * Class used to handle skinning animations
  11466. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11467. */
  11468. var Skeleton = /** @class */ (function () {
  11469. /**
  11470. * Creates a new skeleton
  11471. * @param name defines the skeleton name
  11472. * @param id defines the skeleton Id
  11473. * @param scene defines the hosting scene
  11474. */
  11475. function Skeleton(
  11476. /** defines the skeleton name */
  11477. name,
  11478. /** defines the skeleton Id */
  11479. id, scene) {
  11480. this.name = name;
  11481. this.id = id;
  11482. /**
  11483. * Defines the list of child bones
  11484. */
  11485. this.bones = new Array();
  11486. /**
  11487. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11488. */
  11489. this.needInitialSkinMatrix = false;
  11490. /**
  11491. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11492. */
  11493. this.overrideMesh = null;
  11494. this._isDirty = true;
  11495. this._meshesWithPoseMatrix = new Array();
  11496. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11497. this._ranges = {};
  11498. this._lastAbsoluteTransformsUpdateId = -1;
  11499. this._canUseTextureForBones = false;
  11500. this._uniqueId = 0;
  11501. /** @hidden */
  11502. this._numBonesWithLinkedTransformNode = 0;
  11503. /**
  11504. * Specifies if the skeleton should be serialized
  11505. */
  11506. this.doNotSerialize = false;
  11507. this._useTextureToStoreBoneMatrices = true;
  11508. this._animationPropertiesOverride = null;
  11509. // Events
  11510. /**
  11511. * An observable triggered before computing the skeleton's matrices
  11512. */
  11513. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11514. this.bones = [];
  11515. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  11516. this._uniqueId = this._scene.getUniqueId();
  11517. this._scene.addSkeleton(this);
  11518. //make sure it will recalculate the matrix next time prepare is called.
  11519. this._isDirty = true;
  11520. var engineCaps = this._scene.getEngine().getCaps();
  11521. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11522. }
  11523. Object.defineProperty(Skeleton.prototype, "useTextureToStoreBoneMatrices", {
  11524. /**
  11525. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11526. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11527. */
  11528. get: function () {
  11529. return this._useTextureToStoreBoneMatrices;
  11530. },
  11531. set: function (value) {
  11532. this._useTextureToStoreBoneMatrices = value;
  11533. this._markAsDirty();
  11534. },
  11535. enumerable: true,
  11536. configurable: true
  11537. });
  11538. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11539. /**
  11540. * Gets or sets the animation properties override
  11541. */
  11542. get: function () {
  11543. if (!this._animationPropertiesOverride) {
  11544. return this._scene.animationPropertiesOverride;
  11545. }
  11546. return this._animationPropertiesOverride;
  11547. },
  11548. set: function (value) {
  11549. this._animationPropertiesOverride = value;
  11550. },
  11551. enumerable: true,
  11552. configurable: true
  11553. });
  11554. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11555. /**
  11556. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11557. */
  11558. get: function () {
  11559. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11560. },
  11561. enumerable: true,
  11562. configurable: true
  11563. });
  11564. Object.defineProperty(Skeleton.prototype, "uniqueId", {
  11565. /**
  11566. * Gets the unique ID of this skeleton
  11567. */
  11568. get: function () {
  11569. return this._uniqueId;
  11570. },
  11571. enumerable: true,
  11572. configurable: true
  11573. });
  11574. /**
  11575. * Gets the current object class name.
  11576. * @return the class name
  11577. */
  11578. Skeleton.prototype.getClassName = function () {
  11579. return "Skeleton";
  11580. };
  11581. /**
  11582. * Returns an array containing the root bones
  11583. * @returns an array containing the root bones
  11584. */
  11585. Skeleton.prototype.getChildren = function () {
  11586. return this.bones.filter(function (b) { return !b.getParent(); });
  11587. };
  11588. // Members
  11589. /**
  11590. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11591. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11592. * @returns a Float32Array containing matrices data
  11593. */
  11594. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11595. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11596. return mesh._bonesTransformMatrices;
  11597. }
  11598. if (!this._transformMatrices) {
  11599. this.prepare();
  11600. }
  11601. return this._transformMatrices;
  11602. };
  11603. /**
  11604. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11605. * @returns a raw texture containing the data
  11606. */
  11607. Skeleton.prototype.getTransformMatrixTexture = function () {
  11608. return this._transformMatrixTexture;
  11609. };
  11610. /**
  11611. * Gets the current hosting scene
  11612. * @returns a scene object
  11613. */
  11614. Skeleton.prototype.getScene = function () {
  11615. return this._scene;
  11616. };
  11617. // Methods
  11618. /**
  11619. * Gets a string representing the current skeleton data
  11620. * @param fullDetails defines a boolean indicating if we want a verbose version
  11621. * @returns a string representing the current skeleton data
  11622. */
  11623. Skeleton.prototype.toString = function (fullDetails) {
  11624. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11625. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11626. if (fullDetails) {
  11627. ret += ", Ranges: {";
  11628. var first = true;
  11629. for (var name_1 in this._ranges) {
  11630. if (first) {
  11631. ret += ", ";
  11632. first = false;
  11633. }
  11634. ret += name_1;
  11635. }
  11636. ret += "}";
  11637. }
  11638. return ret;
  11639. };
  11640. /**
  11641. * Get bone's index searching by name
  11642. * @param name defines bone's name to search for
  11643. * @return the indice of the bone. Returns -1 if not found
  11644. */
  11645. Skeleton.prototype.getBoneIndexByName = function (name) {
  11646. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11647. if (this.bones[boneIndex].name === name) {
  11648. return boneIndex;
  11649. }
  11650. }
  11651. return -1;
  11652. };
  11653. /**
  11654. * Creater a new animation range
  11655. * @param name defines the name of the range
  11656. * @param from defines the start key
  11657. * @param to defines the end key
  11658. */
  11659. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11660. // check name not already in use
  11661. if (!this._ranges[name]) {
  11662. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  11663. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11664. if (this.bones[i].animations[0]) {
  11665. this.bones[i].animations[0].createRange(name, from, to);
  11666. }
  11667. }
  11668. }
  11669. };
  11670. /**
  11671. * Delete a specific animation range
  11672. * @param name defines the name of the range
  11673. * @param deleteFrames defines if frames must be removed as well
  11674. */
  11675. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11676. if (deleteFrames === void 0) { deleteFrames = true; }
  11677. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11678. if (this.bones[i].animations[0]) {
  11679. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11680. }
  11681. }
  11682. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11683. };
  11684. /**
  11685. * Gets a specific animation range
  11686. * @param name defines the name of the range to look for
  11687. * @returns the requested animation range or null if not found
  11688. */
  11689. Skeleton.prototype.getAnimationRange = function (name) {
  11690. return this._ranges[name];
  11691. };
  11692. /**
  11693. * Gets the list of all animation ranges defined on this skeleton
  11694. * @returns an array
  11695. */
  11696. Skeleton.prototype.getAnimationRanges = function () {
  11697. var animationRanges = [];
  11698. var name;
  11699. for (name in this._ranges) {
  11700. animationRanges.push(this._ranges[name]);
  11701. }
  11702. return animationRanges;
  11703. };
  11704. /**
  11705. * Copy animation range from a source skeleton.
  11706. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11707. * @param source defines the source skeleton
  11708. * @param name defines the name of the range to copy
  11709. * @param rescaleAsRequired defines if rescaling must be applied if required
  11710. * @returns true if operation was successful
  11711. */
  11712. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11713. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11714. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11715. return false;
  11716. }
  11717. var ret = true;
  11718. var frameOffset = this._getHighestAnimationFrame() + 1;
  11719. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11720. var boneDict = {};
  11721. var sourceBones = source.bones;
  11722. var nBones;
  11723. var i;
  11724. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11725. boneDict[sourceBones[i].name] = sourceBones[i];
  11726. }
  11727. if (this.bones.length !== sourceBones.length) {
  11728. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11729. ret = false;
  11730. }
  11731. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11732. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11733. var boneName = this.bones[i].name;
  11734. var sourceBone = boneDict[boneName];
  11735. if (sourceBone) {
  11736. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11737. }
  11738. else {
  11739. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11740. ret = false;
  11741. }
  11742. }
  11743. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11744. var range = source.getAnimationRange(name);
  11745. if (range) {
  11746. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11747. }
  11748. return ret;
  11749. };
  11750. /**
  11751. * Forces the skeleton to go to rest pose
  11752. */
  11753. Skeleton.prototype.returnToRest = function () {
  11754. for (var index = 0; index < this.bones.length; index++) {
  11755. this.bones[index].returnToRest();
  11756. }
  11757. };
  11758. Skeleton.prototype._getHighestAnimationFrame = function () {
  11759. var ret = 0;
  11760. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11761. if (this.bones[i].animations[0]) {
  11762. var highest = this.bones[i].animations[0].getHighestFrame();
  11763. if (ret < highest) {
  11764. ret = highest;
  11765. }
  11766. }
  11767. }
  11768. return ret;
  11769. };
  11770. /**
  11771. * Begin a specific animation range
  11772. * @param name defines the name of the range to start
  11773. * @param loop defines if looping must be turned on (false by default)
  11774. * @param speedRatio defines the speed ratio to apply (1 by default)
  11775. * @param onAnimationEnd defines a callback which will be called when animation will end
  11776. * @returns a new animatable
  11777. */
  11778. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11779. var range = this.getAnimationRange(name);
  11780. if (!range) {
  11781. return null;
  11782. }
  11783. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11784. };
  11785. /** @hidden */
  11786. Skeleton.prototype._markAsDirty = function () {
  11787. this._isDirty = true;
  11788. };
  11789. /** @hidden */
  11790. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11791. this._meshesWithPoseMatrix.push(mesh);
  11792. };
  11793. /** @hidden */
  11794. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11795. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11796. if (index > -1) {
  11797. this._meshesWithPoseMatrix.splice(index, 1);
  11798. }
  11799. };
  11800. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11801. this.onBeforeComputeObservable.notifyObservers(this);
  11802. for (var index = 0; index < this.bones.length; index++) {
  11803. var bone = this.bones[index];
  11804. bone._childUpdateId++;
  11805. var parentBone = bone.getParent();
  11806. if (parentBone) {
  11807. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11808. }
  11809. else {
  11810. if (initialSkinMatrix) {
  11811. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11812. }
  11813. else {
  11814. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11815. }
  11816. }
  11817. if (bone._index !== -1) {
  11818. var mappedIndex = bone._index === null ? index : bone._index;
  11819. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11820. }
  11821. }
  11822. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11823. };
  11824. /**
  11825. * Build all resources required to render a skeleton
  11826. */
  11827. Skeleton.prototype.prepare = function () {
  11828. // Update the local matrix of bones with linked transform nodes.
  11829. if (this._numBonesWithLinkedTransformNode > 0) {
  11830. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11831. var bone_1 = _a[_i];
  11832. if (bone_1._linkedTransformNode) {
  11833. // Computing the world matrix also computes the local matrix.
  11834. bone_1._linkedTransformNode.computeWorldMatrix();
  11835. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11836. bone_1.markAsDirty();
  11837. }
  11838. }
  11839. }
  11840. if (!this._isDirty) {
  11841. return;
  11842. }
  11843. if (this.needInitialSkinMatrix) {
  11844. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11845. var mesh = this._meshesWithPoseMatrix[index];
  11846. var poseMatrix = mesh.getPoseMatrix();
  11847. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11848. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11849. }
  11850. if (this._synchronizedWithMesh !== mesh) {
  11851. this._synchronizedWithMesh = mesh;
  11852. // Prepare bones
  11853. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11854. var bone = this.bones[boneIndex];
  11855. if (!bone.getParent()) {
  11856. var matrix = bone.getBaseMatrix();
  11857. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11858. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11859. }
  11860. }
  11861. }
  11862. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11863. }
  11864. }
  11865. else {
  11866. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11867. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11868. if (this.isUsingTextureForMatrices) {
  11869. if (this._transformMatrixTexture) {
  11870. this._transformMatrixTexture.dispose();
  11871. }
  11872. this._transformMatrixTexture = _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__["RawTexture"].CreateRGBATexture(this._transformMatrices, (this.bones.length + 1) * 4, 1, this._scene, false, false, _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_FLOAT);
  11873. }
  11874. }
  11875. this._computeTransformMatrices(this._transformMatrices, null);
  11876. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11877. this._transformMatrixTexture.update(this._transformMatrices);
  11878. }
  11879. }
  11880. this._isDirty = false;
  11881. this._scene._activeBones.addCount(this.bones.length, false);
  11882. };
  11883. /**
  11884. * Gets the list of animatables currently running for this skeleton
  11885. * @returns an array of animatables
  11886. */
  11887. Skeleton.prototype.getAnimatables = function () {
  11888. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11889. this._animatables = [];
  11890. for (var index = 0; index < this.bones.length; index++) {
  11891. this._animatables.push(this.bones[index]);
  11892. }
  11893. }
  11894. return this._animatables;
  11895. };
  11896. /**
  11897. * Clone the current skeleton
  11898. * @param name defines the name of the new skeleton
  11899. * @param id defines the id of the enw skeleton
  11900. * @returns the new skeleton
  11901. */
  11902. Skeleton.prototype.clone = function (name, id) {
  11903. var result = new Skeleton(name, id || name, this._scene);
  11904. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11905. for (var index = 0; index < this.bones.length; index++) {
  11906. var source = this.bones[index];
  11907. var parentBone = null;
  11908. var parent_1 = source.getParent();
  11909. if (parent_1) {
  11910. var parentIndex = this.bones.indexOf(parent_1);
  11911. parentBone = result.bones[parentIndex];
  11912. }
  11913. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11914. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11915. }
  11916. if (this._ranges) {
  11917. result._ranges = {};
  11918. for (var rangeName in this._ranges) {
  11919. var range = this._ranges[rangeName];
  11920. if (range) {
  11921. result._ranges[rangeName] = range.clone();
  11922. }
  11923. }
  11924. }
  11925. this._isDirty = true;
  11926. return result;
  11927. };
  11928. /**
  11929. * Enable animation blending for this skeleton
  11930. * @param blendingSpeed defines the blending speed to apply
  11931. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11932. */
  11933. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11934. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11935. this.bones.forEach(function (bone) {
  11936. bone.animations.forEach(function (animation) {
  11937. animation.enableBlending = true;
  11938. animation.blendingSpeed = blendingSpeed;
  11939. });
  11940. });
  11941. };
  11942. /**
  11943. * Releases all resources associated with the current skeleton
  11944. */
  11945. Skeleton.prototype.dispose = function () {
  11946. this._meshesWithPoseMatrix = [];
  11947. // Animations
  11948. this.getScene().stopAnimation(this);
  11949. // Remove from scene
  11950. this.getScene().removeSkeleton(this);
  11951. if (this._transformMatrixTexture) {
  11952. this._transformMatrixTexture.dispose();
  11953. this._transformMatrixTexture = null;
  11954. }
  11955. };
  11956. /**
  11957. * Serialize the skeleton in a JSON object
  11958. * @returns a JSON object
  11959. */
  11960. Skeleton.prototype.serialize = function () {
  11961. var serializationObject = {};
  11962. serializationObject.name = this.name;
  11963. serializationObject.id = this.id;
  11964. if (this.dimensionsAtRest) {
  11965. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11966. }
  11967. serializationObject.bones = [];
  11968. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11969. for (var index = 0; index < this.bones.length; index++) {
  11970. var bone = this.bones[index];
  11971. var parent_2 = bone.getParent();
  11972. var serializedBone = {
  11973. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11974. name: bone.name,
  11975. matrix: bone.getBaseMatrix().toArray(),
  11976. rest: bone.getRestPose().toArray()
  11977. };
  11978. serializationObject.bones.push(serializedBone);
  11979. if (bone.length) {
  11980. serializedBone.length = bone.length;
  11981. }
  11982. if (bone.metadata) {
  11983. serializedBone.metadata = bone.metadata;
  11984. }
  11985. if (bone.animations && bone.animations.length > 0) {
  11986. serializedBone.animation = bone.animations[0].serialize();
  11987. }
  11988. serializationObject.ranges = [];
  11989. for (var name in this._ranges) {
  11990. var source = this._ranges[name];
  11991. if (!source) {
  11992. continue;
  11993. }
  11994. var range = {};
  11995. range.name = name;
  11996. range.from = source.from;
  11997. range.to = source.to;
  11998. serializationObject.ranges.push(range);
  11999. }
  12000. }
  12001. return serializationObject;
  12002. };
  12003. /**
  12004. * Creates a new skeleton from serialized data
  12005. * @param parsedSkeleton defines the serialized data
  12006. * @param scene defines the hosting scene
  12007. * @returns a new skeleton
  12008. */
  12009. Skeleton.Parse = function (parsedSkeleton, scene) {
  12010. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  12011. if (parsedSkeleton.dimensionsAtRest) {
  12012. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  12013. }
  12014. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  12015. var index;
  12016. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  12017. var parsedBone = parsedSkeleton.bones[index];
  12018. var parentBone = null;
  12019. if (parsedBone.parentBoneIndex > -1) {
  12020. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  12021. }
  12022. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  12023. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  12024. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  12025. bone.id = parsedBone.id;
  12026. }
  12027. if (parsedBone.length) {
  12028. bone.length = parsedBone.length;
  12029. }
  12030. if (parsedBone.metadata) {
  12031. bone.metadata = parsedBone.metadata;
  12032. }
  12033. if (parsedBone.animation) {
  12034. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  12035. }
  12036. }
  12037. // placed after bones, so createAnimationRange can cascade down
  12038. if (parsedSkeleton.ranges) {
  12039. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  12040. var data = parsedSkeleton.ranges[index];
  12041. skeleton.createAnimationRange(data.name, data.from, data.to);
  12042. }
  12043. }
  12044. return skeleton;
  12045. };
  12046. /**
  12047. * Compute all node absolute transforms
  12048. * @param forceUpdate defines if computation must be done even if cache is up to date
  12049. */
  12050. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  12051. if (forceUpdate === void 0) { forceUpdate = false; }
  12052. var renderId = this._scene.getRenderId();
  12053. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  12054. this.bones[0].computeAbsoluteTransforms();
  12055. this._lastAbsoluteTransformsUpdateId = renderId;
  12056. }
  12057. };
  12058. /**
  12059. * Gets the root pose matrix
  12060. * @returns a matrix
  12061. */
  12062. Skeleton.prototype.getPoseMatrix = function () {
  12063. var poseMatrix = null;
  12064. if (this._meshesWithPoseMatrix.length > 0) {
  12065. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  12066. }
  12067. return poseMatrix;
  12068. };
  12069. /**
  12070. * Sorts bones per internal index
  12071. */
  12072. Skeleton.prototype.sortBones = function () {
  12073. var bones = new Array();
  12074. var visited = new Array(this.bones.length);
  12075. for (var index = 0; index < this.bones.length; index++) {
  12076. this._sortBones(index, bones, visited);
  12077. }
  12078. this.bones = bones;
  12079. };
  12080. Skeleton.prototype._sortBones = function (index, bones, visited) {
  12081. if (visited[index]) {
  12082. return;
  12083. }
  12084. visited[index] = true;
  12085. var bone = this.bones[index];
  12086. if (bone._index === undefined) {
  12087. bone._index = index;
  12088. }
  12089. var parentBone = bone.getParent();
  12090. if (parentBone) {
  12091. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  12092. }
  12093. bones.push(bone);
  12094. };
  12095. return Skeleton;
  12096. }());
  12097. /***/ }),
  12098. /***/ "./Cameras/Inputs/BaseCameraPointersInput.ts":
  12099. /*!***************************************************!*\
  12100. !*** ./Cameras/Inputs/BaseCameraPointersInput.ts ***!
  12101. \***************************************************/
  12102. /*! exports provided: BaseCameraPointersInput */
  12103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12104. "use strict";
  12105. __webpack_require__.r(__webpack_exports__);
  12106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseCameraPointersInput", function() { return BaseCameraPointersInput; });
  12107. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12108. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12109. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12110. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12111. /**
  12112. * Base class for Camera Pointer Inputs.
  12113. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  12114. * for example usage.
  12115. */
  12116. var BaseCameraPointersInput = /** @class */ (function () {
  12117. function BaseCameraPointersInput() {
  12118. /**
  12119. * Defines the buttons associated with the input to handle camera move.
  12120. */
  12121. this.buttons = [0, 1, 2];
  12122. }
  12123. /**
  12124. * Attach the input controls to a specific dom element to get the input from.
  12125. * @param element Defines the element the controls should be listened from
  12126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12127. */
  12128. BaseCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12129. var _this = this;
  12130. var engine = this.camera.getEngine();
  12131. var previousPinchSquaredDistance = 0;
  12132. var previousMultiTouchPanPosition = null;
  12133. this.pointA = null;
  12134. this.pointB = null;
  12135. this._altKey = false;
  12136. this._ctrlKey = false;
  12137. this._metaKey = false;
  12138. this._shiftKey = false;
  12139. this._buttonsPressed = 0;
  12140. this._pointerInput = function (p, s) {
  12141. var evt = p.event;
  12142. var isTouch = evt.pointerType === "touch";
  12143. if (engine.isInVRExclusivePointerMode) {
  12144. return;
  12145. }
  12146. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE &&
  12147. _this.buttons.indexOf(evt.button) === -1) {
  12148. return;
  12149. }
  12150. var srcElement = (evt.srcElement || evt.target);
  12151. _this._altKey = evt.altKey;
  12152. _this._ctrlKey = evt.ctrlKey;
  12153. _this._metaKey = evt.metaKey;
  12154. _this._shiftKey = evt.shiftKey;
  12155. _this._buttonsPressed = evt.buttons;
  12156. if (engine.isPointerLock) {
  12157. var offsetX = evt.movementX ||
  12158. evt.mozMovementX ||
  12159. evt.webkitMovementX ||
  12160. evt.msMovementX ||
  12161. 0;
  12162. var offsetY = evt.movementY ||
  12163. evt.mozMovementY ||
  12164. evt.webkitMovementY ||
  12165. evt.msMovementY ||
  12166. 0;
  12167. _this.onTouch(null, offsetX, offsetY);
  12168. _this.pointA = null;
  12169. _this.pointB = null;
  12170. }
  12171. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12172. try {
  12173. srcElement.setPointerCapture(evt.pointerId);
  12174. }
  12175. catch (e) {
  12176. //Nothing to do with the error. Execution will continue.
  12177. }
  12178. if (_this.pointA === null) {
  12179. _this.pointA = { x: evt.clientX,
  12180. y: evt.clientY,
  12181. pointerId: evt.pointerId,
  12182. type: evt.pointerType };
  12183. }
  12184. else if (_this.pointB === null) {
  12185. _this.pointB = { x: evt.clientX,
  12186. y: evt.clientY,
  12187. pointerId: evt.pointerId,
  12188. type: evt.pointerType };
  12189. }
  12190. _this.onButtonDown(evt);
  12191. if (!noPreventDefault) {
  12192. evt.preventDefault();
  12193. element.focus();
  12194. }
  12195. }
  12196. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOUBLETAP) {
  12197. _this.onDoubleTap(evt.pointerType);
  12198. }
  12199. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  12200. try {
  12201. srcElement.releasePointerCapture(evt.pointerId);
  12202. }
  12203. catch (e) {
  12204. //Nothing to do with the error.
  12205. }
  12206. if (!isTouch) {
  12207. _this.pointB = null; // Mouse and pen are mono pointer
  12208. }
  12209. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12210. //but emptying completely pointers collection is required to fix a bug on iPhone :
  12211. //when changing orientation while pinching camera,
  12212. //one pointer stay pressed forever if we don't release all pointers
  12213. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12214. if (engine._badOS) {
  12215. _this.pointA = _this.pointB = null;
  12216. }
  12217. else {
  12218. //only remove the impacted pointer in case of multitouch allowing on most
  12219. //platforms switching from rotate to zoom and pan seamlessly.
  12220. if (_this.pointB && _this.pointA && _this.pointA.pointerId == evt.pointerId) {
  12221. _this.pointA = _this.pointB;
  12222. _this.pointB = null;
  12223. }
  12224. else if (_this.pointA && _this.pointB &&
  12225. _this.pointB.pointerId == evt.pointerId) {
  12226. _this.pointB = null;
  12227. }
  12228. else {
  12229. _this.pointA = _this.pointB = null;
  12230. }
  12231. }
  12232. if (previousPinchSquaredDistance !== 0 || previousMultiTouchPanPosition) {
  12233. // Previous pinch data is populated but a button has been lifted
  12234. // so pinch has ended.
  12235. _this.onMultiTouch(_this.pointA, _this.pointB, previousPinchSquaredDistance, 0, // pinchSquaredDistance
  12236. previousMultiTouchPanPosition, null // multiTouchPanPosition
  12237. );
  12238. previousPinchSquaredDistance = 0;
  12239. previousMultiTouchPanPosition = null;
  12240. }
  12241. _this.onButtonUp(evt);
  12242. if (!noPreventDefault) {
  12243. evt.preventDefault();
  12244. }
  12245. }
  12246. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  12247. if (!noPreventDefault) {
  12248. evt.preventDefault();
  12249. }
  12250. // One button down
  12251. if (_this.pointA && _this.pointB === null) {
  12252. var offsetX = evt.clientX - _this.pointA.x;
  12253. var offsetY = evt.clientY - _this.pointA.y;
  12254. _this.onTouch(_this.pointA, offsetX, offsetY);
  12255. _this.pointA.x = evt.clientX;
  12256. _this.pointA.y = evt.clientY;
  12257. }
  12258. // Two buttons down: pinch
  12259. else if (_this.pointA && _this.pointB) {
  12260. var ed = (_this.pointA.pointerId === evt.pointerId) ?
  12261. _this.pointA : _this.pointB;
  12262. ed.x = evt.clientX;
  12263. ed.y = evt.clientY;
  12264. var distX = _this.pointA.x - _this.pointB.x;
  12265. var distY = _this.pointA.y - _this.pointB.y;
  12266. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12267. var multiTouchPanPosition = { x: (_this.pointA.x + _this.pointB.x) / 2,
  12268. y: (_this.pointA.y + _this.pointB.y) / 2,
  12269. pointerId: evt.pointerId,
  12270. type: p.type };
  12271. _this.onMultiTouch(_this.pointA, _this.pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);
  12272. previousMultiTouchPanPosition = multiTouchPanPosition;
  12273. previousPinchSquaredDistance = pinchSquaredDistance;
  12274. }
  12275. }
  12276. };
  12277. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP |
  12278. _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  12279. this._onLostFocus = function () {
  12280. _this.pointA = _this.pointB = null;
  12281. previousPinchSquaredDistance = 0;
  12282. previousMultiTouchPanPosition = null;
  12283. _this.onLostFocus();
  12284. };
  12285. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  12286. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12287. { name: "blur", handler: this._onLostFocus }
  12288. ]);
  12289. };
  12290. /**
  12291. * Detach the current controls from the specified dom element.
  12292. * @param element Defines the element to stop listening the inputs from
  12293. */
  12294. BaseCameraPointersInput.prototype.detachControl = function (element) {
  12295. if (this._onLostFocus) {
  12296. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12297. { name: "blur", handler: this._onLostFocus }
  12298. ]);
  12299. }
  12300. if (element && this._observer) {
  12301. this.camera.getScene().onPointerObservable.remove(this._observer);
  12302. this._observer = null;
  12303. if (this.onContextMenu) {
  12304. element.removeEventListener("contextmenu", this.onContextMenu);
  12305. }
  12306. this._onLostFocus = null;
  12307. }
  12308. this._altKey = false;
  12309. this._ctrlKey = false;
  12310. this._metaKey = false;
  12311. this._shiftKey = false;
  12312. this._buttonsPressed = 0;
  12313. };
  12314. /**
  12315. * Gets the class name of the current input.
  12316. * @returns the class name
  12317. */
  12318. BaseCameraPointersInput.prototype.getClassName = function () {
  12319. return "BaseCameraPointersInput";
  12320. };
  12321. /**
  12322. * Get the friendly name associated with the input class.
  12323. * @returns the input friendly name
  12324. */
  12325. BaseCameraPointersInput.prototype.getSimpleName = function () {
  12326. return "pointers";
  12327. };
  12328. /**
  12329. * Called on pointer POINTERDOUBLETAP event.
  12330. * Override this method to provide functionality on POINTERDOUBLETAP event.
  12331. */
  12332. BaseCameraPointersInput.prototype.onDoubleTap = function (type) {
  12333. };
  12334. /**
  12335. * Called on pointer POINTERMOVE event if only a single touch is active.
  12336. * Override this method to provide functionality.
  12337. */
  12338. BaseCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12339. };
  12340. /**
  12341. * Called on pointer POINTERMOVE event if multiple touches are active.
  12342. * Override this method to provide functionality.
  12343. */
  12344. BaseCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12345. };
  12346. /**
  12347. * Called on JS contextmenu event.
  12348. * Override this method to provide functionality.
  12349. */
  12350. BaseCameraPointersInput.prototype.onContextMenu = function (evt) {
  12351. evt.preventDefault();
  12352. };
  12353. /**
  12354. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  12355. * press.
  12356. * Override this method to provide functionality.
  12357. */
  12358. BaseCameraPointersInput.prototype.onButtonDown = function (evt) {
  12359. };
  12360. /**
  12361. * Called each time a new POINTERUP event occurs. Ie, for each button
  12362. * release.
  12363. * Override this method to provide functionality.
  12364. */
  12365. BaseCameraPointersInput.prototype.onButtonUp = function (evt) {
  12366. };
  12367. /**
  12368. * Called when window becomes inactive.
  12369. * Override this method to provide functionality.
  12370. */
  12371. BaseCameraPointersInput.prototype.onLostFocus = function () {
  12372. };
  12373. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12374. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12375. ], BaseCameraPointersInput.prototype, "buttons", void 0);
  12376. return BaseCameraPointersInput;
  12377. }());
  12378. /***/ }),
  12379. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  12380. /*!*******************************************************!*\
  12381. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  12382. \*******************************************************/
  12383. /*! exports provided: ArcRotateCameraGamepadInput */
  12384. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12385. "use strict";
  12386. __webpack_require__.r(__webpack_exports__);
  12387. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  12388. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12389. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12390. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12391. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  12392. /**
  12393. * Manage the gamepad inputs to control an arc rotate camera.
  12394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12395. */
  12396. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  12397. function ArcRotateCameraGamepadInput() {
  12398. /**
  12399. * Defines the gamepad rotation sensiblity.
  12400. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  12401. */
  12402. this.gamepadRotationSensibility = 80;
  12403. /**
  12404. * Defines the gamepad move sensiblity.
  12405. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  12406. */
  12407. this.gamepadMoveSensibility = 40;
  12408. }
  12409. /**
  12410. * Attach the input controls to a specific dom element to get the input from.
  12411. * @param element Defines the element the controls should be listened from
  12412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12413. */
  12414. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  12415. var _this = this;
  12416. var manager = this.camera.getScene().gamepadManager;
  12417. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  12418. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  12419. // prioritize XBOX gamepads.
  12420. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  12421. _this.gamepad = gamepad;
  12422. }
  12423. }
  12424. });
  12425. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  12426. if (_this.gamepad === gamepad) {
  12427. _this.gamepad = null;
  12428. }
  12429. });
  12430. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  12431. };
  12432. /**
  12433. * Detach the current controls from the specified dom element.
  12434. * @param element Defines the element to stop listening the inputs from
  12435. */
  12436. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  12437. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  12438. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  12439. this.gamepad = null;
  12440. };
  12441. /**
  12442. * Update the current camera state depending on the inputs that have been used this frame.
  12443. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12444. */
  12445. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  12446. if (this.gamepad) {
  12447. var camera = this.camera;
  12448. var RSValues = this.gamepad.rightStick;
  12449. if (RSValues) {
  12450. if (RSValues.x != 0) {
  12451. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  12452. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  12453. camera.inertialAlphaOffset += normalizedRX;
  12454. }
  12455. }
  12456. if (RSValues.y != 0) {
  12457. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  12458. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  12459. camera.inertialBetaOffset += normalizedRY;
  12460. }
  12461. }
  12462. }
  12463. var LSValues = this.gamepad.leftStick;
  12464. if (LSValues && LSValues.y != 0) {
  12465. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  12466. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  12467. this.camera.inertialRadiusOffset -= normalizedLY;
  12468. }
  12469. }
  12470. }
  12471. };
  12472. /**
  12473. * Gets the class name of the current intput.
  12474. * @returns the class name
  12475. */
  12476. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  12477. return "ArcRotateCameraGamepadInput";
  12478. };
  12479. /**
  12480. * Get the friendly name associated with the input class.
  12481. * @returns the input friendly name
  12482. */
  12483. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  12484. return "gamepad";
  12485. };
  12486. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12487. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12488. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  12489. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12490. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12491. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  12492. return ArcRotateCameraGamepadInput;
  12493. }());
  12494. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  12495. /***/ }),
  12496. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  12497. /*!************************************************************!*\
  12498. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  12499. \************************************************************/
  12500. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  12501. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12502. "use strict";
  12503. __webpack_require__.r(__webpack_exports__);
  12504. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  12505. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12506. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12507. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12508. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12509. /**
  12510. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  12511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12512. */
  12513. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  12514. function ArcRotateCameraKeyboardMoveInput() {
  12515. /**
  12516. * Defines the list of key codes associated with the up action (increase alpha)
  12517. */
  12518. this.keysUp = [38];
  12519. /**
  12520. * Defines the list of key codes associated with the down action (decrease alpha)
  12521. */
  12522. this.keysDown = [40];
  12523. /**
  12524. * Defines the list of key codes associated with the left action (increase beta)
  12525. */
  12526. this.keysLeft = [37];
  12527. /**
  12528. * Defines the list of key codes associated with the right action (decrease beta)
  12529. */
  12530. this.keysRight = [39];
  12531. /**
  12532. * Defines the list of key codes associated with the reset action.
  12533. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  12534. */
  12535. this.keysReset = [220];
  12536. /**
  12537. * Defines the panning sensibility of the inputs.
  12538. * (How fast is the camera paning)
  12539. */
  12540. this.panningSensibility = 50.0;
  12541. /**
  12542. * Defines the zooming sensibility of the inputs.
  12543. * (How fast is the camera zooming)
  12544. */
  12545. this.zoomingSensibility = 25.0;
  12546. /**
  12547. * Defines wether maintaining the alt key down switch the movement mode from
  12548. * orientation to zoom.
  12549. */
  12550. this.useAltToZoom = true;
  12551. /**
  12552. * Rotation speed of the camera
  12553. */
  12554. this.angularSpeed = 0.01;
  12555. this._keys = new Array();
  12556. }
  12557. /**
  12558. * Attach the input controls to a specific dom element to get the input from.
  12559. * @param element Defines the element the controls should be listened from
  12560. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12561. */
  12562. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  12563. var _this = this;
  12564. if (this._onCanvasBlurObserver) {
  12565. return;
  12566. }
  12567. this._scene = this.camera.getScene();
  12568. this._engine = this._scene.getEngine();
  12569. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12570. _this._keys = [];
  12571. });
  12572. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12573. var evt = info.event;
  12574. if (!evt.metaKey) {
  12575. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12576. _this._ctrlPressed = evt.ctrlKey;
  12577. _this._altPressed = evt.altKey;
  12578. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12579. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12580. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12581. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12582. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12583. var index = _this._keys.indexOf(evt.keyCode);
  12584. if (index === -1) {
  12585. _this._keys.push(evt.keyCode);
  12586. }
  12587. if (evt.preventDefault) {
  12588. if (!noPreventDefault) {
  12589. evt.preventDefault();
  12590. }
  12591. }
  12592. }
  12593. }
  12594. else {
  12595. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12596. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12597. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12598. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12599. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12600. var index = _this._keys.indexOf(evt.keyCode);
  12601. if (index >= 0) {
  12602. _this._keys.splice(index, 1);
  12603. }
  12604. if (evt.preventDefault) {
  12605. if (!noPreventDefault) {
  12606. evt.preventDefault();
  12607. }
  12608. }
  12609. }
  12610. }
  12611. }
  12612. });
  12613. };
  12614. /**
  12615. * Detach the current controls from the specified dom element.
  12616. * @param element Defines the element to stop listening the inputs from
  12617. */
  12618. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  12619. if (this._scene) {
  12620. if (this._onKeyboardObserver) {
  12621. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12622. }
  12623. if (this._onCanvasBlurObserver) {
  12624. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12625. }
  12626. this._onKeyboardObserver = null;
  12627. this._onCanvasBlurObserver = null;
  12628. }
  12629. this._keys = [];
  12630. };
  12631. /**
  12632. * Update the current camera state depending on the inputs that have been used this frame.
  12633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12634. */
  12635. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  12636. if (this._onKeyboardObserver) {
  12637. var camera = this.camera;
  12638. for (var index = 0; index < this._keys.length; index++) {
  12639. var keyCode = this._keys[index];
  12640. if (this.keysLeft.indexOf(keyCode) !== -1) {
  12641. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12642. camera.inertialPanningX -= 1 / this.panningSensibility;
  12643. }
  12644. else {
  12645. camera.inertialAlphaOffset -= this.angularSpeed;
  12646. }
  12647. }
  12648. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12649. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12650. camera.inertialPanningY += 1 / this.panningSensibility;
  12651. }
  12652. else if (this._altPressed && this.useAltToZoom) {
  12653. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  12654. }
  12655. else {
  12656. camera.inertialBetaOffset -= this.angularSpeed;
  12657. }
  12658. }
  12659. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12660. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12661. camera.inertialPanningX += 1 / this.panningSensibility;
  12662. }
  12663. else {
  12664. camera.inertialAlphaOffset += this.angularSpeed;
  12665. }
  12666. }
  12667. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12668. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12669. camera.inertialPanningY -= 1 / this.panningSensibility;
  12670. }
  12671. else if (this._altPressed && this.useAltToZoom) {
  12672. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12673. }
  12674. else {
  12675. camera.inertialBetaOffset += this.angularSpeed;
  12676. }
  12677. }
  12678. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12679. if (camera.useInputToRestoreState) {
  12680. camera.restoreState();
  12681. }
  12682. }
  12683. }
  12684. }
  12685. };
  12686. /**
  12687. * Gets the class name of the current intput.
  12688. * @returns the class name
  12689. */
  12690. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12691. return "ArcRotateCameraKeyboardMoveInput";
  12692. };
  12693. /**
  12694. * Get the friendly name associated with the input class.
  12695. * @returns the input friendly name
  12696. */
  12697. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12698. return "keyboard";
  12699. };
  12700. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12701. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12702. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12703. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12704. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12705. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12706. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12707. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12708. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12709. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12710. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12711. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12712. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12713. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12714. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12715. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12716. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12717. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12718. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12719. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12720. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12721. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12722. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12723. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12724. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12725. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12726. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12727. return ArcRotateCameraKeyboardMoveInput;
  12728. }());
  12729. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12730. /***/ }),
  12731. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12732. /*!**********************************************************!*\
  12733. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12734. \**********************************************************/
  12735. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12736. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12737. "use strict";
  12738. __webpack_require__.r(__webpack_exports__);
  12739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12740. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12741. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12742. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12743. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12744. /**
  12745. * Manage the mouse wheel inputs to control an arc rotate camera.
  12746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12747. */
  12748. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12749. function ArcRotateCameraMouseWheelInput() {
  12750. /**
  12751. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12752. */
  12753. this.wheelPrecision = 3.0;
  12754. /**
  12755. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12756. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12757. */
  12758. this.wheelDeltaPercentage = 0;
  12759. }
  12760. /**
  12761. * Attach the input controls to a specific dom element to get the input from.
  12762. * @param element Defines the element the controls should be listened from
  12763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12764. */
  12765. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12766. var _this = this;
  12767. this._wheel = function (p, s) {
  12768. //sanity check - this should be a PointerWheel event.
  12769. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12770. return;
  12771. }
  12772. var event = p.event;
  12773. var delta = 0;
  12774. var mouseWheelLegacyEvent = event;
  12775. if (mouseWheelLegacyEvent.wheelDelta) {
  12776. if (_this.wheelDeltaPercentage) {
  12777. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12778. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12779. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12780. }
  12781. else {
  12782. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12783. }
  12784. }
  12785. else {
  12786. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12787. }
  12788. }
  12789. else {
  12790. var deltaValue = event.deltaY || event.detail;
  12791. delta = -deltaValue / _this.wheelPrecision;
  12792. }
  12793. if (delta) {
  12794. _this.camera.inertialRadiusOffset += delta;
  12795. }
  12796. if (event.preventDefault) {
  12797. if (!noPreventDefault) {
  12798. event.preventDefault();
  12799. }
  12800. }
  12801. };
  12802. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12803. };
  12804. /**
  12805. * Detach the current controls from the specified dom element.
  12806. * @param element Defines the element to stop listening the inputs from
  12807. */
  12808. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12809. if (this._observer && element) {
  12810. this.camera.getScene().onPointerObservable.remove(this._observer);
  12811. this._observer = null;
  12812. this._wheel = null;
  12813. }
  12814. };
  12815. /**
  12816. * Gets the class name of the current intput.
  12817. * @returns the class name
  12818. */
  12819. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12820. return "ArcRotateCameraMouseWheelInput";
  12821. };
  12822. /**
  12823. * Get the friendly name associated with the input class.
  12824. * @returns the input friendly name
  12825. */
  12826. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12827. return "mousewheel";
  12828. };
  12829. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12831. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12834. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12835. return ArcRotateCameraMouseWheelInput;
  12836. }());
  12837. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12838. /***/ }),
  12839. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12840. /*!********************************************************!*\
  12841. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12842. \********************************************************/
  12843. /*! exports provided: ArcRotateCameraPointersInput */
  12844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12845. "use strict";
  12846. __webpack_require__.r(__webpack_exports__);
  12847. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12848. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12849. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12850. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12851. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  12852. /**
  12853. * Manage the pointers inputs to control an arc rotate camera.
  12854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12855. */
  12856. var ArcRotateCameraPointersInput = /** @class */ (function (_super) {
  12857. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraPointersInput, _super);
  12858. function ArcRotateCameraPointersInput() {
  12859. var _this = _super !== null && _super.apply(this, arguments) || this;
  12860. /**
  12861. * Defines the buttons associated with the input to handle camera move.
  12862. */
  12863. _this.buttons = [0, 1, 2];
  12864. /**
  12865. * Defines the pointer angular sensibility along the X axis or how fast is
  12866. * the camera rotating.
  12867. */
  12868. _this.angularSensibilityX = 1000.0;
  12869. /**
  12870. * Defines the pointer angular sensibility along the Y axis or how fast is
  12871. * the camera rotating.
  12872. */
  12873. _this.angularSensibilityY = 1000.0;
  12874. /**
  12875. * Defines the pointer pinch precision or how fast is the camera zooming.
  12876. */
  12877. _this.pinchPrecision = 12.0;
  12878. /**
  12879. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  12880. * from 0.
  12881. * It defines the percentage of current camera.radius to use as delta when
  12882. * pinch zoom is used.
  12883. */
  12884. _this.pinchDeltaPercentage = 0;
  12885. /**
  12886. * Defines the pointer panning sensibility or how fast is the camera moving.
  12887. */
  12888. _this.panningSensibility = 1000.0;
  12889. /**
  12890. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12891. */
  12892. _this.multiTouchPanning = true;
  12893. /**
  12894. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  12895. * zoom (pinch) through multitouch.
  12896. */
  12897. _this.multiTouchPanAndZoom = true;
  12898. /**
  12899. * Revers pinch action direction.
  12900. */
  12901. _this.pinchInwards = true;
  12902. _this._isPanClick = false;
  12903. _this._twoFingerActivityCount = 0;
  12904. _this._isPinching = false;
  12905. return _this;
  12906. }
  12907. /**
  12908. * Gets the class name of the current input.
  12909. * @returns the class name
  12910. */
  12911. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12912. return "ArcRotateCameraPointersInput";
  12913. };
  12914. /**
  12915. * Called on pointer POINTERMOVE event if only a single touch is active.
  12916. */
  12917. ArcRotateCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12918. if (this.panningSensibility !== 0 &&
  12919. ((this._ctrlKey && this.camera._useCtrlForPanning) || this._isPanClick)) {
  12920. this.camera.inertialPanningX += -offsetX / this.panningSensibility;
  12921. this.camera.inertialPanningY += offsetY / this.panningSensibility;
  12922. }
  12923. else {
  12924. this.camera.inertialAlphaOffset -= offsetX / this.angularSensibilityX;
  12925. this.camera.inertialBetaOffset -= offsetY / this.angularSensibilityY;
  12926. }
  12927. };
  12928. /**
  12929. * Called on pointer POINTERDOUBLETAP event.
  12930. */
  12931. ArcRotateCameraPointersInput.prototype.onDoubleTap = function (type) {
  12932. if (this.camera.useInputToRestoreState) {
  12933. this.camera.restoreState();
  12934. }
  12935. };
  12936. /**
  12937. * Called on pointer POINTERMOVE event if multiple touches are active.
  12938. */
  12939. ArcRotateCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12940. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  12941. // First time this method is called for new pinch.
  12942. // Next time this is called there will be a
  12943. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  12944. return;
  12945. }
  12946. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  12947. // Last time this method is called at the end of a pinch.
  12948. return;
  12949. }
  12950. var direction = this.pinchInwards ? 1 : -1;
  12951. if (this.multiTouchPanAndZoom) {
  12952. if (this.pinchDeltaPercentage) {
  12953. this.camera.inertialRadiusOffset +=
  12954. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  12955. this.camera.radius * this.pinchDeltaPercentage;
  12956. }
  12957. else {
  12958. this.camera.inertialRadiusOffset +=
  12959. (pinchSquaredDistance - previousPinchSquaredDistance) /
  12960. (this.pinchPrecision * direction *
  12961. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  12962. }
  12963. if (this.panningSensibility !== 0 &&
  12964. previousMultiTouchPanPosition && multiTouchPanPosition) {
  12965. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  12966. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  12967. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  12968. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  12969. }
  12970. }
  12971. else {
  12972. this._twoFingerActivityCount++;
  12973. var previousPinchDistance = Math.sqrt(previousPinchSquaredDistance);
  12974. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12975. if (this._isPinching ||
  12976. (this._twoFingerActivityCount < 20 &&
  12977. Math.abs(pinchDistance - previousPinchDistance) >
  12978. this.camera.pinchToPanMaxDistance)) {
  12979. // Since pinch has not been active long, assume we intend to zoom.
  12980. if (this.pinchDeltaPercentage) {
  12981. this.camera.inertialRadiusOffset +=
  12982. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  12983. this.camera.radius * this.pinchDeltaPercentage;
  12984. }
  12985. else {
  12986. this.camera.inertialRadiusOffset +=
  12987. (pinchSquaredDistance - previousPinchSquaredDistance) /
  12988. (this.pinchPrecision * direction *
  12989. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  12990. }
  12991. // Since we are pinching, remain pinching on next iteration.
  12992. this._isPinching = true;
  12993. }
  12994. else {
  12995. // Pause between pinch starting and moving implies not a zoom event.
  12996. // Pan instead.
  12997. if (this.panningSensibility !== 0 && this.multiTouchPanning &&
  12998. multiTouchPanPosition && previousMultiTouchPanPosition) {
  12999. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  13000. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  13001. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  13002. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  13003. }
  13004. }
  13005. }
  13006. };
  13007. /**
  13008. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  13009. * press.
  13010. */
  13011. ArcRotateCameraPointersInput.prototype.onButtonDown = function (evt) {
  13012. this._isPanClick = evt.button === this.camera._panningMouseButton;
  13013. };
  13014. /**
  13015. * Called each time a new POINTERUP event occurs. Ie, for each button
  13016. * release.
  13017. */
  13018. ArcRotateCameraPointersInput.prototype.onButtonUp = function (evt) {
  13019. this._twoFingerActivityCount = 0;
  13020. this._isPinching = false;
  13021. };
  13022. /**
  13023. * Called when window becomes inactive.
  13024. */
  13025. ArcRotateCameraPointersInput.prototype.onLostFocus = function () {
  13026. this._isPanClick = false;
  13027. this._twoFingerActivityCount = 0;
  13028. this._isPinching = false;
  13029. };
  13030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13032. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  13033. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13035. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  13036. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13038. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  13039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13041. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  13042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13044. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  13045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13047. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  13048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13050. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  13051. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13053. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  13054. return ArcRotateCameraPointersInput;
  13055. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  13056. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraPointersInput"] =
  13057. ArcRotateCameraPointersInput;
  13058. /***/ }),
  13059. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  13060. /*!*******************************************************************!*\
  13061. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  13062. \*******************************************************************/
  13063. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  13064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13065. "use strict";
  13066. __webpack_require__.r(__webpack_exports__);
  13067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  13068. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13069. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  13070. /**
  13071. * Add orientation input support to the input manager.
  13072. * @returns the current input manager
  13073. */
  13074. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  13075. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  13076. return this;
  13077. };
  13078. /**
  13079. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  13080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13081. */
  13082. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  13083. /**
  13084. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  13085. */
  13086. function ArcRotateCameraVRDeviceOrientationInput() {
  13087. /**
  13088. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  13089. */
  13090. this.alphaCorrection = 1;
  13091. /**
  13092. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  13093. */
  13094. this.gammaCorrection = 1;
  13095. this._alpha = 0;
  13096. this._gamma = 0;
  13097. this._dirty = false;
  13098. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  13099. }
  13100. /**
  13101. * Attach the input controls to a specific dom element to get the input from.
  13102. * @param element Defines the element the controls should be listened from
  13103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13104. */
  13105. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13106. this.camera.attachControl(element, noPreventDefault);
  13107. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  13108. };
  13109. /** @hidden */
  13110. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  13111. if (evt.alpha !== null) {
  13112. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  13113. }
  13114. if (evt.gamma !== null) {
  13115. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  13116. }
  13117. this._dirty = true;
  13118. };
  13119. /**
  13120. * Update the current camera state depending on the inputs that have been used this frame.
  13121. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13122. */
  13123. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  13124. if (this._dirty) {
  13125. this._dirty = false;
  13126. if (this._gamma < 0) {
  13127. this._gamma = 180 + this._gamma;
  13128. }
  13129. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  13130. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  13131. }
  13132. };
  13133. /**
  13134. * Detach the current controls from the specified dom element.
  13135. * @param element Defines the element to stop listening the inputs from
  13136. */
  13137. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  13138. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  13139. };
  13140. /**
  13141. * Gets the class name of the current intput.
  13142. * @returns the class name
  13143. */
  13144. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  13145. return "ArcRotateCameraVRDeviceOrientationInput";
  13146. };
  13147. /**
  13148. * Get the friendly name associated with the input class.
  13149. * @returns the input friendly name
  13150. */
  13151. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  13152. return "VRDeviceOrientation";
  13153. };
  13154. return ArcRotateCameraVRDeviceOrientationInput;
  13155. }());
  13156. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  13157. /***/ }),
  13158. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  13159. /*!**************************************************!*\
  13160. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  13161. \**************************************************/
  13162. /*! exports provided: FlyCameraKeyboardInput */
  13163. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13164. "use strict";
  13165. __webpack_require__.r(__webpack_exports__);
  13166. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  13167. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13168. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13169. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13170. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13171. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13172. /**
  13173. * Listen to keyboard events to control the camera.
  13174. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13175. */
  13176. var FlyCameraKeyboardInput = /** @class */ (function () {
  13177. function FlyCameraKeyboardInput() {
  13178. /**
  13179. * The list of keyboard keys used to control the forward move of the camera.
  13180. */
  13181. this.keysForward = [87];
  13182. /**
  13183. * The list of keyboard keys used to control the backward move of the camera.
  13184. */
  13185. this.keysBackward = [83];
  13186. /**
  13187. * The list of keyboard keys used to control the forward move of the camera.
  13188. */
  13189. this.keysUp = [69];
  13190. /**
  13191. * The list of keyboard keys used to control the backward move of the camera.
  13192. */
  13193. this.keysDown = [81];
  13194. /**
  13195. * The list of keyboard keys used to control the right strafe move of the camera.
  13196. */
  13197. this.keysRight = [68];
  13198. /**
  13199. * The list of keyboard keys used to control the left strafe move of the camera.
  13200. */
  13201. this.keysLeft = [65];
  13202. this._keys = new Array();
  13203. }
  13204. /**
  13205. * Attach the input controls to a specific dom element to get the input from.
  13206. * @param element Defines the element the controls should be listened from
  13207. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13208. */
  13209. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  13210. var _this = this;
  13211. if (this._onCanvasBlurObserver) {
  13212. return;
  13213. }
  13214. this._scene = this.camera.getScene();
  13215. this._engine = this._scene.getEngine();
  13216. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13217. _this._keys = [];
  13218. });
  13219. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13220. var evt = info.event;
  13221. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13222. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13223. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13224. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13225. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13226. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13227. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13228. var index = _this._keys.indexOf(evt.keyCode);
  13229. if (index === -1) {
  13230. _this._keys.push(evt.keyCode);
  13231. }
  13232. if (!noPreventDefault) {
  13233. evt.preventDefault();
  13234. }
  13235. }
  13236. }
  13237. else {
  13238. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13239. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13240. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13241. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13242. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13243. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13244. var index = _this._keys.indexOf(evt.keyCode);
  13245. if (index >= 0) {
  13246. _this._keys.splice(index, 1);
  13247. }
  13248. if (!noPreventDefault) {
  13249. evt.preventDefault();
  13250. }
  13251. }
  13252. }
  13253. });
  13254. };
  13255. /**
  13256. * Detach the current controls from the specified dom element.
  13257. * @param element Defines the element to stop listening the inputs from
  13258. */
  13259. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  13260. if (this._scene) {
  13261. if (this._onKeyboardObserver) {
  13262. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13263. }
  13264. if (this._onCanvasBlurObserver) {
  13265. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13266. }
  13267. this._onKeyboardObserver = null;
  13268. this._onCanvasBlurObserver = null;
  13269. }
  13270. this._keys = [];
  13271. };
  13272. /**
  13273. * Gets the class name of the current intput.
  13274. * @returns the class name
  13275. */
  13276. FlyCameraKeyboardInput.prototype.getClassName = function () {
  13277. return "FlyCameraKeyboardInput";
  13278. };
  13279. /** @hidden */
  13280. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  13281. this._keys = [];
  13282. };
  13283. /**
  13284. * Get the friendly name associated with the input class.
  13285. * @returns the input friendly name
  13286. */
  13287. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  13288. return "keyboard";
  13289. };
  13290. /**
  13291. * Update the current camera state depending on the inputs that have been used this frame.
  13292. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13293. */
  13294. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  13295. if (this._onKeyboardObserver) {
  13296. var camera = this.camera;
  13297. // Keyboard
  13298. for (var index = 0; index < this._keys.length; index++) {
  13299. var keyCode = this._keys[index];
  13300. var speed = camera._computeLocalCameraSpeed();
  13301. if (this.keysForward.indexOf(keyCode) !== -1) {
  13302. camera._localDirection.copyFromFloats(0, 0, speed);
  13303. }
  13304. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  13305. camera._localDirection.copyFromFloats(0, 0, -speed);
  13306. }
  13307. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13308. camera._localDirection.copyFromFloats(0, speed, 0);
  13309. }
  13310. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13311. camera._localDirection.copyFromFloats(0, -speed, 0);
  13312. }
  13313. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13314. camera._localDirection.copyFromFloats(speed, 0, 0);
  13315. }
  13316. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  13317. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13318. }
  13319. if (camera.getScene().useRightHandedSystem) {
  13320. camera._localDirection.z *= -1;
  13321. }
  13322. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13323. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13324. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13325. }
  13326. }
  13327. };
  13328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13330. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  13331. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13332. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13333. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  13334. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13335. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13336. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  13337. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13338. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13339. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  13340. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13341. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13342. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  13343. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13344. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13345. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  13346. return FlyCameraKeyboardInput;
  13347. }());
  13348. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  13349. /***/ }),
  13350. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  13351. /*!***********************************************!*\
  13352. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  13353. \***********************************************/
  13354. /*! exports provided: FlyCameraMouseInput */
  13355. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13356. "use strict";
  13357. __webpack_require__.r(__webpack_exports__);
  13358. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  13359. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13360. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13361. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13362. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13363. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13364. /**
  13365. * Listen to mouse events to control the camera.
  13366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13367. */
  13368. var FlyCameraMouseInput = /** @class */ (function () {
  13369. /**
  13370. * Listen to mouse events to control the camera.
  13371. * @param touchEnabled Define if touch is enabled. (Default is true.)
  13372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13373. */
  13374. function FlyCameraMouseInput(touchEnabled) {
  13375. if (touchEnabled === void 0) { touchEnabled = true; }
  13376. /**
  13377. * Defines the buttons associated with the input to handle camera rotation.
  13378. */
  13379. this.buttons = [0, 1, 2];
  13380. /**
  13381. * Assign buttons for Yaw control.
  13382. */
  13383. this.buttonsYaw = [-1, 0, 1];
  13384. /**
  13385. * Assign buttons for Pitch control.
  13386. */
  13387. this.buttonsPitch = [-1, 0, 1];
  13388. /**
  13389. * Assign buttons for Roll control.
  13390. */
  13391. this.buttonsRoll = [2];
  13392. /**
  13393. * Detect if any button is being pressed while mouse is moved.
  13394. * -1 = Mouse locked.
  13395. * 0 = Left button.
  13396. * 1 = Middle Button.
  13397. * 2 = Right Button.
  13398. */
  13399. this.activeButton = -1;
  13400. /**
  13401. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  13402. * Higher values reduce its sensitivity.
  13403. */
  13404. this.angularSensibility = 1000.0;
  13405. this.previousPosition = null;
  13406. }
  13407. /**
  13408. * Attach the mouse control to the HTML DOM element.
  13409. * @param element Defines the element that listens to the input events.
  13410. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  13411. */
  13412. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13413. var _this = this;
  13414. this.element = element;
  13415. this.noPreventDefault = noPreventDefault;
  13416. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  13417. _this._pointerInput(p, s);
  13418. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  13419. // Correct Roll by rate, if enabled.
  13420. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  13421. if (_this.camera.rollCorrect) {
  13422. _this.camera.restoreRoll(_this.camera.rollCorrect);
  13423. }
  13424. });
  13425. // Helper function to keep 'this'.
  13426. this._mousemoveCallback = function (e) {
  13427. _this._onMouseMove(e);
  13428. };
  13429. element.addEventListener("mousemove", this._mousemoveCallback, false);
  13430. };
  13431. /**
  13432. * Detach the current controls from the specified dom element.
  13433. * @param element Defines the element to stop listening the inputs from
  13434. */
  13435. FlyCameraMouseInput.prototype.detachControl = function (element) {
  13436. if (this._observer && element) {
  13437. this.camera.getScene().onPointerObservable.remove(this._observer);
  13438. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  13439. if (this._mousemoveCallback) {
  13440. element.removeEventListener("mousemove", this._mousemoveCallback);
  13441. }
  13442. this._observer = null;
  13443. this._rollObserver = null;
  13444. this.previousPosition = null;
  13445. this.noPreventDefault = undefined;
  13446. }
  13447. };
  13448. /**
  13449. * Gets the class name of the current input.
  13450. * @returns the class name.
  13451. */
  13452. FlyCameraMouseInput.prototype.getClassName = function () {
  13453. return "FlyCameraMouseInput";
  13454. };
  13455. /**
  13456. * Get the friendly name associated with the input class.
  13457. * @returns the input's friendly name.
  13458. */
  13459. FlyCameraMouseInput.prototype.getSimpleName = function () {
  13460. return "mouse";
  13461. };
  13462. // Track mouse movement, when the pointer is not locked.
  13463. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  13464. var e = p.event;
  13465. var camera = this.camera;
  13466. var engine = camera.getEngine();
  13467. if (engine.isInVRExclusivePointerMode) {
  13468. return;
  13469. }
  13470. if (!this.touchEnabled && e.pointerType === "touch") {
  13471. return;
  13472. }
  13473. // Mouse is moved but an unknown mouse button is pressed.
  13474. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  13475. return;
  13476. }
  13477. var srcElement = (e.srcElement || e.target);
  13478. // Mouse down.
  13479. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13480. try {
  13481. srcElement.setPointerCapture(e.pointerId);
  13482. }
  13483. catch (e) {
  13484. // Nothing to do with the error. Execution continues.
  13485. }
  13486. this.previousPosition = {
  13487. x: e.clientX,
  13488. y: e.clientY
  13489. };
  13490. this.activeButton = e.button;
  13491. if (!this.noPreventDefault) {
  13492. e.preventDefault();
  13493. this.element.focus();
  13494. }
  13495. }
  13496. else
  13497. // Mouse up.
  13498. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13499. try {
  13500. srcElement.releasePointerCapture(e.pointerId);
  13501. }
  13502. catch (e) {
  13503. // Nothing to do with the error. Execution continues.
  13504. }
  13505. this.activeButton = -1;
  13506. this.previousPosition = null;
  13507. if (!this.noPreventDefault) {
  13508. e.preventDefault();
  13509. }
  13510. }
  13511. else
  13512. // Mouse move.
  13513. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13514. if (!this.previousPosition || engine.isPointerLock) {
  13515. return;
  13516. }
  13517. var offsetX = e.clientX - this.previousPosition.x;
  13518. var offsetY = e.clientY - this.previousPosition.y;
  13519. this.rotateCamera(offsetX, offsetY);
  13520. this.previousPosition = {
  13521. x: e.clientX,
  13522. y: e.clientY
  13523. };
  13524. if (!this.noPreventDefault) {
  13525. e.preventDefault();
  13526. }
  13527. }
  13528. };
  13529. // Track mouse movement, when pointer is locked.
  13530. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13531. var camera = this.camera;
  13532. var engine = camera.getEngine();
  13533. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13534. return;
  13535. }
  13536. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13537. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13538. this.rotateCamera(offsetX, offsetY);
  13539. this.previousPosition = null;
  13540. if (!this.noPreventDefault) {
  13541. e.preventDefault();
  13542. }
  13543. };
  13544. /**
  13545. * Rotate camera by mouse offset.
  13546. */
  13547. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13548. var _this = this;
  13549. var camera = this.camera;
  13550. var scene = this.camera.getScene();
  13551. if (scene.useRightHandedSystem) {
  13552. offsetX *= -1;
  13553. }
  13554. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13555. offsetX *= -1;
  13556. }
  13557. var x = offsetX / this.angularSensibility;
  13558. var y = offsetY / this.angularSensibility;
  13559. // Initialize to current rotation.
  13560. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13561. var rotationChange;
  13562. // Pitch.
  13563. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13564. // Apply change in Radians to vector Angle.
  13565. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13566. // Apply Pitch to quaternion.
  13567. currentRotation.multiplyInPlace(rotationChange);
  13568. }
  13569. // Yaw.
  13570. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13571. // Apply change in Radians to vector Angle.
  13572. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13573. // Apply Yaw to quaternion.
  13574. currentRotation.multiplyInPlace(rotationChange);
  13575. // Add Roll, if banked turning is enabled, within Roll limit.
  13576. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13577. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13578. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13579. // Apply change in Radians to vector Angle.
  13580. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13581. // Apply Yaw to quaternion.
  13582. currentRotation.multiplyInPlace(rotationChange);
  13583. }
  13584. }
  13585. // Roll.
  13586. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13587. // Apply change in Radians to vector Angle.
  13588. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13589. // Track Rolling.
  13590. camera._trackRoll -= x;
  13591. // Apply Pitch to quaternion.
  13592. currentRotation.multiplyInPlace(rotationChange);
  13593. }
  13594. // Apply rotationQuaternion to Euler camera.rotation.
  13595. currentRotation.toEulerAnglesToRef(camera.rotation);
  13596. };
  13597. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13598. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13599. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13600. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13601. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13602. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13603. return FlyCameraMouseInput;
  13604. }());
  13605. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13606. /***/ }),
  13607. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13608. /*!*********************************************************!*\
  13609. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13610. \*********************************************************/
  13611. /*! exports provided: FollowCameraKeyboardMoveInput */
  13612. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13613. "use strict";
  13614. __webpack_require__.r(__webpack_exports__);
  13615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13616. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13617. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13618. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13619. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13620. /**
  13621. * Manage the keyboard inputs to control the movement of a follow camera.
  13622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13623. */
  13624. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13625. function FollowCameraKeyboardMoveInput() {
  13626. /**
  13627. * Defines the list of key codes associated with the up action (increase heightOffset)
  13628. */
  13629. this.keysHeightOffsetIncr = [38];
  13630. /**
  13631. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13632. */
  13633. this.keysHeightOffsetDecr = [40];
  13634. /**
  13635. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  13636. */
  13637. this.keysHeightOffsetModifierAlt = false;
  13638. /**
  13639. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  13640. */
  13641. this.keysHeightOffsetModifierCtrl = false;
  13642. /**
  13643. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  13644. */
  13645. this.keysHeightOffsetModifierShift = false;
  13646. /**
  13647. * Defines the list of key codes associated with the left action (increase rotationOffset)
  13648. */
  13649. this.keysRotationOffsetIncr = [37];
  13650. /**
  13651. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  13652. */
  13653. this.keysRotationOffsetDecr = [39];
  13654. /**
  13655. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  13656. */
  13657. this.keysRotationOffsetModifierAlt = false;
  13658. /**
  13659. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  13660. */
  13661. this.keysRotationOffsetModifierCtrl = false;
  13662. /**
  13663. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  13664. */
  13665. this.keysRotationOffsetModifierShift = false;
  13666. /**
  13667. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  13668. */
  13669. this.keysRadiusIncr = [40];
  13670. /**
  13671. * Defines the list of key codes associated with the zoom-out action (increase radius)
  13672. */
  13673. this.keysRadiusDecr = [38];
  13674. /**
  13675. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  13676. */
  13677. this.keysRadiusModifierAlt = true;
  13678. /**
  13679. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  13680. */
  13681. this.keysRadiusModifierCtrl = false;
  13682. /**
  13683. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  13684. */
  13685. this.keysRadiusModifierShift = false;
  13686. /**
  13687. * Defines the rate of change of heightOffset.
  13688. */
  13689. this.heightSensibility = 1;
  13690. /**
  13691. * Defines the rate of change of rotationOffset.
  13692. */
  13693. this.rotationSensibility = 1;
  13694. /**
  13695. * Defines the rate of change of radius.
  13696. */
  13697. this.radiusSensibility = 1;
  13698. this._keys = new Array();
  13699. }
  13700. /**
  13701. * Attach the input controls to a specific dom element to get the input from.
  13702. * @param element Defines the element the controls should be listened from
  13703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13704. */
  13705. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13706. var _this = this;
  13707. if (this._onCanvasBlurObserver) {
  13708. return;
  13709. }
  13710. this._scene = this.camera.getScene();
  13711. this._engine = this._scene.getEngine();
  13712. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13713. _this._keys = [];
  13714. });
  13715. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13716. var evt = info.event;
  13717. if (!evt.metaKey) {
  13718. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13719. _this._ctrlPressed = evt.ctrlKey;
  13720. _this._altPressed = evt.altKey;
  13721. _this._shiftPressed = evt.shiftKey;
  13722. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13723. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13724. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13725. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13726. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13727. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13728. var index = _this._keys.indexOf(evt.keyCode);
  13729. if (index === -1) {
  13730. _this._keys.push(evt.keyCode);
  13731. }
  13732. if (evt.preventDefault) {
  13733. if (!noPreventDefault) {
  13734. evt.preventDefault();
  13735. }
  13736. }
  13737. }
  13738. }
  13739. else {
  13740. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13741. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13742. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13743. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13744. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13745. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13746. var index = _this._keys.indexOf(evt.keyCode);
  13747. if (index >= 0) {
  13748. _this._keys.splice(index, 1);
  13749. }
  13750. if (evt.preventDefault) {
  13751. if (!noPreventDefault) {
  13752. evt.preventDefault();
  13753. }
  13754. }
  13755. }
  13756. }
  13757. }
  13758. });
  13759. };
  13760. /**
  13761. * Detach the current controls from the specified dom element.
  13762. * @param element Defines the element to stop listening the inputs from
  13763. */
  13764. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13765. if (this._scene) {
  13766. if (this._onKeyboardObserver) {
  13767. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13768. }
  13769. if (this._onCanvasBlurObserver) {
  13770. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13771. }
  13772. this._onKeyboardObserver = null;
  13773. this._onCanvasBlurObserver = null;
  13774. }
  13775. this._keys = [];
  13776. };
  13777. /**
  13778. * Update the current camera state depending on the inputs that have been used this frame.
  13779. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13780. */
  13781. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13782. var _this = this;
  13783. if (this._onKeyboardObserver) {
  13784. this._keys.forEach(function (keyCode) {
  13785. if (_this.keysHeightOffsetIncr.indexOf(keyCode) !== -1 &&
  13786. _this._modifierHeightOffset()) {
  13787. _this.camera.heightOffset += _this.heightSensibility;
  13788. }
  13789. else if (_this.keysHeightOffsetDecr.indexOf(keyCode) !== -1 &&
  13790. _this._modifierHeightOffset()) {
  13791. _this.camera.heightOffset -= _this.heightSensibility;
  13792. }
  13793. else if (_this.keysRotationOffsetIncr.indexOf(keyCode) !== -1 &&
  13794. _this._modifierRotationOffset()) {
  13795. _this.camera.rotationOffset += _this.rotationSensibility;
  13796. _this.camera.rotationOffset %= 360;
  13797. }
  13798. else if (_this.keysRotationOffsetDecr.indexOf(keyCode) !== -1 &&
  13799. _this._modifierRotationOffset()) {
  13800. _this.camera.rotationOffset -= _this.rotationSensibility;
  13801. _this.camera.rotationOffset %= 360;
  13802. }
  13803. else if (_this.keysRadiusIncr.indexOf(keyCode) !== -1 &&
  13804. _this._modifierRadius()) {
  13805. _this.camera.radius += _this.radiusSensibility;
  13806. }
  13807. else if (_this.keysRadiusDecr.indexOf(keyCode) !== -1 &&
  13808. _this._modifierRadius()) {
  13809. _this.camera.radius -= _this.radiusSensibility;
  13810. }
  13811. });
  13812. }
  13813. };
  13814. /**
  13815. * Gets the class name of the current input.
  13816. * @returns the class name
  13817. */
  13818. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13819. return "FollowCameraKeyboardMoveInput";
  13820. };
  13821. /**
  13822. * Get the friendly name associated with the input class.
  13823. * @returns the input friendly name
  13824. */
  13825. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13826. return "keyboard";
  13827. };
  13828. /**
  13829. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13830. * allow modification of the heightOffset value.
  13831. */
  13832. FollowCameraKeyboardMoveInput.prototype._modifierHeightOffset = function () {
  13833. return (this.keysHeightOffsetModifierAlt === this._altPressed &&
  13834. this.keysHeightOffsetModifierCtrl === this._ctrlPressed &&
  13835. this.keysHeightOffsetModifierShift === this._shiftPressed);
  13836. };
  13837. /**
  13838. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13839. * allow modification of the rotationOffset value.
  13840. */
  13841. FollowCameraKeyboardMoveInput.prototype._modifierRotationOffset = function () {
  13842. return (this.keysRotationOffsetModifierAlt === this._altPressed &&
  13843. this.keysRotationOffsetModifierCtrl === this._ctrlPressed &&
  13844. this.keysRotationOffsetModifierShift === this._shiftPressed);
  13845. };
  13846. /**
  13847. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13848. * allow modification of the radius value.
  13849. */
  13850. FollowCameraKeyboardMoveInput.prototype._modifierRadius = function () {
  13851. return (this.keysRadiusModifierAlt === this._altPressed &&
  13852. this.keysRadiusModifierCtrl === this._ctrlPressed &&
  13853. this.keysRadiusModifierShift === this._shiftPressed);
  13854. };
  13855. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13856. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13857. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetIncr", void 0);
  13858. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13859. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13860. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetDecr", void 0);
  13861. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13862. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13863. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierAlt", void 0);
  13864. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13865. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13866. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierCtrl", void 0);
  13867. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13868. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13869. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierShift", void 0);
  13870. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13871. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13872. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetIncr", void 0);
  13873. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13874. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13875. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetDecr", void 0);
  13876. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13877. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13878. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierAlt", void 0);
  13879. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13880. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13881. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierCtrl", void 0);
  13882. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13883. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13884. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierShift", void 0);
  13885. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13886. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13887. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusIncr", void 0);
  13888. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13889. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13890. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusDecr", void 0);
  13891. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13892. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13893. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierAlt", void 0);
  13894. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13895. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13896. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierCtrl", void 0);
  13897. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13898. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13899. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierShift", void 0);
  13900. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13902. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13903. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13904. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13905. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13906. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13907. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13908. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13909. return FollowCameraKeyboardMoveInput;
  13910. }());
  13911. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13912. /***/ }),
  13913. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  13914. /*!*******************************************************!*\
  13915. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  13916. \*******************************************************/
  13917. /*! exports provided: FollowCameraMouseWheelInput */
  13918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13919. "use strict";
  13920. __webpack_require__.r(__webpack_exports__);
  13921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  13922. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13923. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13924. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13925. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13926. /**
  13927. * Manage the mouse wheel inputs to control a follow camera.
  13928. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13929. */
  13930. var FollowCameraMouseWheelInput = /** @class */ (function () {
  13931. function FollowCameraMouseWheelInput() {
  13932. /**
  13933. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  13934. */
  13935. this.axisControlRadius = true;
  13936. /**
  13937. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  13938. */
  13939. this.axisControlHeight = false;
  13940. /**
  13941. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  13942. */
  13943. this.axisControlRotation = false;
  13944. /**
  13945. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  13946. * relation to mouseWheel events.
  13947. */
  13948. this.wheelPrecision = 3.0;
  13949. /**
  13950. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  13951. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  13952. */
  13953. this.wheelDeltaPercentage = 0;
  13954. }
  13955. /**
  13956. * Attach the input controls to a specific dom element to get the input from.
  13957. * @param element Defines the element the controls should be listened from
  13958. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13959. */
  13960. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  13961. var _this = this;
  13962. this._wheel = function (p, s) {
  13963. // sanity check - this should be a PointerWheel event.
  13964. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  13965. return;
  13966. }
  13967. var event = p.event;
  13968. var delta = 0;
  13969. // Chrome, Safari: event.deltaY
  13970. // IE: event.wheelDelta
  13971. // Firefox: event.detail (inverted)
  13972. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  13973. if (_this.wheelDeltaPercentage) {
  13974. console.assert((_this.axisControlRadius +
  13975. _this.axisControlHeight +
  13976. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  13977. "controlls ONE axis. " +
  13978. "Currently enabled: " +
  13979. "axisControlRadius: " + _this.axisControlRadius +
  13980. ", axisControlHeightOffset: " + _this.axisControlHeight +
  13981. ", axisControlRotationOffset: " + _this.axisControlRotation);
  13982. if (_this.axisControlRadius) {
  13983. delta =
  13984. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13985. _this.camera.radius;
  13986. }
  13987. else if (_this.axisControlHeight) {
  13988. delta =
  13989. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13990. _this.camera.heightOffset;
  13991. }
  13992. else if (_this.axisControlRotation) {
  13993. delta =
  13994. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13995. _this.camera.rotationOffset;
  13996. }
  13997. }
  13998. else {
  13999. delta = wheelDelta * _this.wheelPrecision;
  14000. }
  14001. if (delta) {
  14002. if (_this.axisControlRadius) {
  14003. _this.camera.radius += delta;
  14004. }
  14005. else if (_this.axisControlHeight) {
  14006. _this.camera.heightOffset -= delta;
  14007. }
  14008. else if (_this.axisControlRotation) {
  14009. _this.camera.rotationOffset -= delta;
  14010. }
  14011. }
  14012. if (event.preventDefault) {
  14013. if (!noPreventDefault) {
  14014. event.preventDefault();
  14015. }
  14016. }
  14017. };
  14018. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  14019. };
  14020. /**
  14021. * Detach the current controls from the specified dom element.
  14022. * @param element Defines the element to stop listening the inputs from
  14023. */
  14024. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  14025. if (this._observer && element) {
  14026. this.camera.getScene().onPointerObservable.remove(this._observer);
  14027. this._observer = null;
  14028. this._wheel = null;
  14029. }
  14030. };
  14031. /**
  14032. * Gets the class name of the current intput.
  14033. * @returns the class name
  14034. */
  14035. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  14036. return "ArcRotateCameraMouseWheelInput";
  14037. };
  14038. /**
  14039. * Get the friendly name associated with the input class.
  14040. * @returns the input friendly name
  14041. */
  14042. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  14043. return "mousewheel";
  14044. };
  14045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14047. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  14048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14050. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  14051. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14053. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  14054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14056. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  14057. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14058. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14059. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  14060. return FollowCameraMouseWheelInput;
  14061. }());
  14062. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  14063. /***/ }),
  14064. /***/ "./Cameras/Inputs/followCameraPointersInput.ts":
  14065. /*!*****************************************************!*\
  14066. !*** ./Cameras/Inputs/followCameraPointersInput.ts ***!
  14067. \*****************************************************/
  14068. /*! exports provided: FollowCameraPointersInput */
  14069. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14070. "use strict";
  14071. __webpack_require__.r(__webpack_exports__);
  14072. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return FollowCameraPointersInput; });
  14073. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14074. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14075. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14076. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  14077. /**
  14078. * Manage the pointers inputs to control an follow camera.
  14079. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14080. */
  14081. var FollowCameraPointersInput = /** @class */ (function (_super) {
  14082. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraPointersInput, _super);
  14083. function FollowCameraPointersInput() {
  14084. var _this = _super !== null && _super.apply(this, arguments) || this;
  14085. /**
  14086. * Defines the pointer angular sensibility along the X axis or how fast is
  14087. * the camera rotating.
  14088. * A negative number will reverse the axis direction.
  14089. */
  14090. _this.angularSensibilityX = 1;
  14091. /**
  14092. * Defines the pointer angular sensibility along the Y axis or how fast is
  14093. * the camera rotating.
  14094. * A negative number will reverse the axis direction.
  14095. */
  14096. _this.angularSensibilityY = 1;
  14097. /**
  14098. * Defines the pointer pinch precision or how fast is the camera zooming.
  14099. * A negative number will reverse the axis direction.
  14100. */
  14101. _this.pinchPrecision = 10000.0;
  14102. /**
  14103. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  14104. * from 0.
  14105. * It defines the percentage of current camera.radius to use as delta when
  14106. * pinch zoom is used.
  14107. */
  14108. _this.pinchDeltaPercentage = 0;
  14109. /**
  14110. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  14111. */
  14112. _this.axisXControlRadius = false;
  14113. /**
  14114. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  14115. */
  14116. _this.axisXControlHeight = false;
  14117. /**
  14118. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  14119. */
  14120. _this.axisXControlRotation = true;
  14121. /**
  14122. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  14123. */
  14124. _this.axisYControlRadius = false;
  14125. /**
  14126. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  14127. */
  14128. _this.axisYControlHeight = true;
  14129. /**
  14130. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  14131. */
  14132. _this.axisYControlRotation = false;
  14133. /**
  14134. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  14135. */
  14136. _this.axisPinchControlRadius = true;
  14137. /**
  14138. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  14139. */
  14140. _this.axisPinchControlHeight = false;
  14141. /**
  14142. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  14143. */
  14144. _this.axisPinchControlRotation = false;
  14145. /**
  14146. * Log error messages if basic misconfiguration has occurred.
  14147. */
  14148. _this.warningEnable = true;
  14149. /* Check for obvious misconfiguration. */
  14150. _this._warningCounter = 0;
  14151. return _this;
  14152. }
  14153. /**
  14154. * Gets the class name of the current input.
  14155. * @returns the class name
  14156. */
  14157. FollowCameraPointersInput.prototype.getClassName = function () {
  14158. return "FollowCameraPointersInput";
  14159. };
  14160. FollowCameraPointersInput.prototype.onTouch = function (pointA, offsetX, offsetY) {
  14161. this._warning();
  14162. if (this.axisXControlRotation) {
  14163. this.camera.rotationOffset += offsetX / this.angularSensibilityX;
  14164. }
  14165. else if (this.axisYControlRotation) {
  14166. this.camera.rotationOffset += offsetY / this.angularSensibilityX;
  14167. }
  14168. if (this.axisXControlHeight) {
  14169. this.camera.heightOffset += offsetX / this.angularSensibilityY;
  14170. }
  14171. else if (this.axisYControlHeight) {
  14172. this.camera.heightOffset += offsetY / this.angularSensibilityY;
  14173. }
  14174. if (this.axisXControlRadius) {
  14175. this.camera.radius -= offsetX / this.angularSensibilityY;
  14176. }
  14177. else if (this.axisYControlRadius) {
  14178. this.camera.radius -= offsetY / this.angularSensibilityY;
  14179. }
  14180. };
  14181. FollowCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  14182. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  14183. // First time this method is called for new pinch.
  14184. // Next time this is called there will be a
  14185. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  14186. return;
  14187. }
  14188. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  14189. // Last time this method is called at the end of a pinch.
  14190. return;
  14191. }
  14192. var pinchDelta = (pinchSquaredDistance - previousPinchSquaredDistance) /
  14193. (this.pinchPrecision * (this.angularSensibilityX + this.angularSensibilityY) / 2);
  14194. if (this.pinchDeltaPercentage) {
  14195. pinchDelta *= 0.01 * this.pinchDeltaPercentage;
  14196. if (this.axisPinchControlRotation) {
  14197. this.camera.rotationOffset += pinchDelta * this.camera.rotationOffset;
  14198. }
  14199. if (this.axisPinchControlHeight) {
  14200. this.camera.heightOffset += pinchDelta * this.camera.heightOffset;
  14201. }
  14202. if (this.axisPinchControlRadius) {
  14203. this.camera.radius -= pinchDelta * this.camera.radius;
  14204. }
  14205. }
  14206. else {
  14207. if (this.axisPinchControlRotation) {
  14208. this.camera.rotationOffset += pinchDelta;
  14209. }
  14210. if (this.axisPinchControlHeight) {
  14211. this.camera.heightOffset += pinchDelta;
  14212. }
  14213. if (this.axisPinchControlRadius) {
  14214. this.camera.radius -= pinchDelta;
  14215. }
  14216. }
  14217. };
  14218. FollowCameraPointersInput.prototype._warning = function () {
  14219. if (!this.warningEnable || this._warningCounter++ % 100 !== 0) {
  14220. return;
  14221. }
  14222. var warn = "It probably only makes sense to control ONE camera " +
  14223. "property with each pointer axis. Set 'warningEnable = false' " +
  14224. "if you are sure. Currently enabled: ";
  14225. console.assert((this.axisXControlRotation +
  14226. this.axisXControlHeight +
  14227. this.axisXControlRadius) <= 1, warn +
  14228. "axisXControlRotation: " + this.axisXControlRotation +
  14229. ", axisXControlHeight: " + this.axisXControlHeight +
  14230. ", axisXControlRadius: " + this.axisXControlRadius);
  14231. console.assert((this.axisYControlRotation +
  14232. this.axisYControlHeight +
  14233. this.axisYControlRadius) <= 1, warn +
  14234. "axisYControlRotation: " + this.axisYControlRotation +
  14235. ", axisYControlHeight: " + this.axisYControlHeight +
  14236. ", axisYControlRadius: " + this.axisYControlRadius);
  14237. console.assert((this.axisPinchControlRotation +
  14238. this.axisPinchControlHeight +
  14239. this.axisPinchControlRadius) <= 1, warn +
  14240. "axisPinchControlRotation: " + this.axisPinchControlRotation +
  14241. ", axisPinchControlHeight: " + this.axisPinchControlHeight +
  14242. ", axisPinchControlRadius: " + this.axisPinchControlRadius);
  14243. };
  14244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14246. ], FollowCameraPointersInput.prototype, "angularSensibilityX", void 0);
  14247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14249. ], FollowCameraPointersInput.prototype, "angularSensibilityY", void 0);
  14250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14252. ], FollowCameraPointersInput.prototype, "pinchPrecision", void 0);
  14253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14255. ], FollowCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  14256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14258. ], FollowCameraPointersInput.prototype, "axisXControlRadius", void 0);
  14259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14261. ], FollowCameraPointersInput.prototype, "axisXControlHeight", void 0);
  14262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14264. ], FollowCameraPointersInput.prototype, "axisXControlRotation", void 0);
  14265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14267. ], FollowCameraPointersInput.prototype, "axisYControlRadius", void 0);
  14268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14270. ], FollowCameraPointersInput.prototype, "axisYControlHeight", void 0);
  14271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14273. ], FollowCameraPointersInput.prototype, "axisYControlRotation", void 0);
  14274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14276. ], FollowCameraPointersInput.prototype, "axisPinchControlRadius", void 0);
  14277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14279. ], FollowCameraPointersInput.prototype, "axisPinchControlHeight", void 0);
  14280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14282. ], FollowCameraPointersInput.prototype, "axisPinchControlRotation", void 0);
  14283. return FollowCameraPointersInput;
  14284. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  14285. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraPointersInput"] = FollowCameraPointersInput;
  14286. /***/ }),
  14287. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  14288. /*!************************************************************!*\
  14289. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  14290. \************************************************************/
  14291. /*! exports provided: FreeCameraDeviceOrientationInput */
  14292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14293. "use strict";
  14294. __webpack_require__.r(__webpack_exports__);
  14295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  14296. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14297. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14298. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  14299. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14300. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  14301. /**
  14302. * Add orientation input support to the input manager.
  14303. * @returns the current input manager
  14304. */
  14305. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  14306. if (!this._deviceOrientationInput) {
  14307. this._deviceOrientationInput = new FreeCameraDeviceOrientationInput();
  14308. this.add(this._deviceOrientationInput);
  14309. }
  14310. return this;
  14311. };
  14312. /**
  14313. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  14314. * Screen rotation is taken into account.
  14315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14316. */
  14317. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  14318. /**
  14319. * Instantiates a new input
  14320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14321. */
  14322. function FreeCameraDeviceOrientationInput() {
  14323. var _this = this;
  14324. this._screenOrientationAngle = 0;
  14325. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14326. this._alpha = 0;
  14327. this._beta = 0;
  14328. this._gamma = 0;
  14329. /**
  14330. * @hidden
  14331. */
  14332. this._onDeviceOrientationChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  14333. this._orientationChanged = function () {
  14334. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  14335. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  14336. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  14337. };
  14338. this._deviceOrientation = function (evt) {
  14339. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  14340. _this._beta = evt.beta !== null ? evt.beta : 0;
  14341. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  14342. if (evt.alpha !== null) {
  14343. _this._onDeviceOrientationChangedObservable.notifyObservers();
  14344. }
  14345. };
  14346. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  14347. this._orientationChanged();
  14348. }
  14349. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  14350. /**
  14351. * Define the camera controlled by the input.
  14352. */
  14353. get: function () {
  14354. return this._camera;
  14355. },
  14356. set: function (camera) {
  14357. var _this = this;
  14358. this._camera = camera;
  14359. if (this._camera != null && !this._camera.rotationQuaternion) {
  14360. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14361. }
  14362. if (this._camera) {
  14363. this._camera.onDisposeObservable.add(function () {
  14364. _this._onDeviceOrientationChangedObservable.clear();
  14365. });
  14366. }
  14367. },
  14368. enumerable: true,
  14369. configurable: true
  14370. });
  14371. /**
  14372. * Attach the input controls to a specific dom element to get the input from.
  14373. * @param element Defines the element the controls should be listened from
  14374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14375. */
  14376. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  14377. window.addEventListener("orientationchange", this._orientationChanged);
  14378. window.addEventListener("deviceorientation", this._deviceOrientation);
  14379. //In certain cases, the attach control is called AFTER orientation was changed,
  14380. //So this is needed.
  14381. this._orientationChanged();
  14382. };
  14383. /**
  14384. * Detach the current controls from the specified dom element.
  14385. * @param element Defines the element to stop listening the inputs from
  14386. */
  14387. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  14388. window.removeEventListener("orientationchange", this._orientationChanged);
  14389. window.removeEventListener("deviceorientation", this._deviceOrientation);
  14390. this._alpha = 0;
  14391. };
  14392. /**
  14393. * Update the current camera state depending on the inputs that have been used this frame.
  14394. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14395. */
  14396. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  14397. //if no device orientation provided, don't update the rotation.
  14398. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  14399. if (!this._alpha) {
  14400. return;
  14401. }
  14402. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this._alpha), _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this._beta), -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this._gamma), this.camera.rotationQuaternion);
  14403. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  14404. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  14405. //Mirror on XY Plane
  14406. this._camera.rotationQuaternion.z *= -1;
  14407. this._camera.rotationQuaternion.w *= -1;
  14408. };
  14409. /**
  14410. * Gets the class name of the current intput.
  14411. * @returns the class name
  14412. */
  14413. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  14414. return "FreeCameraDeviceOrientationInput";
  14415. };
  14416. /**
  14417. * Get the friendly name associated with the input class.
  14418. * @returns the input friendly name
  14419. */
  14420. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  14421. return "deviceOrientation";
  14422. };
  14423. return FreeCameraDeviceOrientationInput;
  14424. }());
  14425. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  14426. /***/ }),
  14427. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  14428. /*!**************************************************!*\
  14429. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  14430. \**************************************************/
  14431. /*! exports provided: FreeCameraGamepadInput */
  14432. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14433. "use strict";
  14434. __webpack_require__.r(__webpack_exports__);
  14435. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  14436. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14437. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14438. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14439. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14440. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  14441. /**
  14442. * Manage the gamepad inputs to control a free camera.
  14443. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14444. */
  14445. var FreeCameraGamepadInput = /** @class */ (function () {
  14446. function FreeCameraGamepadInput() {
  14447. /**
  14448. * Defines the gamepad rotation sensiblity.
  14449. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  14450. */
  14451. this.gamepadAngularSensibility = 200;
  14452. /**
  14453. * Defines the gamepad move sensiblity.
  14454. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  14455. */
  14456. this.gamepadMoveSensibility = 40;
  14457. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  14458. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14459. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14460. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  14461. }
  14462. /**
  14463. * Attach the input controls to a specific dom element to get the input from.
  14464. * @param element Defines the element the controls should be listened from
  14465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14466. */
  14467. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  14468. var _this = this;
  14469. var manager = this.camera.getScene().gamepadManager;
  14470. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  14471. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  14472. // prioritize XBOX gamepads.
  14473. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  14474. _this.gamepad = gamepad;
  14475. }
  14476. }
  14477. });
  14478. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  14479. if (_this.gamepad === gamepad) {
  14480. _this.gamepad = null;
  14481. }
  14482. });
  14483. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  14484. };
  14485. /**
  14486. * Detach the current controls from the specified dom element.
  14487. * @param element Defines the element to stop listening the inputs from
  14488. */
  14489. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  14490. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  14491. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  14492. this.gamepad = null;
  14493. };
  14494. /**
  14495. * Update the current camera state depending on the inputs that have been used this frame.
  14496. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14497. */
  14498. FreeCameraGamepadInput.prototype.checkInputs = function () {
  14499. if (this.gamepad && this.gamepad.leftStick) {
  14500. var camera = this.camera;
  14501. var LSValues = this.gamepad.leftStick;
  14502. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  14503. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  14504. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  14505. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  14506. var RSValues = this.gamepad.rightStick;
  14507. if (RSValues) {
  14508. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  14509. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  14510. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  14511. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  14512. }
  14513. else {
  14514. RSValues = { x: 0, y: 0 };
  14515. }
  14516. if (!camera.rotationQuaternion) {
  14517. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  14518. }
  14519. else {
  14520. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  14521. }
  14522. var speed = camera._computeLocalCameraSpeed() * 50.0;
  14523. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  14524. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  14525. camera.cameraDirection.addInPlace(this._deltaTransform);
  14526. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  14527. camera.cameraRotation.addInPlace(this._vector2);
  14528. }
  14529. };
  14530. /**
  14531. * Gets the class name of the current intput.
  14532. * @returns the class name
  14533. */
  14534. FreeCameraGamepadInput.prototype.getClassName = function () {
  14535. return "FreeCameraGamepadInput";
  14536. };
  14537. /**
  14538. * Get the friendly name associated with the input class.
  14539. * @returns the input friendly name
  14540. */
  14541. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  14542. return "gamepad";
  14543. };
  14544. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14545. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14546. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  14547. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14548. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14549. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  14550. return FreeCameraGamepadInput;
  14551. }());
  14552. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  14553. /***/ }),
  14554. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  14555. /*!*******************************************************!*\
  14556. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  14557. \*******************************************************/
  14558. /*! exports provided: FreeCameraKeyboardMoveInput */
  14559. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14560. "use strict";
  14561. __webpack_require__.r(__webpack_exports__);
  14562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  14563. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14564. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14565. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14566. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  14567. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14568. /**
  14569. * Manage the keyboard inputs to control the movement of a free camera.
  14570. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14571. */
  14572. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  14573. function FreeCameraKeyboardMoveInput() {
  14574. /**
  14575. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  14576. */
  14577. this.keysUp = [38];
  14578. /**
  14579. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  14580. */
  14581. this.keysDown = [40];
  14582. /**
  14583. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  14584. */
  14585. this.keysLeft = [37];
  14586. /**
  14587. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  14588. */
  14589. this.keysRight = [39];
  14590. this._keys = new Array();
  14591. }
  14592. /**
  14593. * Attach the input controls to a specific dom element to get the input from.
  14594. * @param element Defines the element the controls should be listened from
  14595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14596. */
  14597. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  14598. var _this = this;
  14599. if (this._onCanvasBlurObserver) {
  14600. return;
  14601. }
  14602. this._scene = this.camera.getScene();
  14603. this._engine = this._scene.getEngine();
  14604. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  14605. _this._keys = [];
  14606. });
  14607. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  14608. var evt = info.event;
  14609. if (!evt.metaKey) {
  14610. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  14611. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14612. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14613. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14614. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14615. var index = _this._keys.indexOf(evt.keyCode);
  14616. if (index === -1) {
  14617. _this._keys.push(evt.keyCode);
  14618. }
  14619. if (!noPreventDefault) {
  14620. evt.preventDefault();
  14621. }
  14622. }
  14623. }
  14624. else {
  14625. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14626. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14627. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14628. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14629. var index = _this._keys.indexOf(evt.keyCode);
  14630. if (index >= 0) {
  14631. _this._keys.splice(index, 1);
  14632. }
  14633. if (!noPreventDefault) {
  14634. evt.preventDefault();
  14635. }
  14636. }
  14637. }
  14638. }
  14639. });
  14640. };
  14641. /**
  14642. * Detach the current controls from the specified dom element.
  14643. * @param element Defines the element to stop listening the inputs from
  14644. */
  14645. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  14646. if (this._scene) {
  14647. if (this._onKeyboardObserver) {
  14648. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  14649. }
  14650. if (this._onCanvasBlurObserver) {
  14651. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  14652. }
  14653. this._onKeyboardObserver = null;
  14654. this._onCanvasBlurObserver = null;
  14655. }
  14656. this._keys = [];
  14657. };
  14658. /**
  14659. * Update the current camera state depending on the inputs that have been used this frame.
  14660. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14661. */
  14662. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  14663. if (this._onKeyboardObserver) {
  14664. var camera = this.camera;
  14665. // Keyboard
  14666. for (var index = 0; index < this._keys.length; index++) {
  14667. var keyCode = this._keys[index];
  14668. var speed = camera._computeLocalCameraSpeed();
  14669. if (this.keysLeft.indexOf(keyCode) !== -1) {
  14670. camera._localDirection.copyFromFloats(-speed, 0, 0);
  14671. }
  14672. else if (this.keysUp.indexOf(keyCode) !== -1) {
  14673. camera._localDirection.copyFromFloats(0, 0, speed);
  14674. }
  14675. else if (this.keysRight.indexOf(keyCode) !== -1) {
  14676. camera._localDirection.copyFromFloats(speed, 0, 0);
  14677. }
  14678. else if (this.keysDown.indexOf(keyCode) !== -1) {
  14679. camera._localDirection.copyFromFloats(0, 0, -speed);
  14680. }
  14681. if (camera.getScene().useRightHandedSystem) {
  14682. camera._localDirection.z *= -1;
  14683. }
  14684. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  14685. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  14686. camera.cameraDirection.addInPlace(camera._transformedDirection);
  14687. }
  14688. }
  14689. };
  14690. /**
  14691. * Gets the class name of the current intput.
  14692. * @returns the class name
  14693. */
  14694. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  14695. return "FreeCameraKeyboardMoveInput";
  14696. };
  14697. /** @hidden */
  14698. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  14699. this._keys = [];
  14700. };
  14701. /**
  14702. * Get the friendly name associated with the input class.
  14703. * @returns the input friendly name
  14704. */
  14705. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14706. return "keyboard";
  14707. };
  14708. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14709. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14710. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  14711. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14712. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14713. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  14714. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14715. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14716. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  14717. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14718. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14719. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  14720. return FreeCameraKeyboardMoveInput;
  14721. }());
  14722. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  14723. /***/ }),
  14724. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  14725. /*!************************************************!*\
  14726. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  14727. \************************************************/
  14728. /*! exports provided: FreeCameraMouseInput */
  14729. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14730. "use strict";
  14731. __webpack_require__.r(__webpack_exports__);
  14732. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  14733. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14734. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  14735. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14736. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14737. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14738. /**
  14739. * Manage the mouse inputs to control the movement of a free camera.
  14740. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14741. */
  14742. var FreeCameraMouseInput = /** @class */ (function () {
  14743. /**
  14744. * Manage the mouse inputs to control the movement of a free camera.
  14745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14746. * @param touchEnabled Defines if touch is enabled or not
  14747. */
  14748. function FreeCameraMouseInput(
  14749. /**
  14750. * Define if touch is enabled in the mouse input
  14751. */
  14752. touchEnabled) {
  14753. if (touchEnabled === void 0) { touchEnabled = true; }
  14754. this.touchEnabled = touchEnabled;
  14755. /**
  14756. * Defines the buttons associated with the input to handle camera move.
  14757. */
  14758. this.buttons = [0, 1, 2];
  14759. /**
  14760. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  14761. */
  14762. this.angularSensibility = 2000.0;
  14763. this.previousPosition = null;
  14764. /**
  14765. * Observable for when a pointer move event occurs containing the move offset
  14766. */
  14767. this.onPointerMovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  14768. /**
  14769. * @hidden
  14770. * If the camera should be rotated automatically based on pointer movement
  14771. */
  14772. this._allowCameraRotation = true;
  14773. }
  14774. /**
  14775. * Attach the input controls to a specific dom element to get the input from.
  14776. * @param element Defines the element the controls should be listened from
  14777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14778. */
  14779. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  14780. var _this = this;
  14781. var engine = this.camera.getEngine();
  14782. if (!this._pointerInput) {
  14783. this._pointerInput = function (p) {
  14784. var evt = p.event;
  14785. if (engine.isInVRExclusivePointerMode) {
  14786. return;
  14787. }
  14788. if (!_this.touchEnabled && evt.pointerType === "touch") {
  14789. return;
  14790. }
  14791. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  14792. return;
  14793. }
  14794. var srcElement = (evt.srcElement || evt.target);
  14795. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN && srcElement) {
  14796. try {
  14797. srcElement.setPointerCapture(evt.pointerId);
  14798. }
  14799. catch (e) {
  14800. //Nothing to do with the error. Execution will continue.
  14801. }
  14802. _this.previousPosition = {
  14803. x: evt.clientX,
  14804. y: evt.clientY
  14805. };
  14806. if (!noPreventDefault) {
  14807. evt.preventDefault();
  14808. element.focus();
  14809. }
  14810. }
  14811. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP && srcElement) {
  14812. try {
  14813. srcElement.releasePointerCapture(evt.pointerId);
  14814. }
  14815. catch (e) {
  14816. //Nothing to do with the error.
  14817. }
  14818. _this.previousPosition = null;
  14819. if (!noPreventDefault) {
  14820. evt.preventDefault();
  14821. }
  14822. }
  14823. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  14824. if (!_this.previousPosition || engine.isPointerLock) {
  14825. return;
  14826. }
  14827. var offsetX = evt.clientX - _this.previousPosition.x;
  14828. var offsetY = evt.clientY - _this.previousPosition.y;
  14829. if (_this.camera.getScene().useRightHandedSystem) {
  14830. offsetX *= -1;
  14831. }
  14832. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14833. offsetX *= -1;
  14834. }
  14835. if (_this._allowCameraRotation) {
  14836. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14837. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14838. }
  14839. _this.onPointerMovedObservable.notifyObservers({ offsetX: offsetX, offsetY: offsetY });
  14840. _this.previousPosition = {
  14841. x: evt.clientX,
  14842. y: evt.clientY
  14843. };
  14844. if (!noPreventDefault) {
  14845. evt.preventDefault();
  14846. }
  14847. }
  14848. };
  14849. }
  14850. this._onMouseMove = function (evt) {
  14851. if (!engine.isPointerLock) {
  14852. return;
  14853. }
  14854. if (engine.isInVRExclusivePointerMode) {
  14855. return;
  14856. }
  14857. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  14858. if (_this.camera.getScene().useRightHandedSystem) {
  14859. offsetX *= -1;
  14860. }
  14861. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14862. offsetX *= -1;
  14863. }
  14864. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14865. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  14866. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14867. _this.previousPosition = null;
  14868. if (!noPreventDefault) {
  14869. evt.preventDefault();
  14870. }
  14871. };
  14872. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE);
  14873. element.addEventListener("mousemove", this._onMouseMove, false);
  14874. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  14875. };
  14876. /**
  14877. * Called on JS contextmenu event.
  14878. * Override this method to provide functionality.
  14879. */
  14880. FreeCameraMouseInput.prototype.onContextMenu = function (evt) {
  14881. evt.preventDefault();
  14882. };
  14883. /**
  14884. * Detach the current controls from the specified dom element.
  14885. * @param element Defines the element to stop listening the inputs from
  14886. */
  14887. FreeCameraMouseInput.prototype.detachControl = function (element) {
  14888. if (this._observer && element) {
  14889. this.camera.getScene().onPointerObservable.remove(this._observer);
  14890. if (this._onMouseMove) {
  14891. element.removeEventListener("mousemove", this._onMouseMove);
  14892. }
  14893. if (this.onContextMenu) {
  14894. element.removeEventListener("contextmenu", this.onContextMenu);
  14895. }
  14896. if (this.onPointerMovedObservable) {
  14897. this.onPointerMovedObservable.clear();
  14898. }
  14899. this._observer = null;
  14900. this._onMouseMove = null;
  14901. this.previousPosition = null;
  14902. }
  14903. };
  14904. /**
  14905. * Gets the class name of the current intput.
  14906. * @returns the class name
  14907. */
  14908. FreeCameraMouseInput.prototype.getClassName = function () {
  14909. return "FreeCameraMouseInput";
  14910. };
  14911. /**
  14912. * Get the friendly name associated with the input class.
  14913. * @returns the input friendly name
  14914. */
  14915. FreeCameraMouseInput.prototype.getSimpleName = function () {
  14916. return "mouse";
  14917. };
  14918. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14920. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  14921. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14922. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14923. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  14924. return FreeCameraMouseInput;
  14925. }());
  14926. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  14927. /***/ }),
  14928. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  14929. /*!************************************************!*\
  14930. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  14931. \************************************************/
  14932. /*! exports provided: FreeCameraTouchInput */
  14933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14934. "use strict";
  14935. __webpack_require__.r(__webpack_exports__);
  14936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  14937. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14938. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14939. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14940. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14941. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14942. /**
  14943. * Manage the touch inputs to control the movement of a free camera.
  14944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14945. */
  14946. var FreeCameraTouchInput = /** @class */ (function () {
  14947. function FreeCameraTouchInput() {
  14948. /**
  14949. * Defines the touch sensibility for rotation.
  14950. * The higher the faster.
  14951. */
  14952. this.touchAngularSensibility = 200000.0;
  14953. /**
  14954. * Defines the touch sensibility for move.
  14955. * The higher the faster.
  14956. */
  14957. this.touchMoveSensibility = 250.0;
  14958. this._offsetX = null;
  14959. this._offsetY = null;
  14960. this._pointerPressed = new Array();
  14961. }
  14962. /**
  14963. * Attach the input controls to a specific dom element to get the input from.
  14964. * @param element Defines the element the controls should be listened from
  14965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14966. */
  14967. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  14968. var _this = this;
  14969. var previousPosition = null;
  14970. if (this._pointerInput === undefined) {
  14971. this._onLostFocus = function () {
  14972. _this._offsetX = null;
  14973. _this._offsetY = null;
  14974. };
  14975. this._pointerInput = function (p) {
  14976. var evt = p.event;
  14977. if (evt.pointerType === "mouse") {
  14978. return;
  14979. }
  14980. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  14981. if (!noPreventDefault) {
  14982. evt.preventDefault();
  14983. }
  14984. _this._pointerPressed.push(evt.pointerId);
  14985. if (_this._pointerPressed.length !== 1) {
  14986. return;
  14987. }
  14988. previousPosition = {
  14989. x: evt.clientX,
  14990. y: evt.clientY
  14991. };
  14992. }
  14993. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  14994. if (!noPreventDefault) {
  14995. evt.preventDefault();
  14996. }
  14997. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14998. if (index === -1) {
  14999. return;
  15000. }
  15001. _this._pointerPressed.splice(index, 1);
  15002. if (index != 0) {
  15003. return;
  15004. }
  15005. previousPosition = null;
  15006. _this._offsetX = null;
  15007. _this._offsetY = null;
  15008. }
  15009. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  15010. if (!noPreventDefault) {
  15011. evt.preventDefault();
  15012. }
  15013. if (!previousPosition) {
  15014. return;
  15015. }
  15016. var index = _this._pointerPressed.indexOf(evt.pointerId);
  15017. if (index != 0) {
  15018. return;
  15019. }
  15020. _this._offsetX = evt.clientX - previousPosition.x;
  15021. _this._offsetY = -(evt.clientY - previousPosition.y);
  15022. }
  15023. };
  15024. }
  15025. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  15026. if (this._onLostFocus) {
  15027. element.addEventListener("blur", this._onLostFocus);
  15028. }
  15029. };
  15030. /**
  15031. * Detach the current controls from the specified dom element.
  15032. * @param element Defines the element to stop listening the inputs from
  15033. */
  15034. FreeCameraTouchInput.prototype.detachControl = function (element) {
  15035. if (this._pointerInput && element) {
  15036. if (this._observer) {
  15037. this.camera.getScene().onPointerObservable.remove(this._observer);
  15038. this._observer = null;
  15039. }
  15040. if (this._onLostFocus) {
  15041. element.removeEventListener("blur", this._onLostFocus);
  15042. this._onLostFocus = null;
  15043. }
  15044. this._pointerPressed = [];
  15045. this._offsetX = null;
  15046. this._offsetY = null;
  15047. }
  15048. };
  15049. /**
  15050. * Update the current camera state depending on the inputs that have been used this frame.
  15051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  15052. */
  15053. FreeCameraTouchInput.prototype.checkInputs = function () {
  15054. if (this._offsetX && this._offsetY) {
  15055. var camera = this.camera;
  15056. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  15057. if (this._pointerPressed.length > 1) {
  15058. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  15059. }
  15060. else {
  15061. var speed = camera._computeLocalCameraSpeed();
  15062. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  15063. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  15064. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  15065. }
  15066. }
  15067. };
  15068. /**
  15069. * Gets the class name of the current intput.
  15070. * @returns the class name
  15071. */
  15072. FreeCameraTouchInput.prototype.getClassName = function () {
  15073. return "FreeCameraTouchInput";
  15074. };
  15075. /**
  15076. * Get the friendly name associated with the input class.
  15077. * @returns the input friendly name
  15078. */
  15079. FreeCameraTouchInput.prototype.getSimpleName = function () {
  15080. return "touch";
  15081. };
  15082. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15083. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15084. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  15085. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15086. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15087. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  15088. return FreeCameraTouchInput;
  15089. }());
  15090. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  15091. /***/ }),
  15092. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  15093. /*!**********************************************************!*\
  15094. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  15095. \**********************************************************/
  15096. /*! exports provided: FreeCameraVirtualJoystickInput */
  15097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15098. "use strict";
  15099. __webpack_require__.r(__webpack_exports__);
  15100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  15101. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  15102. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  15103. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15104. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  15105. /**
  15106. * Add virtual joystick input support to the input manager.
  15107. * @returns the current input manager
  15108. */
  15109. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  15110. this.add(new FreeCameraVirtualJoystickInput());
  15111. return this;
  15112. };
  15113. /**
  15114. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  15115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  15116. */
  15117. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  15118. function FreeCameraVirtualJoystickInput() {
  15119. }
  15120. /**
  15121. * Gets the left stick of the virtual joystick.
  15122. * @returns The virtual Joystick
  15123. */
  15124. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  15125. return this._leftjoystick;
  15126. };
  15127. /**
  15128. * Gets the right stick of the virtual joystick.
  15129. * @returns The virtual Joystick
  15130. */
  15131. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  15132. return this._rightjoystick;
  15133. };
  15134. /**
  15135. * Update the current camera state depending on the inputs that have been used this frame.
  15136. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  15137. */
  15138. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  15139. if (this._leftjoystick) {
  15140. var camera = this.camera;
  15141. var speed = camera._computeLocalCameraSpeed() * 50;
  15142. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  15143. var deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](this._leftjoystick.deltaPosition.x * speed, this._leftjoystick.deltaPosition.y * speed, this._leftjoystick.deltaPosition.z * speed), cameraTransform);
  15144. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  15145. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  15146. if (!this._leftjoystick.pressed) {
  15147. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  15148. }
  15149. if (!this._rightjoystick.pressed) {
  15150. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  15151. }
  15152. }
  15153. };
  15154. /**
  15155. * Attach the input controls to a specific dom element to get the input from.
  15156. * @param element Defines the element the controls should be listened from
  15157. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  15158. */
  15159. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  15160. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  15161. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  15162. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15163. this._leftjoystick.setJoystickSensibility(0.15);
  15164. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  15165. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15166. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  15167. this._rightjoystick.reverseUpDown = true;
  15168. this._rightjoystick.setJoystickSensibility(0.05);
  15169. this._rightjoystick.setJoystickColor("yellow");
  15170. };
  15171. /**
  15172. * Detach the current controls from the specified dom element.
  15173. * @param element Defines the element to stop listening the inputs from
  15174. */
  15175. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  15176. this._leftjoystick.releaseCanvas();
  15177. this._rightjoystick.releaseCanvas();
  15178. };
  15179. /**
  15180. * Gets the class name of the current intput.
  15181. * @returns the class name
  15182. */
  15183. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  15184. return "FreeCameraVirtualJoystickInput";
  15185. };
  15186. /**
  15187. * Get the friendly name associated with the input class.
  15188. * @returns the input friendly name
  15189. */
  15190. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  15191. return "virtualJoystick";
  15192. };
  15193. return FreeCameraVirtualJoystickInput;
  15194. }());
  15195. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  15196. /***/ }),
  15197. /***/ "./Cameras/Inputs/index.ts":
  15198. /*!*********************************!*\
  15199. !*** ./Cameras/Inputs/index.ts ***!
  15200. \*********************************/
  15201. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  15202. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15203. "use strict";
  15204. __webpack_require__.r(__webpack_exports__);
  15205. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  15206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  15207. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  15208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  15209. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  15210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  15211. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  15212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  15213. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  15215. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  15216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  15217. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  15218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  15219. /* harmony import */ var _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  15220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  15221. /* harmony import */ var _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  15222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__["FollowCameraMouseWheelInput"]; });
  15223. /* harmony import */ var _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  15224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__["FollowCameraPointersInput"]; });
  15225. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  15226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraDeviceOrientationInput"]; });
  15227. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  15228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraGamepadInput"]; });
  15229. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  15230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraKeyboardMoveInput"]; });
  15231. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  15232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__["FreeCameraMouseInput"]; });
  15233. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  15234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__["FreeCameraTouchInput"]; });
  15235. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  15236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__["FreeCameraVirtualJoystickInput"]; });
  15237. /***/ }),
  15238. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  15239. /*!*********************************************************!*\
  15240. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  15241. \*********************************************************/
  15242. /*! no exports provided */
  15243. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15244. "use strict";
  15245. __webpack_require__.r(__webpack_exports__);
  15246. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15247. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15248. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  15249. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  15250. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15251. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  15252. };
  15253. /***/ }),
  15254. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  15255. /*!*************************************************!*\
  15256. !*** ./Cameras/RigModes/stereoscopicRigMode.ts ***!
  15257. \*************************************************/
  15258. /*! no exports provided */
  15259. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15260. "use strict";
  15261. __webpack_require__.r(__webpack_exports__);
  15262. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15263. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15264. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  15265. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  15266. var isStereoscopicHoriz = camera.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL || camera.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  15267. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15268. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  15269. };
  15270. /***/ }),
  15271. /***/ "./Cameras/RigModes/vrRigMode.ts":
  15272. /*!***************************************!*\
  15273. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  15274. \***************************************/
  15275. /*! no exports provided */
  15276. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15277. "use strict";
  15278. __webpack_require__.r(__webpack_exports__);
  15279. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15280. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15281. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  15282. /* harmony import */ var _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../PostProcesses/vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  15283. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15284. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15285. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  15286. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_4__["VRCameraMetrics"].GetDefault();
  15287. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  15288. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15289. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15290. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  15291. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  15292. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  15293. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  15294. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15295. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15296. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  15297. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  15298. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  15299. // For multiview on a webVR camera
  15300. // First multiview will be rendered to camera._multiviewTexture
  15301. // Then this postprocess will run on each eye to copy the right texture to each eye
  15302. if (metrics.multiviewEnabled) {
  15303. if (!camera.getScene().getEngine().getCaps().multiview) {
  15304. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("Multiview is not supported, falling back to standard rendering");
  15305. metrics.multiviewEnabled = false;
  15306. }
  15307. else {
  15308. camera._useMultiviewToSingleView = true;
  15309. camera._rigPostProcess = new _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_3__["VRMultiviewToSingleviewPostProcess"]("VRMultiviewToSingleview", camera, metrics.postProcessScaleFactor);
  15310. }
  15311. }
  15312. if (metrics.compensateDistortion) {
  15313. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  15314. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  15315. }
  15316. };
  15317. /***/ }),
  15318. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  15319. /*!******************************************!*\
  15320. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  15321. \******************************************/
  15322. /*! no exports provided */
  15323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15324. "use strict";
  15325. __webpack_require__.r(__webpack_exports__);
  15326. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15327. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15328. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  15329. if (rigParams.vrDisplay) {
  15330. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  15331. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  15332. //Left eye
  15333. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15334. camera._rigCameras[0].setCameraRigParameter("left", true);
  15335. //leaving this for future reference
  15336. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  15337. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  15338. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  15339. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15340. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15341. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15342. camera._rigCameras[0].parent = camera;
  15343. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  15344. //Right eye
  15345. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15346. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  15347. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  15348. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  15349. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15350. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15351. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15352. camera._rigCameras[1].parent = camera;
  15353. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  15354. }
  15355. };
  15356. /***/ }),
  15357. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  15358. /*!*********************************************************!*\
  15359. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  15360. \*********************************************************/
  15361. /*! exports provided: AnaglyphArcRotateCamera */
  15362. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15363. "use strict";
  15364. __webpack_require__.r(__webpack_exports__);
  15365. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  15366. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15367. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15368. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15369. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15370. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15371. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15372. // Side effect import to define the stereoscopic mode.
  15373. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  15374. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15375. });
  15376. /**
  15377. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  15378. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15379. */
  15380. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  15381. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  15382. /**
  15383. * Creates a new AnaglyphArcRotateCamera
  15384. * @param name defines camera name
  15385. * @param alpha defines alpha angle (in radians)
  15386. * @param beta defines beta angle (in radians)
  15387. * @param radius defines radius
  15388. * @param target defines camera target
  15389. * @param interaxialDistance defines distance between each color axis
  15390. * @param scene defines the hosting scene
  15391. */
  15392. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  15393. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15394. _this.interaxialDistance = interaxialDistance;
  15395. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15396. return _this;
  15397. }
  15398. /**
  15399. * Gets camera class name
  15400. * @returns AnaglyphArcRotateCamera
  15401. */
  15402. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  15403. return "AnaglyphArcRotateCamera";
  15404. };
  15405. return AnaglyphArcRotateCamera;
  15406. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15407. /***/ }),
  15408. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  15409. /*!****************************************************!*\
  15410. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  15411. \****************************************************/
  15412. /*! exports provided: AnaglyphFreeCamera */
  15413. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15414. "use strict";
  15415. __webpack_require__.r(__webpack_exports__);
  15416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  15417. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15418. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15419. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15420. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15421. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15422. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15423. // Side effect import to define the stereoscopic mode.
  15424. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  15425. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15426. });
  15427. /**
  15428. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  15429. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15430. */
  15431. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  15432. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  15433. /**
  15434. * Creates a new AnaglyphFreeCamera
  15435. * @param name defines camera name
  15436. * @param position defines initial position
  15437. * @param interaxialDistance defines distance between each color axis
  15438. * @param scene defines the hosting scene
  15439. */
  15440. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  15441. var _this = _super.call(this, name, position, scene) || this;
  15442. _this.interaxialDistance = interaxialDistance;
  15443. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15444. return _this;
  15445. }
  15446. /**
  15447. * Gets camera class name
  15448. * @returns AnaglyphFreeCamera
  15449. */
  15450. AnaglyphFreeCamera.prototype.getClassName = function () {
  15451. return "AnaglyphFreeCamera";
  15452. };
  15453. return AnaglyphFreeCamera;
  15454. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15455. /***/ }),
  15456. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  15457. /*!*******************************************************!*\
  15458. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  15459. \*******************************************************/
  15460. /*! exports provided: AnaglyphGamepadCamera */
  15461. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15462. "use strict";
  15463. __webpack_require__.r(__webpack_exports__);
  15464. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  15465. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15466. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15467. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15468. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15469. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15470. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15471. // Side effect import to define the stereoscopic mode.
  15472. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  15473. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15474. });
  15475. /**
  15476. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  15477. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15478. */
  15479. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  15480. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  15481. /**
  15482. * Creates a new AnaglyphGamepadCamera
  15483. * @param name defines camera name
  15484. * @param position defines initial position
  15485. * @param interaxialDistance defines distance between each color axis
  15486. * @param scene defines the hosting scene
  15487. */
  15488. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  15489. var _this = _super.call(this, name, position, scene) || this;
  15490. _this.interaxialDistance = interaxialDistance;
  15491. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15492. return _this;
  15493. }
  15494. /**
  15495. * Gets camera class name
  15496. * @returns AnaglyphGamepadCamera
  15497. */
  15498. AnaglyphGamepadCamera.prototype.getClassName = function () {
  15499. return "AnaglyphGamepadCamera";
  15500. };
  15501. return AnaglyphGamepadCamera;
  15502. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15503. /***/ }),
  15504. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  15505. /*!*********************************************************!*\
  15506. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  15507. \*********************************************************/
  15508. /*! exports provided: AnaglyphUniversalCamera */
  15509. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15510. "use strict";
  15511. __webpack_require__.r(__webpack_exports__);
  15512. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  15513. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15514. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15515. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15516. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15517. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15518. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15519. // Side effect import to define the stereoscopic mode.
  15520. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  15521. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15522. });
  15523. /**
  15524. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  15525. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15526. */
  15527. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  15528. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  15529. /**
  15530. * Creates a new AnaglyphUniversalCamera
  15531. * @param name defines camera name
  15532. * @param position defines initial position
  15533. * @param interaxialDistance defines distance between each color axis
  15534. * @param scene defines the hosting scene
  15535. */
  15536. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  15537. var _this = _super.call(this, name, position, scene) || this;
  15538. _this.interaxialDistance = interaxialDistance;
  15539. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15540. return _this;
  15541. }
  15542. /**
  15543. * Gets camera class name
  15544. * @returns AnaglyphUniversalCamera
  15545. */
  15546. AnaglyphUniversalCamera.prototype.getClassName = function () {
  15547. return "AnaglyphUniversalCamera";
  15548. };
  15549. return AnaglyphUniversalCamera;
  15550. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15551. /***/ }),
  15552. /***/ "./Cameras/Stereoscopic/index.ts":
  15553. /*!***************************************!*\
  15554. !*** ./Cameras/Stereoscopic/index.ts ***!
  15555. \***************************************/
  15556. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  15557. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15558. "use strict";
  15559. __webpack_require__.r(__webpack_exports__);
  15560. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  15561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  15562. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  15563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  15564. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  15565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  15566. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  15567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  15568. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  15569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  15570. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  15571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  15572. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  15573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  15574. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  15575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  15576. /***/ }),
  15577. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  15578. /*!*************************************************************!*\
  15579. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  15580. \*************************************************************/
  15581. /*! exports provided: StereoscopicArcRotateCamera */
  15582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15583. "use strict";
  15584. __webpack_require__.r(__webpack_exports__);
  15585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  15586. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15587. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15588. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15589. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15590. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15591. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15592. // Side effect import to define the stereoscopic mode.
  15593. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  15594. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15595. });
  15596. /**
  15597. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  15598. * @see http://doc.babylonjs.com/features/cameras
  15599. */
  15600. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  15601. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  15602. /**
  15603. * Creates a new StereoscopicArcRotateCamera
  15604. * @param name defines camera name
  15605. * @param alpha defines alpha angle (in radians)
  15606. * @param beta defines beta angle (in radians)
  15607. * @param radius defines radius
  15608. * @param target defines camera target
  15609. * @param interaxialDistance defines distance between each color axis
  15610. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15611. * @param scene defines the hosting scene
  15612. */
  15613. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  15614. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15615. _this.interaxialDistance = interaxialDistance;
  15616. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15617. _this.setCameraRigMode(isStereoscopicSideBySide ? _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER, { interaxialDistance: interaxialDistance });
  15618. return _this;
  15619. }
  15620. /**
  15621. * Gets camera class name
  15622. * @returns StereoscopicArcRotateCamera
  15623. */
  15624. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  15625. return "StereoscopicArcRotateCamera";
  15626. };
  15627. return StereoscopicArcRotateCamera;
  15628. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15629. /***/ }),
  15630. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  15631. /*!********************************************************!*\
  15632. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  15633. \********************************************************/
  15634. /*! exports provided: StereoscopicFreeCamera */
  15635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15636. "use strict";
  15637. __webpack_require__.r(__webpack_exports__);
  15638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  15639. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15640. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15641. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15642. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15643. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15644. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15645. // Side effect import to define the stereoscopic mode.
  15646. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15647. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15648. });
  15649. /**
  15650. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  15651. * @see http://doc.babylonjs.com/features/cameras
  15652. */
  15653. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  15654. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  15655. /**
  15656. * Creates a new StereoscopicFreeCamera
  15657. * @param name defines camera name
  15658. * @param position defines initial position
  15659. * @param interaxialDistance defines distance between each color axis
  15660. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15661. * @param scene defines the hosting scene
  15662. */
  15663. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15664. var _this = _super.call(this, name, position, scene) || this;
  15665. _this.interaxialDistance = interaxialDistance;
  15666. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15667. _this.setCameraRigMode(isStereoscopicSideBySide ? _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER, { interaxialDistance: interaxialDistance });
  15668. return _this;
  15669. }
  15670. /**
  15671. * Gets camera class name
  15672. * @returns StereoscopicFreeCamera
  15673. */
  15674. StereoscopicFreeCamera.prototype.getClassName = function () {
  15675. return "StereoscopicFreeCamera";
  15676. };
  15677. return StereoscopicFreeCamera;
  15678. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15679. /***/ }),
  15680. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  15681. /*!***********************************************************!*\
  15682. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  15683. \***********************************************************/
  15684. /*! exports provided: StereoscopicGamepadCamera */
  15685. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15686. "use strict";
  15687. __webpack_require__.r(__webpack_exports__);
  15688. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  15689. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15690. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15691. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15692. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15693. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15694. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15695. // Side effect import to define the stereoscopic mode.
  15696. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  15697. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15698. });
  15699. /**
  15700. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  15701. * @see http://doc.babylonjs.com/features/cameras
  15702. */
  15703. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  15704. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  15705. /**
  15706. * Creates a new StereoscopicGamepadCamera
  15707. * @param name defines camera name
  15708. * @param position defines initial position
  15709. * @param interaxialDistance defines distance between each color axis
  15710. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15711. * @param scene defines the hosting scene
  15712. */
  15713. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15714. var _this = _super.call(this, name, position, scene) || this;
  15715. _this.interaxialDistance = interaxialDistance;
  15716. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15717. _this.setCameraRigMode(isStereoscopicSideBySide ? _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER, { interaxialDistance: interaxialDistance });
  15718. return _this;
  15719. }
  15720. /**
  15721. * Gets camera class name
  15722. * @returns StereoscopicGamepadCamera
  15723. */
  15724. StereoscopicGamepadCamera.prototype.getClassName = function () {
  15725. return "StereoscopicGamepadCamera";
  15726. };
  15727. return StereoscopicGamepadCamera;
  15728. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15729. /***/ }),
  15730. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  15731. /*!*************************************************************!*\
  15732. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  15733. \*************************************************************/
  15734. /*! exports provided: StereoscopicUniversalCamera */
  15735. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15736. "use strict";
  15737. __webpack_require__.r(__webpack_exports__);
  15738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  15739. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15740. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15741. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15742. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15743. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15744. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15745. // Side effect import to define the stereoscopic mode.
  15746. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15747. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15748. });
  15749. /**
  15750. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  15751. * @see http://doc.babylonjs.com/features/cameras
  15752. */
  15753. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  15754. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  15755. /**
  15756. * Creates a new StereoscopicUniversalCamera
  15757. * @param name defines camera name
  15758. * @param position defines initial position
  15759. * @param interaxialDistance defines distance between each color axis
  15760. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15761. * @param scene defines the hosting scene
  15762. */
  15763. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15764. var _this = _super.call(this, name, position, scene) || this;
  15765. _this.interaxialDistance = interaxialDistance;
  15766. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15767. _this.setCameraRigMode(isStereoscopicSideBySide ? _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER, { interaxialDistance: interaxialDistance });
  15768. return _this;
  15769. }
  15770. /**
  15771. * Gets camera class name
  15772. * @returns StereoscopicUniversalCamera
  15773. */
  15774. StereoscopicUniversalCamera.prototype.getClassName = function () {
  15775. return "StereoscopicUniversalCamera";
  15776. };
  15777. return StereoscopicUniversalCamera;
  15778. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15779. /***/ }),
  15780. /***/ "./Cameras/VR/index.ts":
  15781. /*!*****************************!*\
  15782. !*** ./Cameras/VR/index.ts ***!
  15783. \*****************************/
  15784. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera */
  15785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15786. "use strict";
  15787. __webpack_require__.r(__webpack_exports__);
  15788. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  15790. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  15791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  15792. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  15794. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  15795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  15796. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  15797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["OnAfterEnteringVRObservableEvent"]; });
  15798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  15799. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  15801. /***/ }),
  15802. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  15803. /*!***************************************!*\
  15804. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  15805. \***************************************/
  15806. /*! exports provided: VRCameraMetrics */
  15807. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15808. "use strict";
  15809. __webpack_require__.r(__webpack_exports__);
  15810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  15811. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15812. /**
  15813. * This represents all the required metrics to create a VR camera.
  15814. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  15815. */
  15816. var VRCameraMetrics = /** @class */ (function () {
  15817. function VRCameraMetrics() {
  15818. /**
  15819. * Define if the current vr camera should compensate the distortion of the lense or not.
  15820. */
  15821. this.compensateDistortion = true;
  15822. /**
  15823. * Defines if multiview should be enabled when rendering (Default: false)
  15824. */
  15825. this.multiviewEnabled = false;
  15826. }
  15827. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  15828. /**
  15829. * Gets the rendering aspect ratio based on the provided resolutions.
  15830. */
  15831. get: function () {
  15832. return this.hResolution / (2 * this.vResolution);
  15833. },
  15834. enumerable: true,
  15835. configurable: true
  15836. });
  15837. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  15838. /**
  15839. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  15840. */
  15841. get: function () {
  15842. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  15843. },
  15844. enumerable: true,
  15845. configurable: true
  15846. });
  15847. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  15848. /**
  15849. * @hidden
  15850. */
  15851. get: function () {
  15852. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15853. var h = (4 * meters) / this.hScreenSize;
  15854. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  15855. },
  15856. enumerable: true,
  15857. configurable: true
  15858. });
  15859. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  15860. /**
  15861. * @hidden
  15862. */
  15863. get: function () {
  15864. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15865. var h = (4 * meters) / this.hScreenSize;
  15866. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  15867. },
  15868. enumerable: true,
  15869. configurable: true
  15870. });
  15871. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  15872. /**
  15873. * @hidden
  15874. */
  15875. get: function () {
  15876. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  15877. },
  15878. enumerable: true,
  15879. configurable: true
  15880. });
  15881. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  15882. /**
  15883. * @hidden
  15884. */
  15885. get: function () {
  15886. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  15887. },
  15888. enumerable: true,
  15889. configurable: true
  15890. });
  15891. /**
  15892. * Get the default VRMetrics based on the most generic setup.
  15893. * @returns the default vr metrics
  15894. */
  15895. VRCameraMetrics.GetDefault = function () {
  15896. var result = new VRCameraMetrics();
  15897. result.hResolution = 1280;
  15898. result.vResolution = 800;
  15899. result.hScreenSize = 0.149759993;
  15900. result.vScreenSize = 0.0935999975;
  15901. result.vScreenCenter = 0.0467999987;
  15902. result.eyeToScreenDistance = 0.0410000011;
  15903. result.lensSeparationDistance = 0.0635000020;
  15904. result.interpupillaryDistance = 0.0640000030;
  15905. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  15906. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  15907. result.postProcessScaleFactor = 1.714605507808412;
  15908. result.lensCenterOffset = 0.151976421;
  15909. return result;
  15910. };
  15911. return VRCameraMetrics;
  15912. }());
  15913. /***/ }),
  15914. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  15915. /*!**********************************************************!*\
  15916. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  15917. \**********************************************************/
  15918. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  15919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15920. "use strict";
  15921. __webpack_require__.r(__webpack_exports__);
  15922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  15923. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15924. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15925. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15926. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15927. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15928. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15929. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15930. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15931. // Side effect import to define the stereoscopic mode.
  15932. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15933. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15934. });
  15935. /**
  15936. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  15937. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15938. */
  15939. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  15940. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  15941. /**
  15942. * Creates a new VRDeviceOrientationArcRotateCamera
  15943. * @param name defines camera name
  15944. * @param alpha defines the camera rotation along the logitudinal axis
  15945. * @param beta defines the camera rotation along the latitudinal axis
  15946. * @param radius defines the camera distance from its target
  15947. * @param target defines the camera target
  15948. * @param scene defines the scene the camera belongs to
  15949. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15950. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15951. */
  15952. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  15953. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15954. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15955. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15956. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15957. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15958. _this.inputs.addVRDeviceOrientation();
  15959. return _this;
  15960. }
  15961. /**
  15962. * Gets camera class name
  15963. * @returns VRDeviceOrientationArcRotateCamera
  15964. */
  15965. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  15966. return "VRDeviceOrientationArcRotateCamera";
  15967. };
  15968. return VRDeviceOrientationArcRotateCamera;
  15969. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15970. /***/ }),
  15971. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  15972. /*!*****************************************************!*\
  15973. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  15974. \*****************************************************/
  15975. /*! exports provided: VRDeviceOrientationFreeCamera */
  15976. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15977. "use strict";
  15978. __webpack_require__.r(__webpack_exports__);
  15979. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  15980. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15981. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15982. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15983. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15984. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15985. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15986. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15987. // Side effect import to define the stereoscopic mode.
  15988. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15989. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15990. });
  15991. /**
  15992. * Camera used to simulate VR rendering (based on FreeCamera)
  15993. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15994. */
  15995. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  15996. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  15997. /**
  15998. * Creates a new VRDeviceOrientationFreeCamera
  15999. * @param name defines camera name
  16000. * @param position defines the start position of the camera
  16001. * @param scene defines the scene the camera belongs to
  16002. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  16003. * @param vrCameraMetrics defines the vr metrics associated to the camera
  16004. */
  16005. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  16006. if (compensateDistortion === void 0) { compensateDistortion = true; }
  16007. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  16008. var _this = _super.call(this, name, position, scene) || this;
  16009. vrCameraMetrics.compensateDistortion = compensateDistortion;
  16010. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  16011. return _this;
  16012. }
  16013. /**
  16014. * Gets camera class name
  16015. * @returns VRDeviceOrientationFreeCamera
  16016. */
  16017. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  16018. return "VRDeviceOrientationFreeCamera";
  16019. };
  16020. return VRDeviceOrientationFreeCamera;
  16021. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  16022. /***/ }),
  16023. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  16024. /*!********************************************************!*\
  16025. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  16026. \********************************************************/
  16027. /*! exports provided: VRDeviceOrientationGamepadCamera */
  16028. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16029. "use strict";
  16030. __webpack_require__.r(__webpack_exports__);
  16031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  16032. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16033. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  16034. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  16035. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  16036. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  16037. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  16038. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  16039. });
  16040. /**
  16041. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  16042. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  16043. */
  16044. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  16045. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  16046. /**
  16047. * Creates a new VRDeviceOrientationGamepadCamera
  16048. * @param name defines camera name
  16049. * @param position defines the start position of the camera
  16050. * @param scene defines the scene the camera belongs to
  16051. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  16052. * @param vrCameraMetrics defines the vr metrics associated to the camera
  16053. */
  16054. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  16055. if (compensateDistortion === void 0) { compensateDistortion = true; }
  16056. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  16057. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  16058. _this.inputs.addGamepad();
  16059. return _this;
  16060. }
  16061. /**
  16062. * Gets camera class name
  16063. * @returns VRDeviceOrientationGamepadCamera
  16064. */
  16065. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  16066. return "VRDeviceOrientationGamepadCamera";
  16067. };
  16068. return VRDeviceOrientationGamepadCamera;
  16069. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  16070. /***/ }),
  16071. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  16072. /*!******************************************!*\
  16073. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  16074. \******************************************/
  16075. /*! exports provided: OnAfterEnteringVRObservableEvent, VRExperienceHelper */
  16076. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16077. "use strict";
  16078. __webpack_require__.r(__webpack_exports__);
  16079. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return OnAfterEnteringVRObservableEvent; });
  16080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  16081. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16082. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  16083. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  16084. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  16085. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  16086. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  16087. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  16088. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  16089. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  16090. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  16091. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  16092. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  16093. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  16094. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  16095. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  16096. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  16097. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  16098. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  16099. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  16100. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  16101. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  16102. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  16103. /* harmony import */ var _Cameras_VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Cameras/VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  16104. /* harmony import */ var _Meshes_Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Meshes/Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  16105. /* harmony import */ var _Meshes_Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Meshes/Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  16106. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  16107. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  16108. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ../../Animations/animatable */ "./Animations/animatable.ts");
  16109. var VRExperienceHelperGazer = /** @class */ (function () {
  16110. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  16111. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  16112. this.scene = scene;
  16113. /** @hidden */
  16114. this._pointerDownOnMeshAsked = false;
  16115. /** @hidden */
  16116. this._isActionableMesh = false;
  16117. /** @hidden */
  16118. this._teleportationRequestInitiated = false;
  16119. /** @hidden */
  16120. this._teleportationBackRequestInitiated = false;
  16121. /** @hidden */
  16122. this._rotationRightAsked = false;
  16123. /** @hidden */
  16124. this._rotationLeftAsked = false;
  16125. /** @hidden */
  16126. this._dpadPressed = true;
  16127. /** @hidden */
  16128. this._activePointer = false;
  16129. this._id = VRExperienceHelperGazer._idCounter++;
  16130. // Gaze tracker
  16131. if (!gazeTrackerToClone) {
  16132. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  16133. this._gazeTracker.bakeCurrentTransformIntoVertices();
  16134. this._gazeTracker.isPickable = false;
  16135. this._gazeTracker.isVisible = false;
  16136. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  16137. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  16138. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16139. targetMat.backFaceCulling = false;
  16140. this._gazeTracker.material = targetMat;
  16141. }
  16142. else {
  16143. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  16144. }
  16145. }
  16146. /** @hidden */
  16147. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  16148. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero(), new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, length));
  16149. };
  16150. /** @hidden */
  16151. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  16152. this._pointerDownOnMeshAsked = true;
  16153. if (this._currentHit) {
  16154. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  16155. }
  16156. };
  16157. /** @hidden */
  16158. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  16159. if (this._currentHit) {
  16160. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  16161. }
  16162. this._pointerDownOnMeshAsked = false;
  16163. };
  16164. /** @hidden */
  16165. VRExperienceHelperGazer.prototype._activatePointer = function () {
  16166. this._activePointer = true;
  16167. };
  16168. /** @hidden */
  16169. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  16170. this._activePointer = false;
  16171. };
  16172. /** @hidden */
  16173. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  16174. if (distance === void 0) { distance = 100; }
  16175. };
  16176. VRExperienceHelperGazer.prototype.dispose = function () {
  16177. this._interactionsEnabled = false;
  16178. this._teleportationEnabled = false;
  16179. if (this._gazeTracker) {
  16180. this._gazeTracker.dispose();
  16181. }
  16182. };
  16183. VRExperienceHelperGazer._idCounter = 0;
  16184. return VRExperienceHelperGazer;
  16185. }());
  16186. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  16187. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  16188. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  16189. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  16190. _this.webVRController = webVRController;
  16191. // Laser pointer
  16192. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  16193. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  16194. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16195. laserPointerMaterial.alpha = 0.6;
  16196. _this._laserPointer.material = laserPointerMaterial;
  16197. _this._laserPointer.rotation.x = Math.PI / 2;
  16198. _this._laserPointer.position.z = -0.5;
  16199. _this._laserPointer.isVisible = false;
  16200. _this._laserPointer.isPickable = false;
  16201. if (!webVRController.mesh) {
  16202. // Create an empty mesh that is used prior to loading the high quality model
  16203. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  16204. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  16205. preloadPointerPose.rotation.x = -0.7;
  16206. preloadMesh.addChild(preloadPointerPose);
  16207. webVRController.attachToMesh(preloadMesh);
  16208. }
  16209. _this._setLaserPointerParent(webVRController.mesh);
  16210. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  16211. _this._setLaserPointerParent(mesh);
  16212. });
  16213. return _this;
  16214. }
  16215. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  16216. return this.webVRController.getForwardRay(length);
  16217. };
  16218. /** @hidden */
  16219. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  16220. _super.prototype._activatePointer.call(this);
  16221. this._laserPointer.isVisible = true;
  16222. };
  16223. /** @hidden */
  16224. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  16225. _super.prototype._deactivatePointer.call(this);
  16226. this._laserPointer.isVisible = false;
  16227. };
  16228. /** @hidden */
  16229. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  16230. this._laserPointer.material.emissiveColor = color;
  16231. };
  16232. /** @hidden */
  16233. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  16234. var makeNotPick = function (root) {
  16235. root.isPickable = false;
  16236. root.getChildMeshes().forEach(function (c) {
  16237. makeNotPick(c);
  16238. });
  16239. };
  16240. makeNotPick(mesh);
  16241. var meshChildren = mesh.getChildren(undefined, false);
  16242. var laserParent = mesh;
  16243. this.webVRController._pointingPoseNode = null;
  16244. for (var i = 0; i < meshChildren.length; i++) {
  16245. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  16246. laserParent = meshChildren[i];
  16247. this.webVRController._pointingPoseNode = laserParent;
  16248. break;
  16249. }
  16250. }
  16251. this._laserPointer.parent = laserParent;
  16252. };
  16253. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  16254. if (distance === void 0) { distance = 100; }
  16255. this._laserPointer.scaling.y = distance;
  16256. this._laserPointer.position.z = -distance / 2;
  16257. };
  16258. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  16259. _super.prototype.dispose.call(this);
  16260. this._laserPointer.dispose();
  16261. if (this._meshAttachedObserver) {
  16262. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  16263. }
  16264. };
  16265. return VRExperienceHelperControllerGazer;
  16266. }(VRExperienceHelperGazer));
  16267. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  16268. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  16269. function VRExperienceHelperCameraGazer(getCamera, scene) {
  16270. var _this = _super.call(this, scene) || this;
  16271. _this.getCamera = getCamera;
  16272. return _this;
  16273. }
  16274. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  16275. var camera = this.getCamera();
  16276. if (camera) {
  16277. return camera.getForwardRay(length);
  16278. }
  16279. else {
  16280. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Forward());
  16281. }
  16282. };
  16283. return VRExperienceHelperCameraGazer;
  16284. }(VRExperienceHelperGazer));
  16285. /**
  16286. * Event containing information after VR has been entered
  16287. */
  16288. var OnAfterEnteringVRObservableEvent = /** @class */ (function () {
  16289. function OnAfterEnteringVRObservableEvent() {
  16290. }
  16291. return OnAfterEnteringVRObservableEvent;
  16292. }());
  16293. /**
  16294. * Helps to quickly add VR support to an existing scene.
  16295. * See http://doc.babylonjs.com/how_to/webvr_helper
  16296. */
  16297. var VRExperienceHelper = /** @class */ (function () {
  16298. /**
  16299. * Instantiates a VRExperienceHelper.
  16300. * Helps to quickly add VR support to an existing scene.
  16301. * @param scene The scene the VRExperienceHelper belongs to.
  16302. * @param webVROptions Options to modify the vr experience helper's behavior.
  16303. */
  16304. function VRExperienceHelper(scene,
  16305. /** Options to modify the vr experience helper's behavior. */
  16306. webVROptions) {
  16307. if (webVROptions === void 0) { webVROptions = {}; }
  16308. var _this = this;
  16309. this.webVROptions = webVROptions;
  16310. // Can the system support WebVR, even if a headset isn't plugged in?
  16311. this._webVRsupported = false;
  16312. // If WebVR is supported, is a headset plugged in and are we ready to present?
  16313. this._webVRready = false;
  16314. // Are we waiting for the requestPresent callback to complete?
  16315. this._webVRrequesting = false;
  16316. // Are we presenting to the headset right now? (this is the vrDevice state)
  16317. this._webVRpresenting = false;
  16318. // Are we presenting in the fullscreen fallback?
  16319. this._fullscreenVRpresenting = false;
  16320. /**
  16321. * Observable raised right before entering VR.
  16322. */
  16323. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16324. /**
  16325. * Observable raised when entering VR has completed.
  16326. */
  16327. this.onAfterEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16328. /**
  16329. * Observable raised when exiting VR.
  16330. */
  16331. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16332. /**
  16333. * Observable raised when controller mesh is loaded.
  16334. */
  16335. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16336. this._useCustomVRButton = false;
  16337. this._teleportationRequested = false;
  16338. this._teleportActive = false;
  16339. this._floorMeshesCollection = [];
  16340. this._rotationAllowed = true;
  16341. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  16342. this._isDefaultTeleportationTarget = true;
  16343. this._teleportationFillColor = "#444444";
  16344. this._teleportationBorderColor = "#FFFFFF";
  16345. this._rotationAngle = 0;
  16346. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  16347. this._padSensibilityUp = 0.65;
  16348. this._padSensibilityDown = 0.35;
  16349. this._leftController = null;
  16350. this._rightController = null;
  16351. /**
  16352. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  16353. */
  16354. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16355. /**
  16356. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  16357. */
  16358. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16359. /**
  16360. * Observable raised before camera teleportation
  16361. */
  16362. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16363. /**
  16364. * Observable raised after camera teleportation
  16365. */
  16366. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16367. /**
  16368. * Observable raised when current selected mesh gets unselected
  16369. */
  16370. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16371. /**
  16372. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  16373. */
  16374. this.teleportationEnabled = true;
  16375. this._teleportationInitialized = false;
  16376. this._interactionsEnabled = false;
  16377. this._interactionsRequested = false;
  16378. this._displayGaze = true;
  16379. this._displayLaserPointer = true;
  16380. /**
  16381. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  16382. */
  16383. this.updateGazeTrackerScale = true;
  16384. /**
  16385. * If the gaze trackers color should be updated when selecting meshes
  16386. */
  16387. this.updateGazeTrackerColor = true;
  16388. /**
  16389. * Defines wether or not Pointer lock should be requested when switching to
  16390. * full screen.
  16391. */
  16392. this.requestPointerLockOnFullScreen = true;
  16393. this._onResize = function () {
  16394. _this.moveButtonToBottomRight();
  16395. if (_this._fullscreenVRpresenting && _this._webVRready) {
  16396. _this.exitVR();
  16397. }
  16398. };
  16399. this._onFullscreenChange = function () {
  16400. var anyDoc = document;
  16401. if (anyDoc.fullscreen !== undefined) {
  16402. _this._fullscreenVRpresenting = document.fullscreen;
  16403. }
  16404. else if (anyDoc.mozFullScreen !== undefined) {
  16405. _this._fullscreenVRpresenting = anyDoc.mozFullScreen;
  16406. }
  16407. else if (anyDoc.webkitIsFullScreen !== undefined) {
  16408. _this._fullscreenVRpresenting = anyDoc.webkitIsFullScreen;
  16409. }
  16410. else if (anyDoc.msIsFullScreen !== undefined) {
  16411. _this._fullscreenVRpresenting = anyDoc.msIsFullScreen;
  16412. }
  16413. else if (document.msFullscreenElement !== undefined) {
  16414. _this._fullscreenVRpresenting = document.msFullscreenElement;
  16415. }
  16416. if (!_this._fullscreenVRpresenting && _this._canvas) {
  16417. _this.exitVR();
  16418. if (!_this._useCustomVRButton) {
  16419. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  16420. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  16421. }
  16422. }
  16423. };
  16424. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  16425. this.beforeRender = function () {
  16426. if (_this._leftController && _this._leftController._activePointer) {
  16427. _this._castRayAndSelectObject(_this._leftController);
  16428. }
  16429. if (_this._rightController && _this._rightController._activePointer) {
  16430. _this._castRayAndSelectObject(_this._rightController);
  16431. }
  16432. if (_this._noControllerIsActive) {
  16433. _this._castRayAndSelectObject(_this._cameraGazer);
  16434. }
  16435. else {
  16436. _this._cameraGazer._gazeTracker.isVisible = false;
  16437. }
  16438. };
  16439. this._onNewGamepadConnected = function (gamepad) {
  16440. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  16441. if (gamepad.leftStick) {
  16442. gamepad.onleftstickchanged(function (stickValues) {
  16443. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  16444. // Listening to classic/xbox gamepad only if no VR controller is active
  16445. if ((!_this._leftController && !_this._rightController) ||
  16446. ((_this._leftController && !_this._leftController._activePointer) &&
  16447. (_this._rightController && !_this._rightController._activePointer))) {
  16448. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  16449. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  16450. }
  16451. }
  16452. });
  16453. }
  16454. if (gamepad.rightStick) {
  16455. gamepad.onrightstickchanged(function (stickValues) {
  16456. if (_this._teleportationInitialized) {
  16457. _this._checkRotate(stickValues, _this._cameraGazer);
  16458. }
  16459. });
  16460. }
  16461. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  16462. gamepad.onbuttondown(function (buttonPressed) {
  16463. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16464. _this._cameraGazer._selectionPointerDown();
  16465. }
  16466. });
  16467. gamepad.onbuttonup(function (buttonPressed) {
  16468. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16469. _this._cameraGazer._selectionPointerUp();
  16470. }
  16471. });
  16472. }
  16473. }
  16474. else {
  16475. var webVRController = gamepad;
  16476. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  16477. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  16478. _this._rightController = controller;
  16479. }
  16480. else {
  16481. _this._leftController = controller;
  16482. }
  16483. _this._tryEnableInteractionOnController(controller);
  16484. }
  16485. };
  16486. // This only succeeds if the controller's mesh exists for the controller so this must be called whenever new controller is connected or when mesh is loaded
  16487. this._tryEnableInteractionOnController = function (controller) {
  16488. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  16489. _this._enableInteractionOnController(controller);
  16490. }
  16491. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  16492. _this._enableTeleportationOnController(controller);
  16493. }
  16494. };
  16495. this._onNewGamepadDisconnected = function (gamepad) {
  16496. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  16497. if (gamepad.hand === "left" && _this._leftController != null) {
  16498. _this._leftController.dispose();
  16499. _this._leftController = null;
  16500. }
  16501. if (gamepad.hand === "right" && _this._rightController != null) {
  16502. _this._rightController.dispose();
  16503. _this._rightController = null;
  16504. }
  16505. }
  16506. };
  16507. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  16508. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  16509. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  16510. this._scene = scene;
  16511. this._canvas = scene.getEngine().getRenderingCanvas();
  16512. // Parse options
  16513. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  16514. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  16515. }
  16516. if (webVROptions.createDeviceOrientationCamera === undefined) {
  16517. webVROptions.createDeviceOrientationCamera = true;
  16518. }
  16519. if (webVROptions.laserToggle === undefined) {
  16520. webVROptions.laserToggle = true;
  16521. }
  16522. if (webVROptions.defaultHeight === undefined) {
  16523. webVROptions.defaultHeight = 1.7;
  16524. }
  16525. if (webVROptions.useCustomVRButton) {
  16526. this._useCustomVRButton = true;
  16527. if (webVROptions.customVRButton) {
  16528. this._btnVR = webVROptions.customVRButton;
  16529. }
  16530. }
  16531. if (webVROptions.rayLength) {
  16532. this._rayLength = webVROptions.rayLength;
  16533. }
  16534. this._defaultHeight = webVROptions.defaultHeight;
  16535. if (webVROptions.positionScale) {
  16536. this._rayLength *= webVROptions.positionScale;
  16537. this._defaultHeight *= webVROptions.positionScale;
  16538. }
  16539. this._hasEnteredVR = false;
  16540. // Set position
  16541. if (this._scene.activeCamera) {
  16542. this._position = this._scene.activeCamera.position.clone();
  16543. }
  16544. else {
  16545. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  16546. }
  16547. // Set non-vr camera
  16548. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  16549. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  16550. // Copy data from existing camera
  16551. if (this._scene.activeCamera) {
  16552. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16553. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  16554. // Set rotation from previous camera
  16555. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  16556. var targetCamera = this._scene.activeCamera;
  16557. if (targetCamera.rotationQuaternion) {
  16558. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  16559. }
  16560. else {
  16561. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  16562. }
  16563. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  16564. }
  16565. }
  16566. this._scene.activeCamera = this._deviceOrientationCamera;
  16567. if (this._canvas) {
  16568. this._scene.activeCamera.attachControl(this._canvas);
  16569. }
  16570. }
  16571. else {
  16572. this._existingCamera = this._scene.activeCamera;
  16573. }
  16574. // Create VR cameras
  16575. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16576. if (webVROptions.useMultiview) {
  16577. if (!webVROptions.vrDeviceOrientationCameraMetrics) {
  16578. webVROptions.vrDeviceOrientationCameraMetrics = _Cameras_VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_22__["VRCameraMetrics"].GetDefault();
  16579. }
  16580. webVROptions.vrDeviceOrientationCameraMetrics.multiviewEnabled = true;
  16581. }
  16582. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene, true, webVROptions.vrDeviceOrientationCameraMetrics);
  16583. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16584. }
  16585. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  16586. this._webVRCamera.useStandingMatrix();
  16587. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  16588. // Create default button
  16589. if (!this._useCustomVRButton) {
  16590. this._btnVR = document.createElement("BUTTON");
  16591. this._btnVR.className = "babylonVRicon";
  16592. this._btnVR.id = "babylonVRiconbtn";
  16593. this._btnVR.title = "Click to switch to VR";
  16594. var css = ".babylonVRicon { position: absolute; right: 20px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(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) }";
  16595. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  16596. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  16597. // css += ".babylonVRicon.vrdisplaysupported { }";
  16598. // css += ".babylonVRicon.vrdisplayready { }";
  16599. // css += ".babylonVRicon.vrdisplayrequesting { }";
  16600. var style = document.createElement('style');
  16601. style.appendChild(document.createTextNode(css));
  16602. document.getElementsByTagName('head')[0].appendChild(style);
  16603. this.moveButtonToBottomRight();
  16604. }
  16605. // VR button click event
  16606. if (this._btnVR) {
  16607. this._btnVR.addEventListener("click", function () {
  16608. if (!_this.isInVRMode) {
  16609. _this.enterVR();
  16610. }
  16611. else {
  16612. _this.exitVR();
  16613. }
  16614. });
  16615. }
  16616. // Window events
  16617. window.addEventListener("resize", this._onResize);
  16618. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  16619. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  16620. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  16621. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  16622. document.onmsfullscreenchange = this._onFullscreenChange;
  16623. // Display vr button when headset is connected
  16624. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16625. this.displayVRButton();
  16626. }
  16627. else {
  16628. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  16629. if (e.vrDisplay) {
  16630. _this.displayVRButton();
  16631. }
  16632. });
  16633. }
  16634. // Exiting VR mode using 'ESC' key on desktop
  16635. this._onKeyDown = function (event) {
  16636. if (event.keyCode === 27 && _this.isInVRMode) {
  16637. _this.exitVR();
  16638. }
  16639. };
  16640. document.addEventListener("keydown", this._onKeyDown);
  16641. // Exiting VR mode double tapping the touch screen
  16642. this._scene.onPrePointerObservable.add(function () {
  16643. if (_this.isInVRMode) {
  16644. _this.exitVR();
  16645. if (_this._fullscreenVRpresenting) {
  16646. _this._scene.getEngine().exitFullscreen();
  16647. }
  16648. }
  16649. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  16650. // Listen for WebVR display changes
  16651. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  16652. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  16653. this._onVRRequestPresentStart = function () {
  16654. _this._webVRrequesting = true;
  16655. _this.updateButtonVisibility();
  16656. };
  16657. this._onVRRequestPresentComplete = function () {
  16658. _this._webVRrequesting = false;
  16659. _this.updateButtonVisibility();
  16660. };
  16661. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  16662. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  16663. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  16664. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16665. scene.onDisposeObservable.add(function () {
  16666. _this.dispose();
  16667. });
  16668. // Gamepad connection events
  16669. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  16670. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  16671. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  16672. this.updateButtonVisibility();
  16673. //create easing functions
  16674. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  16675. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16676. if (this.webVROptions.floorMeshes) {
  16677. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  16678. }
  16679. }
  16680. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  16681. /** Return this.onEnteringVRObservable
  16682. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  16683. */
  16684. get: function () {
  16685. return this.onEnteringVRObservable;
  16686. },
  16687. enumerable: true,
  16688. configurable: true
  16689. });
  16690. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  16691. /** Return this.onExitingVRObservable
  16692. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  16693. */
  16694. get: function () {
  16695. return this.onExitingVRObservable;
  16696. },
  16697. enumerable: true,
  16698. configurable: true
  16699. });
  16700. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  16701. /** Return this.onControllerMeshLoadedObservable
  16702. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  16703. */
  16704. get: function () {
  16705. return this.onControllerMeshLoadedObservable;
  16706. },
  16707. enumerable: true,
  16708. configurable: true
  16709. });
  16710. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  16711. /**
  16712. * The mesh used to display where the user is going to teleport.
  16713. */
  16714. get: function () {
  16715. return this._teleportationTarget;
  16716. },
  16717. /**
  16718. * Sets the mesh to be used to display where the user is going to teleport.
  16719. */
  16720. set: function (value) {
  16721. if (value) {
  16722. value.name = "teleportationTarget";
  16723. this._isDefaultTeleportationTarget = false;
  16724. this._teleportationTarget = value;
  16725. }
  16726. },
  16727. enumerable: true,
  16728. configurable: true
  16729. });
  16730. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  16731. /**
  16732. * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
  16733. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  16734. * See http://doc.babylonjs.com/resources/baking_transformations
  16735. */
  16736. get: function () {
  16737. return this._cameraGazer._gazeTracker;
  16738. },
  16739. set: function (value) {
  16740. if (value) {
  16741. // Dispose of existing meshes
  16742. if (this._cameraGazer._gazeTracker) {
  16743. this._cameraGazer._gazeTracker.dispose();
  16744. }
  16745. if (this._leftController && this._leftController._gazeTracker) {
  16746. this._leftController._gazeTracker.dispose();
  16747. }
  16748. if (this._rightController && this._rightController._gazeTracker) {
  16749. this._rightController._gazeTracker.dispose();
  16750. }
  16751. // Set and create gaze trackers on head and controllers
  16752. this._cameraGazer._gazeTracker = value;
  16753. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  16754. this._cameraGazer._gazeTracker.isPickable = false;
  16755. this._cameraGazer._gazeTracker.isVisible = false;
  16756. this._cameraGazer._gazeTracker.name = "gazeTracker";
  16757. if (this._leftController) {
  16758. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16759. }
  16760. if (this._rightController) {
  16761. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16762. }
  16763. }
  16764. },
  16765. enumerable: true,
  16766. configurable: true
  16767. });
  16768. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  16769. /**
  16770. * The gaze tracking mesh corresponding to the left controller
  16771. */
  16772. get: function () {
  16773. if (this._leftController) {
  16774. return this._leftController._gazeTracker;
  16775. }
  16776. return null;
  16777. },
  16778. enumerable: true,
  16779. configurable: true
  16780. });
  16781. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  16782. /**
  16783. * The gaze tracking mesh corresponding to the right controller
  16784. */
  16785. get: function () {
  16786. if (this._rightController) {
  16787. return this._rightController._gazeTracker;
  16788. }
  16789. return null;
  16790. },
  16791. enumerable: true,
  16792. configurable: true
  16793. });
  16794. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  16795. /**
  16796. * If the ray of the gaze should be displayed.
  16797. */
  16798. get: function () {
  16799. return this._displayGaze;
  16800. },
  16801. /**
  16802. * Sets if the ray of the gaze should be displayed.
  16803. */
  16804. set: function (value) {
  16805. this._displayGaze = value;
  16806. if (!value) {
  16807. this._cameraGazer._gazeTracker.isVisible = false;
  16808. if (this._leftController) {
  16809. this._leftController._gazeTracker.isVisible = false;
  16810. }
  16811. if (this._rightController) {
  16812. this._rightController._gazeTracker.isVisible = false;
  16813. }
  16814. }
  16815. },
  16816. enumerable: true,
  16817. configurable: true
  16818. });
  16819. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  16820. /**
  16821. * If the ray of the LaserPointer should be displayed.
  16822. */
  16823. get: function () {
  16824. return this._displayLaserPointer;
  16825. },
  16826. /**
  16827. * Sets if the ray of the LaserPointer should be displayed.
  16828. */
  16829. set: function (value) {
  16830. this._displayLaserPointer = value;
  16831. if (!value) {
  16832. if (this._rightController) {
  16833. this._rightController._deactivatePointer();
  16834. this._rightController._gazeTracker.isVisible = false;
  16835. }
  16836. if (this._leftController) {
  16837. this._leftController._deactivatePointer();
  16838. this._leftController._gazeTracker.isVisible = false;
  16839. }
  16840. }
  16841. else {
  16842. if (this._rightController) {
  16843. this._rightController._activatePointer();
  16844. }
  16845. if (this._leftController) {
  16846. this._leftController._activatePointer();
  16847. }
  16848. }
  16849. },
  16850. enumerable: true,
  16851. configurable: true
  16852. });
  16853. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  16854. /**
  16855. * The deviceOrientationCamera used as the camera when not in VR.
  16856. */
  16857. get: function () {
  16858. return this._deviceOrientationCamera;
  16859. },
  16860. enumerable: true,
  16861. configurable: true
  16862. });
  16863. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  16864. /**
  16865. * Based on the current WebVR support, returns the current VR camera used.
  16866. */
  16867. get: function () {
  16868. if (this._webVRready) {
  16869. return this._webVRCamera;
  16870. }
  16871. else {
  16872. return this._scene.activeCamera;
  16873. }
  16874. },
  16875. enumerable: true,
  16876. configurable: true
  16877. });
  16878. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  16879. /**
  16880. * The webVRCamera which is used when in VR.
  16881. */
  16882. get: function () {
  16883. return this._webVRCamera;
  16884. },
  16885. enumerable: true,
  16886. configurable: true
  16887. });
  16888. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  16889. /**
  16890. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  16891. */
  16892. get: function () {
  16893. return this._vrDeviceOrientationCamera;
  16894. },
  16895. enumerable: true,
  16896. configurable: true
  16897. });
  16898. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  16899. get: function () {
  16900. var result = this._cameraGazer._teleportationRequestInitiated
  16901. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  16902. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  16903. return result;
  16904. },
  16905. enumerable: true,
  16906. configurable: true
  16907. });
  16908. // Raised when one of the controller has loaded successfully its associated default mesh
  16909. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  16910. if (this._leftController && this._leftController.webVRController == webVRController) {
  16911. if (webVRController.mesh) {
  16912. this._leftController._setLaserPointerParent(webVRController.mesh);
  16913. }
  16914. }
  16915. if (this._rightController && this._rightController.webVRController == webVRController) {
  16916. if (webVRController.mesh) {
  16917. this._rightController._setLaserPointerParent(webVRController.mesh);
  16918. }
  16919. }
  16920. try {
  16921. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  16922. }
  16923. catch (err) {
  16924. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  16925. }
  16926. };
  16927. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  16928. /**
  16929. * Gets a value indicating if we are currently in VR mode.
  16930. */
  16931. get: function () {
  16932. return this._webVRpresenting || this._fullscreenVRpresenting;
  16933. },
  16934. enumerable: true,
  16935. configurable: true
  16936. });
  16937. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  16938. var vrDisplay = this._scene.getEngine().getVRDevice();
  16939. if (vrDisplay) {
  16940. var wasPresenting = this._webVRpresenting;
  16941. this._webVRpresenting = vrDisplay.isPresenting;
  16942. if (wasPresenting && !this._webVRpresenting) {
  16943. this.exitVR();
  16944. }
  16945. }
  16946. else {
  16947. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  16948. }
  16949. this.updateButtonVisibility();
  16950. };
  16951. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  16952. this._webVRsupported = eventArgs.vrSupported;
  16953. this._webVRready = !!eventArgs.vrDisplay;
  16954. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  16955. this.updateButtonVisibility();
  16956. };
  16957. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  16958. if (this._canvas && !this._useCustomVRButton) {
  16959. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  16960. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  16961. }
  16962. };
  16963. VRExperienceHelper.prototype.displayVRButton = function () {
  16964. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  16965. document.body.appendChild(this._btnVR);
  16966. this._btnVRDisplayed = true;
  16967. }
  16968. };
  16969. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  16970. if (!this._btnVR || this._useCustomVRButton) {
  16971. return;
  16972. }
  16973. this._btnVR.className = "babylonVRicon";
  16974. if (this.isInVRMode) {
  16975. this._btnVR.className += " vrdisplaypresenting";
  16976. }
  16977. else {
  16978. if (this._webVRready) {
  16979. this._btnVR.className += " vrdisplayready";
  16980. }
  16981. if (this._webVRsupported) {
  16982. this._btnVR.className += " vrdisplaysupported";
  16983. }
  16984. if (this._webVRrequesting) {
  16985. this._btnVR.className += " vrdisplayrequesting";
  16986. }
  16987. }
  16988. };
  16989. /**
  16990. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  16991. * Otherwise, will use the fullscreen API.
  16992. */
  16993. VRExperienceHelper.prototype.enterVR = function () {
  16994. var _this = this;
  16995. if (this.onEnteringVRObservable) {
  16996. try {
  16997. this.onEnteringVRObservable.notifyObservers(this);
  16998. }
  16999. catch (err) {
  17000. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  17001. }
  17002. }
  17003. if (this._scene.activeCamera) {
  17004. this._position = this._scene.activeCamera.position.clone();
  17005. if (this.vrDeviceOrientationCamera) {
  17006. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  17007. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  17008. }
  17009. if (this.webVRCamera) {
  17010. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  17011. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  17012. var delta = desiredYRotation - currentYRotation;
  17013. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  17014. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  17015. }
  17016. // make sure that we return to the last active camera
  17017. this._existingCamera = this._scene.activeCamera;
  17018. // Remove and cache angular sensability to avoid camera rotation when in VR
  17019. if (this._existingCamera.angularSensibilityX) {
  17020. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  17021. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  17022. }
  17023. if (this._existingCamera.angularSensibilityY) {
  17024. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  17025. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  17026. }
  17027. if (this._existingCamera.angularSensibility) {
  17028. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  17029. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  17030. }
  17031. }
  17032. if (this._webVRrequesting) {
  17033. return;
  17034. }
  17035. // If WebVR is supported and a headset is connected
  17036. if (this._webVRready) {
  17037. if (!this._webVRpresenting) {
  17038. this._scene.getEngine().onVRRequestPresentComplete.addOnce(function (result) {
  17039. _this.onAfterEnteringVRObservable.notifyObservers({ success: result });
  17040. });
  17041. this._webVRCamera.position = this._position;
  17042. this._scene.activeCamera = this._webVRCamera;
  17043. }
  17044. }
  17045. else if (this._vrDeviceOrientationCamera) {
  17046. this._vrDeviceOrientationCamera.position = this._position;
  17047. if (this._scene.activeCamera) {
  17048. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  17049. }
  17050. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  17051. this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen);
  17052. this.updateButtonVisibility();
  17053. this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce(function () {
  17054. _this.onAfterEnteringVRObservable.notifyObservers({ success: true });
  17055. });
  17056. }
  17057. if (this._scene.activeCamera && this._canvas) {
  17058. this._scene.activeCamera.attachControl(this._canvas);
  17059. }
  17060. if (this._interactionsEnabled) {
  17061. this._scene.registerBeforeRender(this.beforeRender);
  17062. }
  17063. if (this._displayLaserPointer) {
  17064. [this._leftController, this._rightController].forEach(function (controller) {
  17065. if (controller) {
  17066. controller._activatePointer();
  17067. }
  17068. });
  17069. }
  17070. this._hasEnteredVR = true;
  17071. };
  17072. /**
  17073. * Attempt to exit VR, or fullscreen.
  17074. */
  17075. VRExperienceHelper.prototype.exitVR = function () {
  17076. if (this._hasEnteredVR) {
  17077. if (this.onExitingVRObservable) {
  17078. try {
  17079. this.onExitingVRObservable.notifyObservers(this);
  17080. }
  17081. catch (err) {
  17082. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  17083. }
  17084. }
  17085. if (this._webVRpresenting) {
  17086. this._scene.getEngine().disableVR();
  17087. }
  17088. if (this._scene.activeCamera) {
  17089. this._position = this._scene.activeCamera.position.clone();
  17090. }
  17091. if (this.vrDeviceOrientationCamera) {
  17092. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  17093. }
  17094. if (this._deviceOrientationCamera) {
  17095. this._deviceOrientationCamera.position = this._position;
  17096. this._scene.activeCamera = this._deviceOrientationCamera;
  17097. if (this._canvas) {
  17098. this._scene.activeCamera.attachControl(this._canvas);
  17099. }
  17100. // Restore angular sensibility
  17101. if (this._cachedAngularSensibility.angularSensibilityX) {
  17102. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  17103. this._cachedAngularSensibility.angularSensibilityX = null;
  17104. }
  17105. if (this._cachedAngularSensibility.angularSensibilityY) {
  17106. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  17107. this._cachedAngularSensibility.angularSensibilityY = null;
  17108. }
  17109. if (this._cachedAngularSensibility.angularSensibility) {
  17110. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17111. this._cachedAngularSensibility.angularSensibility = null;
  17112. }
  17113. }
  17114. else if (this._existingCamera) {
  17115. this._existingCamera.position = this._position;
  17116. this._scene.activeCamera = this._existingCamera;
  17117. // Restore angular sensibility
  17118. if (this._cachedAngularSensibility.angularSensibilityX) {
  17119. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  17120. this._cachedAngularSensibility.angularSensibilityX = null;
  17121. }
  17122. if (this._cachedAngularSensibility.angularSensibilityY) {
  17123. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  17124. this._cachedAngularSensibility.angularSensibilityY = null;
  17125. }
  17126. if (this._cachedAngularSensibility.angularSensibility) {
  17127. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17128. this._cachedAngularSensibility.angularSensibility = null;
  17129. }
  17130. }
  17131. this.updateButtonVisibility();
  17132. if (this._interactionsEnabled) {
  17133. this._scene.unregisterBeforeRender(this.beforeRender);
  17134. this._cameraGazer._gazeTracker.isVisible = false;
  17135. if (this._leftController) {
  17136. this._leftController._gazeTracker.isVisible = false;
  17137. }
  17138. if (this._rightController) {
  17139. this._rightController._gazeTracker.isVisible = false;
  17140. }
  17141. }
  17142. // resize to update width and height when exiting vr exits fullscreen
  17143. this._scene.getEngine().resize();
  17144. [this._leftController, this._rightController].forEach(function (controller) {
  17145. if (controller) {
  17146. controller._deactivatePointer();
  17147. }
  17148. });
  17149. this._hasEnteredVR = false;
  17150. }
  17151. };
  17152. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  17153. /**
  17154. * The position of the vr experience helper.
  17155. */
  17156. get: function () {
  17157. return this._position;
  17158. },
  17159. /**
  17160. * Sets the position of the vr experience helper.
  17161. */
  17162. set: function (value) {
  17163. this._position = value;
  17164. if (this._scene.activeCamera) {
  17165. this._scene.activeCamera.position = value;
  17166. }
  17167. },
  17168. enumerable: true,
  17169. configurable: true
  17170. });
  17171. /**
  17172. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  17173. */
  17174. VRExperienceHelper.prototype.enableInteractions = function () {
  17175. var _this = this;
  17176. if (!this._interactionsEnabled) {
  17177. this._interactionsRequested = true;
  17178. if (this._leftController) {
  17179. this._enableInteractionOnController(this._leftController);
  17180. }
  17181. if (this._rightController) {
  17182. this._enableInteractionOnController(this._rightController);
  17183. }
  17184. this.raySelectionPredicate = function (mesh) {
  17185. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  17186. };
  17187. this.meshSelectionPredicate = function () {
  17188. return true;
  17189. };
  17190. this._raySelectionPredicate = function (mesh) {
  17191. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  17192. && mesh.name.indexOf("teleportationTarget") === -1
  17193. && mesh.name.indexOf("torusTeleportation") === -1)) {
  17194. return _this.raySelectionPredicate(mesh);
  17195. }
  17196. return false;
  17197. };
  17198. this._interactionsEnabled = true;
  17199. }
  17200. };
  17201. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  17202. get: function () {
  17203. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  17204. },
  17205. enumerable: true,
  17206. configurable: true
  17207. });
  17208. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  17209. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  17210. if (this._floorMeshesCollection[i].id === mesh.id) {
  17211. return true;
  17212. }
  17213. }
  17214. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  17215. return true;
  17216. }
  17217. return false;
  17218. };
  17219. /**
  17220. * Adds a floor mesh to be used for teleportation.
  17221. * @param floorMesh the mesh to be used for teleportation.
  17222. */
  17223. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  17224. if (!this._floorMeshesCollection) {
  17225. return;
  17226. }
  17227. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  17228. return;
  17229. }
  17230. this._floorMeshesCollection.push(floorMesh);
  17231. };
  17232. /**
  17233. * Removes a floor mesh from being used for teleportation.
  17234. * @param floorMesh the mesh to be removed.
  17235. */
  17236. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  17237. if (!this._floorMeshesCollection) {
  17238. return;
  17239. }
  17240. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  17241. if (meshIndex !== -1) {
  17242. this._floorMeshesCollection.splice(meshIndex, 1);
  17243. }
  17244. };
  17245. /**
  17246. * Enables interactions and teleportation using the VR controllers and gaze.
  17247. * @param vrTeleportationOptions options to modify teleportation behavior.
  17248. */
  17249. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  17250. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  17251. if (!this._teleportationInitialized) {
  17252. this._teleportationRequested = true;
  17253. this.enableInteractions();
  17254. if (vrTeleportationOptions.floorMeshName) {
  17255. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  17256. }
  17257. if (vrTeleportationOptions.floorMeshes) {
  17258. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  17259. }
  17260. if (this._leftController != null) {
  17261. this._enableTeleportationOnController(this._leftController);
  17262. }
  17263. if (this._rightController != null) {
  17264. this._enableTeleportationOnController(this._rightController);
  17265. }
  17266. // Creates an image processing post process for the vignette not relying
  17267. // on the main scene configuration for image processing to reduce setup and spaces
  17268. // (gamma/linear) conflicts.
  17269. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  17270. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  17271. imageProcessingConfiguration.vignetteEnabled = true;
  17272. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  17273. this._webVRCamera.detachPostProcess(this._postProcessMove);
  17274. this._teleportationInitialized = true;
  17275. if (this._isDefaultTeleportationTarget) {
  17276. this._createTeleportationCircles();
  17277. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  17278. }
  17279. }
  17280. };
  17281. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  17282. var _this = this;
  17283. var controllerMesh = controller.webVRController.mesh;
  17284. if (controllerMesh) {
  17285. controller._interactionsEnabled = true;
  17286. if (this.isInVRMode && this._displayLaserPointer) {
  17287. controller._activatePointer();
  17288. }
  17289. if (this.webVROptions.laserToggle) {
  17290. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  17291. // Enabling / disabling laserPointer
  17292. if (_this._displayLaserPointer && stateObject.value === 1) {
  17293. if (controller._activePointer) {
  17294. controller._deactivatePointer();
  17295. }
  17296. else {
  17297. controller._activatePointer();
  17298. }
  17299. if (_this.displayGaze) {
  17300. controller._gazeTracker.isVisible = controller._activePointer;
  17301. }
  17302. }
  17303. });
  17304. }
  17305. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  17306. var gazer = controller;
  17307. if (_this._noControllerIsActive) {
  17308. gazer = _this._cameraGazer;
  17309. }
  17310. if (!gazer._pointerDownOnMeshAsked) {
  17311. if (stateObject.value > _this._padSensibilityUp) {
  17312. gazer._selectionPointerDown();
  17313. }
  17314. }
  17315. else if (stateObject.value < _this._padSensibilityDown) {
  17316. gazer._selectionPointerUp();
  17317. }
  17318. });
  17319. }
  17320. };
  17321. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  17322. // Dont teleport if another gaze already requested teleportation
  17323. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  17324. return;
  17325. }
  17326. if (!gazer._teleportationRequestInitiated) {
  17327. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  17328. gazer._activatePointer();
  17329. gazer._teleportationRequestInitiated = true;
  17330. }
  17331. }
  17332. else {
  17333. // Listening to the proper controller values changes to confirm teleportation
  17334. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  17335. if (this._teleportActive) {
  17336. this.teleportCamera(this._haloCenter);
  17337. }
  17338. gazer._teleportationRequestInitiated = false;
  17339. }
  17340. }
  17341. };
  17342. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  17343. // Only rotate when user is not currently selecting a teleportation location
  17344. if (gazer._teleportationRequestInitiated) {
  17345. return;
  17346. }
  17347. if (!gazer._rotationLeftAsked) {
  17348. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  17349. gazer._rotationLeftAsked = true;
  17350. if (this._rotationAllowed) {
  17351. this._rotateCamera(false);
  17352. }
  17353. }
  17354. }
  17355. else {
  17356. if (stateObject.x > -this._padSensibilityDown) {
  17357. gazer._rotationLeftAsked = false;
  17358. }
  17359. }
  17360. if (!gazer._rotationRightAsked) {
  17361. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  17362. gazer._rotationRightAsked = true;
  17363. if (this._rotationAllowed) {
  17364. this._rotateCamera(true);
  17365. }
  17366. }
  17367. }
  17368. else {
  17369. if (stateObject.x < this._padSensibilityDown) {
  17370. gazer._rotationRightAsked = false;
  17371. }
  17372. }
  17373. };
  17374. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  17375. // Only teleport backwards when user is not currently selecting a teleportation location
  17376. if (gazer._teleportationRequestInitiated) {
  17377. return;
  17378. }
  17379. // Teleport backwards
  17380. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  17381. if (!gazer._teleportationBackRequestInitiated) {
  17382. if (!this.currentVRCamera) {
  17383. return;
  17384. }
  17385. // Get rotation and position of the current camera
  17386. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  17387. var position = this.currentVRCamera.position;
  17388. // If the camera has device position, use that instead
  17389. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  17390. rotation = this.currentVRCamera.deviceRotationQuaternion;
  17391. position = this.currentVRCamera.devicePosition;
  17392. }
  17393. // Get matrix with only the y rotation of the device rotation
  17394. rotation.toEulerAnglesToRef(this._workingVector);
  17395. this._workingVector.z = 0;
  17396. this._workingVector.x = 0;
  17397. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  17398. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  17399. // Rotate backwards ray by device rotation to cast at the ground behind the user
  17400. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  17401. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  17402. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  17403. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17404. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  17405. this.teleportCamera(hit.pickedPoint);
  17406. }
  17407. gazer._teleportationBackRequestInitiated = true;
  17408. }
  17409. }
  17410. else {
  17411. gazer._teleportationBackRequestInitiated = false;
  17412. }
  17413. };
  17414. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  17415. var _this = this;
  17416. var controllerMesh = controller.webVRController.mesh;
  17417. if (controllerMesh) {
  17418. if (!controller._interactionsEnabled) {
  17419. this._enableInteractionOnController(controller);
  17420. }
  17421. controller._interactionsEnabled = true;
  17422. controller._teleportationEnabled = true;
  17423. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  17424. controller._dpadPressed = false;
  17425. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  17426. controller._dpadPressed = stateObject.pressed;
  17427. if (!controller._dpadPressed) {
  17428. controller._rotationLeftAsked = false;
  17429. controller._rotationRightAsked = false;
  17430. controller._teleportationBackRequestInitiated = false;
  17431. }
  17432. });
  17433. }
  17434. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  17435. if (_this.teleportationEnabled) {
  17436. _this._checkTeleportBackwards(stateObject, controller);
  17437. _this._checkTeleportWithRay(stateObject, controller);
  17438. }
  17439. _this._checkRotate(stateObject, controller);
  17440. });
  17441. }
  17442. };
  17443. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  17444. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  17445. this._teleportationTarget.isPickable = false;
  17446. var length = 512;
  17447. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  17448. dynamicTexture.hasAlpha = true;
  17449. var context = dynamicTexture.getContext();
  17450. var centerX = length / 2;
  17451. var centerY = length / 2;
  17452. var radius = 200;
  17453. context.beginPath();
  17454. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  17455. context.fillStyle = this._teleportationFillColor;
  17456. context.fill();
  17457. context.lineWidth = 10;
  17458. context.strokeStyle = this._teleportationBorderColor;
  17459. context.stroke();
  17460. context.closePath();
  17461. dynamicTexture.update();
  17462. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  17463. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  17464. this._teleportationTarget.material = teleportationCircleMaterial;
  17465. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  17466. torus.isPickable = false;
  17467. torus.parent = this._teleportationTarget;
  17468. var animationInnerCircle = new _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"]("animationInnerCircle", "position.y", 30, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  17469. var keys = [];
  17470. keys.push({
  17471. frame: 0,
  17472. value: 0
  17473. });
  17474. keys.push({
  17475. frame: 30,
  17476. value: 0.4
  17477. });
  17478. keys.push({
  17479. frame: 60,
  17480. value: 0
  17481. });
  17482. animationInnerCircle.setKeys(keys);
  17483. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  17484. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  17485. animationInnerCircle.setEasingFunction(easingFunction);
  17486. torus.animations = [];
  17487. torus.animations.push(animationInnerCircle);
  17488. this._scene.beginAnimation(torus, 0, 60, true);
  17489. this._hideTeleportationTarget();
  17490. };
  17491. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  17492. this._teleportActive = true;
  17493. if (this._teleportationInitialized) {
  17494. this._teleportationTarget.isVisible = true;
  17495. if (this._isDefaultTeleportationTarget) {
  17496. this._teleportationTarget.getChildren()[0].isVisible = true;
  17497. }
  17498. }
  17499. };
  17500. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  17501. this._teleportActive = false;
  17502. if (this._teleportationInitialized) {
  17503. this._teleportationTarget.isVisible = false;
  17504. if (this._isDefaultTeleportationTarget) {
  17505. this._teleportationTarget.getChildren()[0].isVisible = false;
  17506. }
  17507. }
  17508. };
  17509. VRExperienceHelper.prototype._rotateCamera = function (right) {
  17510. var _this = this;
  17511. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17512. return;
  17513. }
  17514. if (right) {
  17515. this._rotationAngle++;
  17516. }
  17517. else {
  17518. this._rotationAngle--;
  17519. }
  17520. this.currentVRCamera.animations = [];
  17521. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  17522. var animationRotation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"]("animationRotation", "rotationQuaternion", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONTYPE_QUATERNION, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17523. var animationRotationKeys = [];
  17524. animationRotationKeys.push({
  17525. frame: 0,
  17526. value: this.currentVRCamera.rotationQuaternion
  17527. });
  17528. animationRotationKeys.push({
  17529. frame: 6,
  17530. value: target
  17531. });
  17532. animationRotation.setKeys(animationRotationKeys);
  17533. animationRotation.setEasingFunction(this._circleEase);
  17534. this.currentVRCamera.animations.push(animationRotation);
  17535. this._postProcessMove.animations = [];
  17536. var animationPP = new _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"]("animationPP", "vignetteWeight", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17537. var vignetteWeightKeys = [];
  17538. vignetteWeightKeys.push({
  17539. frame: 0,
  17540. value: 0
  17541. });
  17542. vignetteWeightKeys.push({
  17543. frame: 3,
  17544. value: 4
  17545. });
  17546. vignetteWeightKeys.push({
  17547. frame: 6,
  17548. value: 0
  17549. });
  17550. animationPP.setKeys(vignetteWeightKeys);
  17551. animationPP.setEasingFunction(this._circleEase);
  17552. this._postProcessMove.animations.push(animationPP);
  17553. var animationPP2 = new _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"]("animationPP2", "vignetteStretch", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17554. var vignetteStretchKeys = [];
  17555. vignetteStretchKeys.push({
  17556. frame: 0,
  17557. value: 0
  17558. });
  17559. vignetteStretchKeys.push({
  17560. frame: 3,
  17561. value: 10
  17562. });
  17563. vignetteStretchKeys.push({
  17564. frame: 6,
  17565. value: 0
  17566. });
  17567. animationPP2.setKeys(vignetteStretchKeys);
  17568. animationPP2.setEasingFunction(this._circleEase);
  17569. this._postProcessMove.animations.push(animationPP2);
  17570. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17571. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17572. this._postProcessMove.samples = 4;
  17573. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17574. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  17575. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17576. });
  17577. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  17578. };
  17579. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  17580. if (hit.pickedPoint) {
  17581. if (gazer._teleportationRequestInitiated) {
  17582. this._displayTeleportationTarget();
  17583. this._haloCenter.copyFrom(hit.pickedPoint);
  17584. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  17585. }
  17586. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  17587. if (pickNormal) {
  17588. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17589. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17590. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  17591. }
  17592. this._teleportationTarget.position.y += 0.1;
  17593. }
  17594. };
  17595. /**
  17596. * Teleports the users feet to the desired location
  17597. * @param location The location where the user's feet should be placed
  17598. */
  17599. VRExperienceHelper.prototype.teleportCamera = function (location) {
  17600. var _this = this;
  17601. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17602. return;
  17603. }
  17604. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  17605. // offset of the headset from the anchor.
  17606. if (this.webVRCamera.leftCamera) {
  17607. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  17608. this._workingVector.subtractInPlace(this.webVRCamera.position);
  17609. location.subtractToRef(this._workingVector, this._workingVector);
  17610. }
  17611. else {
  17612. this._workingVector.copyFrom(location);
  17613. }
  17614. // Add height to account for user's height offset
  17615. if (this.isInVRMode) {
  17616. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  17617. }
  17618. else {
  17619. this._workingVector.y += this._defaultHeight;
  17620. }
  17621. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  17622. // Create animation from the camera's position to the new location
  17623. this.currentVRCamera.animations = [];
  17624. var animationCameraTeleportation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"]("animationCameraTeleportation", "position", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONTYPE_VECTOR3, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17625. var animationCameraTeleportationKeys = [{
  17626. frame: 0,
  17627. value: this.currentVRCamera.position
  17628. },
  17629. {
  17630. frame: 11,
  17631. value: this._workingVector
  17632. }
  17633. ];
  17634. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  17635. animationCameraTeleportation.setEasingFunction(this._circleEase);
  17636. this.currentVRCamera.animations.push(animationCameraTeleportation);
  17637. this._postProcessMove.animations = [];
  17638. var animationPP = new _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"]("animationPP", "vignetteWeight", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17639. var vignetteWeightKeys = [];
  17640. vignetteWeightKeys.push({
  17641. frame: 0,
  17642. value: 0
  17643. });
  17644. vignetteWeightKeys.push({
  17645. frame: 5,
  17646. value: 8
  17647. });
  17648. vignetteWeightKeys.push({
  17649. frame: 11,
  17650. value: 0
  17651. });
  17652. animationPP.setKeys(vignetteWeightKeys);
  17653. this._postProcessMove.animations.push(animationPP);
  17654. var animationPP2 = new _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"]("animationPP2", "vignetteStretch", 90, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONTYPE_FLOAT, _Animations_animation__WEBPACK_IMPORTED_MODULE_21__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  17655. var vignetteStretchKeys = [];
  17656. vignetteStretchKeys.push({
  17657. frame: 0,
  17658. value: 0
  17659. });
  17660. vignetteStretchKeys.push({
  17661. frame: 5,
  17662. value: 10
  17663. });
  17664. vignetteStretchKeys.push({
  17665. frame: 11,
  17666. value: 0
  17667. });
  17668. animationPP2.setKeys(vignetteStretchKeys);
  17669. this._postProcessMove.animations.push(animationPP2);
  17670. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17671. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17672. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17673. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  17674. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17675. });
  17676. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  17677. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  17678. });
  17679. this._hideTeleportationTarget();
  17680. };
  17681. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  17682. if (normal) {
  17683. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  17684. if (angle < Math.PI / 2) {
  17685. normal.scaleInPlace(-1);
  17686. }
  17687. }
  17688. return normal;
  17689. };
  17690. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  17691. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17692. return;
  17693. }
  17694. var ray = gazer._getForwardRay(this._rayLength);
  17695. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17696. if (hit) {
  17697. // Populate the contrllers mesh that can be used for drag/drop
  17698. if (gazer._laserPointer) {
  17699. hit.originMesh = gazer._laserPointer.parent;
  17700. }
  17701. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  17702. }
  17703. gazer._currentHit = hit;
  17704. // Moving the gazeTracker on the mesh face targetted
  17705. if (hit && hit.pickedPoint) {
  17706. if (this._displayGaze) {
  17707. var multiplier = 1;
  17708. gazer._gazeTracker.isVisible = true;
  17709. if (gazer._isActionableMesh) {
  17710. multiplier = 3;
  17711. }
  17712. if (this.updateGazeTrackerScale) {
  17713. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  17714. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  17715. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  17716. }
  17717. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  17718. // To avoid z-fighting
  17719. var deltaFighting = 0.002;
  17720. if (pickNormal) {
  17721. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17722. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17723. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  17724. }
  17725. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  17726. if (gazer._gazeTracker.position.x < 0) {
  17727. gazer._gazeTracker.position.x += deltaFighting;
  17728. }
  17729. else {
  17730. gazer._gazeTracker.position.x -= deltaFighting;
  17731. }
  17732. if (gazer._gazeTracker.position.y < 0) {
  17733. gazer._gazeTracker.position.y += deltaFighting;
  17734. }
  17735. else {
  17736. gazer._gazeTracker.position.y -= deltaFighting;
  17737. }
  17738. if (gazer._gazeTracker.position.z < 0) {
  17739. gazer._gazeTracker.position.z += deltaFighting;
  17740. }
  17741. else {
  17742. gazer._gazeTracker.position.z -= deltaFighting;
  17743. }
  17744. }
  17745. // Changing the size of the laser pointer based on the distance from the targetted point
  17746. gazer._updatePointerDistance(hit.distance);
  17747. }
  17748. else {
  17749. gazer._updatePointerDistance();
  17750. gazer._gazeTracker.isVisible = false;
  17751. }
  17752. if (hit && hit.pickedMesh) {
  17753. // The object selected is the floor, we're in a teleportation scenario
  17754. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  17755. // Moving the teleportation area to this targetted point
  17756. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  17757. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  17758. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17759. }
  17760. gazer._currentMeshSelected = null;
  17761. if (gazer._teleportationRequestInitiated) {
  17762. this._moveTeleportationSelectorTo(hit, gazer, ray);
  17763. }
  17764. return;
  17765. }
  17766. // If not, we're in a selection scenario
  17767. //this._teleportationAllowed = false;
  17768. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  17769. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  17770. this.onNewMeshPicked.notifyObservers(hit);
  17771. gazer._currentMeshSelected = hit.pickedMesh;
  17772. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  17773. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  17774. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  17775. gazer._isActionableMesh = true;
  17776. }
  17777. else {
  17778. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17779. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17780. gazer._isActionableMesh = false;
  17781. }
  17782. try {
  17783. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  17784. }
  17785. catch (err) {
  17786. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  17787. }
  17788. }
  17789. else {
  17790. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17791. gazer._currentMeshSelected = null;
  17792. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17793. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17794. }
  17795. }
  17796. }
  17797. else {
  17798. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17799. gazer._currentMeshSelected = null;
  17800. //this._teleportationAllowed = false;
  17801. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17802. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17803. }
  17804. };
  17805. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  17806. if (mesh) {
  17807. this.onSelectedMeshUnselected.notifyObservers(mesh);
  17808. }
  17809. };
  17810. /**
  17811. * Sets the color of the laser ray from the vr controllers.
  17812. * @param color new color for the ray.
  17813. */
  17814. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  17815. if (this._leftController) {
  17816. this._leftController._setLaserPointerColor(color);
  17817. }
  17818. if (this._rightController) {
  17819. this._rightController._setLaserPointerColor(color);
  17820. }
  17821. };
  17822. /**
  17823. * Sets the color of the ray from the vr headsets gaze.
  17824. * @param color new color for the ray.
  17825. */
  17826. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  17827. if (!this.updateGazeTrackerColor) {
  17828. return;
  17829. }
  17830. if (!this._cameraGazer._gazeTracker.material) {
  17831. return;
  17832. }
  17833. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  17834. if (this._leftController) {
  17835. this._leftController._gazeTracker.material.emissiveColor = color;
  17836. }
  17837. if (this._rightController) {
  17838. this._rightController._gazeTracker.material.emissiveColor = color;
  17839. }
  17840. };
  17841. /**
  17842. * Exits VR and disposes of the vr experience helper
  17843. */
  17844. VRExperienceHelper.prototype.dispose = function () {
  17845. if (this.isInVRMode) {
  17846. this.exitVR();
  17847. }
  17848. if (this._postProcessMove) {
  17849. this._postProcessMove.dispose();
  17850. }
  17851. if (this._webVRCamera) {
  17852. this._webVRCamera.dispose();
  17853. }
  17854. if (this._vrDeviceOrientationCamera) {
  17855. this._vrDeviceOrientationCamera.dispose();
  17856. }
  17857. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  17858. document.body.removeChild(this._btnVR);
  17859. }
  17860. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  17861. this._deviceOrientationCamera.dispose();
  17862. }
  17863. if (this._cameraGazer) {
  17864. this._cameraGazer.dispose();
  17865. }
  17866. if (this._leftController) {
  17867. this._leftController.dispose();
  17868. }
  17869. if (this._rightController) {
  17870. this._rightController.dispose();
  17871. }
  17872. if (this._teleportationTarget) {
  17873. this._teleportationTarget.dispose();
  17874. }
  17875. this._floorMeshesCollection = [];
  17876. document.removeEventListener("keydown", this._onKeyDown);
  17877. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17878. window.removeEventListener("resize", this._onResize);
  17879. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  17880. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  17881. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  17882. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  17883. document.onmsfullscreenchange = null;
  17884. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  17885. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  17886. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  17887. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17888. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  17889. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  17890. this._scene.unregisterBeforeRender(this.beforeRender);
  17891. };
  17892. /**
  17893. * Gets the name of the VRExperienceHelper class
  17894. * @returns "VRExperienceHelper"
  17895. */
  17896. VRExperienceHelper.prototype.getClassName = function () {
  17897. return "VRExperienceHelper";
  17898. };
  17899. return VRExperienceHelper;
  17900. }());
  17901. /***/ }),
  17902. /***/ "./Cameras/VR/webVRCamera.ts":
  17903. /*!***********************************!*\
  17904. !*** ./Cameras/VR/webVRCamera.ts ***!
  17905. \***********************************/
  17906. /*! exports provided: WebVRFreeCamera */
  17907. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17908. "use strict";
  17909. __webpack_require__.r(__webpack_exports__);
  17910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  17911. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17912. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17913. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17914. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17915. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17916. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  17917. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  17918. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  17919. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  17920. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  17921. /* harmony import */ var _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../PostProcesses/vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  17922. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  17923. // Side effect import to define the stereoscopic mode.
  17924. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  17925. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17926. });
  17927. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  17928. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17929. });
  17930. /**
  17931. * This represents a WebVR camera.
  17932. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17933. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17934. */
  17935. var WebVRFreeCamera = /** @class */ (function (_super) {
  17936. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  17937. /**
  17938. * Instantiates a WebVRFreeCamera.
  17939. * @param name The name of the WebVRFreeCamera
  17940. * @param position The starting anchor position for the camera
  17941. * @param scene The scene the camera belongs to
  17942. * @param webVROptions a set of customizable options for the webVRCamera
  17943. */
  17944. function WebVRFreeCamera(name, position, scene, webVROptions) {
  17945. if (webVROptions === void 0) { webVROptions = {}; }
  17946. var _this = _super.call(this, name, position, scene) || this;
  17947. _this.webVROptions = webVROptions;
  17948. /**
  17949. * @hidden
  17950. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17951. */
  17952. _this._vrDevice = null;
  17953. /**
  17954. * The rawPose of the vrDevice.
  17955. */
  17956. _this.rawPose = null;
  17957. _this._specsVersion = "1.1";
  17958. _this._attached = false;
  17959. _this._descendants = [];
  17960. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  17961. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17962. /** @hidden */
  17963. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17964. _this._standingMatrix = null;
  17965. /**
  17966. * Represents device position in babylon space.
  17967. */
  17968. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17969. /**
  17970. * Represents device rotation in babylon space.
  17971. */
  17972. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17973. /**
  17974. * The scale of the device to be used when translating from device space to babylon space.
  17975. */
  17976. _this.deviceScaleFactor = 1;
  17977. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17978. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17979. /**
  17980. * References to the webVR controllers for the vrDevice.
  17981. */
  17982. _this.controllers = [];
  17983. /**
  17984. * Emits an event when a controller is attached.
  17985. */
  17986. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17987. /**
  17988. * Emits an event when a controller's mesh has been loaded;
  17989. */
  17990. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17991. /**
  17992. * Emits an event when the HMD's pose has been updated.
  17993. */
  17994. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17995. _this._poseSet = false;
  17996. /**
  17997. * If the rig cameras be used as parent instead of this camera.
  17998. */
  17999. _this.rigParenting = true;
  18000. _this._defaultHeight = undefined;
  18001. _this._htmlElementAttached = null;
  18002. _this._detachIfAttached = function () {
  18003. var vrDisplay = _this.getEngine().getVRDevice();
  18004. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  18005. _this.detachControl(_this._htmlElementAttached);
  18006. }
  18007. };
  18008. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  18009. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  18010. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18011. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  18012. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  18013. if (webVROptions.defaultHeight) {
  18014. _this._defaultHeight = webVROptions.defaultHeight;
  18015. _this.position.y = _this._defaultHeight;
  18016. }
  18017. _this.minZ = 0.1;
  18018. //legacy support - the compensation boolean was removed.
  18019. if (arguments.length === 5) {
  18020. _this.webVROptions = arguments[4];
  18021. }
  18022. // default webVR options
  18023. if (_this.webVROptions.trackPosition == undefined) {
  18024. _this.webVROptions.trackPosition = true;
  18025. }
  18026. if (_this.webVROptions.controllerMeshes == undefined) {
  18027. _this.webVROptions.controllerMeshes = true;
  18028. }
  18029. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  18030. _this.webVROptions.defaultLightingOnControllers = true;
  18031. }
  18032. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  18033. if (_this.webVROptions && _this.webVROptions.positionScale) {
  18034. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  18035. }
  18036. //enable VR
  18037. var engine = _this.getEngine();
  18038. _this._onVREnabled = function (success) { if (success) {
  18039. _this.initControllers();
  18040. } };
  18041. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  18042. engine.initWebVR().add(function (event) {
  18043. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  18044. return;
  18045. }
  18046. _this._vrDevice = event.vrDisplay;
  18047. //reset the rig parameters.
  18048. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  18049. if (_this._attached) {
  18050. _this.getEngine().enableVR();
  18051. }
  18052. });
  18053. if (typeof (VRFrameData) !== "undefined") {
  18054. _this._frameData = new VRFrameData();
  18055. }
  18056. if (webVROptions.useMultiview) {
  18057. if (!_this.getScene().getEngine().getCaps().multiview) {
  18058. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn("Multiview is not supported, falling back to standard rendering");
  18059. _this._useMultiviewToSingleView = false;
  18060. }
  18061. else {
  18062. _this._useMultiviewToSingleView = true;
  18063. _this._rigPostProcess = new _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_10__["VRMultiviewToSingleviewPostProcess"]("VRMultiviewToSingleview", _this, 1.0);
  18064. }
  18065. }
  18066. /**
  18067. * The idea behind the following lines:
  18068. * objects that have the camera as parent should actually have the rig cameras as a parent.
  18069. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  18070. * the second will not show it correctly.
  18071. *
  18072. * To solve this - each object that has the camera as parent will be added to a protected array.
  18073. * When the rig camera renders, it will take this array and set all of those to be its children.
  18074. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  18075. * Amazing!
  18076. */
  18077. scene.onBeforeCameraRenderObservable.add(function (camera) {
  18078. if (camera.parent === _this && _this.rigParenting) {
  18079. _this._descendants = _this.getDescendants(true, function (n) {
  18080. // don't take the cameras or the controllers!
  18081. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  18082. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  18083. return !isController && !isRigCamera;
  18084. });
  18085. _this._descendants.forEach(function (node) {
  18086. node.parent = camera;
  18087. });
  18088. }
  18089. });
  18090. scene.onAfterCameraRenderObservable.add(function (camera) {
  18091. if (camera.parent === _this && _this.rigParenting) {
  18092. _this._descendants.forEach(function (node) {
  18093. node.parent = _this;
  18094. });
  18095. }
  18096. });
  18097. return _this;
  18098. }
  18099. /**
  18100. * Gets the device distance from the ground in meters.
  18101. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  18102. */
  18103. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  18104. if (this._standingMatrix) {
  18105. // Add standing matrix offset to get real offset from ground in room
  18106. this._standingMatrix.getTranslationToRef(this._workingVector);
  18107. return this._deviceRoomPosition.y + this._workingVector.y;
  18108. }
  18109. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  18110. return this._defaultHeight || 0;
  18111. };
  18112. /**
  18113. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18114. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18115. */
  18116. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  18117. var _this = this;
  18118. if (callback === void 0) { callback = function (bool) { }; }
  18119. // Use standing matrix if available
  18120. this.getEngine().initWebVRAsync().then(function (result) {
  18121. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  18122. callback(false);
  18123. }
  18124. else {
  18125. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  18126. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  18127. if (!_this.getScene().useRightHandedSystem) {
  18128. if (_this._standingMatrix) {
  18129. _this._standingMatrix.toggleModelMatrixHandInPlace();
  18130. }
  18131. }
  18132. callback(true);
  18133. }
  18134. });
  18135. };
  18136. /**
  18137. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18138. * @returns A promise with a boolean set to if the standing matrix is supported.
  18139. */
  18140. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  18141. var _this = this;
  18142. return new Promise(function (res) {
  18143. _this.useStandingMatrix(function (supported) {
  18144. res(supported);
  18145. });
  18146. });
  18147. };
  18148. /**
  18149. * Disposes the camera
  18150. */
  18151. WebVRFreeCamera.prototype.dispose = function () {
  18152. this._detachIfAttached();
  18153. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  18154. if (this._updateCacheWhenTrackingDisabledObserver) {
  18155. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  18156. }
  18157. _super.prototype.dispose.call(this);
  18158. };
  18159. /**
  18160. * Gets a vrController by name.
  18161. * @param name The name of the controller to retreive
  18162. * @returns the controller matching the name specified or null if not found
  18163. */
  18164. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  18165. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  18166. var gp = _a[_i];
  18167. if (gp.hand === name) {
  18168. return gp;
  18169. }
  18170. }
  18171. return null;
  18172. };
  18173. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  18174. /**
  18175. * The controller corrisponding to the users left hand.
  18176. */
  18177. get: function () {
  18178. if (!this._leftController) {
  18179. this._leftController = this.getControllerByName("left");
  18180. }
  18181. return this._leftController;
  18182. },
  18183. enumerable: true,
  18184. configurable: true
  18185. });
  18186. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  18187. /**
  18188. * The controller corrisponding to the users right hand.
  18189. */
  18190. get: function () {
  18191. if (!this._rightController) {
  18192. this._rightController = this.getControllerByName("right");
  18193. }
  18194. return this._rightController;
  18195. },
  18196. enumerable: true,
  18197. configurable: true
  18198. });
  18199. /**
  18200. * Casts a ray forward from the vrCamera's gaze.
  18201. * @param length Length of the ray (default: 100)
  18202. * @returns the ray corrisponding to the gaze
  18203. */
  18204. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  18205. if (length === void 0) { length = 100; }
  18206. if (this.leftCamera) {
  18207. // Use left eye to avoid computation to compute center on every call
  18208. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  18209. }
  18210. else {
  18211. return _super.prototype.getForwardRay.call(this, length);
  18212. }
  18213. };
  18214. /**
  18215. * @hidden
  18216. * Updates the camera based on device's frame data
  18217. */
  18218. WebVRFreeCamera.prototype._checkInputs = function () {
  18219. if (this._vrDevice && this._vrDevice.isPresenting) {
  18220. this._vrDevice.getFrameData(this._frameData);
  18221. this.updateFromDevice(this._frameData.pose);
  18222. }
  18223. _super.prototype._checkInputs.call(this);
  18224. };
  18225. /**
  18226. * Updates the poseControlled values based on the input device pose.
  18227. * @param poseData Pose coming from the device
  18228. */
  18229. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  18230. if (poseData && poseData.orientation) {
  18231. this.rawPose = poseData;
  18232. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  18233. if (this.getScene().useRightHandedSystem) {
  18234. this._deviceRoomRotationQuaternion.z *= -1;
  18235. this._deviceRoomRotationQuaternion.w *= -1;
  18236. }
  18237. if (this.webVROptions.trackPosition && this.rawPose.position) {
  18238. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  18239. if (this.getScene().useRightHandedSystem) {
  18240. this._deviceRoomPosition.z *= -1;
  18241. }
  18242. }
  18243. this._poseSet = true;
  18244. }
  18245. };
  18246. /**
  18247. * WebVR's attach control will start broadcasting frames to the device.
  18248. * Note that in certain browsers (chrome for example) this function must be called
  18249. * within a user-interaction callback. Example:
  18250. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18251. *
  18252. * @param element html element to attach the vrDevice to
  18253. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18254. */
  18255. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  18256. _super.prototype.attachControl.call(this, element, noPreventDefault);
  18257. this._attached = true;
  18258. this._htmlElementAttached = element;
  18259. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  18260. if (this._vrDevice) {
  18261. this.getEngine().enableVR();
  18262. }
  18263. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18264. };
  18265. /**
  18266. * Detaches the camera from the html element and disables VR
  18267. *
  18268. * @param element html element to detach from
  18269. */
  18270. WebVRFreeCamera.prototype.detachControl = function (element) {
  18271. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  18272. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  18273. _super.prototype.detachControl.call(this, element);
  18274. this._attached = false;
  18275. this.getEngine().disableVR();
  18276. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18277. };
  18278. /**
  18279. * @returns the name of this class
  18280. */
  18281. WebVRFreeCamera.prototype.getClassName = function () {
  18282. return "WebVRFreeCamera";
  18283. };
  18284. /**
  18285. * Calls resetPose on the vrDisplay
  18286. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18287. */
  18288. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  18289. //uses the vrDisplay's "resetPose()".
  18290. //pitch and roll won't be affected.
  18291. this._vrDevice.resetPose();
  18292. };
  18293. /**
  18294. * @hidden
  18295. * Updates the rig cameras (left and right eye)
  18296. */
  18297. WebVRFreeCamera.prototype._updateRigCameras = function () {
  18298. var camLeft = this._rigCameras[0];
  18299. var camRight = this._rigCameras[1];
  18300. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18301. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18302. camLeft.position.copyFrom(this._deviceRoomPosition);
  18303. camRight.position.copyFrom(this._deviceRoomPosition);
  18304. };
  18305. // Remove translation from 6dof headset if trackposition is set to false
  18306. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  18307. if (isViewMatrix === void 0) { isViewMatrix = false; }
  18308. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  18309. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  18310. if (!isViewMatrix) {
  18311. this._tmpMatrix.invert();
  18312. }
  18313. this._tmpMatrix.multiplyToRef(matrix, matrix);
  18314. }
  18315. };
  18316. /**
  18317. * @hidden
  18318. * Updates the cached values of the camera
  18319. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18320. */
  18321. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  18322. var _this = this;
  18323. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  18324. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  18325. if (!this.updateCacheCalled) {
  18326. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  18327. this.updateCacheCalled = true;
  18328. this.update();
  18329. }
  18330. // Set working vector to the device position in room space rotated by the new rotation
  18331. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  18332. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  18333. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  18334. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  18335. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  18336. // Add translation from anchor position
  18337. this._deviceToWorld.getTranslationToRef(this._workingVector);
  18338. this._workingVector.addInPlace(this.position);
  18339. this._workingVector.subtractInPlace(this._cache.position);
  18340. this._deviceToWorld.setTranslation(this._workingVector);
  18341. // Set an inverted matrix to be used when updating the camera
  18342. this._deviceToWorld.invertToRef(this._worldToDevice);
  18343. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  18344. this.controllers.forEach(function (controller) {
  18345. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  18346. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  18347. controller.update();
  18348. });
  18349. }
  18350. if (!ignoreParentClass) {
  18351. _super.prototype._updateCache.call(this);
  18352. }
  18353. this.updateCacheCalled = false;
  18354. };
  18355. /**
  18356. * @hidden
  18357. * Get current device position in babylon world
  18358. */
  18359. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  18360. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  18361. };
  18362. /**
  18363. * Updates the current device position and rotation in the babylon world
  18364. */
  18365. WebVRFreeCamera.prototype.update = function () {
  18366. this._computeDevicePosition();
  18367. // Get current device rotation in babylon world
  18368. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  18369. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  18370. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  18371. if (this._poseSet) {
  18372. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  18373. }
  18374. _super.prototype.update.call(this);
  18375. };
  18376. /**
  18377. * @hidden
  18378. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18379. * @returns an identity matrix
  18380. */
  18381. WebVRFreeCamera.prototype._getViewMatrix = function () {
  18382. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18383. };
  18384. /**
  18385. * This function is called by the two RIG cameras.
  18386. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18387. * @hidden
  18388. */
  18389. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  18390. // Update the parent camera prior to using a child camera to avoid desynchronization
  18391. var parentCamera = this._cameraRigParams["parentCamera"];
  18392. parentCamera._updateCache();
  18393. //WebVR 1.1
  18394. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  18395. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  18396. if (!this.getScene().useRightHandedSystem) {
  18397. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  18398. }
  18399. // update the camera rotation matrix
  18400. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  18401. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  18402. // Computing target and final matrix
  18403. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  18404. // should the view matrix be updated with scale and position offset?
  18405. if (parentCamera.deviceScaleFactor !== 1) {
  18406. this._webvrViewMatrix.invert();
  18407. // scale the position, if set
  18408. if (parentCamera.deviceScaleFactor) {
  18409. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  18410. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  18411. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  18412. }
  18413. this._webvrViewMatrix.invert();
  18414. }
  18415. // Remove translation from 6dof headset if trackposition is set to false
  18416. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  18417. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  18418. // Compute global position
  18419. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18420. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  18421. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  18422. this._workingMatrix.getTranslationToRef(this._globalPosition);
  18423. this._markSyncedWithParent();
  18424. return this._webvrViewMatrix;
  18425. };
  18426. /** @hidden */
  18427. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  18428. var parentCamera = this.parent;
  18429. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  18430. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  18431. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  18432. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  18433. //babylon compatible matrix
  18434. if (!this.getScene().useRightHandedSystem) {
  18435. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18436. }
  18437. return this._projectionMatrix;
  18438. };
  18439. /**
  18440. * Initializes the controllers and their meshes
  18441. */
  18442. WebVRFreeCamera.prototype.initControllers = function () {
  18443. var _this = this;
  18444. this.controllers = [];
  18445. var manager = this.getScene().gamepadManager;
  18446. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  18447. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18448. var webVrController = gamepad;
  18449. if (webVrController.defaultModel) {
  18450. webVrController.defaultModel.setEnabled(false);
  18451. }
  18452. if (webVrController.hand === "right") {
  18453. _this._rightController = null;
  18454. }
  18455. if (webVrController.hand === "left") {
  18456. _this._leftController = null;
  18457. }
  18458. var controllerIndex = _this.controllers.indexOf(webVrController);
  18459. if (controllerIndex !== -1) {
  18460. _this.controllers.splice(controllerIndex, 1);
  18461. }
  18462. }
  18463. });
  18464. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  18465. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18466. var webVrController_1 = gamepad;
  18467. if (!_this.webVROptions.trackPosition) {
  18468. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  18469. // Cache must be updated before rendering controllers to avoid them being one frame behind
  18470. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  18471. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  18472. _this._updateCache();
  18473. });
  18474. }
  18475. }
  18476. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  18477. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  18478. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  18479. if (_this.webVROptions.controllerMeshes) {
  18480. if (webVrController_1.defaultModel) {
  18481. webVrController_1.defaultModel.setEnabled(true);
  18482. }
  18483. else {
  18484. // Load the meshes
  18485. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  18486. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  18487. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  18488. if (_this.webVROptions.defaultLightingOnControllers) {
  18489. if (!_this._lightOnControllers) {
  18490. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  18491. }
  18492. var activateLightOnSubMeshes_1 = function (mesh, light) {
  18493. var children = mesh.getChildren();
  18494. if (children && children.length !== 0) {
  18495. children.forEach(function (mesh) {
  18496. light.includedOnlyMeshes.push(mesh);
  18497. activateLightOnSubMeshes_1(mesh, light);
  18498. });
  18499. }
  18500. };
  18501. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  18502. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  18503. }
  18504. });
  18505. }
  18506. }
  18507. webVrController_1.attachToPoseControlledCamera(_this);
  18508. // since this is async - sanity check. Is the controller already stored?
  18509. if (_this.controllers.indexOf(webVrController_1) === -1) {
  18510. //add to the controllers array
  18511. _this.controllers.push(webVrController_1);
  18512. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  18513. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  18514. // So we're overriding setting left & right manually to be sure
  18515. var firstViveWandDetected = false;
  18516. for (var i = 0; i < _this.controllers.length; i++) {
  18517. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  18518. if (!firstViveWandDetected) {
  18519. firstViveWandDetected = true;
  18520. _this.controllers[i].hand = "left";
  18521. }
  18522. else {
  18523. _this.controllers[i].hand = "right";
  18524. }
  18525. }
  18526. }
  18527. //did we find enough controllers? Great! let the developer know.
  18528. if (_this.controllers.length >= 2) {
  18529. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  18530. }
  18531. }
  18532. }
  18533. });
  18534. };
  18535. return WebVRFreeCamera;
  18536. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  18537. /***/ }),
  18538. /***/ "./Cameras/XR/index.ts":
  18539. /*!*****************************!*\
  18540. !*** ./Cameras/XR/index.ts ***!
  18541. \*****************************/
  18542. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  18543. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18544. "use strict";
  18545. __webpack_require__.r(__webpack_exports__);
  18546. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  18548. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  18549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  18550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  18551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  18552. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  18554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  18555. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  18556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  18557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  18558. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  18559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  18560. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  18562. /***/ }),
  18563. /***/ "./Cameras/XR/webXRCamera.ts":
  18564. /*!***********************************!*\
  18565. !*** ./Cameras/XR/webXRCamera.ts ***!
  18566. \***********************************/
  18567. /*! exports provided: WebXRCamera */
  18568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18569. "use strict";
  18570. __webpack_require__.r(__webpack_exports__);
  18571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  18572. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18573. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18574. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18575. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18576. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  18577. /**
  18578. * WebXR Camera which holds the views for the xrSession
  18579. * @see https://doc.babylonjs.com/how_to/webxr
  18580. */
  18581. var WebXRCamera = /** @class */ (function (_super) {
  18582. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  18583. /**
  18584. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  18585. * @param name the name of the camera
  18586. * @param scene the scene to add the camera to
  18587. */
  18588. function WebXRCamera(name, scene) {
  18589. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  18590. // Initial camera configuration
  18591. _this.minZ = 0;
  18592. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18593. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  18594. _this.updateUpVectorFromRotation = true;
  18595. _this._updateNumberOfRigCameras(1);
  18596. return _this;
  18597. }
  18598. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  18599. if (viewCount === void 0) { viewCount = 1; }
  18600. while (this.rigCameras.length < viewCount) {
  18601. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  18602. newCamera.minZ = 0;
  18603. newCamera.parent = this;
  18604. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18605. newCamera.updateUpVectorFromRotation = true;
  18606. this.rigCameras.push(newCamera);
  18607. }
  18608. while (this.rigCameras.length > viewCount) {
  18609. var removedCamera = this.rigCameras.pop();
  18610. if (removedCamera) {
  18611. removedCamera.dispose();
  18612. }
  18613. }
  18614. };
  18615. /** @hidden */
  18616. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  18617. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  18618. // Create initial camera rigs
  18619. this._updateNumberOfRigCameras(2);
  18620. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  18621. this.rigCameras[0].position.x = -pupilDistance / 2;
  18622. this.rigCameras[0].outputRenderTarget = null;
  18623. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  18624. this.rigCameras[1].position.x = pupilDistance / 2;
  18625. this.rigCameras[1].outputRenderTarget = null;
  18626. };
  18627. /**
  18628. * Updates the cameras position from the current pose information of the XR session
  18629. * @param xrSessionManager the session containing pose information
  18630. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  18631. */
  18632. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  18633. var _this = this;
  18634. // Ensure all frame data is available
  18635. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  18636. return false;
  18637. }
  18638. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  18639. if (!pose || !pose.poseModelMatrix) {
  18640. return false;
  18641. }
  18642. // Update the parent cameras matrix
  18643. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  18644. if (!this._scene.useRightHandedSystem) {
  18645. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  18646. }
  18647. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  18648. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  18649. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  18650. this.computeWorldMatrix();
  18651. // Update camera rigs
  18652. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  18653. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  18654. // Update view/projection matrix
  18655. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  18656. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  18657. if (!_this._scene.useRightHandedSystem) {
  18658. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  18659. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18660. }
  18661. // Update viewport
  18662. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  18663. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  18664. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  18665. _this.rigCameras[i].viewport.width = viewport.width / width;
  18666. _this.rigCameras[i].viewport.height = viewport.height / height;
  18667. _this.rigCameras[i].viewport.x = viewport.x / width;
  18668. _this.rigCameras[i].viewport.y = viewport.y / height;
  18669. // Set cameras to render to the session's render target
  18670. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  18671. });
  18672. return true;
  18673. };
  18674. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  18675. return WebXRCamera;
  18676. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  18677. /***/ }),
  18678. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  18679. /*!****************************************!*\
  18680. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  18681. \****************************************/
  18682. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  18683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18684. "use strict";
  18685. __webpack_require__.r(__webpack_exports__);
  18686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  18687. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  18688. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  18689. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18690. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18691. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18692. /**
  18693. * Button which can be used to enter a different mode of XR
  18694. */
  18695. var WebXREnterExitUIButton = /** @class */ (function () {
  18696. /**
  18697. * Creates a WebXREnterExitUIButton
  18698. * @param element button element
  18699. * @param initializationOptions XR initialization options for the button
  18700. */
  18701. function WebXREnterExitUIButton(
  18702. /** button element */
  18703. element,
  18704. /** XR initialization options for the button */
  18705. initializationOptions) {
  18706. this.element = element;
  18707. this.initializationOptions = initializationOptions;
  18708. }
  18709. /**
  18710. * Overwritable function which can be used to update the button's visuals when the state changes
  18711. * @param activeButton the current active button in the UI
  18712. */
  18713. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  18714. };
  18715. return WebXREnterExitUIButton;
  18716. }());
  18717. /**
  18718. * Options to create the webXR UI
  18719. */
  18720. var WebXREnterExitUIOptions = /** @class */ (function () {
  18721. function WebXREnterExitUIOptions() {
  18722. }
  18723. return WebXREnterExitUIOptions;
  18724. }());
  18725. /**
  18726. * UI to allow the user to enter/exit XR mode
  18727. */
  18728. var WebXREnterExitUI = /** @class */ (function () {
  18729. function WebXREnterExitUI(scene, options) {
  18730. var _this = this;
  18731. this.scene = scene;
  18732. this._buttons = [];
  18733. this._activeButton = null;
  18734. /**
  18735. * Fired every time the active button is changed.
  18736. *
  18737. * When xr is entered via a button that launches xr that button will be the callback parameter
  18738. *
  18739. * When exiting xr the callback parameter will be null)
  18740. */
  18741. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18742. this._overlay = document.createElement("div");
  18743. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  18744. if (options.customButtons) {
  18745. this._buttons = options.customButtons;
  18746. }
  18747. else {
  18748. var hmdBtn = document.createElement("button");
  18749. hmdBtn.style.cssText = "color: #868686; border-color: #868686; border-style: solid; margin-left: 10px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-repeat:no-repeat; background-position: center; outline: none;";
  18750. hmdBtn.innerText = "HMD";
  18751. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  18752. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18753. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18754. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  18755. };
  18756. var windowBtn = document.createElement("button");
  18757. windowBtn.style.cssText = hmdBtn.style.cssText;
  18758. windowBtn.innerText = "Window";
  18759. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  18760. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18761. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18762. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  18763. };
  18764. this._updateButtons(null);
  18765. }
  18766. var renderCanvas = scene.getEngine().getRenderingCanvas();
  18767. if (renderCanvas && renderCanvas.parentNode) {
  18768. renderCanvas.parentNode.appendChild(this._overlay);
  18769. scene.onDisposeObservable.addOnce(function () {
  18770. _this.dispose();
  18771. });
  18772. }
  18773. }
  18774. /**
  18775. * Creates UI to allow the user to enter/exit XR mode
  18776. * @param scene the scene to add the ui to
  18777. * @param helper the xr experience helper to enter/exit xr with
  18778. * @param options options to configure the UI
  18779. * @returns the created ui
  18780. */
  18781. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  18782. var _this = this;
  18783. var ui = new WebXREnterExitUI(scene, options);
  18784. var supportedPromises = ui._buttons.map(function (btn) {
  18785. return helper.supportsSessionAsync(btn.initializationOptions);
  18786. });
  18787. helper.onStateChangedObservable.add(function (state) {
  18788. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  18789. ui._updateButtons(null);
  18790. }
  18791. });
  18792. return Promise.all(supportedPromises).then(function (results) {
  18793. results.forEach(function (supported, i) {
  18794. if (supported) {
  18795. ui._overlay.appendChild(ui._buttons[i].element);
  18796. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  18797. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  18798. switch (_a.label) {
  18799. case 0:
  18800. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  18801. ui._updateButtons(null);
  18802. return [4 /*yield*/, helper.exitXRAsync()];
  18803. case 1:
  18804. _a.sent();
  18805. return [2 /*return*/];
  18806. case 2:
  18807. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  18808. ui._updateButtons(ui._buttons[i]);
  18809. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  18810. case 3:
  18811. _a.sent();
  18812. _a.label = 4;
  18813. case 4: return [2 /*return*/];
  18814. }
  18815. });
  18816. }); };
  18817. }
  18818. });
  18819. return ui;
  18820. });
  18821. };
  18822. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  18823. var _this = this;
  18824. this._activeButton = activeButton;
  18825. this._buttons.forEach(function (b) {
  18826. b.update(_this._activeButton);
  18827. });
  18828. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  18829. };
  18830. /**
  18831. * Disposes of the object
  18832. */
  18833. WebXREnterExitUI.prototype.dispose = function () {
  18834. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  18835. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  18836. renderCanvas.parentNode.removeChild(this._overlay);
  18837. }
  18838. this.activeButtonChangedObservable.clear();
  18839. };
  18840. return WebXREnterExitUI;
  18841. }());
  18842. /***/ }),
  18843. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  18844. /*!*********************************************!*\
  18845. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  18846. \*********************************************/
  18847. /*! exports provided: WebXRState, WebXRExperienceHelper */
  18848. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18849. "use strict";
  18850. __webpack_require__.r(__webpack_exports__);
  18851. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  18852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  18853. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18854. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18855. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18856. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18857. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18858. /**
  18859. * States of the webXR experience
  18860. */
  18861. var WebXRState;
  18862. (function (WebXRState) {
  18863. /**
  18864. * Transitioning to being in XR mode
  18865. */
  18866. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  18867. /**
  18868. * Transitioning to non XR mode
  18869. */
  18870. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  18871. /**
  18872. * In XR mode and presenting
  18873. */
  18874. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  18875. /**
  18876. * Not entered XR mode
  18877. */
  18878. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  18879. })(WebXRState || (WebXRState = {}));
  18880. /**
  18881. * Helper class used to enable XR
  18882. * @see https://doc.babylonjs.com/how_to/webxr
  18883. */
  18884. var WebXRExperienceHelper = /** @class */ (function () {
  18885. /**
  18886. * Creates a WebXRExperienceHelper
  18887. * @param scene The scene the helper should be created in
  18888. */
  18889. function WebXRExperienceHelper(scene) {
  18890. this.scene = scene;
  18891. /**
  18892. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  18893. */
  18894. this.state = WebXRState.NOT_IN_XR;
  18895. /**
  18896. * Fires when the state of the experience helper has changed
  18897. */
  18898. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  18899. this._nonVRCamera = null;
  18900. this._originalSceneAutoClear = true;
  18901. this._supported = false;
  18902. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  18903. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  18904. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  18905. this.camera.parent = this.container;
  18906. }
  18907. WebXRExperienceHelper.prototype._setState = function (val) {
  18908. this.state = val;
  18909. this.onStateChangedObservable.notifyObservers(this.state);
  18910. };
  18911. /**
  18912. * Creates the experience helper
  18913. * @param scene the scene to attach the experience helper to
  18914. * @returns a promise for the experience helper
  18915. */
  18916. WebXRExperienceHelper.CreateAsync = function (scene) {
  18917. var helper = new WebXRExperienceHelper(scene);
  18918. return helper._sessionManager.initializeAsync().then(function () {
  18919. helper._supported = true;
  18920. return helper;
  18921. }).catch(function () {
  18922. return helper;
  18923. });
  18924. };
  18925. /**
  18926. * Exits XR mode and returns the scene to its original state
  18927. * @returns promise that resolves after xr mode has exited
  18928. */
  18929. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  18930. this._setState(WebXRState.EXITING_XR);
  18931. return this._sessionManager.exitXRAsync();
  18932. };
  18933. /**
  18934. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  18935. * @param sessionCreationOptions options for the XR session
  18936. * @param frameOfReference frame of reference of the XR session
  18937. * @returns promise that resolves after xr mode has entered
  18938. */
  18939. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  18940. var _this = this;
  18941. if (!this._supported) {
  18942. throw "XR session not supported by this browser";
  18943. }
  18944. this._setState(WebXRState.ENTERING_XR);
  18945. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  18946. // Cache pre xr scene settings
  18947. _this._originalSceneAutoClear = _this.scene.autoClear;
  18948. _this._nonVRCamera = _this.scene.activeCamera;
  18949. // Overwrite current scene settings
  18950. _this.scene.autoClear = false;
  18951. _this.scene.activeCamera = _this.camera;
  18952. _this._sessionManager.onXRFrameObservable.add(function () {
  18953. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  18954. });
  18955. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  18956. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  18957. _this.camera.rigCameras.forEach(function (c) {
  18958. c.outputRenderTarget = null;
  18959. });
  18960. // Restore scene settings
  18961. _this.scene.autoClear = _this._originalSceneAutoClear;
  18962. _this.scene.activeCamera = _this._nonVRCamera;
  18963. _this._sessionManager.onXRFrameObservable.clear();
  18964. _this._setState(WebXRState.NOT_IN_XR);
  18965. });
  18966. _this._setState(WebXRState.IN_XR);
  18967. });
  18968. };
  18969. /**
  18970. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18971. * @param ray ray to cast into the environment
  18972. * @returns Promise which resolves with a collision point in the environment if it exists
  18973. */
  18974. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  18975. return this._sessionManager.environmentPointHitTestAsync(ray);
  18976. };
  18977. /**
  18978. * Updates the global position of the camera by moving the camera's container
  18979. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  18980. * @param position The desired global position of the camera
  18981. */
  18982. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  18983. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  18984. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  18985. };
  18986. /**
  18987. * Rotates the xr camera by rotating the camera's container around the camera's position
  18988. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  18989. * @param rotation the desired quaternion rotation to apply to the camera
  18990. */
  18991. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  18992. if (!this.container.rotationQuaternion) {
  18993. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  18994. }
  18995. this.container.rotationQuaternion.multiplyInPlace(rotation);
  18996. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  18997. };
  18998. /**
  18999. * Checks if the creation options are supported by the xr session
  19000. * @param options creation options
  19001. * @returns true if supported
  19002. */
  19003. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  19004. if (!this._supported) {
  19005. return Promise.resolve(false);
  19006. }
  19007. return this._sessionManager.supportsSessionAsync(options);
  19008. };
  19009. /**
  19010. * Disposes of the experience helper
  19011. */
  19012. WebXRExperienceHelper.prototype.dispose = function () {
  19013. this.camera.dispose();
  19014. this.container.dispose();
  19015. this.onStateChangedObservable.clear();
  19016. this._sessionManager.dispose();
  19017. };
  19018. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  19019. return WebXRExperienceHelper;
  19020. }());
  19021. /***/ }),
  19022. /***/ "./Cameras/XR/webXRInput.ts":
  19023. /*!**********************************!*\
  19024. !*** ./Cameras/XR/webXRInput.ts ***!
  19025. \**********************************/
  19026. /*! exports provided: WebXRController, WebXRInput */
  19027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19028. "use strict";
  19029. __webpack_require__.r(__webpack_exports__);
  19030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  19031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  19032. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  19033. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  19034. /**
  19035. * Represents an XR input
  19036. */
  19037. var WebXRController = /** @class */ (function () {
  19038. /**
  19039. * Creates the controller
  19040. * @see https://doc.babylonjs.com/how_to/webxr
  19041. * @param scene the scene which the controller should be associated to
  19042. */
  19043. function WebXRController(scene) {
  19044. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  19045. }
  19046. /**
  19047. * Disposes of the object
  19048. */
  19049. WebXRController.prototype.dispose = function () {
  19050. if (this.grip) {
  19051. this.grip.dispose();
  19052. }
  19053. this.pointer.dispose();
  19054. };
  19055. return WebXRController;
  19056. }());
  19057. /**
  19058. * XR input used to track XR inputs such as controllers/rays
  19059. */
  19060. var WebXRInput = /** @class */ (function () {
  19061. /**
  19062. * Initializes the WebXRInput
  19063. * @param helper experience helper which the input should be created for
  19064. */
  19065. function WebXRInput(helper) {
  19066. var _this = this;
  19067. this.helper = helper;
  19068. /**
  19069. * XR controllers being tracked
  19070. */
  19071. this.controllers = [];
  19072. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  19073. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  19074. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  19075. return;
  19076. }
  19077. var xrFrame = helper._sessionManager._currentXRFrame;
  19078. var inputSources = helper._sessionManager._xrSession.getInputSources();
  19079. inputSources.forEach(function (input, i) {
  19080. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  19081. if (inputPose) {
  19082. if (_this.controllers.length <= i) {
  19083. _this.controllers.push(new WebXRController(helper.container.getScene()));
  19084. }
  19085. var controller = _this.controllers[i];
  19086. // Manage the grip if it exists
  19087. if (inputPose.gripMatrix) {
  19088. if (!controller.grip) {
  19089. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  19090. }
  19091. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  19092. if (!controller.grip.getScene().useRightHandedSystem) {
  19093. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  19094. }
  19095. if (!controller.grip.rotationQuaternion) {
  19096. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  19097. }
  19098. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  19099. }
  19100. // Manager pointer of controller
  19101. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  19102. if (!controller.pointer.getScene().useRightHandedSystem) {
  19103. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  19104. }
  19105. if (!controller.pointer.rotationQuaternion) {
  19106. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  19107. }
  19108. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  19109. }
  19110. });
  19111. });
  19112. }
  19113. /**
  19114. * Disposes of the object
  19115. */
  19116. WebXRInput.prototype.dispose = function () {
  19117. this.controllers.forEach(function (c) {
  19118. c.dispose();
  19119. });
  19120. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  19121. };
  19122. return WebXRInput;
  19123. }());
  19124. /***/ }),
  19125. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  19126. /*!************************************************!*\
  19127. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  19128. \************************************************/
  19129. /*! exports provided: WebXRManagedOutputCanvas */
  19130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19131. "use strict";
  19132. __webpack_require__.r(__webpack_exports__);
  19133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  19134. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  19135. /**
  19136. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  19137. */
  19138. var WebXRManagedOutputCanvas = /** @class */ (function () {
  19139. /**
  19140. * Initializes the canvas to be added/removed upon entering/exiting xr
  19141. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  19142. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  19143. */
  19144. function WebXRManagedOutputCanvas(helper, canvas) {
  19145. var _this = this;
  19146. this._canvas = null;
  19147. /**
  19148. * xrpresent context of the canvas which can be used to display/mirror xr content
  19149. */
  19150. this.canvasContext = null;
  19151. if (!canvas) {
  19152. canvas = document.createElement('canvas');
  19153. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  19154. }
  19155. this._setManagedOutputCanvas(canvas);
  19156. helper.onStateChangedObservable.add(function (stateInfo) {
  19157. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  19158. // The canvas is added to the screen before entering XR because currently the xr session must be initialized while the canvas is added render properly
  19159. _this._addCanvas();
  19160. }
  19161. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  19162. _this._removeCanvas();
  19163. }
  19164. });
  19165. }
  19166. /**
  19167. * Disposes of the object
  19168. */
  19169. WebXRManagedOutputCanvas.prototype.dispose = function () {
  19170. this._removeCanvas();
  19171. this._setManagedOutputCanvas(null);
  19172. };
  19173. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  19174. this._removeCanvas();
  19175. if (!canvas) {
  19176. this._canvas = null;
  19177. this.canvasContext = null;
  19178. }
  19179. else {
  19180. this._canvas = canvas;
  19181. this.canvasContext = this._canvas.getContext('xrpresent');
  19182. }
  19183. };
  19184. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  19185. if (this._canvas) {
  19186. document.body.appendChild(this._canvas);
  19187. }
  19188. };
  19189. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  19190. if (this._canvas && document.body.contains(this._canvas)) {
  19191. document.body.removeChild(this._canvas);
  19192. }
  19193. };
  19194. return WebXRManagedOutputCanvas;
  19195. }());
  19196. /***/ }),
  19197. /***/ "./Cameras/XR/webXRSessionManager.ts":
  19198. /*!*******************************************!*\
  19199. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  19200. \*******************************************/
  19201. /*! exports provided: WebXRSessionManager */
  19202. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19203. "use strict";
  19204. __webpack_require__.r(__webpack_exports__);
  19205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  19206. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  19207. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  19208. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  19209. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  19210. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  19211. /**
  19212. * Manages an XRSession
  19213. * @see https://doc.babylonjs.com/how_to/webxr
  19214. */
  19215. var WebXRSessionManager = /** @class */ (function () {
  19216. /**
  19217. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  19218. * @param scene The scene which the session should be created for
  19219. */
  19220. function WebXRSessionManager(scene) {
  19221. this.scene = scene;
  19222. /**
  19223. * Fires every time a new xrFrame arrives which can be used to update the camera
  19224. */
  19225. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19226. /**
  19227. * Fires when the xr session is ended either by the device or manually done
  19228. */
  19229. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19230. /** @hidden */
  19231. this._sessionRenderTargetTexture = null;
  19232. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  19233. }
  19234. /**
  19235. * Initializes the manager
  19236. * After initialization enterXR can be called to start an XR session
  19237. * @returns Promise which resolves after it is initialized
  19238. */
  19239. WebXRSessionManager.prototype.initializeAsync = function () {
  19240. var _this = this;
  19241. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  19242. // Check if the browser supports webXR
  19243. this._xrNavigator = navigator;
  19244. if (!this._xrNavigator.xr) {
  19245. return Promise.reject("webXR not supported by this browser");
  19246. }
  19247. // Request the webXR device
  19248. return this._xrNavigator.xr.requestDevice().then(function (device) {
  19249. _this._xrDevice = device;
  19250. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  19251. });
  19252. };
  19253. /**
  19254. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  19255. * @param sessionCreationOptions xr options to create the session with
  19256. * @param frameOfReferenceType option to configure how the xr pose is expressed
  19257. * @returns Promise which resolves after it enters XR
  19258. */
  19259. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  19260. var _this = this;
  19261. // initialize session
  19262. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  19263. _this._xrSession = session;
  19264. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  19265. _this._xrSession.addEventListener("end", function () {
  19266. // Remove render target texture and notify frame obervers
  19267. _this._sessionRenderTargetTexture = null;
  19268. // Restore frame buffer to avoid clear on xr framebuffer after session end
  19269. _this.scene.getEngine().restoreDefaultFramebuffer();
  19270. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  19271. _this.scene.getEngine().customAnimationFrameRequester = null;
  19272. _this.onXRSessionEnded.notifyObservers(null);
  19273. _this.scene.getEngine()._renderLoop();
  19274. }, { once: true });
  19275. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  19276. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  19277. }).then(function (frameOfRef) {
  19278. _this._frameOfReference = frameOfRef;
  19279. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  19280. _this.scene.getEngine().customAnimationFrameRequester = {
  19281. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  19282. renderFunction: function (timestamp, xrFrame) {
  19283. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  19284. _this._currentXRFrame = xrFrame;
  19285. _this.onXRFrameObservable.notifyObservers(null);
  19286. _this.scene.getEngine()._renderLoop();
  19287. }
  19288. };
  19289. // Create render target texture from xr's webgl render target
  19290. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  19291. // Stop window's animation frame and trigger sessions animation frame
  19292. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  19293. _this.scene.getEngine()._renderLoop();
  19294. });
  19295. };
  19296. /**
  19297. * Stops the xrSession and restores the renderloop
  19298. * @returns Promise which resolves after it exits XR
  19299. */
  19300. WebXRSessionManager.prototype.exitXRAsync = function () {
  19301. return this._xrSession.end();
  19302. };
  19303. /**
  19304. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  19305. * @param ray ray to cast into the environment
  19306. * @returns Promise which resolves with a collision point in the environment if it exists
  19307. */
  19308. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  19309. var _this = this;
  19310. return new Promise(function (res) {
  19311. // Compute left handed inputs to request hit test
  19312. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  19313. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  19314. if (!_this.scene.useRightHandedSystem) {
  19315. origin[2] *= -1;
  19316. direction[2] *= -1;
  19317. }
  19318. // Fire hittest
  19319. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  19320. .then(function (hits) {
  19321. if (hits.length > 0) {
  19322. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  19323. var hitPoint = _this._tmpMatrix.getTranslation();
  19324. if (!_this.scene.useRightHandedSystem) {
  19325. hitPoint.z *= -1;
  19326. }
  19327. res(hitPoint);
  19328. }
  19329. else {
  19330. res(null);
  19331. }
  19332. }).catch(function () {
  19333. res(null);
  19334. });
  19335. });
  19336. };
  19337. /**
  19338. * Checks if a session would be supported for the creation options specified
  19339. * @param options creation options to check if they are supported
  19340. * @returns true if supported
  19341. */
  19342. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  19343. return this._xrDevice.supportsSession(options).then(function () {
  19344. return true;
  19345. }).catch(function () {
  19346. return false;
  19347. });
  19348. };
  19349. /**
  19350. * @hidden
  19351. * Converts the render layer of xrSession to a render target
  19352. * @param session session to create render target for
  19353. * @param scene scene the new render target should be created for
  19354. */
  19355. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  19356. // Create internal texture
  19357. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  19358. internalTexture.width = session.baseLayer.framebufferWidth;
  19359. internalTexture.height = session.baseLayer.framebufferHeight;
  19360. internalTexture._framebuffer = session.baseLayer.framebuffer;
  19361. // Create render target texture from the internal texture
  19362. var renderTargetTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__["RenderTargetTexture"]("XR renderTargetTexture", { width: internalTexture.width, height: internalTexture.height }, scene, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, true);
  19363. renderTargetTexture._texture = internalTexture;
  19364. return renderTargetTexture;
  19365. };
  19366. /**
  19367. * Disposes of the session manager
  19368. */
  19369. WebXRSessionManager.prototype.dispose = function () {
  19370. this.onXRFrameObservable.clear();
  19371. this.onXRSessionEnded.clear();
  19372. };
  19373. return WebXRSessionManager;
  19374. }());
  19375. /***/ }),
  19376. /***/ "./Cameras/arcRotateCamera.ts":
  19377. /*!************************************!*\
  19378. !*** ./Cameras/arcRotateCamera.ts ***!
  19379. \************************************/
  19380. /*! exports provided: ArcRotateCamera */
  19381. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19382. "use strict";
  19383. __webpack_require__.r(__webpack_exports__);
  19384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  19385. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19386. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19387. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19388. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19389. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  19390. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  19391. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  19392. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  19393. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  19394. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  19395. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  19396. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  19397. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  19398. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  19399. });
  19400. /**
  19401. * This represents an orbital type of camera.
  19402. *
  19403. * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events.
  19404. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position.
  19405. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  19406. */
  19407. var ArcRotateCamera = /** @class */ (function (_super) {
  19408. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  19409. /**
  19410. * Instantiates a new ArcRotateCamera in a given scene
  19411. * @param name Defines the name of the camera
  19412. * @param alpha Defines the camera rotation along the logitudinal axis
  19413. * @param beta Defines the camera rotation along the latitudinal axis
  19414. * @param radius Defines the camera distance from its target
  19415. * @param target Defines the camera target
  19416. * @param scene Defines the scene the camera belongs to
  19417. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19418. */
  19419. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  19420. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19421. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  19422. _this._upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  19423. /**
  19424. * Current inertia value on the longitudinal axis.
  19425. * The bigger this number the longer it will take for the camera to stop.
  19426. */
  19427. _this.inertialAlphaOffset = 0;
  19428. /**
  19429. * Current inertia value on the latitudinal axis.
  19430. * The bigger this number the longer it will take for the camera to stop.
  19431. */
  19432. _this.inertialBetaOffset = 0;
  19433. /**
  19434. * Current inertia value on the radius axis.
  19435. * The bigger this number the longer it will take for the camera to stop.
  19436. */
  19437. _this.inertialRadiusOffset = 0;
  19438. /**
  19439. * Minimum allowed angle on the longitudinal axis.
  19440. * This can help limiting how the Camera is able to move in the scene.
  19441. */
  19442. _this.lowerAlphaLimit = null;
  19443. /**
  19444. * Maximum allowed angle on the longitudinal axis.
  19445. * This can help limiting how the Camera is able to move in the scene.
  19446. */
  19447. _this.upperAlphaLimit = null;
  19448. /**
  19449. * Minimum allowed angle on the latitudinal axis.
  19450. * This can help limiting how the Camera is able to move in the scene.
  19451. */
  19452. _this.lowerBetaLimit = 0.01;
  19453. /**
  19454. * Maximum allowed angle on the latitudinal axis.
  19455. * This can help limiting how the Camera is able to move in the scene.
  19456. */
  19457. _this.upperBetaLimit = Math.PI - 0.01;
  19458. /**
  19459. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  19460. * This can help limiting how the Camera is able to move in the scene.
  19461. */
  19462. _this.lowerRadiusLimit = null;
  19463. /**
  19464. * Maximum allowed distance of the camera to the target (The camera can not get further).
  19465. * This can help limiting how the Camera is able to move in the scene.
  19466. */
  19467. _this.upperRadiusLimit = null;
  19468. /**
  19469. * Defines the current inertia value used during panning of the camera along the X axis.
  19470. */
  19471. _this.inertialPanningX = 0;
  19472. /**
  19473. * Defines the current inertia value used during panning of the camera along the Y axis.
  19474. */
  19475. _this.inertialPanningY = 0;
  19476. /**
  19477. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  19478. * Basically if your fingers moves away from more than this distance you will be considered
  19479. * in pinch mode.
  19480. */
  19481. _this.pinchToPanMaxDistance = 20;
  19482. /**
  19483. * Defines the maximum distance the camera can pan.
  19484. * This could help keeping the cammera always in your scene.
  19485. */
  19486. _this.panningDistanceLimit = null;
  19487. /**
  19488. * Defines the target of the camera before paning.
  19489. */
  19490. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19491. /**
  19492. * Defines the value of the inertia used during panning.
  19493. * 0 would mean stop inertia and one would mean no decelleration at all.
  19494. */
  19495. _this.panningInertia = 0.9;
  19496. //-- end properties for backward compatibility for inputs
  19497. /**
  19498. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  19499. */
  19500. _this.zoomOnFactor = 1;
  19501. /**
  19502. * Defines a screen offset for the camera position.
  19503. */
  19504. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19505. /**
  19506. * Allows the camera to be completely reversed.
  19507. * If false the camera can not arrive upside down.
  19508. */
  19509. _this.allowUpsideDown = true;
  19510. /**
  19511. * Define if double tap/click is used to restore the previously saved state of the camera.
  19512. */
  19513. _this.useInputToRestoreState = true;
  19514. /** @hidden */
  19515. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19516. /**
  19517. * Defines the allowed panning axis.
  19518. */
  19519. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  19520. /**
  19521. * Observable triggered when the mesh target has been changed on the camera.
  19522. */
  19523. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  19524. /**
  19525. * Defines whether the camera should check collision with the objects oh the scene.
  19526. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  19527. */
  19528. _this.checkCollisions = false;
  19529. /**
  19530. * Defines the collision radius of the camera.
  19531. * This simulates a sphere around the camera.
  19532. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19533. */
  19534. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  19535. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19536. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19537. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19538. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19539. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  19540. if (collidedMesh === void 0) { collidedMesh = null; }
  19541. if (!collidedMesh) {
  19542. _this._previousPosition.copyFrom(_this._position);
  19543. }
  19544. else {
  19545. _this.setPosition(newPosition);
  19546. if (_this.onCollide) {
  19547. _this.onCollide(collidedMesh);
  19548. }
  19549. }
  19550. // Recompute because of constraints
  19551. var cosa = Math.cos(_this.alpha);
  19552. var sina = Math.sin(_this.alpha);
  19553. var cosb = Math.cos(_this.beta);
  19554. var sinb = Math.sin(_this.beta);
  19555. if (sinb === 0) {
  19556. sinb = 0.0001;
  19557. }
  19558. var target = _this._getTargetPosition();
  19559. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  19560. target.addToRef(_this._computationVector, _this._newPosition);
  19561. _this._position.copyFrom(_this._newPosition);
  19562. var up = _this.upVector;
  19563. if (_this.allowUpsideDown && _this.beta < 0) {
  19564. up = up.clone();
  19565. up = up.negate();
  19566. }
  19567. _this._computeViewMatrix(_this._position, target, up);
  19568. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  19569. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  19570. _this._collisionTriggered = false;
  19571. };
  19572. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19573. if (target) {
  19574. _this.setTarget(target);
  19575. }
  19576. _this.alpha = alpha;
  19577. _this.beta = beta;
  19578. _this.radius = radius;
  19579. _this.getViewMatrix();
  19580. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["ArcRotateCameraInputsManager"](_this);
  19581. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  19582. return _this;
  19583. }
  19584. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  19585. /**
  19586. * Defines the target point of the camera.
  19587. * The camera looks towards it form the radius distance.
  19588. */
  19589. get: function () {
  19590. return this._target;
  19591. },
  19592. set: function (value) {
  19593. this.setTarget(value);
  19594. },
  19595. enumerable: true,
  19596. configurable: true
  19597. });
  19598. Object.defineProperty(ArcRotateCamera.prototype, "position", {
  19599. /**
  19600. * Define the current local position of the camera in the scene
  19601. */
  19602. get: function () {
  19603. return this._position;
  19604. },
  19605. set: function (newPosition) {
  19606. this.setPosition(newPosition);
  19607. },
  19608. enumerable: true,
  19609. configurable: true
  19610. });
  19611. Object.defineProperty(ArcRotateCamera.prototype, "upVector", {
  19612. get: function () {
  19613. return this._upVector;
  19614. },
  19615. /**
  19616. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  19617. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  19618. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  19619. */
  19620. set: function (vec) {
  19621. if (!this._upToYMatrix) {
  19622. this._YToUpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19623. this._upToYMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19624. this._upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19625. }
  19626. vec.normalize();
  19627. this._upVector.copyFrom(vec);
  19628. this.setMatUp();
  19629. },
  19630. enumerable: true,
  19631. configurable: true
  19632. });
  19633. /**
  19634. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  19635. */
  19636. ArcRotateCamera.prototype.setMatUp = function () {
  19637. // from y-up to custom-up (used in _getViewMatrix)
  19638. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAlignToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this._upVector, this._YToUpMatrix);
  19639. // from custom-up to y-up (used in rebuildAnglesAndRadius)
  19640. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAlignToRef(this._upVector, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this._upToYMatrix);
  19641. };
  19642. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  19643. //-- begin properties for backward compatibility for inputs
  19644. /**
  19645. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  19646. */
  19647. get: function () {
  19648. var pointers = this.inputs.attached["pointers"];
  19649. if (pointers) {
  19650. return pointers.angularSensibilityX;
  19651. }
  19652. return 0;
  19653. },
  19654. set: function (value) {
  19655. var pointers = this.inputs.attached["pointers"];
  19656. if (pointers) {
  19657. pointers.angularSensibilityX = value;
  19658. }
  19659. },
  19660. enumerable: true,
  19661. configurable: true
  19662. });
  19663. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  19664. /**
  19665. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  19666. */
  19667. get: function () {
  19668. var pointers = this.inputs.attached["pointers"];
  19669. if (pointers) {
  19670. return pointers.angularSensibilityY;
  19671. }
  19672. return 0;
  19673. },
  19674. set: function (value) {
  19675. var pointers = this.inputs.attached["pointers"];
  19676. if (pointers) {
  19677. pointers.angularSensibilityY = value;
  19678. }
  19679. },
  19680. enumerable: true,
  19681. configurable: true
  19682. });
  19683. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  19684. /**
  19685. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  19686. */
  19687. get: function () {
  19688. var pointers = this.inputs.attached["pointers"];
  19689. if (pointers) {
  19690. return pointers.pinchPrecision;
  19691. }
  19692. return 0;
  19693. },
  19694. set: function (value) {
  19695. var pointers = this.inputs.attached["pointers"];
  19696. if (pointers) {
  19697. pointers.pinchPrecision = value;
  19698. }
  19699. },
  19700. enumerable: true,
  19701. configurable: true
  19702. });
  19703. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  19704. /**
  19705. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  19706. * It will be used instead of pinchDeltaPrecision if different from 0.
  19707. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19708. */
  19709. get: function () {
  19710. var pointers = this.inputs.attached["pointers"];
  19711. if (pointers) {
  19712. return pointers.pinchDeltaPercentage;
  19713. }
  19714. return 0;
  19715. },
  19716. set: function (value) {
  19717. var pointers = this.inputs.attached["pointers"];
  19718. if (pointers) {
  19719. pointers.pinchDeltaPercentage = value;
  19720. }
  19721. },
  19722. enumerable: true,
  19723. configurable: true
  19724. });
  19725. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  19726. /**
  19727. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  19728. */
  19729. get: function () {
  19730. var pointers = this.inputs.attached["pointers"];
  19731. if (pointers) {
  19732. return pointers.panningSensibility;
  19733. }
  19734. return 0;
  19735. },
  19736. set: function (value) {
  19737. var pointers = this.inputs.attached["pointers"];
  19738. if (pointers) {
  19739. pointers.panningSensibility = value;
  19740. }
  19741. },
  19742. enumerable: true,
  19743. configurable: true
  19744. });
  19745. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  19746. /**
  19747. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  19748. */
  19749. get: function () {
  19750. var keyboard = this.inputs.attached["keyboard"];
  19751. if (keyboard) {
  19752. return keyboard.keysUp;
  19753. }
  19754. return [];
  19755. },
  19756. set: function (value) {
  19757. var keyboard = this.inputs.attached["keyboard"];
  19758. if (keyboard) {
  19759. keyboard.keysUp = value;
  19760. }
  19761. },
  19762. enumerable: true,
  19763. configurable: true
  19764. });
  19765. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  19766. /**
  19767. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  19768. */
  19769. get: function () {
  19770. var keyboard = this.inputs.attached["keyboard"];
  19771. if (keyboard) {
  19772. return keyboard.keysDown;
  19773. }
  19774. return [];
  19775. },
  19776. set: function (value) {
  19777. var keyboard = this.inputs.attached["keyboard"];
  19778. if (keyboard) {
  19779. keyboard.keysDown = value;
  19780. }
  19781. },
  19782. enumerable: true,
  19783. configurable: true
  19784. });
  19785. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  19786. /**
  19787. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  19788. */
  19789. get: function () {
  19790. var keyboard = this.inputs.attached["keyboard"];
  19791. if (keyboard) {
  19792. return keyboard.keysLeft;
  19793. }
  19794. return [];
  19795. },
  19796. set: function (value) {
  19797. var keyboard = this.inputs.attached["keyboard"];
  19798. if (keyboard) {
  19799. keyboard.keysLeft = value;
  19800. }
  19801. },
  19802. enumerable: true,
  19803. configurable: true
  19804. });
  19805. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  19806. /**
  19807. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  19808. */
  19809. get: function () {
  19810. var keyboard = this.inputs.attached["keyboard"];
  19811. if (keyboard) {
  19812. return keyboard.keysRight;
  19813. }
  19814. return [];
  19815. },
  19816. set: function (value) {
  19817. var keyboard = this.inputs.attached["keyboard"];
  19818. if (keyboard) {
  19819. keyboard.keysRight = value;
  19820. }
  19821. },
  19822. enumerable: true,
  19823. configurable: true
  19824. });
  19825. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  19826. /**
  19827. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  19828. */
  19829. get: function () {
  19830. var mousewheel = this.inputs.attached["mousewheel"];
  19831. if (mousewheel) {
  19832. return mousewheel.wheelPrecision;
  19833. }
  19834. return 0;
  19835. },
  19836. set: function (value) {
  19837. var mousewheel = this.inputs.attached["mousewheel"];
  19838. if (mousewheel) {
  19839. mousewheel.wheelPrecision = value;
  19840. }
  19841. },
  19842. enumerable: true,
  19843. configurable: true
  19844. });
  19845. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  19846. /**
  19847. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  19848. * It will be used instead of pinchDeltaPrecision if different from 0.
  19849. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19850. */
  19851. get: function () {
  19852. var mousewheel = this.inputs.attached["mousewheel"];
  19853. if (mousewheel) {
  19854. return mousewheel.wheelDeltaPercentage;
  19855. }
  19856. return 0;
  19857. },
  19858. set: function (value) {
  19859. var mousewheel = this.inputs.attached["mousewheel"];
  19860. if (mousewheel) {
  19861. mousewheel.wheelDeltaPercentage = value;
  19862. }
  19863. },
  19864. enumerable: true,
  19865. configurable: true
  19866. });
  19867. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  19868. /**
  19869. * Gets the bouncing behavior of the camera if it has been enabled.
  19870. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19871. */
  19872. get: function () {
  19873. return this._bouncingBehavior;
  19874. },
  19875. enumerable: true,
  19876. configurable: true
  19877. });
  19878. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  19879. /**
  19880. * Defines if the bouncing behavior of the camera is enabled on the camera.
  19881. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19882. */
  19883. get: function () {
  19884. return this._bouncingBehavior != null;
  19885. },
  19886. set: function (value) {
  19887. if (value === this.useBouncingBehavior) {
  19888. return;
  19889. }
  19890. if (value) {
  19891. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  19892. this.addBehavior(this._bouncingBehavior);
  19893. }
  19894. else if (this._bouncingBehavior) {
  19895. this.removeBehavior(this._bouncingBehavior);
  19896. this._bouncingBehavior = null;
  19897. }
  19898. },
  19899. enumerable: true,
  19900. configurable: true
  19901. });
  19902. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  19903. /**
  19904. * Gets the framing behavior of the camera if it has been enabled.
  19905. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19906. */
  19907. get: function () {
  19908. return this._framingBehavior;
  19909. },
  19910. enumerable: true,
  19911. configurable: true
  19912. });
  19913. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  19914. /**
  19915. * Defines if the framing behavior of the camera is enabled on the camera.
  19916. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19917. */
  19918. get: function () {
  19919. return this._framingBehavior != null;
  19920. },
  19921. set: function (value) {
  19922. if (value === this.useFramingBehavior) {
  19923. return;
  19924. }
  19925. if (value) {
  19926. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  19927. this.addBehavior(this._framingBehavior);
  19928. }
  19929. else if (this._framingBehavior) {
  19930. this.removeBehavior(this._framingBehavior);
  19931. this._framingBehavior = null;
  19932. }
  19933. },
  19934. enumerable: true,
  19935. configurable: true
  19936. });
  19937. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  19938. /**
  19939. * Gets the auto rotation behavior of the camera if it has been enabled.
  19940. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19941. */
  19942. get: function () {
  19943. return this._autoRotationBehavior;
  19944. },
  19945. enumerable: true,
  19946. configurable: true
  19947. });
  19948. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  19949. /**
  19950. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  19951. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19952. */
  19953. get: function () {
  19954. return this._autoRotationBehavior != null;
  19955. },
  19956. set: function (value) {
  19957. if (value === this.useAutoRotationBehavior) {
  19958. return;
  19959. }
  19960. if (value) {
  19961. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  19962. this.addBehavior(this._autoRotationBehavior);
  19963. }
  19964. else if (this._autoRotationBehavior) {
  19965. this.removeBehavior(this._autoRotationBehavior);
  19966. this._autoRotationBehavior = null;
  19967. }
  19968. },
  19969. enumerable: true,
  19970. configurable: true
  19971. });
  19972. // Cache
  19973. /** @hidden */
  19974. ArcRotateCamera.prototype._initCache = function () {
  19975. _super.prototype._initCache.call(this);
  19976. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19977. this._cache.alpha = undefined;
  19978. this._cache.beta = undefined;
  19979. this._cache.radius = undefined;
  19980. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19981. };
  19982. /** @hidden */
  19983. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  19984. if (!ignoreParentClass) {
  19985. _super.prototype._updateCache.call(this);
  19986. }
  19987. this._cache._target.copyFrom(this._getTargetPosition());
  19988. this._cache.alpha = this.alpha;
  19989. this._cache.beta = this.beta;
  19990. this._cache.radius = this.radius;
  19991. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  19992. };
  19993. ArcRotateCamera.prototype._getTargetPosition = function () {
  19994. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  19995. var pos = this._targetHost.absolutePosition;
  19996. if (this._targetBoundingCenter) {
  19997. pos.addToRef(this._targetBoundingCenter, this._target);
  19998. }
  19999. else {
  20000. this._target.copyFrom(pos);
  20001. }
  20002. }
  20003. var lockedTargetPosition = this._getLockedTargetPosition();
  20004. if (lockedTargetPosition) {
  20005. return lockedTargetPosition;
  20006. }
  20007. return this._target;
  20008. };
  20009. /**
  20010. * Stores the current state of the camera (alpha, beta, radius and target)
  20011. * @returns the camera itself
  20012. */
  20013. ArcRotateCamera.prototype.storeState = function () {
  20014. this._storedAlpha = this.alpha;
  20015. this._storedBeta = this.beta;
  20016. this._storedRadius = this.radius;
  20017. this._storedTarget = this._getTargetPosition().clone();
  20018. return _super.prototype.storeState.call(this);
  20019. };
  20020. /**
  20021. * @hidden
  20022. * Restored camera state. You must call storeState() first
  20023. */
  20024. ArcRotateCamera.prototype._restoreStateValues = function () {
  20025. if (!_super.prototype._restoreStateValues.call(this)) {
  20026. return false;
  20027. }
  20028. this.alpha = this._storedAlpha;
  20029. this.beta = this._storedBeta;
  20030. this.radius = this._storedRadius;
  20031. this.setTarget(this._storedTarget.clone());
  20032. this.inertialAlphaOffset = 0;
  20033. this.inertialBetaOffset = 0;
  20034. this.inertialRadiusOffset = 0;
  20035. this.inertialPanningX = 0;
  20036. this.inertialPanningY = 0;
  20037. return true;
  20038. };
  20039. // Synchronized
  20040. /** @hidden */
  20041. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  20042. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  20043. return false;
  20044. }
  20045. return this._cache._target.equals(this._getTargetPosition())
  20046. && this._cache.alpha === this.alpha
  20047. && this._cache.beta === this.beta
  20048. && this._cache.radius === this.radius
  20049. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  20050. };
  20051. /**
  20052. * Attached controls to the current camera.
  20053. * @param element Defines the element the controls should be listened from
  20054. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20055. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  20056. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  20057. */
  20058. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  20059. var _this = this;
  20060. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  20061. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  20062. this._useCtrlForPanning = useCtrlForPanning;
  20063. this._panningMouseButton = panningMouseButton;
  20064. this.inputs.attachElement(element, noPreventDefault);
  20065. this._reset = function () {
  20066. _this.inertialAlphaOffset = 0;
  20067. _this.inertialBetaOffset = 0;
  20068. _this.inertialRadiusOffset = 0;
  20069. _this.inertialPanningX = 0;
  20070. _this.inertialPanningY = 0;
  20071. };
  20072. };
  20073. /**
  20074. * Detach the current controls from the camera.
  20075. * The camera will stop reacting to inputs.
  20076. * @param element Defines the element to stop listening the inputs from
  20077. */
  20078. ArcRotateCamera.prototype.detachControl = function (element) {
  20079. this.inputs.detachElement(element);
  20080. if (this._reset) {
  20081. this._reset();
  20082. }
  20083. };
  20084. /** @hidden */
  20085. ArcRotateCamera.prototype._checkInputs = function () {
  20086. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  20087. if (this._collisionTriggered) {
  20088. return;
  20089. }
  20090. this.inputs.checkInputs();
  20091. // Inertia
  20092. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  20093. var inertialAlphaOffset = this.inertialAlphaOffset;
  20094. if (this.beta <= 0) {
  20095. inertialAlphaOffset *= -1;
  20096. }
  20097. if (this.getScene().useRightHandedSystem) {
  20098. inertialAlphaOffset *= -1;
  20099. }
  20100. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  20101. inertialAlphaOffset *= -1;
  20102. }
  20103. this.alpha += inertialAlphaOffset;
  20104. this.beta += this.inertialBetaOffset;
  20105. this.radius -= this.inertialRadiusOffset;
  20106. this.inertialAlphaOffset *= this.inertia;
  20107. this.inertialBetaOffset *= this.inertia;
  20108. this.inertialRadiusOffset *= this.inertia;
  20109. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20110. this.inertialAlphaOffset = 0;
  20111. }
  20112. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20113. this.inertialBetaOffset = 0;
  20114. }
  20115. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20116. this.inertialRadiusOffset = 0;
  20117. }
  20118. }
  20119. // Panning inertia
  20120. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  20121. if (!this._localDirection) {
  20122. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20123. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20124. }
  20125. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  20126. this._localDirection.multiplyInPlace(this.panningAxis);
  20127. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  20128. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  20129. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  20130. if (!this.panningAxis.y) {
  20131. this._transformedDirection.y = 0;
  20132. }
  20133. if (!this._targetHost) {
  20134. if (this.panningDistanceLimit) {
  20135. this._transformedDirection.addInPlace(this._target);
  20136. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  20137. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  20138. this._target.copyFrom(this._transformedDirection);
  20139. }
  20140. }
  20141. else {
  20142. this._target.addInPlace(this._transformedDirection);
  20143. }
  20144. }
  20145. this.inertialPanningX *= this.panningInertia;
  20146. this.inertialPanningY *= this.panningInertia;
  20147. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20148. this.inertialPanningX = 0;
  20149. }
  20150. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20151. this.inertialPanningY = 0;
  20152. }
  20153. }
  20154. // Limits
  20155. this._checkLimits();
  20156. _super.prototype._checkInputs.call(this);
  20157. };
  20158. ArcRotateCamera.prototype._checkLimits = function () {
  20159. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  20160. if (this.allowUpsideDown && this.beta > Math.PI) {
  20161. this.beta = this.beta - (2 * Math.PI);
  20162. }
  20163. }
  20164. else {
  20165. if (this.beta < this.lowerBetaLimit) {
  20166. this.beta = this.lowerBetaLimit;
  20167. }
  20168. }
  20169. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  20170. if (this.allowUpsideDown && this.beta < -Math.PI) {
  20171. this.beta = this.beta + (2 * Math.PI);
  20172. }
  20173. }
  20174. else {
  20175. if (this.beta > this.upperBetaLimit) {
  20176. this.beta = this.upperBetaLimit;
  20177. }
  20178. }
  20179. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  20180. this.alpha = this.lowerAlphaLimit;
  20181. }
  20182. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  20183. this.alpha = this.upperAlphaLimit;
  20184. }
  20185. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  20186. this.radius = this.lowerRadiusLimit;
  20187. this.inertialRadiusOffset = 0;
  20188. }
  20189. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  20190. this.radius = this.upperRadiusLimit;
  20191. this.inertialRadiusOffset = 0;
  20192. }
  20193. };
  20194. /**
  20195. * Rebuilds angles (alpha, beta) and radius from the give position and target
  20196. */
  20197. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
  20198. this._position.subtractToRef(this._getTargetPosition(), this._computationVector);
  20199. // need to rotate to Y up equivalent if up vector not Axis.Y
  20200. if (this._upVector.x !== 0 || this._upVector.y !== 1.0 || this._upVector.z !== 0) {
  20201. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._computationVector, this._upToYMatrix, this._computationVector);
  20202. }
  20203. this.radius = this._computationVector.length();
  20204. if (this.radius === 0) {
  20205. this.radius = 0.0001; // Just to avoid division by zero
  20206. }
  20207. // Alpha
  20208. if (this._computationVector.x === 0 && this._computationVector.z === 0) {
  20209. this.alpha = Math.PI / 2; // avoid division by zero when looking along up axis, and set to acos(0)
  20210. }
  20211. else {
  20212. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  20213. }
  20214. if (this._computationVector.z < 0) {
  20215. this.alpha = 2 * Math.PI - this.alpha;
  20216. }
  20217. // Beta
  20218. this.beta = Math.acos(this._computationVector.y / this.radius);
  20219. this._checkLimits();
  20220. };
  20221. /**
  20222. * Use a position to define the current camera related information like aplha, beta and radius
  20223. * @param position Defines the position to set the camera at
  20224. */
  20225. ArcRotateCamera.prototype.setPosition = function (position) {
  20226. if (this._position.equals(position)) {
  20227. return;
  20228. }
  20229. this._position.copyFrom(position);
  20230. this.rebuildAnglesAndRadius();
  20231. };
  20232. /**
  20233. * Defines the target the camera should look at.
  20234. * This will automatically adapt alpha beta and radius to fit within the new target.
  20235. * @param target Defines the new target as a Vector or a mesh
  20236. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  20237. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  20238. */
  20239. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  20240. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  20241. if (allowSamePosition === void 0) { allowSamePosition = false; }
  20242. if (target.getBoundingInfo) {
  20243. if (toBoundingCenter) {
  20244. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  20245. }
  20246. else {
  20247. this._targetBoundingCenter = null;
  20248. }
  20249. target.computeWorldMatrix();
  20250. this._targetHost = target;
  20251. this._target = this._getTargetPosition();
  20252. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  20253. }
  20254. else {
  20255. var newTarget = target;
  20256. var currentTarget = this._getTargetPosition();
  20257. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  20258. return;
  20259. }
  20260. this._targetHost = null;
  20261. this._target = newTarget;
  20262. this._targetBoundingCenter = null;
  20263. this.onMeshTargetChangedObservable.notifyObservers(null);
  20264. }
  20265. this.rebuildAnglesAndRadius();
  20266. };
  20267. /** @hidden */
  20268. ArcRotateCamera.prototype._getViewMatrix = function () {
  20269. // Compute
  20270. var cosa = Math.cos(this.alpha);
  20271. var sina = Math.sin(this.alpha);
  20272. var cosb = Math.cos(this.beta);
  20273. var sinb = Math.sin(this.beta);
  20274. if (sinb === 0) {
  20275. sinb = 0.0001;
  20276. }
  20277. var target = this._getTargetPosition();
  20278. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  20279. // Rotate according to up vector
  20280. if (this._upVector.x !== 0 || this._upVector.y !== 1.0 || this._upVector.z !== 0) {
  20281. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._computationVector, this._YToUpMatrix, this._computationVector);
  20282. }
  20283. target.addToRef(this._computationVector, this._newPosition);
  20284. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  20285. var coordinator = this.getScene().collisionCoordinator;
  20286. if (!this._collider) {
  20287. this._collider = coordinator.createCollider();
  20288. }
  20289. this._collider._radius = this.collisionRadius;
  20290. this._newPosition.subtractToRef(this._position, this._collisionVelocity);
  20291. this._collisionTriggered = true;
  20292. coordinator.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  20293. }
  20294. else {
  20295. this._position.copyFrom(this._newPosition);
  20296. var up = this.upVector;
  20297. if (this.allowUpsideDown && sinb < 0) {
  20298. up = up.clone();
  20299. up = up.negate();
  20300. }
  20301. this._computeViewMatrix(this._position, target, up);
  20302. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  20303. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  20304. }
  20305. this._currentTarget = target;
  20306. return this._viewMatrix;
  20307. };
  20308. /**
  20309. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  20310. * @param meshes Defines the mesh to zoom on
  20311. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  20312. */
  20313. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  20314. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20315. meshes = meshes || this.getScene().meshes;
  20316. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20317. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  20318. this.radius = distance * this.zoomOnFactor;
  20319. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  20320. };
  20321. /**
  20322. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  20323. * The target will be changed but the radius
  20324. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  20325. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  20326. */
  20327. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  20328. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20329. var meshesOrMinMaxVector;
  20330. var distance;
  20331. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  20332. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  20333. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20334. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  20335. }
  20336. else { //minMaxVector and distance
  20337. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  20338. meshesOrMinMaxVector = minMaxVectorAndDistance;
  20339. distance = minMaxVectorAndDistance.distance;
  20340. }
  20341. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  20342. if (!doNotUpdateMaxZ) {
  20343. this.maxZ = distance * 2;
  20344. }
  20345. };
  20346. /**
  20347. * @override
  20348. * Override Camera.createRigCamera
  20349. */
  20350. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  20351. var alphaShift = 0;
  20352. switch (this.cameraRigMode) {
  20353. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20354. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20355. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20356. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20357. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  20358. break;
  20359. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20360. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  20361. break;
  20362. }
  20363. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  20364. rigCam._cameraRigParams = {};
  20365. return rigCam;
  20366. };
  20367. /**
  20368. * @hidden
  20369. * @override
  20370. * Override Camera._updateRigCameras
  20371. */
  20372. ArcRotateCamera.prototype._updateRigCameras = function () {
  20373. var camLeft = this._rigCameras[0];
  20374. var camRight = this._rigCameras[1];
  20375. camLeft.beta = camRight.beta = this.beta;
  20376. switch (this.cameraRigMode) {
  20377. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20378. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20379. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20380. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20381. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20382. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20383. break;
  20384. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20385. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20386. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20387. break;
  20388. }
  20389. _super.prototype._updateRigCameras.call(this);
  20390. };
  20391. /**
  20392. * Destroy the camera and release the current resources hold by it.
  20393. */
  20394. ArcRotateCamera.prototype.dispose = function () {
  20395. this.inputs.clear();
  20396. _super.prototype.dispose.call(this);
  20397. };
  20398. /**
  20399. * Gets the current object class name.
  20400. * @return the class name
  20401. */
  20402. ArcRotateCamera.prototype.getClassName = function () {
  20403. return "ArcRotateCamera";
  20404. };
  20405. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20406. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20407. ], ArcRotateCamera.prototype, "alpha", void 0);
  20408. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20409. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20410. ], ArcRotateCamera.prototype, "beta", void 0);
  20411. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20412. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20413. ], ArcRotateCamera.prototype, "radius", void 0);
  20414. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20415. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  20416. ], ArcRotateCamera.prototype, "_target", void 0);
  20417. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20418. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("upVector")
  20419. ], ArcRotateCamera.prototype, "_upVector", void 0);
  20420. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20421. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20422. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  20423. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20424. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20425. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  20426. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20427. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20428. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  20429. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20430. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20431. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  20432. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20433. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20434. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  20435. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20436. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20437. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  20438. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20439. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20440. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  20441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20443. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  20444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20446. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  20447. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20449. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  20450. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20452. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  20453. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20454. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20455. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  20456. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20457. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20458. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  20459. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20460. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20461. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  20462. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20463. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20464. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  20465. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20466. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20467. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  20468. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20469. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20470. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  20471. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20472. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20473. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  20474. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20475. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20476. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  20477. return ArcRotateCamera;
  20478. }(_targetCamera__WEBPACK_IMPORTED_MODULE_10__["TargetCamera"]));
  20479. /***/ }),
  20480. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  20481. /*!*************************************************!*\
  20482. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  20483. \*************************************************/
  20484. /*! exports provided: ArcRotateCameraInputsManager */
  20485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20486. "use strict";
  20487. __webpack_require__.r(__webpack_exports__);
  20488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  20489. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20490. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  20491. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  20492. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  20493. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  20494. /**
  20495. * Default Inputs manager for the ArcRotateCamera.
  20496. * It groups all the default supported inputs for ease of use.
  20497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  20498. */
  20499. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  20500. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  20501. /**
  20502. * Instantiates a new ArcRotateCameraInputsManager.
  20503. * @param camera Defines the camera the inputs belong to
  20504. */
  20505. function ArcRotateCameraInputsManager(camera) {
  20506. return _super.call(this, camera) || this;
  20507. }
  20508. /**
  20509. * Add mouse wheel input support to the input manager.
  20510. * @returns the current input manager
  20511. */
  20512. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  20513. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  20514. return this;
  20515. };
  20516. /**
  20517. * Add pointers input support to the input manager.
  20518. * @returns the current input manager
  20519. */
  20520. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  20521. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  20522. return this;
  20523. };
  20524. /**
  20525. * Add keyboard input support to the input manager.
  20526. * @returns the current input manager
  20527. */
  20528. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  20529. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  20530. return this;
  20531. };
  20532. return ArcRotateCameraInputsManager;
  20533. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  20534. /***/ }),
  20535. /***/ "./Cameras/camera.ts":
  20536. /*!***************************!*\
  20537. !*** ./Cameras/camera.ts ***!
  20538. \***************************/
  20539. /*! exports provided: Camera */
  20540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20541. "use strict";
  20542. __webpack_require__.r(__webpack_exports__);
  20543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  20544. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20545. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  20546. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  20547. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  20548. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  20549. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  20550. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  20551. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  20552. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  20553. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  20554. /**
  20555. * This is the base class of all the camera used in the application.
  20556. * @see http://doc.babylonjs.com/features/cameras
  20557. */
  20558. var Camera = /** @class */ (function (_super) {
  20559. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  20560. /**
  20561. * Instantiates a new camera object.
  20562. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  20563. * @see http://doc.babylonjs.com/features/cameras
  20564. * @param name Defines the name of the camera in the scene
  20565. * @param position Defines the position of the camera
  20566. * @param scene Defines the scene the camera belongs too
  20567. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  20568. */
  20569. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  20570. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  20571. var _this = _super.call(this, name, scene) || this;
  20572. /** @hidden */
  20573. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20574. /**
  20575. * The vector the camera should consider as up.
  20576. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  20577. */
  20578. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  20579. /**
  20580. * Define the current limit on the left side for an orthographic camera
  20581. * In scene unit
  20582. */
  20583. _this.orthoLeft = null;
  20584. /**
  20585. * Define the current limit on the right side for an orthographic camera
  20586. * In scene unit
  20587. */
  20588. _this.orthoRight = null;
  20589. /**
  20590. * Define the current limit on the bottom side for an orthographic camera
  20591. * In scene unit
  20592. */
  20593. _this.orthoBottom = null;
  20594. /**
  20595. * Define the current limit on the top side for an orthographic camera
  20596. * In scene unit
  20597. */
  20598. _this.orthoTop = null;
  20599. /**
  20600. * Field Of View is set in Radians. (default is 0.8)
  20601. */
  20602. _this.fov = 0.8;
  20603. /**
  20604. * Define the minimum distance the camera can see from.
  20605. * This is important to note that the depth buffer are not infinite and the closer it starts
  20606. * the more your scene might encounter depth fighting issue.
  20607. */
  20608. _this.minZ = 1;
  20609. /**
  20610. * Define the maximum distance the camera can see to.
  20611. * This is important to note that the depth buffer are not infinite and the further it end
  20612. * the more your scene might encounter depth fighting issue.
  20613. */
  20614. _this.maxZ = 10000.0;
  20615. /**
  20616. * Define the default inertia of the camera.
  20617. * This helps giving a smooth feeling to the camera movement.
  20618. */
  20619. _this.inertia = 0.9;
  20620. /**
  20621. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  20622. */
  20623. _this.mode = Camera.PERSPECTIVE_CAMERA;
  20624. /**
  20625. * Define wether the camera is intermediate.
  20626. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  20627. */
  20628. _this.isIntermediate = false;
  20629. /**
  20630. * Define the viewport of the camera.
  20631. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  20632. */
  20633. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  20634. /**
  20635. * Restricts the camera to viewing objects with the same layerMask.
  20636. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  20637. */
  20638. _this.layerMask = 0x0FFFFFFF;
  20639. /**
  20640. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  20641. */
  20642. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  20643. /**
  20644. * Rig mode of the camera.
  20645. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  20646. * This is normally controlled byt the camera themselves as internal use.
  20647. */
  20648. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  20649. /**
  20650. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  20651. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  20652. * else in the scene.
  20653. */
  20654. _this.customRenderTargets = new Array();
  20655. /**
  20656. * When set, the camera will render to this render target instead of the default canvas
  20657. */
  20658. _this.outputRenderTarget = null;
  20659. /**
  20660. * Observable triggered when the camera view matrix has changed.
  20661. */
  20662. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20663. /**
  20664. * Observable triggered when the camera Projection matrix has changed.
  20665. */
  20666. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20667. /**
  20668. * Observable triggered when the inputs have been processed.
  20669. */
  20670. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20671. /**
  20672. * Observable triggered when reset has been called and applied to the camera.
  20673. */
  20674. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20675. /** @hidden */
  20676. _this._rigCameras = new Array();
  20677. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20678. /** @hidden */
  20679. _this._skipRendering = false;
  20680. /** @hidden */
  20681. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20682. /** @hidden */
  20683. _this._postProcesses = new Array();
  20684. /** @hidden */
  20685. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  20686. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20687. /** hidden */
  20688. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20689. _this._doNotComputeProjectionMatrix = false;
  20690. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  20691. _this._refreshFrustumPlanes = true;
  20692. /** @hidden */
  20693. _this._isCamera = true;
  20694. /** @hidden */
  20695. _this._isLeftCamera = false;
  20696. /** @hidden */
  20697. _this._isRightCamera = true;
  20698. _this.getScene().addCamera(_this);
  20699. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  20700. _this.getScene().activeCamera = _this;
  20701. }
  20702. _this.position = position;
  20703. return _this;
  20704. }
  20705. Object.defineProperty(Camera.prototype, "position", {
  20706. /**
  20707. * Define the current local position of the camera in the scene
  20708. */
  20709. get: function () {
  20710. return this._position;
  20711. },
  20712. set: function (newPosition) {
  20713. this._position = newPosition;
  20714. },
  20715. enumerable: true,
  20716. configurable: true
  20717. });
  20718. /**
  20719. * Store current camera state (fov, position, etc..)
  20720. * @returns the camera
  20721. */
  20722. Camera.prototype.storeState = function () {
  20723. this._stateStored = true;
  20724. this._storedFov = this.fov;
  20725. return this;
  20726. };
  20727. /**
  20728. * Restores the camera state values if it has been stored. You must call storeState() first
  20729. */
  20730. Camera.prototype._restoreStateValues = function () {
  20731. if (!this._stateStored) {
  20732. return false;
  20733. }
  20734. this.fov = this._storedFov;
  20735. return true;
  20736. };
  20737. /**
  20738. * Restored camera state. You must call storeState() first.
  20739. * @returns true if restored and false otherwise
  20740. */
  20741. Camera.prototype.restoreState = function () {
  20742. if (this._restoreStateValues()) {
  20743. this.onRestoreStateObservable.notifyObservers(this);
  20744. return true;
  20745. }
  20746. return false;
  20747. };
  20748. /**
  20749. * Gets the class name of the camera.
  20750. * @returns the class name
  20751. */
  20752. Camera.prototype.getClassName = function () {
  20753. return "Camera";
  20754. };
  20755. /**
  20756. * Gets a string representation of the camera useful for debug purpose.
  20757. * @param fullDetails Defines that a more verboe level of logging is required
  20758. * @returns the string representation
  20759. */
  20760. Camera.prototype.toString = function (fullDetails) {
  20761. var ret = "Name: " + this.name;
  20762. ret += ", type: " + this.getClassName();
  20763. if (this.animations) {
  20764. for (var i = 0; i < this.animations.length; i++) {
  20765. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  20766. }
  20767. }
  20768. if (fullDetails) {
  20769. }
  20770. return ret;
  20771. };
  20772. Object.defineProperty(Camera.prototype, "globalPosition", {
  20773. /**
  20774. * Gets the current world space position of the camera.
  20775. */
  20776. get: function () {
  20777. return this._globalPosition;
  20778. },
  20779. enumerable: true,
  20780. configurable: true
  20781. });
  20782. /**
  20783. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  20784. * @returns the active meshe list
  20785. */
  20786. Camera.prototype.getActiveMeshes = function () {
  20787. return this._activeMeshes;
  20788. };
  20789. /**
  20790. * Check wether a mesh is part of the current active mesh list of the camera
  20791. * @param mesh Defines the mesh to check
  20792. * @returns true if active, false otherwise
  20793. */
  20794. Camera.prototype.isActiveMesh = function (mesh) {
  20795. return (this._activeMeshes.indexOf(mesh) !== -1);
  20796. };
  20797. /**
  20798. * Is this camera ready to be used/rendered
  20799. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  20800. * @return true if the camera is ready
  20801. */
  20802. Camera.prototype.isReady = function (completeCheck) {
  20803. if (completeCheck === void 0) { completeCheck = false; }
  20804. if (completeCheck) {
  20805. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  20806. var pp = _a[_i];
  20807. if (pp && !pp.isReady()) {
  20808. return false;
  20809. }
  20810. }
  20811. }
  20812. return _super.prototype.isReady.call(this, completeCheck);
  20813. };
  20814. /** @hidden */
  20815. Camera.prototype._initCache = function () {
  20816. _super.prototype._initCache.call(this);
  20817. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20818. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20819. this._cache.mode = undefined;
  20820. this._cache.minZ = undefined;
  20821. this._cache.maxZ = undefined;
  20822. this._cache.fov = undefined;
  20823. this._cache.fovMode = undefined;
  20824. this._cache.aspectRatio = undefined;
  20825. this._cache.orthoLeft = undefined;
  20826. this._cache.orthoRight = undefined;
  20827. this._cache.orthoBottom = undefined;
  20828. this._cache.orthoTop = undefined;
  20829. this._cache.renderWidth = undefined;
  20830. this._cache.renderHeight = undefined;
  20831. };
  20832. /** @hidden */
  20833. Camera.prototype._updateCache = function (ignoreParentClass) {
  20834. if (!ignoreParentClass) {
  20835. _super.prototype._updateCache.call(this);
  20836. }
  20837. this._cache.position.copyFrom(this.position);
  20838. this._cache.upVector.copyFrom(this.upVector);
  20839. };
  20840. /** @hidden */
  20841. Camera.prototype._isSynchronized = function () {
  20842. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  20843. };
  20844. /** @hidden */
  20845. Camera.prototype._isSynchronizedViewMatrix = function () {
  20846. if (!_super.prototype._isSynchronized.call(this)) {
  20847. return false;
  20848. }
  20849. return this._cache.position.equals(this.position)
  20850. && this._cache.upVector.equals(this.upVector)
  20851. && this.isSynchronizedWithParent();
  20852. };
  20853. /** @hidden */
  20854. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  20855. var check = this._cache.mode === this.mode
  20856. && this._cache.minZ === this.minZ
  20857. && this._cache.maxZ === this.maxZ;
  20858. if (!check) {
  20859. return false;
  20860. }
  20861. var engine = this.getEngine();
  20862. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20863. check = this._cache.fov === this.fov
  20864. && this._cache.fovMode === this.fovMode
  20865. && this._cache.aspectRatio === engine.getAspectRatio(this);
  20866. }
  20867. else {
  20868. check = this._cache.orthoLeft === this.orthoLeft
  20869. && this._cache.orthoRight === this.orthoRight
  20870. && this._cache.orthoBottom === this.orthoBottom
  20871. && this._cache.orthoTop === this.orthoTop
  20872. && this._cache.renderWidth === engine.getRenderWidth()
  20873. && this._cache.renderHeight === engine.getRenderHeight();
  20874. }
  20875. return check;
  20876. };
  20877. /**
  20878. * Attach the input controls to a specific dom element to get the input from.
  20879. * @param element Defines the element the controls should be listened from
  20880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20881. */
  20882. Camera.prototype.attachControl = function (element, noPreventDefault) {
  20883. };
  20884. /**
  20885. * Detach the current controls from the specified dom element.
  20886. * @param element Defines the element to stop listening the inputs from
  20887. */
  20888. Camera.prototype.detachControl = function (element) {
  20889. };
  20890. /**
  20891. * Update the camera state according to the different inputs gathered during the frame.
  20892. */
  20893. Camera.prototype.update = function () {
  20894. this._checkInputs();
  20895. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20896. this._updateRigCameras();
  20897. }
  20898. };
  20899. /** @hidden */
  20900. Camera.prototype._checkInputs = function () {
  20901. this.onAfterCheckInputsObservable.notifyObservers(this);
  20902. };
  20903. Object.defineProperty(Camera.prototype, "rigCameras", {
  20904. /** @hidden */
  20905. get: function () {
  20906. return this._rigCameras;
  20907. },
  20908. enumerable: true,
  20909. configurable: true
  20910. });
  20911. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  20912. /**
  20913. * Gets the post process used by the rig cameras
  20914. */
  20915. get: function () {
  20916. return this._rigPostProcess;
  20917. },
  20918. enumerable: true,
  20919. configurable: true
  20920. });
  20921. /**
  20922. * Internal, gets the first post proces.
  20923. * @returns the first post process to be run on this camera.
  20924. */
  20925. Camera.prototype._getFirstPostProcess = function () {
  20926. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  20927. if (this._postProcesses[ppIndex] !== null) {
  20928. return this._postProcesses[ppIndex];
  20929. }
  20930. }
  20931. return null;
  20932. };
  20933. Camera.prototype._cascadePostProcessesToRigCams = function () {
  20934. // invalidate framebuffer
  20935. var firstPostProcess = this._getFirstPostProcess();
  20936. if (firstPostProcess) {
  20937. firstPostProcess.markTextureDirty();
  20938. }
  20939. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  20940. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  20941. var cam = this._rigCameras[i];
  20942. var rigPostProcess = cam._rigPostProcess;
  20943. // for VR rig, there does not have to be a post process
  20944. if (rigPostProcess) {
  20945. var isPass = rigPostProcess.getEffectName() === "pass";
  20946. if (isPass) {
  20947. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  20948. cam.isIntermediate = this._postProcesses.length === 0;
  20949. }
  20950. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  20951. rigPostProcess.markTextureDirty();
  20952. }
  20953. else {
  20954. cam._postProcesses = this._postProcesses.slice(0);
  20955. }
  20956. }
  20957. };
  20958. /**
  20959. * Attach a post process to the camera.
  20960. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20961. * @param postProcess The post process to attach to the camera
  20962. * @param insertAt The position of the post process in case several of them are in use in the scene
  20963. * @returns the position the post process has been inserted at
  20964. */
  20965. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  20966. if (insertAt === void 0) { insertAt = null; }
  20967. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  20968. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  20969. return 0;
  20970. }
  20971. if (insertAt == null || insertAt < 0) {
  20972. this._postProcesses.push(postProcess);
  20973. }
  20974. else if (this._postProcesses[insertAt] === null) {
  20975. this._postProcesses[insertAt] = postProcess;
  20976. }
  20977. else {
  20978. this._postProcesses.splice(insertAt, 0, postProcess);
  20979. }
  20980. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20981. return this._postProcesses.indexOf(postProcess);
  20982. };
  20983. /**
  20984. * Detach a post process to the camera.
  20985. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20986. * @param postProcess The post process to detach from the camera
  20987. */
  20988. Camera.prototype.detachPostProcess = function (postProcess) {
  20989. var idx = this._postProcesses.indexOf(postProcess);
  20990. if (idx !== -1) {
  20991. this._postProcesses[idx] = null;
  20992. }
  20993. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20994. };
  20995. /**
  20996. * Gets the current world matrix of the camera
  20997. */
  20998. Camera.prototype.getWorldMatrix = function () {
  20999. if (this._isSynchronizedViewMatrix()) {
  21000. return this._worldMatrix;
  21001. }
  21002. // Getting the the view matrix will also compute the world matrix.
  21003. this.getViewMatrix();
  21004. return this._worldMatrix;
  21005. };
  21006. /** @hidden */
  21007. Camera.prototype._getViewMatrix = function () {
  21008. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21009. };
  21010. /**
  21011. * Gets the current view matrix of the camera.
  21012. * @param force forces the camera to recompute the matrix without looking at the cached state
  21013. * @returns the view matrix
  21014. */
  21015. Camera.prototype.getViewMatrix = function (force) {
  21016. if (!force && this._isSynchronizedViewMatrix()) {
  21017. return this._computedViewMatrix;
  21018. }
  21019. this.updateCache();
  21020. this._computedViewMatrix = this._getViewMatrix();
  21021. this._currentRenderId = this.getScene().getRenderId();
  21022. this._childUpdateId++;
  21023. this._refreshFrustumPlanes = true;
  21024. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  21025. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  21026. }
  21027. this.onViewMatrixChangedObservable.notifyObservers(this);
  21028. this._computedViewMatrix.invertToRef(this._worldMatrix);
  21029. return this._computedViewMatrix;
  21030. };
  21031. /**
  21032. * Freeze the projection matrix.
  21033. * It will prevent the cache check of the camera projection compute and can speed up perf
  21034. * if no parameter of the camera are meant to change
  21035. * @param projection Defines manually a projection if necessary
  21036. */
  21037. Camera.prototype.freezeProjectionMatrix = function (projection) {
  21038. this._doNotComputeProjectionMatrix = true;
  21039. if (projection !== undefined) {
  21040. this._projectionMatrix = projection;
  21041. }
  21042. };
  21043. /**
  21044. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  21045. */
  21046. Camera.prototype.unfreezeProjectionMatrix = function () {
  21047. this._doNotComputeProjectionMatrix = false;
  21048. };
  21049. /**
  21050. * Gets the current projection matrix of the camera.
  21051. * @param force forces the camera to recompute the matrix without looking at the cached state
  21052. * @returns the projection matrix
  21053. */
  21054. Camera.prototype.getProjectionMatrix = function (force) {
  21055. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  21056. return this._projectionMatrix;
  21057. }
  21058. // Cache
  21059. this._cache.mode = this.mode;
  21060. this._cache.minZ = this.minZ;
  21061. this._cache.maxZ = this.maxZ;
  21062. // Matrix
  21063. this._refreshFrustumPlanes = true;
  21064. var engine = this.getEngine();
  21065. var scene = this.getScene();
  21066. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  21067. this._cache.fov = this.fov;
  21068. this._cache.fovMode = this.fovMode;
  21069. this._cache.aspectRatio = engine.getAspectRatio(this);
  21070. if (this.minZ <= 0) {
  21071. this.minZ = 0.1;
  21072. }
  21073. if (scene.useRightHandedSystem) {
  21074. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovRHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode === Camera.FOVMODE_VERTICAL_FIXED);
  21075. }
  21076. else {
  21077. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode === Camera.FOVMODE_VERTICAL_FIXED);
  21078. }
  21079. }
  21080. else {
  21081. var halfWidth = engine.getRenderWidth() / 2.0;
  21082. var halfHeight = engine.getRenderHeight() / 2.0;
  21083. if (scene.useRightHandedSystem) {
  21084. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].OrthoOffCenterRHToRef(this.orthoLeft || -halfWidth, this.orthoRight || halfWidth, this.orthoBottom || -halfHeight, this.orthoTop || halfHeight, this.minZ, this.maxZ, this._projectionMatrix);
  21085. }
  21086. else {
  21087. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].OrthoOffCenterLHToRef(this.orthoLeft || -halfWidth, this.orthoRight || halfWidth, this.orthoBottom || -halfHeight, this.orthoTop || halfHeight, this.minZ, this.maxZ, this._projectionMatrix);
  21088. }
  21089. this._cache.orthoLeft = this.orthoLeft;
  21090. this._cache.orthoRight = this.orthoRight;
  21091. this._cache.orthoBottom = this.orthoBottom;
  21092. this._cache.orthoTop = this.orthoTop;
  21093. this._cache.renderWidth = engine.getRenderWidth();
  21094. this._cache.renderHeight = engine.getRenderHeight();
  21095. }
  21096. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  21097. return this._projectionMatrix;
  21098. };
  21099. /**
  21100. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  21101. * @returns a Matrix
  21102. */
  21103. Camera.prototype.getTransformationMatrix = function () {
  21104. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  21105. return this._transformMatrix;
  21106. };
  21107. Camera.prototype._updateFrustumPlanes = function () {
  21108. if (!this._refreshFrustumPlanes) {
  21109. return;
  21110. }
  21111. this.getTransformationMatrix();
  21112. if (!this._frustumPlanes) {
  21113. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  21114. }
  21115. else {
  21116. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  21117. }
  21118. this._refreshFrustumPlanes = false;
  21119. };
  21120. /**
  21121. * Checks if a cullable object (mesh...) is in the camera frustum
  21122. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  21123. * @param target The object to check
  21124. * @returns true if the object is in frustum otherwise false
  21125. */
  21126. Camera.prototype.isInFrustum = function (target) {
  21127. this._updateFrustumPlanes();
  21128. return target.isInFrustum(this._frustumPlanes);
  21129. };
  21130. /**
  21131. * Checks if a cullable object (mesh...) is in the camera frustum
  21132. * Unlike isInFrustum this cheks the full bounding box
  21133. * @param target The object to check
  21134. * @returns true if the object is in frustum otherwise false
  21135. */
  21136. Camera.prototype.isCompletelyInFrustum = function (target) {
  21137. this._updateFrustumPlanes();
  21138. return target.isCompletelyInFrustum(this._frustumPlanes);
  21139. };
  21140. /**
  21141. * Gets a ray in the forward direction from the camera.
  21142. * @param length Defines the length of the ray to create
  21143. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  21144. * @param origin Defines the start point of the ray which defaults to the camera position
  21145. * @returns the forward ray
  21146. */
  21147. Camera.prototype.getForwardRay = function (length, transform, origin) {
  21148. if (length === void 0) { length = 100; }
  21149. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
  21150. };
  21151. /**
  21152. * Releases resources associated with this node.
  21153. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21154. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21155. */
  21156. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  21157. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  21158. // Observables
  21159. this.onViewMatrixChangedObservable.clear();
  21160. this.onProjectionMatrixChangedObservable.clear();
  21161. this.onAfterCheckInputsObservable.clear();
  21162. this.onRestoreStateObservable.clear();
  21163. // Inputs
  21164. if (this.inputs) {
  21165. this.inputs.clear();
  21166. }
  21167. // Animations
  21168. this.getScene().stopAnimation(this);
  21169. // Remove from scene
  21170. this.getScene().removeCamera(this);
  21171. while (this._rigCameras.length > 0) {
  21172. var camera = this._rigCameras.pop();
  21173. if (camera) {
  21174. camera.dispose();
  21175. }
  21176. }
  21177. // Postprocesses
  21178. if (this._rigPostProcess) {
  21179. this._rigPostProcess.dispose(this);
  21180. this._rigPostProcess = null;
  21181. this._postProcesses = [];
  21182. }
  21183. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21184. this._rigPostProcess = null;
  21185. this._postProcesses = [];
  21186. }
  21187. else {
  21188. var i = this._postProcesses.length;
  21189. while (--i >= 0) {
  21190. var postProcess = this._postProcesses[i];
  21191. if (postProcess) {
  21192. postProcess.dispose(this);
  21193. }
  21194. }
  21195. }
  21196. // Render targets
  21197. var i = this.customRenderTargets.length;
  21198. while (--i >= 0) {
  21199. this.customRenderTargets[i].dispose();
  21200. }
  21201. this.customRenderTargets = [];
  21202. // Active Meshes
  21203. this._activeMeshes.dispose();
  21204. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  21205. };
  21206. Object.defineProperty(Camera.prototype, "isLeftCamera", {
  21207. /**
  21208. * Gets the left camera of a rig setup in case of Rigged Camera
  21209. */
  21210. get: function () {
  21211. return this._isLeftCamera;
  21212. },
  21213. enumerable: true,
  21214. configurable: true
  21215. });
  21216. Object.defineProperty(Camera.prototype, "isRightCamera", {
  21217. /**
  21218. * Gets the right camera of a rig setup in case of Rigged Camera
  21219. */
  21220. get: function () {
  21221. return this._isRightCamera;
  21222. },
  21223. enumerable: true,
  21224. configurable: true
  21225. });
  21226. Object.defineProperty(Camera.prototype, "leftCamera", {
  21227. /**
  21228. * Gets the left camera of a rig setup in case of Rigged Camera
  21229. */
  21230. get: function () {
  21231. if (this._rigCameras.length < 1) {
  21232. return null;
  21233. }
  21234. return this._rigCameras[0];
  21235. },
  21236. enumerable: true,
  21237. configurable: true
  21238. });
  21239. Object.defineProperty(Camera.prototype, "rightCamera", {
  21240. /**
  21241. * Gets the right camera of a rig setup in case of Rigged Camera
  21242. */
  21243. get: function () {
  21244. if (this._rigCameras.length < 2) {
  21245. return null;
  21246. }
  21247. return this._rigCameras[1];
  21248. },
  21249. enumerable: true,
  21250. configurable: true
  21251. });
  21252. /**
  21253. * Gets the left camera target of a rig setup in case of Rigged Camera
  21254. * @returns the target position
  21255. */
  21256. Camera.prototype.getLeftTarget = function () {
  21257. if (this._rigCameras.length < 1) {
  21258. return null;
  21259. }
  21260. return this._rigCameras[0].getTarget();
  21261. };
  21262. /**
  21263. * Gets the right camera target of a rig setup in case of Rigged Camera
  21264. * @returns the target position
  21265. */
  21266. Camera.prototype.getRightTarget = function () {
  21267. if (this._rigCameras.length < 2) {
  21268. return null;
  21269. }
  21270. return this._rigCameras[1].getTarget();
  21271. };
  21272. /**
  21273. * @hidden
  21274. */
  21275. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  21276. if (this.cameraRigMode === mode) {
  21277. return;
  21278. }
  21279. while (this._rigCameras.length > 0) {
  21280. var camera = this._rigCameras.pop();
  21281. if (camera) {
  21282. camera.dispose();
  21283. }
  21284. }
  21285. this.cameraRigMode = mode;
  21286. this._cameraRigParams = {};
  21287. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  21288. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  21289. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  21290. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  21291. // create the rig cameras, unless none
  21292. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21293. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  21294. if (leftCamera) {
  21295. leftCamera._isLeftCamera = true;
  21296. }
  21297. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  21298. if (rightCamera) {
  21299. rightCamera._isRightCamera = true;
  21300. }
  21301. if (leftCamera && rightCamera) {
  21302. this._rigCameras.push(leftCamera);
  21303. this._rigCameras.push(rightCamera);
  21304. }
  21305. }
  21306. switch (this.cameraRigMode) {
  21307. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  21308. Camera._setStereoscopicAnaglyphRigMode(this);
  21309. break;
  21310. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  21311. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  21312. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  21313. Camera._setStereoscopicRigMode(this);
  21314. break;
  21315. case Camera.RIG_MODE_VR:
  21316. Camera._setVRRigMode(this, rigParams);
  21317. break;
  21318. case Camera.RIG_MODE_WEBVR:
  21319. Camera._setWebVRRigMode(this, rigParams);
  21320. break;
  21321. }
  21322. this._cascadePostProcessesToRigCams();
  21323. this.update();
  21324. };
  21325. /** @hidden */
  21326. Camera._setStereoscopicRigMode = function (camera) {
  21327. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  21328. };
  21329. /** @hidden */
  21330. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  21331. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  21332. };
  21333. /** @hidden */
  21334. Camera._setVRRigMode = function (camera, rigParams) {
  21335. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  21336. };
  21337. /** @hidden */
  21338. Camera._setWebVRRigMode = function (camera, rigParams) {
  21339. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  21340. };
  21341. /** @hidden */
  21342. Camera.prototype._getVRProjectionMatrix = function () {
  21343. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  21344. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  21345. return this._projectionMatrix;
  21346. };
  21347. Camera.prototype._updateCameraRotationMatrix = function () {
  21348. //Here for WebVR
  21349. };
  21350. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  21351. //Here for WebVR
  21352. };
  21353. /**
  21354. * This function MUST be overwritten by the different WebVR cameras available.
  21355. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21356. * @hidden
  21357. */
  21358. Camera.prototype._getWebVRProjectionMatrix = function () {
  21359. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21360. };
  21361. /**
  21362. * This function MUST be overwritten by the different WebVR cameras available.
  21363. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21364. * @hidden
  21365. */
  21366. Camera.prototype._getWebVRViewMatrix = function () {
  21367. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21368. };
  21369. /** @hidden */
  21370. Camera.prototype.setCameraRigParameter = function (name, value) {
  21371. if (!this._cameraRigParams) {
  21372. this._cameraRigParams = {};
  21373. }
  21374. this._cameraRigParams[name] = value;
  21375. //provisionnally:
  21376. if (name === "interaxialDistance") {
  21377. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  21378. }
  21379. };
  21380. /**
  21381. * needs to be overridden by children so sub has required properties to be copied
  21382. * @hidden
  21383. */
  21384. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  21385. return null;
  21386. };
  21387. /**
  21388. * May need to be overridden by children
  21389. * @hidden
  21390. */
  21391. Camera.prototype._updateRigCameras = function () {
  21392. for (var i = 0; i < this._rigCameras.length; i++) {
  21393. this._rigCameras[i].minZ = this.minZ;
  21394. this._rigCameras[i].maxZ = this.maxZ;
  21395. this._rigCameras[i].fov = this.fov;
  21396. this._rigCameras[i].upVector.copyFrom(this.upVector);
  21397. }
  21398. // only update viewport when ANAGLYPH
  21399. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  21400. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  21401. }
  21402. };
  21403. /** @hidden */
  21404. Camera.prototype._setupInputs = function () {
  21405. };
  21406. /**
  21407. * Serialiaze the camera setup to a json represention
  21408. * @returns the JSON representation
  21409. */
  21410. Camera.prototype.serialize = function () {
  21411. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  21412. // Type
  21413. serializationObject.type = this.getClassName();
  21414. // Parent
  21415. if (this.parent) {
  21416. serializationObject.parentId = this.parent.id;
  21417. }
  21418. if (this.inputs) {
  21419. this.inputs.serialize(serializationObject);
  21420. }
  21421. // Animations
  21422. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  21423. serializationObject.ranges = this.serializeAnimationRanges();
  21424. return serializationObject;
  21425. };
  21426. /**
  21427. * Clones the current camera.
  21428. * @param name The cloned camera name
  21429. * @returns the cloned camera
  21430. */
  21431. Camera.prototype.clone = function (name) {
  21432. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  21433. };
  21434. /**
  21435. * Gets the direction of the camera relative to a given local axis.
  21436. * @param localAxis Defines the reference axis to provide a relative direction.
  21437. * @return the direction
  21438. */
  21439. Camera.prototype.getDirection = function (localAxis) {
  21440. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  21441. this.getDirectionToRef(localAxis, result);
  21442. return result;
  21443. };
  21444. /**
  21445. * Gets the direction of the camera relative to a given local axis into a passed vector.
  21446. * @param localAxis Defines the reference axis to provide a relative direction.
  21447. * @param result Defines the vector to store the result in
  21448. */
  21449. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  21450. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  21451. };
  21452. /**
  21453. * Gets a camera constructor for a given camera type
  21454. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  21455. * @param name The name of the camera the result will be able to instantiate
  21456. * @param scene The scene the result will construct the camera in
  21457. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  21458. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  21459. * @returns a factory method to construc the camera
  21460. */
  21461. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  21462. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  21463. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  21464. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  21465. interaxial_distance: interaxial_distance,
  21466. isStereoscopicSideBySide: isStereoscopicSideBySide
  21467. });
  21468. if (constructorFunc) {
  21469. return constructorFunc;
  21470. }
  21471. // Default to universal camera
  21472. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  21473. };
  21474. /**
  21475. * Compute the world matrix of the camera.
  21476. * @returns the camera workd matrix
  21477. */
  21478. Camera.prototype.computeWorldMatrix = function () {
  21479. return this.getWorldMatrix();
  21480. };
  21481. /**
  21482. * Parse a JSON and creates the camera from the parsed information
  21483. * @param parsedCamera The JSON to parse
  21484. * @param scene The scene to instantiate the camera in
  21485. * @returns the newly constructed camera
  21486. */
  21487. Camera.Parse = function (parsedCamera, scene) {
  21488. var type = parsedCamera.type;
  21489. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  21490. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  21491. // Parent
  21492. if (parsedCamera.parentId) {
  21493. camera._waitingParentId = parsedCamera.parentId;
  21494. }
  21495. //If camera has an input manager, let it parse inputs settings
  21496. if (camera.inputs) {
  21497. camera.inputs.parse(parsedCamera);
  21498. camera._setupInputs();
  21499. }
  21500. if (camera.setPosition) { // need to force position
  21501. camera.position.copyFromFloats(0, 0, 0);
  21502. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  21503. }
  21504. // Target
  21505. if (parsedCamera.target) {
  21506. if (camera.setTarget) {
  21507. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  21508. }
  21509. }
  21510. // Apply 3d rig, when found
  21511. if (parsedCamera.cameraRigMode) {
  21512. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  21513. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  21514. }
  21515. // Animations
  21516. if (parsedCamera.animations) {
  21517. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  21518. var parsedAnimation = parsedCamera.animations[animationIndex];
  21519. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON.Animation");
  21520. if (internalClass) {
  21521. camera.animations.push(internalClass.Parse(parsedAnimation));
  21522. }
  21523. }
  21524. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  21525. }
  21526. if (parsedCamera.autoAnimate) {
  21527. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  21528. }
  21529. return camera;
  21530. };
  21531. /** @hidden */
  21532. Camera._createDefaultParsedCamera = function (name, scene) {
  21533. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("UniversalCamera");
  21534. };
  21535. /**
  21536. * This is the default projection mode used by the cameras.
  21537. * It helps recreating a feeling of perspective and better appreciate depth.
  21538. * This is the best way to simulate real life cameras.
  21539. */
  21540. Camera.PERSPECTIVE_CAMERA = 0;
  21541. /**
  21542. * This helps creating camera with an orthographic mode.
  21543. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  21544. */
  21545. Camera.ORTHOGRAPHIC_CAMERA = 1;
  21546. /**
  21547. * This is the default FOV mode for perspective cameras.
  21548. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  21549. */
  21550. Camera.FOVMODE_VERTICAL_FIXED = 0;
  21551. /**
  21552. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  21553. */
  21554. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  21555. /**
  21556. * This specifies ther is no need for a camera rig.
  21557. * Basically only one eye is rendered corresponding to the camera.
  21558. */
  21559. Camera.RIG_MODE_NONE = 0;
  21560. /**
  21561. * Simulates a camera Rig with one blue eye and one red eye.
  21562. * This can be use with 3d blue and red glasses.
  21563. */
  21564. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  21565. /**
  21566. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  21567. */
  21568. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  21569. /**
  21570. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  21571. */
  21572. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  21573. /**
  21574. * Defines that both eyes of the camera will be rendered over under each other.
  21575. */
  21576. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  21577. /**
  21578. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  21579. */
  21580. Camera.RIG_MODE_VR = 20;
  21581. /**
  21582. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  21583. */
  21584. Camera.RIG_MODE_WEBVR = 21;
  21585. /**
  21586. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  21587. */
  21588. Camera.RIG_MODE_CUSTOM = 22;
  21589. /**
  21590. * Defines if by default attaching controls should prevent the default javascript event to continue.
  21591. */
  21592. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  21593. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21594. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  21595. ], Camera.prototype, "_position", void 0);
  21596. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21597. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21598. ], Camera.prototype, "upVector", void 0);
  21599. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21600. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21601. ], Camera.prototype, "orthoLeft", void 0);
  21602. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21603. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21604. ], Camera.prototype, "orthoRight", void 0);
  21605. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21606. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21607. ], Camera.prototype, "orthoBottom", void 0);
  21608. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21609. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21610. ], Camera.prototype, "orthoTop", void 0);
  21611. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21612. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21613. ], Camera.prototype, "fov", void 0);
  21614. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21615. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21616. ], Camera.prototype, "minZ", void 0);
  21617. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21618. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21619. ], Camera.prototype, "maxZ", void 0);
  21620. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21621. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21622. ], Camera.prototype, "inertia", void 0);
  21623. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21624. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21625. ], Camera.prototype, "mode", void 0);
  21626. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21627. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21628. ], Camera.prototype, "layerMask", void 0);
  21629. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21630. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21631. ], Camera.prototype, "fovMode", void 0);
  21632. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21633. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21634. ], Camera.prototype, "cameraRigMode", void 0);
  21635. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21636. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21637. ], Camera.prototype, "interaxialDistance", void 0);
  21638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21639. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21640. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  21641. return Camera;
  21642. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  21643. /***/ }),
  21644. /***/ "./Cameras/cameraInputsManager.ts":
  21645. /*!****************************************!*\
  21646. !*** ./Cameras/cameraInputsManager.ts ***!
  21647. \****************************************/
  21648. /*! exports provided: CameraInputTypes, CameraInputsManager */
  21649. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21650. "use strict";
  21651. __webpack_require__.r(__webpack_exports__);
  21652. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  21653. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  21654. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  21655. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21656. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21657. /**
  21658. * @ignore
  21659. * This is a list of all the different input types that are available in the application.
  21660. * Fo instance: ArcRotateCameraGamepadInput...
  21661. */
  21662. var CameraInputTypes = {};
  21663. /**
  21664. * This represents the input manager used within a camera.
  21665. * It helps dealing with all the different kind of input attached to a camera.
  21666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21667. */
  21668. var CameraInputsManager = /** @class */ (function () {
  21669. /**
  21670. * Instantiate a new Camera Input Manager.
  21671. * @param camera Defines the camera the input manager blongs to
  21672. */
  21673. function CameraInputsManager(camera) {
  21674. this.attached = {};
  21675. this.camera = camera;
  21676. this.checkInputs = function () { };
  21677. }
  21678. /**
  21679. * Add an input method to a camera
  21680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21681. * @param input camera input method
  21682. */
  21683. CameraInputsManager.prototype.add = function (input) {
  21684. var type = input.getSimpleName();
  21685. if (this.attached[type]) {
  21686. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  21687. return;
  21688. }
  21689. this.attached[type] = input;
  21690. input.camera = this.camera;
  21691. //for checkInputs, we are dynamically creating a function
  21692. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  21693. if (input.checkInputs) {
  21694. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21695. }
  21696. if (this.attachedElement) {
  21697. input.attachControl(this.attachedElement);
  21698. }
  21699. };
  21700. /**
  21701. * Remove a specific input method from a camera
  21702. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  21703. * @param inputToRemove camera input method
  21704. */
  21705. CameraInputsManager.prototype.remove = function (inputToRemove) {
  21706. for (var cam in this.attached) {
  21707. var input = this.attached[cam];
  21708. if (input === inputToRemove) {
  21709. input.detachControl(this.attachedElement);
  21710. input.camera = null;
  21711. delete this.attached[cam];
  21712. this.rebuildInputCheck();
  21713. }
  21714. }
  21715. };
  21716. /**
  21717. * Remove a specific input type from a camera
  21718. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  21719. * @param inputType the type of the input to remove
  21720. */
  21721. CameraInputsManager.prototype.removeByType = function (inputType) {
  21722. for (var cam in this.attached) {
  21723. var input = this.attached[cam];
  21724. if (input.getClassName() === inputType) {
  21725. input.detachControl(this.attachedElement);
  21726. input.camera = null;
  21727. delete this.attached[cam];
  21728. this.rebuildInputCheck();
  21729. }
  21730. }
  21731. };
  21732. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  21733. var current = this.checkInputs;
  21734. return function () {
  21735. current();
  21736. fn();
  21737. };
  21738. };
  21739. /**
  21740. * Attach the input controls to the currently attached dom element to listen the events from.
  21741. * @param input Defines the input to attach
  21742. */
  21743. CameraInputsManager.prototype.attachInput = function (input) {
  21744. if (this.attachedElement) {
  21745. input.attachControl(this.attachedElement, this.noPreventDefault);
  21746. }
  21747. };
  21748. /**
  21749. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  21750. * @param element Defines the dom element to collect the events from
  21751. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21752. */
  21753. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  21754. if (noPreventDefault === void 0) { noPreventDefault = false; }
  21755. if (this.attachedElement) {
  21756. return;
  21757. }
  21758. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  21759. this.attachedElement = element;
  21760. this.noPreventDefault = noPreventDefault;
  21761. for (var cam in this.attached) {
  21762. this.attached[cam].attachControl(element, noPreventDefault);
  21763. }
  21764. };
  21765. /**
  21766. * Detach the current manager inputs controls from a specific dom element.
  21767. * @param element Defines the dom element to collect the events from
  21768. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  21769. */
  21770. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  21771. if (disconnect === void 0) { disconnect = false; }
  21772. if (this.attachedElement !== element) {
  21773. return;
  21774. }
  21775. for (var cam in this.attached) {
  21776. this.attached[cam].detachControl(element);
  21777. if (disconnect) {
  21778. this.attached[cam].camera = null;
  21779. }
  21780. }
  21781. this.attachedElement = null;
  21782. };
  21783. /**
  21784. * Rebuild the dynamic inputCheck function from the current list of
  21785. * defined inputs in the manager.
  21786. */
  21787. CameraInputsManager.prototype.rebuildInputCheck = function () {
  21788. this.checkInputs = function () { };
  21789. for (var cam in this.attached) {
  21790. var input = this.attached[cam];
  21791. if (input.checkInputs) {
  21792. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21793. }
  21794. }
  21795. };
  21796. /**
  21797. * Remove all attached input methods from a camera
  21798. */
  21799. CameraInputsManager.prototype.clear = function () {
  21800. if (this.attachedElement) {
  21801. this.detachElement(this.attachedElement, true);
  21802. }
  21803. this.attached = {};
  21804. this.attachedElement = null;
  21805. this.checkInputs = function () { };
  21806. };
  21807. /**
  21808. * Serialize the current input manager attached to a camera.
  21809. * This ensures than once parsed,
  21810. * the input associated to the camera will be identical to the current ones
  21811. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  21812. */
  21813. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  21814. var inputs = {};
  21815. for (var cam in this.attached) {
  21816. var input = this.attached[cam];
  21817. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  21818. inputs[input.getClassName()] = res;
  21819. }
  21820. serializedCamera.inputsmgr = inputs;
  21821. };
  21822. /**
  21823. * Parses an input manager serialized JSON to restore the previous list of inputs
  21824. * and states associated to a camera.
  21825. * @param parsedCamera Defines the JSON to parse
  21826. */
  21827. CameraInputsManager.prototype.parse = function (parsedCamera) {
  21828. var parsedInputs = parsedCamera.inputsmgr;
  21829. if (parsedInputs) {
  21830. this.clear();
  21831. for (var n in parsedInputs) {
  21832. var construct = CameraInputTypes[n];
  21833. if (construct) {
  21834. var parsedinput = parsedInputs[n];
  21835. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  21836. this.add(input);
  21837. }
  21838. }
  21839. }
  21840. else {
  21841. //2016-03-08 this part is for managing backward compatibility
  21842. for (var n in this.attached) {
  21843. var construct = CameraInputTypes[this.attached[n].getClassName()];
  21844. if (construct) {
  21845. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  21846. this.remove(this.attached[n]);
  21847. this.add(input);
  21848. }
  21849. }
  21850. }
  21851. };
  21852. return CameraInputsManager;
  21853. }());
  21854. /***/ }),
  21855. /***/ "./Cameras/deviceOrientationCamera.ts":
  21856. /*!********************************************!*\
  21857. !*** ./Cameras/deviceOrientationCamera.ts ***!
  21858. \********************************************/
  21859. /*! exports provided: DeviceOrientationCamera */
  21860. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21861. "use strict";
  21862. __webpack_require__.r(__webpack_exports__);
  21863. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  21864. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21865. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21866. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21867. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21868. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  21869. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  21870. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21871. });
  21872. // We're mainly based on the logic defined into the FreeCamera code
  21873. /**
  21874. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  21875. * being tilted forward or back and left or right.
  21876. */
  21877. var DeviceOrientationCamera = /** @class */ (function (_super) {
  21878. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  21879. /**
  21880. * Creates a new device orientation camera
  21881. * @param name The name of the camera
  21882. * @param position The start position camera
  21883. * @param scene The scene the camera belongs to
  21884. */
  21885. function DeviceOrientationCamera(name, position, scene) {
  21886. var _this = _super.call(this, name, position, scene) || this;
  21887. _this._tmpDragQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21888. /**
  21889. * Disabled pointer input on first orientation sensor update (Default: true)
  21890. */
  21891. _this.disablePointerInputWhenUsingDeviceOrientation = true;
  21892. _this._dragFactor = 0;
  21893. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21894. _this.inputs.addDeviceOrientation();
  21895. // When the orientation sensor fires it's first event, disable mouse input
  21896. if (_this.inputs._deviceOrientationInput) {
  21897. _this.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce(function () {
  21898. if (_this.disablePointerInputWhenUsingDeviceOrientation) {
  21899. if (_this.inputs._mouseInput) {
  21900. _this.inputs._mouseInput._allowCameraRotation = false;
  21901. _this.inputs._mouseInput.onPointerMovedObservable.add(function (e) {
  21902. if (_this._dragFactor != 0) {
  21903. if (!_this._initialQuaternion) {
  21904. _this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21905. }
  21906. // Rotate the initial space around the y axis to allow users to "turn around" via touch/mouse
  21907. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromEulerAnglesToRef(0, e.offsetX * _this._dragFactor, 0, _this._tmpDragQuaternion);
  21908. _this._initialQuaternion.multiplyToRef(_this._tmpDragQuaternion, _this._initialQuaternion);
  21909. }
  21910. });
  21911. }
  21912. }
  21913. });
  21914. }
  21915. return _this;
  21916. }
  21917. /**
  21918. * Enabled turning on the y axis when the orientation sensor is active
  21919. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  21920. */
  21921. DeviceOrientationCamera.prototype.enableHorizontalDragging = function (dragFactor) {
  21922. if (dragFactor === void 0) { dragFactor = 1 / 300; }
  21923. this._dragFactor = dragFactor;
  21924. };
  21925. /**
  21926. * Gets the current instance class name ("DeviceOrientationCamera").
  21927. * This helps avoiding instanceof at run time.
  21928. * @returns the class name
  21929. */
  21930. DeviceOrientationCamera.prototype.getClassName = function () {
  21931. return "DeviceOrientationCamera";
  21932. };
  21933. /**
  21934. * @hidden
  21935. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  21936. */
  21937. DeviceOrientationCamera.prototype._checkInputs = function () {
  21938. _super.prototype._checkInputs.call(this);
  21939. this._quaternionCache.copyFrom(this.rotationQuaternion);
  21940. if (this._initialQuaternion) {
  21941. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21942. }
  21943. };
  21944. /**
  21945. * Reset the camera to its default orientation on the specified axis only.
  21946. * @param axis The axis to reset
  21947. */
  21948. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  21949. var _this = this;
  21950. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  21951. //can only work if this camera has a rotation quaternion already.
  21952. if (!this.rotationQuaternion) {
  21953. return;
  21954. }
  21955. if (!this._initialQuaternion) {
  21956. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21957. }
  21958. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  21959. ['x', 'y', 'z'].forEach(function (axisName) {
  21960. if (!axis[axisName]) {
  21961. _this._initialQuaternion[axisName] = 0;
  21962. }
  21963. else {
  21964. _this._initialQuaternion[axisName] *= -1;
  21965. }
  21966. });
  21967. this._initialQuaternion.normalize();
  21968. //force rotation update
  21969. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21970. };
  21971. return DeviceOrientationCamera;
  21972. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  21973. /***/ }),
  21974. /***/ "./Cameras/flyCamera.ts":
  21975. /*!******************************!*\
  21976. !*** ./Cameras/flyCamera.ts ***!
  21977. \******************************/
  21978. /*! exports provided: FlyCamera */
  21979. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21980. "use strict";
  21981. __webpack_require__.r(__webpack_exports__);
  21982. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  21983. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21984. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21985. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21986. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21987. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21988. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  21989. /**
  21990. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21991. * such as in a 3D Space Shooter or a Flight Simulator.
  21992. */
  21993. var FlyCamera = /** @class */ (function (_super) {
  21994. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  21995. /**
  21996. * Instantiates a FlyCamera.
  21997. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21998. * such as in a 3D Space Shooter or a Flight Simulator.
  21999. * @param name Define the name of the camera in the scene.
  22000. * @param position Define the starting position of the camera in the scene.
  22001. * @param scene Define the scene the camera belongs to.
  22002. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  22003. */
  22004. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22005. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22006. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22007. /**
  22008. * Define the collision ellipsoid of the camera.
  22009. * This is helpful for simulating a camera body, like a player's body.
  22010. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22011. */
  22012. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  22013. /**
  22014. * Define an offset for the position of the ellipsoid around the camera.
  22015. * This can be helpful if the camera is attached away from the player's body center,
  22016. * such as at its head.
  22017. */
  22018. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22019. /**
  22020. * Enable or disable collisions of the camera with the rest of the scene objects.
  22021. */
  22022. _this.checkCollisions = false;
  22023. /**
  22024. * Enable or disable gravity on the camera.
  22025. */
  22026. _this.applyGravity = false;
  22027. /**
  22028. * Define the current direction the camera is moving to.
  22029. */
  22030. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22031. /**
  22032. * Track Roll to maintain the wanted Rolling when looking around.
  22033. */
  22034. _this._trackRoll = 0;
  22035. /**
  22036. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  22037. */
  22038. _this.rollCorrect = 100;
  22039. /**
  22040. * Mimic a banked turn, Rolling the camera when Yawing.
  22041. * It's recommended to use rollCorrect = 10 for faster banking correction.
  22042. */
  22043. _this.bankedTurn = false;
  22044. /**
  22045. * Limit in radians for how much Roll banking will add. (Default: 90°)
  22046. */
  22047. _this.bankedTurnLimit = Math.PI / 2;
  22048. /**
  22049. * Value of 0 disables the banked Roll.
  22050. * Value of 1 is equal to the Yaw angle in radians.
  22051. */
  22052. _this.bankedTurnMultiplier = 1;
  22053. _this._needMoveForGravity = false;
  22054. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22055. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22056. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22057. // Collisions.
  22058. _this._collisionMask = -1;
  22059. /** @hidden */
  22060. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22061. if (collidedMesh === void 0) { collidedMesh = null; }
  22062. var updatePosition = function (newPos) {
  22063. _this._newPosition.copyFrom(newPos);
  22064. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22065. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22066. _this.position.addInPlace(_this._diffPosition);
  22067. if (_this.onCollide && collidedMesh) {
  22068. _this.onCollide(collidedMesh);
  22069. }
  22070. }
  22071. };
  22072. updatePosition(newPosition);
  22073. };
  22074. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FlyCameraInputsManager"](_this);
  22075. _this.inputs.addKeyboard().addMouse();
  22076. return _this;
  22077. }
  22078. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  22079. /**
  22080. * Gets the input sensibility for mouse input.
  22081. * Higher values reduce sensitivity.
  22082. */
  22083. get: function () {
  22084. var mouse = this.inputs.attached["mouse"];
  22085. if (mouse) {
  22086. return mouse.angularSensibility;
  22087. }
  22088. return 0;
  22089. },
  22090. /**
  22091. * Sets the input sensibility for a mouse input.
  22092. * Higher values reduce sensitivity.
  22093. */
  22094. set: function (value) {
  22095. var mouse = this.inputs.attached["mouse"];
  22096. if (mouse) {
  22097. mouse.angularSensibility = value;
  22098. }
  22099. },
  22100. enumerable: true,
  22101. configurable: true
  22102. });
  22103. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  22104. /**
  22105. * Get the keys for camera movement forward.
  22106. */
  22107. get: function () {
  22108. var keyboard = this.inputs.attached["keyboard"];
  22109. if (keyboard) {
  22110. return keyboard.keysForward;
  22111. }
  22112. return [];
  22113. },
  22114. /**
  22115. * Set the keys for camera movement forward.
  22116. */
  22117. set: function (value) {
  22118. var keyboard = this.inputs.attached["keyboard"];
  22119. if (keyboard) {
  22120. keyboard.keysForward = value;
  22121. }
  22122. },
  22123. enumerable: true,
  22124. configurable: true
  22125. });
  22126. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  22127. /**
  22128. * Get the keys for camera movement backward.
  22129. */
  22130. get: function () {
  22131. var keyboard = this.inputs.attached["keyboard"];
  22132. if (keyboard) {
  22133. return keyboard.keysBackward;
  22134. }
  22135. return [];
  22136. },
  22137. set: function (value) {
  22138. var keyboard = this.inputs.attached["keyboard"];
  22139. if (keyboard) {
  22140. keyboard.keysBackward = value;
  22141. }
  22142. },
  22143. enumerable: true,
  22144. configurable: true
  22145. });
  22146. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  22147. /**
  22148. * Get the keys for camera movement up.
  22149. */
  22150. get: function () {
  22151. var keyboard = this.inputs.attached["keyboard"];
  22152. if (keyboard) {
  22153. return keyboard.keysUp;
  22154. }
  22155. return [];
  22156. },
  22157. /**
  22158. * Set the keys for camera movement up.
  22159. */
  22160. set: function (value) {
  22161. var keyboard = this.inputs.attached["keyboard"];
  22162. if (keyboard) {
  22163. keyboard.keysUp = value;
  22164. }
  22165. },
  22166. enumerable: true,
  22167. configurable: true
  22168. });
  22169. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  22170. /**
  22171. * Get the keys for camera movement down.
  22172. */
  22173. get: function () {
  22174. var keyboard = this.inputs.attached["keyboard"];
  22175. if (keyboard) {
  22176. return keyboard.keysDown;
  22177. }
  22178. return [];
  22179. },
  22180. /**
  22181. * Set the keys for camera movement down.
  22182. */
  22183. set: function (value) {
  22184. var keyboard = this.inputs.attached["keyboard"];
  22185. if (keyboard) {
  22186. keyboard.keysDown = value;
  22187. }
  22188. },
  22189. enumerable: true,
  22190. configurable: true
  22191. });
  22192. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  22193. /**
  22194. * Get the keys for camera movement left.
  22195. */
  22196. get: function () {
  22197. var keyboard = this.inputs.attached["keyboard"];
  22198. if (keyboard) {
  22199. return keyboard.keysLeft;
  22200. }
  22201. return [];
  22202. },
  22203. /**
  22204. * Set the keys for camera movement left.
  22205. */
  22206. set: function (value) {
  22207. var keyboard = this.inputs.attached["keyboard"];
  22208. if (keyboard) {
  22209. keyboard.keysLeft = value;
  22210. }
  22211. },
  22212. enumerable: true,
  22213. configurable: true
  22214. });
  22215. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  22216. /**
  22217. * Set the keys for camera movement right.
  22218. */
  22219. get: function () {
  22220. var keyboard = this.inputs.attached["keyboard"];
  22221. if (keyboard) {
  22222. return keyboard.keysRight;
  22223. }
  22224. return [];
  22225. },
  22226. /**
  22227. * Set the keys for camera movement right.
  22228. */
  22229. set: function (value) {
  22230. var keyboard = this.inputs.attached["keyboard"];
  22231. if (keyboard) {
  22232. keyboard.keysRight = value;
  22233. }
  22234. },
  22235. enumerable: true,
  22236. configurable: true
  22237. });
  22238. /**
  22239. * Attach a control to the HTML DOM element.
  22240. * @param element Defines the element that listens to the input events.
  22241. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  22242. */
  22243. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  22244. this.inputs.attachElement(element, noPreventDefault);
  22245. };
  22246. /**
  22247. * Detach a control from the HTML DOM element.
  22248. * The camera will stop reacting to that input.
  22249. * @param element Defines the element that listens to the input events.
  22250. */
  22251. FlyCamera.prototype.detachControl = function (element) {
  22252. this.inputs.detachElement(element);
  22253. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22254. };
  22255. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  22256. /**
  22257. * Get the mask that the camera ignores in collision events.
  22258. */
  22259. get: function () {
  22260. return this._collisionMask;
  22261. },
  22262. /**
  22263. * Set the mask that the camera ignores in collision events.
  22264. */
  22265. set: function (mask) {
  22266. this._collisionMask = !isNaN(mask) ? mask : -1;
  22267. },
  22268. enumerable: true,
  22269. configurable: true
  22270. });
  22271. /** @hidden */
  22272. FlyCamera.prototype._collideWithWorld = function (displacement) {
  22273. var globalPosition;
  22274. if (this.parent) {
  22275. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22276. }
  22277. else {
  22278. globalPosition = this.position;
  22279. }
  22280. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22281. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22282. var coordinator = this.getScene().collisionCoordinator;
  22283. if (!this._collider) {
  22284. this._collider = coordinator.createCollider();
  22285. }
  22286. this._collider._radius = this.ellipsoid;
  22287. this._collider.collisionMask = this._collisionMask;
  22288. // No need for clone, as long as gravity is not on.
  22289. var actualDisplacement = displacement;
  22290. // Add gravity to direction to prevent dual-collision checking.
  22291. if (this.applyGravity) {
  22292. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  22293. actualDisplacement = displacement.add(this.getScene().gravity);
  22294. }
  22295. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22296. };
  22297. /** @hidden */
  22298. FlyCamera.prototype._checkInputs = function () {
  22299. if (!this._localDirection) {
  22300. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22301. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22302. }
  22303. this.inputs.checkInputs();
  22304. _super.prototype._checkInputs.call(this);
  22305. };
  22306. /** @hidden */
  22307. FlyCamera.prototype._decideIfNeedsToMove = function () {
  22308. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22309. };
  22310. /** @hidden */
  22311. FlyCamera.prototype._updatePosition = function () {
  22312. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22313. this._collideWithWorld(this.cameraDirection);
  22314. }
  22315. else {
  22316. _super.prototype._updatePosition.call(this);
  22317. }
  22318. };
  22319. /**
  22320. * Restore the Roll to its target value at the rate specified.
  22321. * @param rate - Higher means slower restoring.
  22322. * @hidden
  22323. */
  22324. FlyCamera.prototype.restoreRoll = function (rate) {
  22325. var limit = this._trackRoll; // Target Roll.
  22326. var z = this.rotation.z; // Current Roll.
  22327. var delta = limit - z; // Difference in Roll.
  22328. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  22329. // If the difference is noticable, restore the Roll.
  22330. if (Math.abs(delta) >= minRad) {
  22331. // Change Z rotation towards the target Roll.
  22332. this.rotation.z += delta / rate;
  22333. // Match when near enough.
  22334. if (Math.abs(limit - this.rotation.z) <= minRad) {
  22335. this.rotation.z = limit;
  22336. }
  22337. }
  22338. };
  22339. /**
  22340. * Destroy the camera and release the current resources held by it.
  22341. */
  22342. FlyCamera.prototype.dispose = function () {
  22343. this.inputs.clear();
  22344. _super.prototype.dispose.call(this);
  22345. };
  22346. /**
  22347. * Get the current object class name.
  22348. * @returns the class name.
  22349. */
  22350. FlyCamera.prototype.getClassName = function () {
  22351. return "FlyCamera";
  22352. };
  22353. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22354. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22355. ], FlyCamera.prototype, "ellipsoid", void 0);
  22356. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22357. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22358. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  22359. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22360. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22361. ], FlyCamera.prototype, "checkCollisions", void 0);
  22362. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22363. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22364. ], FlyCamera.prototype, "applyGravity", void 0);
  22365. return FlyCamera;
  22366. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22367. /***/ }),
  22368. /***/ "./Cameras/flyCameraInputsManager.ts":
  22369. /*!*******************************************!*\
  22370. !*** ./Cameras/flyCameraInputsManager.ts ***!
  22371. \*******************************************/
  22372. /*! exports provided: FlyCameraInputsManager */
  22373. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22374. "use strict";
  22375. __webpack_require__.r(__webpack_exports__);
  22376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  22377. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22378. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22379. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  22380. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  22381. /**
  22382. * Default Inputs manager for the FlyCamera.
  22383. * It groups all the default supported inputs for ease of use.
  22384. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22385. */
  22386. var FlyCameraInputsManager = /** @class */ (function (_super) {
  22387. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  22388. /**
  22389. * Instantiates a new FlyCameraInputsManager.
  22390. * @param camera Defines the camera the inputs belong to.
  22391. */
  22392. function FlyCameraInputsManager(camera) {
  22393. return _super.call(this, camera) || this;
  22394. }
  22395. /**
  22396. * Add keyboard input support to the input manager.
  22397. * @returns the new FlyCameraKeyboardMoveInput().
  22398. */
  22399. FlyCameraInputsManager.prototype.addKeyboard = function () {
  22400. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  22401. return this;
  22402. };
  22403. /**
  22404. * Add mouse input support to the input manager.
  22405. * @param touchEnabled Enable touch screen support.
  22406. * @returns the new FlyCameraMouseInput().
  22407. */
  22408. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22409. if (touchEnabled === void 0) { touchEnabled = true; }
  22410. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  22411. return this;
  22412. };
  22413. return FlyCameraInputsManager;
  22414. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22415. /***/ }),
  22416. /***/ "./Cameras/followCamera.ts":
  22417. /*!*********************************!*\
  22418. !*** ./Cameras/followCamera.ts ***!
  22419. \*********************************/
  22420. /*! exports provided: FollowCamera, ArcFollowCamera */
  22421. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22422. "use strict";
  22423. __webpack_require__.r(__webpack_exports__);
  22424. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  22425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  22426. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22427. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22428. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  22429. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22430. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22431. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  22432. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  22433. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  22434. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  22435. });
  22436. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  22437. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  22438. });
  22439. /**
  22440. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  22441. * an arc rotate version arcFollowCamera are available.
  22442. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22443. */
  22444. var FollowCamera = /** @class */ (function (_super) {
  22445. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  22446. /**
  22447. * Instantiates the follow camera.
  22448. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22449. * @param name Define the name of the camera in the scene
  22450. * @param position Define the position of the camera
  22451. * @param scene Define the scene the camera belong to
  22452. * @param lockedTarget Define the target of the camera
  22453. */
  22454. function FollowCamera(name, position, scene, lockedTarget) {
  22455. if (lockedTarget === void 0) { lockedTarget = null; }
  22456. var _this = _super.call(this, name, position, scene) || this;
  22457. /**
  22458. * Distance the follow camera should follow an object at
  22459. */
  22460. _this.radius = 12;
  22461. /**
  22462. * Minimum allowed distance of the camera to the axis of rotation
  22463. * (The camera can not get closer).
  22464. * This can help limiting how the Camera is able to move in the scene.
  22465. */
  22466. _this.lowerRadiusLimit = null;
  22467. /**
  22468. * Maximum allowed distance of the camera to the axis of rotation
  22469. * (The camera can not get further).
  22470. * This can help limiting how the Camera is able to move in the scene.
  22471. */
  22472. _this.upperRadiusLimit = null;
  22473. /**
  22474. * Define a rotation offset between the camera and the object it follows
  22475. */
  22476. _this.rotationOffset = 0;
  22477. /**
  22478. * Minimum allowed angle to camera position relative to target object.
  22479. * This can help limiting how the Camera is able to move in the scene.
  22480. */
  22481. _this.lowerRotationOffsetLimit = null;
  22482. /**
  22483. * Maximum allowed angle to camera position relative to target object.
  22484. * This can help limiting how the Camera is able to move in the scene.
  22485. */
  22486. _this.upperRotationOffsetLimit = null;
  22487. /**
  22488. * Define a height offset between the camera and the object it follows.
  22489. * It can help following an object from the top (like a car chaing a plane)
  22490. */
  22491. _this.heightOffset = 4;
  22492. /**
  22493. * Minimum allowed height of camera position relative to target object.
  22494. * This can help limiting how the Camera is able to move in the scene.
  22495. */
  22496. _this.lowerHeightOffsetLimit = null;
  22497. /**
  22498. * Maximum allowed height of camera position relative to target object.
  22499. * This can help limiting how the Camera is able to move in the scene.
  22500. */
  22501. _this.upperHeightOffsetLimit = null;
  22502. /**
  22503. * Define how fast the camera can accelerate to follow it s target.
  22504. */
  22505. _this.cameraAcceleration = 0.05;
  22506. /**
  22507. * Define the speed limit of the camera following an object.
  22508. */
  22509. _this.maxCameraSpeed = 20;
  22510. _this.lockedTarget = lockedTarget;
  22511. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  22512. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  22513. return _this;
  22514. // Uncomment the following line when the relevant handlers have been implemented.
  22515. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  22516. }
  22517. FollowCamera.prototype._follow = function (cameraTarget) {
  22518. if (!cameraTarget) {
  22519. return;
  22520. }
  22521. var yRotation;
  22522. if (cameraTarget.rotationQuaternion) {
  22523. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  22524. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  22525. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  22526. }
  22527. else {
  22528. yRotation = cameraTarget.rotation.y;
  22529. }
  22530. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  22531. var targetPosition = cameraTarget.getAbsolutePosition();
  22532. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  22533. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  22534. var dx = targetX - this.position.x;
  22535. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  22536. var dz = (targetZ) - this.position.z;
  22537. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  22538. var vy = dy * this.cameraAcceleration;
  22539. var vz = dz * this.cameraAcceleration * 2;
  22540. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  22541. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22542. }
  22543. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  22544. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22545. }
  22546. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  22547. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22548. }
  22549. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  22550. this.setTarget(targetPosition);
  22551. };
  22552. /**
  22553. * Attached controls to the current camera.
  22554. * @param element Defines the element the controls should be listened from
  22555. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22556. */
  22557. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  22558. this.inputs.attachElement(element, noPreventDefault);
  22559. this._reset = function () {
  22560. };
  22561. };
  22562. /**
  22563. * Detach the current controls from the camera.
  22564. * The camera will stop reacting to inputs.
  22565. * @param element Defines the element to stop listening the inputs from
  22566. */
  22567. FollowCamera.prototype.detachControl = function (element) {
  22568. this.inputs.detachElement(element);
  22569. if (this._reset) {
  22570. this._reset();
  22571. }
  22572. };
  22573. /** @hidden */
  22574. FollowCamera.prototype._checkInputs = function () {
  22575. this.inputs.checkInputs();
  22576. this._checkLimits();
  22577. _super.prototype._checkInputs.call(this);
  22578. if (this.lockedTarget) {
  22579. this._follow(this.lockedTarget);
  22580. }
  22581. };
  22582. FollowCamera.prototype._checkLimits = function () {
  22583. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  22584. this.radius = this.lowerRadiusLimit;
  22585. }
  22586. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  22587. this.radius = this.upperRadiusLimit;
  22588. }
  22589. if (this.lowerHeightOffsetLimit !== null &&
  22590. this.heightOffset < this.lowerHeightOffsetLimit) {
  22591. this.heightOffset = this.lowerHeightOffsetLimit;
  22592. }
  22593. if (this.upperHeightOffsetLimit !== null &&
  22594. this.heightOffset > this.upperHeightOffsetLimit) {
  22595. this.heightOffset = this.upperHeightOffsetLimit;
  22596. }
  22597. if (this.lowerRotationOffsetLimit !== null &&
  22598. this.rotationOffset < this.lowerRotationOffsetLimit) {
  22599. this.rotationOffset = this.lowerRotationOffsetLimit;
  22600. }
  22601. if (this.upperRotationOffsetLimit !== null &&
  22602. this.rotationOffset > this.upperRotationOffsetLimit) {
  22603. this.rotationOffset = this.upperRotationOffsetLimit;
  22604. }
  22605. };
  22606. /**
  22607. * Gets the camera class name.
  22608. * @returns the class name
  22609. */
  22610. FollowCamera.prototype.getClassName = function () {
  22611. return "FollowCamera";
  22612. };
  22613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22615. ], FollowCamera.prototype, "radius", void 0);
  22616. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22617. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22618. ], FollowCamera.prototype, "lowerRadiusLimit", void 0);
  22619. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22620. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22621. ], FollowCamera.prototype, "upperRadiusLimit", void 0);
  22622. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22623. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22624. ], FollowCamera.prototype, "rotationOffset", void 0);
  22625. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22626. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22627. ], FollowCamera.prototype, "lowerRotationOffsetLimit", void 0);
  22628. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22629. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22630. ], FollowCamera.prototype, "upperRotationOffsetLimit", void 0);
  22631. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22632. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22633. ], FollowCamera.prototype, "heightOffset", void 0);
  22634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22636. ], FollowCamera.prototype, "lowerHeightOffsetLimit", void 0);
  22637. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22638. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22639. ], FollowCamera.prototype, "upperHeightOffsetLimit", void 0);
  22640. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22641. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22642. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  22643. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22644. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22645. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  22646. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  22648. ], FollowCamera.prototype, "lockedTarget", void 0);
  22649. return FollowCamera;
  22650. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22651. /**
  22652. * Arc Rotate version of the follow camera.
  22653. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  22654. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22655. */
  22656. var ArcFollowCamera = /** @class */ (function (_super) {
  22657. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  22658. /**
  22659. * Instantiates a new ArcFollowCamera
  22660. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22661. * @param name Define the name of the camera
  22662. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  22663. * @param beta Define the rotation angle of the camera around the elevation axis
  22664. * @param radius Define the radius of the camera from its target point
  22665. * @param target Define the target of the camera
  22666. * @param scene Define the scene the camera belongs to
  22667. */
  22668. function ArcFollowCamera(name,
  22669. /** The longitudinal angle of the camera */
  22670. alpha,
  22671. /** The latitudinal angle of the camera */
  22672. beta,
  22673. /** The radius of the camera from its target */
  22674. radius,
  22675. /** Define the camera target (the messh it should follow) */
  22676. target, scene) {
  22677. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  22678. _this.alpha = alpha;
  22679. _this.beta = beta;
  22680. _this.radius = radius;
  22681. _this.target = target;
  22682. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  22683. _this._follow();
  22684. return _this;
  22685. }
  22686. ArcFollowCamera.prototype._follow = function () {
  22687. if (!this.target) {
  22688. return;
  22689. }
  22690. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  22691. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  22692. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  22693. var targetPosition = this.target.getAbsolutePosition();
  22694. this.position = targetPosition.add(this._cartesianCoordinates);
  22695. this.setTarget(targetPosition);
  22696. };
  22697. /** @hidden */
  22698. ArcFollowCamera.prototype._checkInputs = function () {
  22699. _super.prototype._checkInputs.call(this);
  22700. this._follow();
  22701. };
  22702. /**
  22703. * Returns the class name of the object.
  22704. * It is mostly used internally for serialization purposes.
  22705. */
  22706. ArcFollowCamera.prototype.getClassName = function () {
  22707. return "ArcFollowCamera";
  22708. };
  22709. return ArcFollowCamera;
  22710. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22711. /***/ }),
  22712. /***/ "./Cameras/followCameraInputsManager.ts":
  22713. /*!**********************************************!*\
  22714. !*** ./Cameras/followCameraInputsManager.ts ***!
  22715. \**********************************************/
  22716. /*! exports provided: FollowCameraInputsManager */
  22717. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22718. "use strict";
  22719. __webpack_require__.r(__webpack_exports__);
  22720. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  22721. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22722. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22723. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  22724. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  22725. /* harmony import */ var _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  22726. /**
  22727. * Default Inputs manager for the FollowCamera.
  22728. * It groups all the default supported inputs for ease of use.
  22729. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22730. */
  22731. var FollowCameraInputsManager = /** @class */ (function (_super) {
  22732. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  22733. /**
  22734. * Instantiates a new FollowCameraInputsManager.
  22735. * @param camera Defines the camera the inputs belong to
  22736. */
  22737. function FollowCameraInputsManager(camera) {
  22738. return _super.call(this, camera) || this;
  22739. }
  22740. /**
  22741. * Add keyboard input support to the input manager.
  22742. * @returns the current input manager
  22743. */
  22744. FollowCameraInputsManager.prototype.addKeyboard = function () {
  22745. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  22746. return this;
  22747. };
  22748. /**
  22749. * Add mouse wheel input support to the input manager.
  22750. * @returns the current input manager
  22751. */
  22752. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  22753. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  22754. return this;
  22755. };
  22756. /**
  22757. * Add pointers input support to the input manager.
  22758. * @returns the current input manager
  22759. */
  22760. FollowCameraInputsManager.prototype.addPointers = function () {
  22761. this.add(new _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__["FollowCameraPointersInput"]());
  22762. return this;
  22763. };
  22764. /**
  22765. * Add orientation input support to the input manager.
  22766. * @returns the current input manager
  22767. */
  22768. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  22769. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  22770. return this;
  22771. };
  22772. return FollowCameraInputsManager;
  22773. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22774. /***/ }),
  22775. /***/ "./Cameras/freeCamera.ts":
  22776. /*!*******************************!*\
  22777. !*** ./Cameras/freeCamera.ts ***!
  22778. \*******************************/
  22779. /*! exports provided: FreeCamera */
  22780. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22781. "use strict";
  22782. __webpack_require__.r(__webpack_exports__);
  22783. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  22784. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22785. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22786. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22787. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22788. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22789. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22790. /**
  22791. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22792. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  22793. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22794. */
  22795. var FreeCamera = /** @class */ (function (_super) {
  22796. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  22797. /**
  22798. * Instantiates a Free Camera.
  22799. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22800. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  22801. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22802. * @param name Define the name of the camera in the scene
  22803. * @param position Define the start position of the camera in the scene
  22804. * @param scene Define the scene the camera belongs to
  22805. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22806. */
  22807. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22808. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22809. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22810. /**
  22811. * Define the collision ellipsoid of the camera.
  22812. * This is helpful to simulate a camera body like the player body around the camera
  22813. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22814. */
  22815. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  22816. /**
  22817. * Define an offset for the position of the ellipsoid around the camera.
  22818. * This can be helpful to determine the center of the body near the gravity center of the body
  22819. * instead of its head.
  22820. */
  22821. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22822. /**
  22823. * Enable or disable collisions of the camera with the rest of the scene objects.
  22824. */
  22825. _this.checkCollisions = false;
  22826. /**
  22827. * Enable or disable gravity on the camera.
  22828. */
  22829. _this.applyGravity = false;
  22830. _this._needMoveForGravity = false;
  22831. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22832. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22833. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22834. // Collisions
  22835. _this._collisionMask = -1;
  22836. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22837. if (collidedMesh === void 0) { collidedMesh = null; }
  22838. var updatePosition = function (newPos) {
  22839. _this._newPosition.copyFrom(newPos);
  22840. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22841. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22842. _this.position.addInPlace(_this._diffPosition);
  22843. if (_this.onCollide && collidedMesh) {
  22844. _this.onCollide(collidedMesh);
  22845. }
  22846. }
  22847. };
  22848. updatePosition(newPosition);
  22849. };
  22850. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"](_this);
  22851. _this.inputs.addKeyboard().addMouse();
  22852. return _this;
  22853. }
  22854. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  22855. /**
  22856. * Gets the input sensibility for a mouse input. (default is 2000.0)
  22857. * Higher values reduce sensitivity.
  22858. */
  22859. get: function () {
  22860. var mouse = this.inputs.attached["mouse"];
  22861. if (mouse) {
  22862. return mouse.angularSensibility;
  22863. }
  22864. return 0;
  22865. },
  22866. /**
  22867. * Sets the input sensibility for a mouse input. (default is 2000.0)
  22868. * Higher values reduce sensitivity.
  22869. */
  22870. set: function (value) {
  22871. var mouse = this.inputs.attached["mouse"];
  22872. if (mouse) {
  22873. mouse.angularSensibility = value;
  22874. }
  22875. },
  22876. enumerable: true,
  22877. configurable: true
  22878. });
  22879. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  22880. /**
  22881. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  22882. */
  22883. get: function () {
  22884. var keyboard = this.inputs.attached["keyboard"];
  22885. if (keyboard) {
  22886. return keyboard.keysUp;
  22887. }
  22888. return [];
  22889. },
  22890. set: function (value) {
  22891. var keyboard = this.inputs.attached["keyboard"];
  22892. if (keyboard) {
  22893. keyboard.keysUp = value;
  22894. }
  22895. },
  22896. enumerable: true,
  22897. configurable: true
  22898. });
  22899. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  22900. /**
  22901. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  22902. */
  22903. get: function () {
  22904. var keyboard = this.inputs.attached["keyboard"];
  22905. if (keyboard) {
  22906. return keyboard.keysDown;
  22907. }
  22908. return [];
  22909. },
  22910. set: function (value) {
  22911. var keyboard = this.inputs.attached["keyboard"];
  22912. if (keyboard) {
  22913. keyboard.keysDown = value;
  22914. }
  22915. },
  22916. enumerable: true,
  22917. configurable: true
  22918. });
  22919. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  22920. /**
  22921. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  22922. */
  22923. get: function () {
  22924. var keyboard = this.inputs.attached["keyboard"];
  22925. if (keyboard) {
  22926. return keyboard.keysLeft;
  22927. }
  22928. return [];
  22929. },
  22930. set: function (value) {
  22931. var keyboard = this.inputs.attached["keyboard"];
  22932. if (keyboard) {
  22933. keyboard.keysLeft = value;
  22934. }
  22935. },
  22936. enumerable: true,
  22937. configurable: true
  22938. });
  22939. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  22940. /**
  22941. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  22942. */
  22943. get: function () {
  22944. var keyboard = this.inputs.attached["keyboard"];
  22945. if (keyboard) {
  22946. return keyboard.keysRight;
  22947. }
  22948. return [];
  22949. },
  22950. set: function (value) {
  22951. var keyboard = this.inputs.attached["keyboard"];
  22952. if (keyboard) {
  22953. keyboard.keysRight = value;
  22954. }
  22955. },
  22956. enumerable: true,
  22957. configurable: true
  22958. });
  22959. /**
  22960. * Attached controls to the current camera.
  22961. * @param element Defines the element the controls should be listened from
  22962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22963. */
  22964. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  22965. this.inputs.attachElement(element, noPreventDefault);
  22966. };
  22967. /**
  22968. * Detach the current controls from the camera.
  22969. * The camera will stop reacting to inputs.
  22970. * @param element Defines the element to stop listening the inputs from
  22971. */
  22972. FreeCamera.prototype.detachControl = function (element) {
  22973. this.inputs.detachElement(element);
  22974. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22975. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  22976. };
  22977. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  22978. /**
  22979. * Define a collision mask to limit the list of object the camera can collide with
  22980. */
  22981. get: function () {
  22982. return this._collisionMask;
  22983. },
  22984. set: function (mask) {
  22985. this._collisionMask = !isNaN(mask) ? mask : -1;
  22986. },
  22987. enumerable: true,
  22988. configurable: true
  22989. });
  22990. /** @hidden */
  22991. FreeCamera.prototype._collideWithWorld = function (displacement) {
  22992. var globalPosition;
  22993. if (this.parent) {
  22994. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22995. }
  22996. else {
  22997. globalPosition = this.position;
  22998. }
  22999. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  23000. this._oldPosition.addInPlace(this.ellipsoidOffset);
  23001. var coordinator = this.getScene().collisionCoordinator;
  23002. if (!this._collider) {
  23003. this._collider = coordinator.createCollider();
  23004. }
  23005. this._collider._radius = this.ellipsoid;
  23006. this._collider.collisionMask = this._collisionMask;
  23007. //no need for clone, as long as gravity is not on.
  23008. var actualDisplacement = displacement;
  23009. //add gravity to the direction to prevent the dual-collision checking
  23010. if (this.applyGravity) {
  23011. //this prevents mending with cameraDirection, a global variable of the free camera class.
  23012. actualDisplacement = displacement.add(this.getScene().gravity);
  23013. }
  23014. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  23015. };
  23016. /** @hidden */
  23017. FreeCamera.prototype._checkInputs = function () {
  23018. if (!this._localDirection) {
  23019. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  23020. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  23021. }
  23022. this.inputs.checkInputs();
  23023. _super.prototype._checkInputs.call(this);
  23024. };
  23025. /** @hidden */
  23026. FreeCamera.prototype._decideIfNeedsToMove = function () {
  23027. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  23028. };
  23029. /** @hidden */
  23030. FreeCamera.prototype._updatePosition = function () {
  23031. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  23032. this._collideWithWorld(this.cameraDirection);
  23033. }
  23034. else {
  23035. _super.prototype._updatePosition.call(this);
  23036. }
  23037. };
  23038. /**
  23039. * Destroy the camera and release the current resources hold by it.
  23040. */
  23041. FreeCamera.prototype.dispose = function () {
  23042. this.inputs.clear();
  23043. _super.prototype.dispose.call(this);
  23044. };
  23045. /**
  23046. * Gets the current object class name.
  23047. * @return the class name
  23048. */
  23049. FreeCamera.prototype.getClassName = function () {
  23050. return "FreeCamera";
  23051. };
  23052. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23053. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23054. ], FreeCamera.prototype, "ellipsoid", void 0);
  23055. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23056. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23057. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  23058. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23059. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23060. ], FreeCamera.prototype, "checkCollisions", void 0);
  23061. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23062. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23063. ], FreeCamera.prototype, "applyGravity", void 0);
  23064. return FreeCamera;
  23065. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  23066. /***/ }),
  23067. /***/ "./Cameras/freeCameraInputsManager.ts":
  23068. /*!********************************************!*\
  23069. !*** ./Cameras/freeCameraInputsManager.ts ***!
  23070. \********************************************/
  23071. /*! exports provided: FreeCameraInputsManager */
  23072. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23073. "use strict";
  23074. __webpack_require__.r(__webpack_exports__);
  23075. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  23076. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23077. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  23078. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  23079. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  23080. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  23081. /**
  23082. * Default Inputs manager for the FreeCamera.
  23083. * It groups all the default supported inputs for ease of use.
  23084. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  23085. */
  23086. var FreeCameraInputsManager = /** @class */ (function (_super) {
  23087. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  23088. /**
  23089. * Instantiates a new FreeCameraInputsManager.
  23090. * @param camera Defines the camera the inputs belong to
  23091. */
  23092. function FreeCameraInputsManager(camera) {
  23093. var _this = _super.call(this, camera) || this;
  23094. /**
  23095. * @hidden
  23096. */
  23097. _this._keyboardInput = null;
  23098. /**
  23099. * @hidden
  23100. */
  23101. _this._mouseInput = null;
  23102. return _this;
  23103. }
  23104. /**
  23105. * Add keyboard input support to the input manager.
  23106. * @returns the current input manager
  23107. */
  23108. FreeCameraInputsManager.prototype.addKeyboard = function () {
  23109. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  23110. return this;
  23111. };
  23112. /**
  23113. * Add mouse input support to the input manager.
  23114. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  23115. * @returns the current input manager
  23116. */
  23117. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  23118. if (touchEnabled === void 0) { touchEnabled = true; }
  23119. if (!this._mouseInput) {
  23120. this._mouseInput = new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled);
  23121. this.add(this._mouseInput);
  23122. }
  23123. return this;
  23124. };
  23125. /**
  23126. * Removes the mouse input support from the manager
  23127. * @returns the current input manager
  23128. */
  23129. FreeCameraInputsManager.prototype.removeMouse = function () {
  23130. if (this._mouseInput) {
  23131. this.remove(this._mouseInput);
  23132. }
  23133. return this;
  23134. };
  23135. /**
  23136. * Add touch input support to the input manager.
  23137. * @returns the current input manager
  23138. */
  23139. FreeCameraInputsManager.prototype.addTouch = function () {
  23140. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  23141. return this;
  23142. };
  23143. return FreeCameraInputsManager;
  23144. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  23145. /***/ }),
  23146. /***/ "./Cameras/gamepadCamera.ts":
  23147. /*!**********************************!*\
  23148. !*** ./Cameras/gamepadCamera.ts ***!
  23149. \**********************************/
  23150. /*! exports provided: GamepadCamera */
  23151. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23152. "use strict";
  23153. __webpack_require__.r(__webpack_exports__);
  23154. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  23155. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23156. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  23157. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23158. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23159. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  23160. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23161. });
  23162. /**
  23163. * This represents a FPS type of camera. This is only here for back compat purpose.
  23164. * Please use the UniversalCamera instead as both are identical.
  23165. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23166. */
  23167. var GamepadCamera = /** @class */ (function (_super) {
  23168. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  23169. /**
  23170. * Instantiates a new Gamepad Camera
  23171. * This represents a FPS type of camera. This is only here for back compat purpose.
  23172. * Please use the UniversalCamera instead as both are identical.
  23173. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23174. * @param name Define the name of the camera in the scene
  23175. * @param position Define the start position of the camera in the scene
  23176. * @param scene Define the scene the camera belongs to
  23177. */
  23178. function GamepadCamera(name, position, scene) {
  23179. return _super.call(this, name, position, scene) || this;
  23180. }
  23181. /**
  23182. * Gets the current object class name.
  23183. * @return the class name
  23184. */
  23185. GamepadCamera.prototype.getClassName = function () {
  23186. return "GamepadCamera";
  23187. };
  23188. return GamepadCamera;
  23189. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  23190. /***/ }),
  23191. /***/ "./Cameras/index.ts":
  23192. /*!**************************!*\
  23193. !*** ./Cameras/index.ts ***!
  23194. \**************************/
  23195. /*! exports provided: CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  23196. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23197. "use strict";
  23198. __webpack_require__.r(__webpack_exports__);
  23199. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  23200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  23201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  23202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  23203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  23204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  23205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  23206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  23207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  23208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  23209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  23210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  23211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  23212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  23213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  23214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  23215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  23216. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  23217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  23218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  23219. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  23221. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  23222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  23223. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  23225. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  23226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  23227. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  23229. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  23230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  23231. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  23232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  23233. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  23234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  23235. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  23236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  23237. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  23238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  23239. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  23240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  23241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  23242. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  23243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  23244. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  23245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  23246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  23247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  23248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  23249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  23250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  23251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  23252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  23253. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  23254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  23255. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  23256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  23257. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  23258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  23259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  23260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  23261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  23262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["OnAfterEnteringVRObservableEvent"]; });
  23263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  23264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  23265. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  23266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  23267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  23268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  23269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  23270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  23271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  23272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  23273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  23274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  23275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  23276. /***/ }),
  23277. /***/ "./Cameras/targetCamera.ts":
  23278. /*!*********************************!*\
  23279. !*** ./Cameras/targetCamera.ts ***!
  23280. \*********************************/
  23281. /*! exports provided: TargetCamera */
  23282. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23283. "use strict";
  23284. __webpack_require__.r(__webpack_exports__);
  23285. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  23286. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23287. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  23288. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23289. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23290. /**
  23291. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  23292. * This is the base of the follow, arc rotate cameras and Free camera
  23293. * @see http://doc.babylonjs.com/features/cameras
  23294. */
  23295. var TargetCamera = /** @class */ (function (_super) {
  23296. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  23297. /**
  23298. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  23299. * This is the base of the follow, arc rotate cameras and Free camera
  23300. * @see http://doc.babylonjs.com/features/cameras
  23301. * @param name Defines the name of the camera in the scene
  23302. * @param position Defines the start position of the camera in the scene
  23303. * @param scene Defines the scene the camera belongs to
  23304. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  23305. */
  23306. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  23307. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  23308. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  23309. /**
  23310. * Define the current direction the camera is moving to
  23311. */
  23312. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23313. /**
  23314. * Define the current rotation the camera is rotating to
  23315. */
  23316. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  23317. /**
  23318. * When set, the up vector of the camera will be updated by the rotation of the camera
  23319. */
  23320. _this.updateUpVectorFromRotation = false;
  23321. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23322. /**
  23323. * Define the current rotation of the camera
  23324. */
  23325. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23326. /**
  23327. * Define the current speed of the camera
  23328. */
  23329. _this.speed = 2.0;
  23330. /**
  23331. * Add cconstraint to the camera to prevent it to move freely in all directions and
  23332. * around all axis.
  23333. */
  23334. _this.noRotationConstraint = false;
  23335. /**
  23336. * Define the current target of the camera as an object or a position.
  23337. */
  23338. _this.lockedTarget = null;
  23339. /** @hidden */
  23340. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23341. /** @hidden */
  23342. _this._initialFocalDistance = 1;
  23343. /** @hidden */
  23344. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23345. /** @hidden */
  23346. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23347. /** @hidden */
  23348. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23349. /** @hidden */
  23350. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23351. /** @hidden */
  23352. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  23353. /** @hidden */
  23354. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23355. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23356. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23357. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  23358. _this._cachedRotationZ = 0;
  23359. _this._cachedQuaternionRotationZ = 0;
  23360. return _this;
  23361. }
  23362. /**
  23363. * Gets the position in front of the camera at a given distance.
  23364. * @param distance The distance from the camera we want the position to be
  23365. * @returns the position
  23366. */
  23367. TargetCamera.prototype.getFrontPosition = function (distance) {
  23368. this.getWorldMatrix();
  23369. var direction = this.getTarget().subtract(this.position);
  23370. direction.normalize();
  23371. direction.scaleInPlace(distance);
  23372. return this.globalPosition.add(direction);
  23373. };
  23374. /** @hidden */
  23375. TargetCamera.prototype._getLockedTargetPosition = function () {
  23376. if (!this.lockedTarget) {
  23377. return null;
  23378. }
  23379. if (this.lockedTarget.absolutePosition) {
  23380. this.lockedTarget.computeWorldMatrix();
  23381. }
  23382. return this.lockedTarget.absolutePosition || this.lockedTarget;
  23383. };
  23384. /**
  23385. * Store current camera state of the camera (fov, position, rotation, etc..)
  23386. * @returns the camera
  23387. */
  23388. TargetCamera.prototype.storeState = function () {
  23389. this._storedPosition = this.position.clone();
  23390. this._storedRotation = this.rotation.clone();
  23391. if (this.rotationQuaternion) {
  23392. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  23393. }
  23394. return _super.prototype.storeState.call(this);
  23395. };
  23396. /**
  23397. * Restored camera state. You must call storeState() first
  23398. * @returns whether it was successful or not
  23399. * @hidden
  23400. */
  23401. TargetCamera.prototype._restoreStateValues = function () {
  23402. if (!_super.prototype._restoreStateValues.call(this)) {
  23403. return false;
  23404. }
  23405. this.position = this._storedPosition.clone();
  23406. this.rotation = this._storedRotation.clone();
  23407. if (this.rotationQuaternion) {
  23408. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  23409. }
  23410. this.cameraDirection.copyFromFloats(0, 0, 0);
  23411. this.cameraRotation.copyFromFloats(0, 0);
  23412. return true;
  23413. };
  23414. /** @hidden */
  23415. TargetCamera.prototype._initCache = function () {
  23416. _super.prototype._initCache.call(this);
  23417. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23418. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23419. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23420. };
  23421. /** @hidden */
  23422. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  23423. if (!ignoreParentClass) {
  23424. _super.prototype._updateCache.call(this);
  23425. }
  23426. var lockedTargetPosition = this._getLockedTargetPosition();
  23427. if (!lockedTargetPosition) {
  23428. this._cache.lockedTarget = null;
  23429. }
  23430. else {
  23431. if (!this._cache.lockedTarget) {
  23432. this._cache.lockedTarget = lockedTargetPosition.clone();
  23433. }
  23434. else {
  23435. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  23436. }
  23437. }
  23438. this._cache.rotation.copyFrom(this.rotation);
  23439. if (this.rotationQuaternion) {
  23440. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23441. }
  23442. };
  23443. // Synchronized
  23444. /** @hidden */
  23445. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  23446. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  23447. return false;
  23448. }
  23449. var lockedTargetPosition = this._getLockedTargetPosition();
  23450. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  23451. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  23452. };
  23453. // Methods
  23454. /** @hidden */
  23455. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  23456. var engine = this.getEngine();
  23457. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  23458. };
  23459. // Target
  23460. /**
  23461. * Defines the target the camera should look at.
  23462. * This will automatically adapt alpha beta and radius to fit within the new target.
  23463. * @param target Defines the new target as a Vector or a mesh
  23464. */
  23465. TargetCamera.prototype.setTarget = function (target) {
  23466. this.upVector.normalize();
  23467. this._initialFocalDistance = target.subtract(this.position).length();
  23468. if (this.position.z === target.z) {
  23469. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  23470. }
  23471. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  23472. this._camMatrix.invert();
  23473. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  23474. var vDir = target.subtract(this.position);
  23475. if (vDir.x >= 0.0) {
  23476. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  23477. }
  23478. else {
  23479. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  23480. }
  23481. this.rotation.z = 0;
  23482. if (isNaN(this.rotation.x)) {
  23483. this.rotation.x = 0;
  23484. }
  23485. if (isNaN(this.rotation.y)) {
  23486. this.rotation.y = 0;
  23487. }
  23488. if (isNaN(this.rotation.z)) {
  23489. this.rotation.z = 0;
  23490. }
  23491. if (this.rotationQuaternion) {
  23492. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23493. }
  23494. };
  23495. /**
  23496. * Return the current target position of the camera. This value is expressed in local space.
  23497. * @returns the target position
  23498. */
  23499. TargetCamera.prototype.getTarget = function () {
  23500. return this._currentTarget;
  23501. };
  23502. /** @hidden */
  23503. TargetCamera.prototype._decideIfNeedsToMove = function () {
  23504. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  23505. };
  23506. /** @hidden */
  23507. TargetCamera.prototype._updatePosition = function () {
  23508. if (this.parent) {
  23509. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  23510. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this.cameraDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  23511. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  23512. return;
  23513. }
  23514. this.position.addInPlace(this.cameraDirection);
  23515. };
  23516. /** @hidden */
  23517. TargetCamera.prototype._checkInputs = function () {
  23518. var needToMove = this._decideIfNeedsToMove();
  23519. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  23520. // Move
  23521. if (needToMove) {
  23522. this._updatePosition();
  23523. }
  23524. // Rotate
  23525. if (needToRotate) {
  23526. this.rotation.x += this.cameraRotation.x;
  23527. this.rotation.y += this.cameraRotation.y;
  23528. //rotate, if quaternion is set and rotation was used
  23529. if (this.rotationQuaternion) {
  23530. var len = this.rotation.lengthSquared();
  23531. if (len) {
  23532. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23533. }
  23534. }
  23535. if (!this.noRotationConstraint) {
  23536. var limit = (Math.PI / 2) * 0.95;
  23537. if (this.rotation.x > limit) {
  23538. this.rotation.x = limit;
  23539. }
  23540. if (this.rotation.x < -limit) {
  23541. this.rotation.x = -limit;
  23542. }
  23543. }
  23544. }
  23545. // Inertia
  23546. if (needToMove) {
  23547. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23548. this.cameraDirection.x = 0;
  23549. }
  23550. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23551. this.cameraDirection.y = 0;
  23552. }
  23553. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23554. this.cameraDirection.z = 0;
  23555. }
  23556. this.cameraDirection.scaleInPlace(this.inertia);
  23557. }
  23558. if (needToRotate) {
  23559. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23560. this.cameraRotation.x = 0;
  23561. }
  23562. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23563. this.cameraRotation.y = 0;
  23564. }
  23565. this.cameraRotation.scaleInPlace(this.inertia);
  23566. }
  23567. _super.prototype._checkInputs.call(this);
  23568. };
  23569. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  23570. if (this.rotationQuaternion) {
  23571. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  23572. }
  23573. else {
  23574. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  23575. }
  23576. };
  23577. /**
  23578. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  23579. * @returns the current camera
  23580. */
  23581. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  23582. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  23583. return this;
  23584. };
  23585. /** @hidden */
  23586. TargetCamera.prototype._getViewMatrix = function () {
  23587. if (this.lockedTarget) {
  23588. this.setTarget(this._getLockedTargetPosition());
  23589. }
  23590. // Compute
  23591. this._updateCameraRotationMatrix();
  23592. // Apply the changed rotation to the upVector
  23593. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  23594. this._rotateUpVectorWithCameraRotationMatrix();
  23595. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  23596. }
  23597. else if (this._cachedRotationZ != this.rotation.z) {
  23598. this._rotateUpVectorWithCameraRotationMatrix();
  23599. this._cachedRotationZ = this.rotation.z;
  23600. }
  23601. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  23602. // Computing target and final matrix
  23603. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  23604. if (this.updateUpVectorFromRotation) {
  23605. if (this.rotationQuaternion) {
  23606. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  23607. }
  23608. else {
  23609. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  23610. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  23611. }
  23612. }
  23613. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  23614. return this._viewMatrix;
  23615. };
  23616. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  23617. if (this.parent) {
  23618. var parentWorldMatrix = this.parent.getWorldMatrix();
  23619. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  23620. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  23621. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  23622. this._markSyncedWithParent();
  23623. }
  23624. else {
  23625. this._globalPosition.copyFrom(position);
  23626. this._globalCurrentTarget.copyFrom(target);
  23627. this._globalCurrentUpVector.copyFrom(up);
  23628. }
  23629. if (this.getScene().useRightHandedSystem) {
  23630. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23631. }
  23632. else {
  23633. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23634. }
  23635. };
  23636. /**
  23637. * @hidden
  23638. */
  23639. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  23640. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  23641. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  23642. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  23643. if (!this.rotationQuaternion) {
  23644. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23645. }
  23646. rigCamera._cameraRigParams = {};
  23647. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23648. }
  23649. return rigCamera;
  23650. }
  23651. return null;
  23652. };
  23653. /**
  23654. * @hidden
  23655. */
  23656. TargetCamera.prototype._updateRigCameras = function () {
  23657. var camLeft = this._rigCameras[0];
  23658. var camRight = this._rigCameras[1];
  23659. this.computeWorldMatrix();
  23660. switch (this.cameraRigMode) {
  23661. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  23662. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  23663. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  23664. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  23665. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  23666. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  23667. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  23668. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  23669. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  23670. break;
  23671. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  23672. if (camLeft.rotationQuaternion) {
  23673. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23674. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23675. }
  23676. else {
  23677. camLeft.rotation.copyFrom(this.rotation);
  23678. camRight.rotation.copyFrom(this.rotation);
  23679. }
  23680. camLeft.position.copyFrom(this.position);
  23681. camRight.position.copyFrom(this.position);
  23682. break;
  23683. }
  23684. _super.prototype._updateRigCameras.call(this);
  23685. };
  23686. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  23687. var target = this.getTarget();
  23688. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  23689. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  23690. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  23691. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23692. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  23693. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23694. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  23695. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  23696. rigCamera.setTarget(newFocalTarget);
  23697. };
  23698. /**
  23699. * Gets the current object class name.
  23700. * @return the class name
  23701. */
  23702. TargetCamera.prototype.getClassName = function () {
  23703. return "TargetCamera";
  23704. };
  23705. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23706. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23707. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  23708. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23709. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23710. ], TargetCamera.prototype, "rotation", void 0);
  23711. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23712. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23713. ], TargetCamera.prototype, "speed", void 0);
  23714. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23715. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  23716. ], TargetCamera.prototype, "lockedTarget", void 0);
  23717. return TargetCamera;
  23718. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  23719. /***/ }),
  23720. /***/ "./Cameras/touchCamera.ts":
  23721. /*!********************************!*\
  23722. !*** ./Cameras/touchCamera.ts ***!
  23723. \********************************/
  23724. /*! exports provided: TouchCamera */
  23725. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23726. "use strict";
  23727. __webpack_require__.r(__webpack_exports__);
  23728. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  23729. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23730. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23731. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23732. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23733. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  23734. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23735. });
  23736. /**
  23737. * This represents a FPS type of camera controlled by touch.
  23738. * This is like a universal camera minus the Gamepad controls.
  23739. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23740. */
  23741. var TouchCamera = /** @class */ (function (_super) {
  23742. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  23743. /**
  23744. * Instantiates a new touch camera.
  23745. * This represents a FPS type of camera controlled by touch.
  23746. * This is like a universal camera minus the Gamepad controls.
  23747. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23748. * @param name Define the name of the camera in the scene
  23749. * @param position Define the start position of the camera in the scene
  23750. * @param scene Define the scene the camera belongs to
  23751. */
  23752. function TouchCamera(name, position, scene) {
  23753. var _this = _super.call(this, name, position, scene) || this;
  23754. _this.inputs.addTouch();
  23755. _this._setupInputs();
  23756. return _this;
  23757. }
  23758. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  23759. /**
  23760. * Defines the touch sensibility for rotation.
  23761. * The higher the faster.
  23762. */
  23763. get: function () {
  23764. var touch = this.inputs.attached["touch"];
  23765. if (touch) {
  23766. return touch.touchAngularSensibility;
  23767. }
  23768. return 0;
  23769. },
  23770. set: function (value) {
  23771. var touch = this.inputs.attached["touch"];
  23772. if (touch) {
  23773. touch.touchAngularSensibility = value;
  23774. }
  23775. },
  23776. enumerable: true,
  23777. configurable: true
  23778. });
  23779. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  23780. /**
  23781. * Defines the touch sensibility for move.
  23782. * The higher the faster.
  23783. */
  23784. get: function () {
  23785. var touch = this.inputs.attached["touch"];
  23786. if (touch) {
  23787. return touch.touchMoveSensibility;
  23788. }
  23789. return 0;
  23790. },
  23791. set: function (value) {
  23792. var touch = this.inputs.attached["touch"];
  23793. if (touch) {
  23794. touch.touchMoveSensibility = value;
  23795. }
  23796. },
  23797. enumerable: true,
  23798. configurable: true
  23799. });
  23800. /**
  23801. * Gets the current object class name.
  23802. * @return the class name
  23803. */
  23804. TouchCamera.prototype.getClassName = function () {
  23805. return "TouchCamera";
  23806. };
  23807. /** @hidden */
  23808. TouchCamera.prototype._setupInputs = function () {
  23809. var mouse = this.inputs.attached["mouse"];
  23810. if (mouse) {
  23811. mouse.touchEnabled = false;
  23812. }
  23813. };
  23814. return TouchCamera;
  23815. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23816. /***/ }),
  23817. /***/ "./Cameras/universalCamera.ts":
  23818. /*!************************************!*\
  23819. !*** ./Cameras/universalCamera.ts ***!
  23820. \************************************/
  23821. /*! exports provided: UniversalCamera */
  23822. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23823. "use strict";
  23824. __webpack_require__.r(__webpack_exports__);
  23825. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  23826. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23827. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23828. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  23829. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23830. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23831. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  23832. // Forcing to use the Universal camera
  23833. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  23834. });
  23835. /**
  23836. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  23837. * which still works and will still be found in many Playgrounds.
  23838. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23839. */
  23840. var UniversalCamera = /** @class */ (function (_super) {
  23841. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  23842. /**
  23843. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  23844. * which still works and will still be found in many Playgrounds.
  23845. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23846. * @param name Define the name of the camera in the scene
  23847. * @param position Define the start position of the camera in the scene
  23848. * @param scene Define the scene the camera belongs to
  23849. */
  23850. function UniversalCamera(name, position, scene) {
  23851. var _this = _super.call(this, name, position, scene) || this;
  23852. _this.inputs.addGamepad();
  23853. return _this;
  23854. }
  23855. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  23856. /**
  23857. * Defines the gamepad rotation sensiblity.
  23858. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  23859. */
  23860. get: function () {
  23861. var gamepad = this.inputs.attached["gamepad"];
  23862. if (gamepad) {
  23863. return gamepad.gamepadAngularSensibility;
  23864. }
  23865. return 0;
  23866. },
  23867. set: function (value) {
  23868. var gamepad = this.inputs.attached["gamepad"];
  23869. if (gamepad) {
  23870. gamepad.gamepadAngularSensibility = value;
  23871. }
  23872. },
  23873. enumerable: true,
  23874. configurable: true
  23875. });
  23876. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  23877. /**
  23878. * Defines the gamepad move sensiblity.
  23879. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  23880. */
  23881. get: function () {
  23882. var gamepad = this.inputs.attached["gamepad"];
  23883. if (gamepad) {
  23884. return gamepad.gamepadMoveSensibility;
  23885. }
  23886. return 0;
  23887. },
  23888. set: function (value) {
  23889. var gamepad = this.inputs.attached["gamepad"];
  23890. if (gamepad) {
  23891. gamepad.gamepadMoveSensibility = value;
  23892. }
  23893. },
  23894. enumerable: true,
  23895. configurable: true
  23896. });
  23897. /**
  23898. * Gets the current object class name.
  23899. * @return the class name
  23900. */
  23901. UniversalCamera.prototype.getClassName = function () {
  23902. return "UniversalCamera";
  23903. };
  23904. return UniversalCamera;
  23905. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  23906. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  23907. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  23908. };
  23909. /***/ }),
  23910. /***/ "./Cameras/virtualJoysticksCamera.ts":
  23911. /*!*******************************************!*\
  23912. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  23913. \*******************************************/
  23914. /*! exports provided: VirtualJoysticksCamera */
  23915. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23916. "use strict";
  23917. __webpack_require__.r(__webpack_exports__);
  23918. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  23919. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23920. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23921. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23922. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23923. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  23924. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  23925. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23926. });
  23927. /**
  23928. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  23929. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23930. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23931. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23932. */
  23933. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  23934. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  23935. /**
  23936. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  23937. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23938. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23939. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23940. * @param name Define the name of the camera in the scene
  23941. * @param position Define the start position of the camera in the scene
  23942. * @param scene Define the scene the camera belongs to
  23943. */
  23944. function VirtualJoysticksCamera(name, position, scene) {
  23945. var _this = _super.call(this, name, position, scene) || this;
  23946. _this.inputs.addVirtualJoystick();
  23947. return _this;
  23948. }
  23949. /**
  23950. * Gets the current object class name.
  23951. * @return the class name
  23952. */
  23953. VirtualJoysticksCamera.prototype.getClassName = function () {
  23954. return "VirtualJoysticksCamera";
  23955. };
  23956. return VirtualJoysticksCamera;
  23957. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23958. /***/ }),
  23959. /***/ "./Collisions/collider.ts":
  23960. /*!********************************!*\
  23961. !*** ./Collisions/collider.ts ***!
  23962. \********************************/
  23963. /*! exports provided: Collider */
  23964. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23965. "use strict";
  23966. __webpack_require__.r(__webpack_exports__);
  23967. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  23968. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23969. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  23970. if (boxMin.x > sphereCenter.x + sphereRadius) {
  23971. return false;
  23972. }
  23973. if (sphereCenter.x - sphereRadius > boxMax.x) {
  23974. return false;
  23975. }
  23976. if (boxMin.y > sphereCenter.y + sphereRadius) {
  23977. return false;
  23978. }
  23979. if (sphereCenter.y - sphereRadius > boxMax.y) {
  23980. return false;
  23981. }
  23982. if (boxMin.z > sphereCenter.z + sphereRadius) {
  23983. return false;
  23984. }
  23985. if (sphereCenter.z - sphereRadius > boxMax.z) {
  23986. return false;
  23987. }
  23988. return true;
  23989. };
  23990. var getLowestRoot = (function () {
  23991. var result = { root: 0, found: false };
  23992. return function (a, b, c, maxR) {
  23993. result.root = 0;
  23994. result.found = false;
  23995. var determinant = b * b - 4.0 * a * c;
  23996. if (determinant < 0) {
  23997. return result;
  23998. }
  23999. var sqrtD = Math.sqrt(determinant);
  24000. var r1 = (-b - sqrtD) / (2.0 * a);
  24001. var r2 = (-b + sqrtD) / (2.0 * a);
  24002. if (r1 > r2) {
  24003. var temp = r2;
  24004. r2 = r1;
  24005. r1 = temp;
  24006. }
  24007. if (r1 > 0 && r1 < maxR) {
  24008. result.root = r1;
  24009. result.found = true;
  24010. return result;
  24011. }
  24012. if (r2 > 0 && r2 < maxR) {
  24013. result.root = r2;
  24014. result.found = true;
  24015. return result;
  24016. }
  24017. return result;
  24018. };
  24019. })();
  24020. /** @hidden */
  24021. var Collider = /** @class */ (function () {
  24022. function Collider() {
  24023. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24024. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24025. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24026. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24027. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24028. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24029. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24030. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24031. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24032. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24033. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24034. /** @hidden */
  24035. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  24036. /** @hidden */
  24037. this._retry = 0;
  24038. /** @hidden */
  24039. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24040. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24041. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24042. this._collisionMask = -1;
  24043. }
  24044. Object.defineProperty(Collider.prototype, "collisionMask", {
  24045. get: function () {
  24046. return this._collisionMask;
  24047. },
  24048. set: function (mask) {
  24049. this._collisionMask = !isNaN(mask) ? mask : -1;
  24050. },
  24051. enumerable: true,
  24052. configurable: true
  24053. });
  24054. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  24055. /**
  24056. * Gets the plane normal used to compute the sliding response (in local space)
  24057. */
  24058. get: function () {
  24059. return this._slidePlaneNormal;
  24060. },
  24061. enumerable: true,
  24062. configurable: true
  24063. });
  24064. // Methods
  24065. /** @hidden */
  24066. Collider.prototype._initialize = function (source, dir, e) {
  24067. this._velocity = dir;
  24068. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  24069. this._basePoint = source;
  24070. source.multiplyToRef(this._radius, this._basePointWorld);
  24071. dir.multiplyToRef(this._radius, this._velocityWorld);
  24072. this._velocityWorldLength = this._velocityWorld.length();
  24073. this._epsilon = e;
  24074. this.collisionFound = false;
  24075. };
  24076. /** @hidden */
  24077. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  24078. pa.subtractToRef(point, this._tempVector);
  24079. pb.subtractToRef(point, this._tempVector2);
  24080. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  24081. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24082. if (d < 0) {
  24083. return false;
  24084. }
  24085. pc.subtractToRef(point, this._tempVector3);
  24086. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  24087. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24088. if (d < 0) {
  24089. return false;
  24090. }
  24091. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  24092. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24093. return d >= 0;
  24094. };
  24095. /** @hidden */
  24096. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  24097. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  24098. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  24099. if (distance > this._velocityWorldLength + max + sphereRadius) {
  24100. return false;
  24101. }
  24102. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  24103. return false;
  24104. }
  24105. return true;
  24106. };
  24107. /** @hidden */
  24108. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  24109. var t0;
  24110. var embeddedInPlane = false;
  24111. //defensive programming, actually not needed.
  24112. if (!trianglePlaneArray) {
  24113. trianglePlaneArray = [];
  24114. }
  24115. if (!trianglePlaneArray[faceIndex]) {
  24116. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  24117. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  24118. }
  24119. var trianglePlane = trianglePlaneArray[faceIndex];
  24120. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  24121. return;
  24122. }
  24123. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  24124. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  24125. if (normalDotVelocity == 0) {
  24126. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  24127. return;
  24128. }
  24129. embeddedInPlane = true;
  24130. t0 = 0;
  24131. }
  24132. else {
  24133. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  24134. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  24135. if (t0 > t1) {
  24136. var temp = t1;
  24137. t1 = t0;
  24138. t0 = temp;
  24139. }
  24140. if (t0 > 1.0 || t1 < 0.0) {
  24141. return;
  24142. }
  24143. if (t0 < 0) {
  24144. t0 = 0;
  24145. }
  24146. if (t0 > 1.0) {
  24147. t0 = 1.0;
  24148. }
  24149. }
  24150. this._collisionPoint.copyFromFloats(0, 0, 0);
  24151. var found = false;
  24152. var t = 1.0;
  24153. if (!embeddedInPlane) {
  24154. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  24155. this._velocity.scaleToRef(t0, this._tempVector);
  24156. this._planeIntersectionPoint.addInPlace(this._tempVector);
  24157. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  24158. found = true;
  24159. t = t0;
  24160. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  24161. }
  24162. }
  24163. if (!found) {
  24164. var velocitySquaredLength = this._velocity.lengthSquared();
  24165. var a = velocitySquaredLength;
  24166. this._basePoint.subtractToRef(p1, this._tempVector);
  24167. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24168. var c = this._tempVector.lengthSquared() - 1.0;
  24169. var lowestRoot = getLowestRoot(a, b, c, t);
  24170. if (lowestRoot.found) {
  24171. t = lowestRoot.root;
  24172. found = true;
  24173. this._collisionPoint.copyFrom(p1);
  24174. }
  24175. this._basePoint.subtractToRef(p2, this._tempVector);
  24176. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24177. c = this._tempVector.lengthSquared() - 1.0;
  24178. lowestRoot = getLowestRoot(a, b, c, t);
  24179. if (lowestRoot.found) {
  24180. t = lowestRoot.root;
  24181. found = true;
  24182. this._collisionPoint.copyFrom(p2);
  24183. }
  24184. this._basePoint.subtractToRef(p3, this._tempVector);
  24185. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24186. c = this._tempVector.lengthSquared() - 1.0;
  24187. lowestRoot = getLowestRoot(a, b, c, t);
  24188. if (lowestRoot.found) {
  24189. t = lowestRoot.root;
  24190. found = true;
  24191. this._collisionPoint.copyFrom(p3);
  24192. }
  24193. p2.subtractToRef(p1, this._edge);
  24194. p1.subtractToRef(this._basePoint, this._baseToVertex);
  24195. var edgeSquaredLength = this._edge.lengthSquared();
  24196. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24197. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24198. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24199. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24200. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24201. lowestRoot = getLowestRoot(a, b, c, t);
  24202. if (lowestRoot.found) {
  24203. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24204. if (f >= 0.0 && f <= 1.0) {
  24205. t = lowestRoot.root;
  24206. found = true;
  24207. this._edge.scaleInPlace(f);
  24208. p1.addToRef(this._edge, this._collisionPoint);
  24209. }
  24210. }
  24211. p3.subtractToRef(p2, this._edge);
  24212. p2.subtractToRef(this._basePoint, this._baseToVertex);
  24213. edgeSquaredLength = this._edge.lengthSquared();
  24214. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24215. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24216. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24217. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24218. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24219. lowestRoot = getLowestRoot(a, b, c, t);
  24220. if (lowestRoot.found) {
  24221. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24222. if (f >= 0.0 && f <= 1.0) {
  24223. t = lowestRoot.root;
  24224. found = true;
  24225. this._edge.scaleInPlace(f);
  24226. p2.addToRef(this._edge, this._collisionPoint);
  24227. }
  24228. }
  24229. p1.subtractToRef(p3, this._edge);
  24230. p3.subtractToRef(this._basePoint, this._baseToVertex);
  24231. edgeSquaredLength = this._edge.lengthSquared();
  24232. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24233. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24234. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24235. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24236. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24237. lowestRoot = getLowestRoot(a, b, c, t);
  24238. if (lowestRoot.found) {
  24239. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24240. if (f >= 0.0 && f <= 1.0) {
  24241. t = lowestRoot.root;
  24242. found = true;
  24243. this._edge.scaleInPlace(f);
  24244. p3.addToRef(this._edge, this._collisionPoint);
  24245. }
  24246. }
  24247. }
  24248. if (found) {
  24249. var distToCollision = t * this._velocity.length();
  24250. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  24251. if (!this.intersectionPoint) {
  24252. this.intersectionPoint = this._collisionPoint.clone();
  24253. }
  24254. else {
  24255. this.intersectionPoint.copyFrom(this._collisionPoint);
  24256. }
  24257. this._nearestDistance = distToCollision;
  24258. this.collisionFound = true;
  24259. }
  24260. }
  24261. };
  24262. /** @hidden */
  24263. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  24264. for (var i = indexStart; i < indexEnd; i += 3) {
  24265. var p1 = pts[indices[i] - decal];
  24266. var p2 = pts[indices[i + 1] - decal];
  24267. var p3 = pts[indices[i + 2] - decal];
  24268. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  24269. }
  24270. };
  24271. /** @hidden */
  24272. Collider.prototype._getResponse = function (pos, vel) {
  24273. pos.addToRef(vel, this._destinationPoint);
  24274. vel.scaleInPlace((this._nearestDistance / vel.length()));
  24275. this._basePoint.addToRef(vel, pos);
  24276. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  24277. this._slidePlaneNormal.normalize();
  24278. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  24279. pos.addInPlace(this._displacementVector);
  24280. this.intersectionPoint.addInPlace(this._displacementVector);
  24281. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  24282. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  24283. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  24284. };
  24285. return Collider;
  24286. }());
  24287. /***/ }),
  24288. /***/ "./Collisions/collisionCoordinator.ts":
  24289. /*!********************************************!*\
  24290. !*** ./Collisions/collisionCoordinator.ts ***!
  24291. \********************************************/
  24292. /*! exports provided: DefaultCollisionCoordinator */
  24293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24294. "use strict";
  24295. __webpack_require__.r(__webpack_exports__);
  24296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return DefaultCollisionCoordinator; });
  24297. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  24298. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24299. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  24300. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24301. /** @hidden */
  24302. var DefaultCollisionCoordinator = /** @class */ (function () {
  24303. function DefaultCollisionCoordinator() {
  24304. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24305. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24306. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24307. }
  24308. DefaultCollisionCoordinator.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  24309. position.divideToRef(collider._radius, this._scaledPosition);
  24310. displacement.divideToRef(collider._radius, this._scaledVelocity);
  24311. collider.collidedMesh = null;
  24312. collider._retry = 0;
  24313. collider._initialVelocity = this._scaledVelocity;
  24314. collider._initialPosition = this._scaledPosition;
  24315. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  24316. this._finalPosition.multiplyInPlace(collider._radius);
  24317. //run the callback
  24318. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  24319. };
  24320. DefaultCollisionCoordinator.prototype.createCollider = function () {
  24321. return new _collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  24322. };
  24323. DefaultCollisionCoordinator.prototype.init = function (scene) {
  24324. this._scene = scene;
  24325. };
  24326. DefaultCollisionCoordinator.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  24327. if (excludedMesh === void 0) { excludedMesh = null; }
  24328. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].CollisionsEpsilon * 10.0;
  24329. if (collider._retry >= maximumRetry) {
  24330. finalPosition.copyFrom(position);
  24331. return;
  24332. }
  24333. // Check if this is a mesh else camera or -1
  24334. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  24335. collider._initialize(position, velocity, closeDistance);
  24336. // Check all meshes
  24337. for (var index = 0; index < this._scene.meshes.length; index++) {
  24338. var mesh = this._scene.meshes[index];
  24339. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  24340. mesh._checkCollision(collider);
  24341. }
  24342. }
  24343. if (!collider.collisionFound) {
  24344. position.addToRef(velocity, finalPosition);
  24345. return;
  24346. }
  24347. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  24348. collider._getResponse(position, velocity);
  24349. }
  24350. if (velocity.length() <= closeDistance) {
  24351. finalPosition.copyFrom(position);
  24352. return;
  24353. }
  24354. collider._retry++;
  24355. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  24356. };
  24357. return DefaultCollisionCoordinator;
  24358. }());
  24359. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].CollisionCoordinatorFactory = function () {
  24360. return new DefaultCollisionCoordinator();
  24361. };
  24362. /***/ }),
  24363. /***/ "./Collisions/index.ts":
  24364. /*!*****************************!*\
  24365. !*** ./Collisions/index.ts ***!
  24366. \*****************************/
  24367. /*! exports provided: Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo */
  24368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24369. "use strict";
  24370. __webpack_require__.r(__webpack_exports__);
  24371. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  24373. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  24374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["DefaultCollisionCoordinator"]; });
  24375. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  24376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  24377. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  24378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  24379. /***/ }),
  24380. /***/ "./Collisions/intersectionInfo.ts":
  24381. /*!****************************************!*\
  24382. !*** ./Collisions/intersectionInfo.ts ***!
  24383. \****************************************/
  24384. /*! exports provided: IntersectionInfo */
  24385. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24386. "use strict";
  24387. __webpack_require__.r(__webpack_exports__);
  24388. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  24389. /**
  24390. * @hidden
  24391. */
  24392. var IntersectionInfo = /** @class */ (function () {
  24393. function IntersectionInfo(bu, bv, distance) {
  24394. this.bu = bu;
  24395. this.bv = bv;
  24396. this.distance = distance;
  24397. this.faceId = 0;
  24398. this.subMeshId = 0;
  24399. }
  24400. return IntersectionInfo;
  24401. }());
  24402. /***/ }),
  24403. /***/ "./Collisions/pickingInfo.ts":
  24404. /*!***********************************!*\
  24405. !*** ./Collisions/pickingInfo.ts ***!
  24406. \***********************************/
  24407. /*! exports provided: PickingInfo */
  24408. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24409. "use strict";
  24410. __webpack_require__.r(__webpack_exports__);
  24411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  24412. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24413. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  24414. /**
  24415. * Information about the result of picking within a scene
  24416. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24417. */
  24418. var PickingInfo = /** @class */ (function () {
  24419. function PickingInfo() {
  24420. /** @hidden */
  24421. this._pickingUnavailable = false;
  24422. /**
  24423. * If the pick collided with an object
  24424. */
  24425. this.hit = false;
  24426. /**
  24427. * Distance away where the pick collided
  24428. */
  24429. this.distance = 0;
  24430. /**
  24431. * The location of pick collision
  24432. */
  24433. this.pickedPoint = null;
  24434. /**
  24435. * The mesh corresponding the the pick collision
  24436. */
  24437. this.pickedMesh = null;
  24438. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  24439. this.bu = 0;
  24440. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  24441. this.bv = 0;
  24442. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24443. this.faceId = -1;
  24444. /** Id of the the submesh that was picked */
  24445. this.subMeshId = 0;
  24446. /** If a sprite was picked, this will be the sprite the pick collided with */
  24447. this.pickedSprite = null;
  24448. /**
  24449. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24450. */
  24451. this.originMesh = null;
  24452. /**
  24453. * The ray that was used to perform the picking.
  24454. */
  24455. this.ray = null;
  24456. }
  24457. /**
  24458. * Gets the normal correspodning to the face the pick collided with
  24459. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24460. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24461. * @returns The normal correspodning to the face the pick collided with
  24462. */
  24463. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  24464. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  24465. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  24466. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  24467. return null;
  24468. }
  24469. var indices = this.pickedMesh.getIndices();
  24470. if (!indices) {
  24471. return null;
  24472. }
  24473. var result;
  24474. if (useVerticesNormals) {
  24475. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  24476. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  24477. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  24478. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  24479. normal0 = normal0.scale(this.bu);
  24480. normal1 = normal1.scale(this.bv);
  24481. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  24482. result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal0.x + normal1.x + normal2.x, normal0.y + normal1.y + normal2.y, normal0.z + normal1.z + normal2.z);
  24483. }
  24484. else {
  24485. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  24486. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  24487. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  24488. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  24489. var p1p2 = vertex1.subtract(vertex2);
  24490. var p3p2 = vertex3.subtract(vertex2);
  24491. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  24492. }
  24493. if (useWorldCoordinates) {
  24494. var wm = this.pickedMesh.getWorldMatrix();
  24495. if (this.pickedMesh.nonUniformScaling) {
  24496. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  24497. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  24498. wm.setTranslationFromFloats(0, 0, 0);
  24499. wm.invert();
  24500. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  24501. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  24502. }
  24503. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  24504. }
  24505. result.normalize();
  24506. return result;
  24507. };
  24508. /**
  24509. * Gets the texture coordinates of where the pick occured
  24510. * @returns the vector containing the coordnates of the texture
  24511. */
  24512. PickingInfo.prototype.getTextureCoordinates = function () {
  24513. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  24514. return null;
  24515. }
  24516. var indices = this.pickedMesh.getIndices();
  24517. if (!indices) {
  24518. return null;
  24519. }
  24520. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  24521. if (!uvs) {
  24522. return null;
  24523. }
  24524. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  24525. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  24526. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  24527. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  24528. uv1 = uv1.scale(this.bu);
  24529. uv2 = uv2.scale(this.bv);
  24530. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  24531. };
  24532. return PickingInfo;
  24533. }());
  24534. /***/ }),
  24535. /***/ "./Culling/Octrees/index.ts":
  24536. /*!**********************************!*\
  24537. !*** ./Culling/Octrees/index.ts ***!
  24538. \**********************************/
  24539. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  24540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24541. "use strict";
  24542. __webpack_require__.r(__webpack_exports__);
  24543. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  24545. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  24547. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  24548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  24549. /***/ }),
  24550. /***/ "./Culling/Octrees/octree.ts":
  24551. /*!***********************************!*\
  24552. !*** ./Culling/Octrees/octree.ts ***!
  24553. \***********************************/
  24554. /*! exports provided: Octree */
  24555. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24556. "use strict";
  24557. __webpack_require__.r(__webpack_exports__);
  24558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  24559. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  24560. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24561. /**
  24562. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  24563. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24564. */
  24565. var Octree = /** @class */ (function () {
  24566. /**
  24567. * Creates a octree
  24568. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24569. * @param creationFunc function to be used to instatiate the octree
  24570. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  24571. * @param maxDepth defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)
  24572. */
  24573. function Octree(creationFunc, maxBlockCapacity,
  24574. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  24575. maxDepth) {
  24576. if (maxDepth === void 0) { maxDepth = 2; }
  24577. this.maxDepth = maxDepth;
  24578. /**
  24579. * Content stored in the octree
  24580. */
  24581. this.dynamicContent = new Array();
  24582. this._maxBlockCapacity = maxBlockCapacity || 64;
  24583. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  24584. this._creationFunc = creationFunc;
  24585. }
  24586. // Methods
  24587. /**
  24588. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  24589. * @param worldMin worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  24590. * @param worldMax worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  24591. * @param entries meshes to be added to the octree blocks
  24592. */
  24593. Octree.prototype.update = function (worldMin, worldMax, entries) {
  24594. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  24595. };
  24596. /**
  24597. * Adds a mesh to the octree
  24598. * @param entry Mesh to add to the octree
  24599. */
  24600. Octree.prototype.addMesh = function (entry) {
  24601. for (var index = 0; index < this.blocks.length; index++) {
  24602. var block = this.blocks[index];
  24603. block.addEntry(entry);
  24604. }
  24605. };
  24606. /**
  24607. * Remove an element from the octree
  24608. * @param entry defines the element to remove
  24609. */
  24610. Octree.prototype.removeMesh = function (entry) {
  24611. for (var index = 0; index < this.blocks.length; index++) {
  24612. var block = this.blocks[index];
  24613. block.removeEntry(entry);
  24614. }
  24615. };
  24616. /**
  24617. * Selects an array of meshes within the frustum
  24618. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  24619. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  24620. * @returns array of meshes within the frustum
  24621. */
  24622. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  24623. this._selectionContent.reset();
  24624. for (var index = 0; index < this.blocks.length; index++) {
  24625. var block = this.blocks[index];
  24626. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  24627. }
  24628. if (allowDuplicate) {
  24629. this._selectionContent.concat(this.dynamicContent);
  24630. }
  24631. else {
  24632. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24633. }
  24634. return this._selectionContent;
  24635. };
  24636. /**
  24637. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  24638. * @param sphereCenter defines the bounding sphere center
  24639. * @param sphereRadius defines the bounding sphere radius
  24640. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24641. * @returns an array of objects that intersect the sphere
  24642. */
  24643. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  24644. this._selectionContent.reset();
  24645. for (var index = 0; index < this.blocks.length; index++) {
  24646. var block = this.blocks[index];
  24647. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  24648. }
  24649. if (allowDuplicate) {
  24650. this._selectionContent.concat(this.dynamicContent);
  24651. }
  24652. else {
  24653. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24654. }
  24655. return this._selectionContent;
  24656. };
  24657. /**
  24658. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  24659. * @param ray defines the ray to test with
  24660. * @returns array of intersected objects
  24661. */
  24662. Octree.prototype.intersectsRay = function (ray) {
  24663. this._selectionContent.reset();
  24664. for (var index = 0; index < this.blocks.length; index++) {
  24665. var block = this.blocks[index];
  24666. block.intersectsRay(ray, this._selectionContent);
  24667. }
  24668. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24669. return this._selectionContent;
  24670. };
  24671. /**
  24672. * Adds a mesh into the octree block if it intersects the block
  24673. */
  24674. Octree.CreationFuncForMeshes = function (entry, block) {
  24675. var boundingInfo = entry.getBoundingInfo();
  24676. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24677. block.entries.push(entry);
  24678. }
  24679. };
  24680. /**
  24681. * Adds a submesh into the octree block if it intersects the block
  24682. */
  24683. Octree.CreationFuncForSubMeshes = function (entry, block) {
  24684. var boundingInfo = entry.getBoundingInfo();
  24685. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24686. block.entries.push(entry);
  24687. }
  24688. };
  24689. return Octree;
  24690. }());
  24691. /***/ }),
  24692. /***/ "./Culling/Octrees/octreeBlock.ts":
  24693. /*!****************************************!*\
  24694. !*** ./Culling/Octrees/octreeBlock.ts ***!
  24695. \****************************************/
  24696. /*! exports provided: OctreeBlock */
  24697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24698. "use strict";
  24699. __webpack_require__.r(__webpack_exports__);
  24700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  24701. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24702. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  24703. /**
  24704. * Class used to store a cell in an octree
  24705. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24706. */
  24707. var OctreeBlock = /** @class */ (function () {
  24708. /**
  24709. * Creates a new block
  24710. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  24711. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  24712. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24713. * @param depth defines the current depth of this block in the octree
  24714. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  24715. * @param creationFunc defines a callback to call when an element is added to the block
  24716. */
  24717. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  24718. /**
  24719. * Gets the content of the current block
  24720. */
  24721. this.entries = new Array();
  24722. this._boundingVectors = new Array();
  24723. this._capacity = capacity;
  24724. this._depth = depth;
  24725. this._maxDepth = maxDepth;
  24726. this._creationFunc = creationFunc;
  24727. this._minPoint = minPoint;
  24728. this._maxPoint = maxPoint;
  24729. this._boundingVectors.push(minPoint.clone());
  24730. this._boundingVectors.push(maxPoint.clone());
  24731. this._boundingVectors.push(minPoint.clone());
  24732. this._boundingVectors[2].x = maxPoint.x;
  24733. this._boundingVectors.push(minPoint.clone());
  24734. this._boundingVectors[3].y = maxPoint.y;
  24735. this._boundingVectors.push(minPoint.clone());
  24736. this._boundingVectors[4].z = maxPoint.z;
  24737. this._boundingVectors.push(maxPoint.clone());
  24738. this._boundingVectors[5].z = minPoint.z;
  24739. this._boundingVectors.push(maxPoint.clone());
  24740. this._boundingVectors[6].x = minPoint.x;
  24741. this._boundingVectors.push(maxPoint.clone());
  24742. this._boundingVectors[7].y = minPoint.y;
  24743. }
  24744. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  24745. // Property
  24746. /**
  24747. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24748. */
  24749. get: function () {
  24750. return this._capacity;
  24751. },
  24752. enumerable: true,
  24753. configurable: true
  24754. });
  24755. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  24756. /**
  24757. * Gets the minimum vector (in world space) of the block's bounding box
  24758. */
  24759. get: function () {
  24760. return this._minPoint;
  24761. },
  24762. enumerable: true,
  24763. configurable: true
  24764. });
  24765. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  24766. /**
  24767. * Gets the maximum vector (in world space) of the block's bounding box
  24768. */
  24769. get: function () {
  24770. return this._maxPoint;
  24771. },
  24772. enumerable: true,
  24773. configurable: true
  24774. });
  24775. // Methods
  24776. /**
  24777. * Add a new element to this block
  24778. * @param entry defines the element to add
  24779. */
  24780. OctreeBlock.prototype.addEntry = function (entry) {
  24781. if (this.blocks) {
  24782. for (var index = 0; index < this.blocks.length; index++) {
  24783. var block = this.blocks[index];
  24784. block.addEntry(entry);
  24785. }
  24786. return;
  24787. }
  24788. this._creationFunc(entry, this);
  24789. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  24790. this.createInnerBlocks();
  24791. }
  24792. };
  24793. /**
  24794. * Remove an element from this block
  24795. * @param entry defines the element to remove
  24796. */
  24797. OctreeBlock.prototype.removeEntry = function (entry) {
  24798. if (this.blocks) {
  24799. for (var index = 0; index < this.blocks.length; index++) {
  24800. var block = this.blocks[index];
  24801. block.removeEntry(entry);
  24802. }
  24803. return;
  24804. }
  24805. var entryIndex = this.entries.indexOf(entry);
  24806. if (entryIndex > -1) {
  24807. this.entries.splice(entryIndex, 1);
  24808. }
  24809. };
  24810. /**
  24811. * Add an array of elements to this block
  24812. * @param entries defines the array of elements to add
  24813. */
  24814. OctreeBlock.prototype.addEntries = function (entries) {
  24815. for (var index = 0; index < entries.length; index++) {
  24816. var mesh = entries[index];
  24817. this.addEntry(mesh);
  24818. }
  24819. };
  24820. /**
  24821. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  24822. * @param frustumPlanes defines the frustum planes to test
  24823. * @param selection defines the array to store current content if selection is positive
  24824. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24825. */
  24826. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  24827. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  24828. if (this.blocks) {
  24829. for (var index = 0; index < this.blocks.length; index++) {
  24830. var block = this.blocks[index];
  24831. block.select(frustumPlanes, selection, allowDuplicate);
  24832. }
  24833. return;
  24834. }
  24835. if (allowDuplicate) {
  24836. selection.concat(this.entries);
  24837. }
  24838. else {
  24839. selection.concatWithNoDuplicate(this.entries);
  24840. }
  24841. }
  24842. };
  24843. /**
  24844. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  24845. * @param sphereCenter defines the bounding sphere center
  24846. * @param sphereRadius defines the bounding sphere radius
  24847. * @param selection defines the array to store current content if selection is positive
  24848. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24849. */
  24850. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  24851. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  24852. if (this.blocks) {
  24853. for (var index = 0; index < this.blocks.length; index++) {
  24854. var block = this.blocks[index];
  24855. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  24856. }
  24857. return;
  24858. }
  24859. if (allowDuplicate) {
  24860. selection.concat(this.entries);
  24861. }
  24862. else {
  24863. selection.concatWithNoDuplicate(this.entries);
  24864. }
  24865. }
  24866. };
  24867. /**
  24868. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  24869. * @param ray defines the ray to test with
  24870. * @param selection defines the array to store current content if selection is positive
  24871. */
  24872. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  24873. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  24874. if (this.blocks) {
  24875. for (var index = 0; index < this.blocks.length; index++) {
  24876. var block = this.blocks[index];
  24877. block.intersectsRay(ray, selection);
  24878. }
  24879. return;
  24880. }
  24881. selection.concatWithNoDuplicate(this.entries);
  24882. }
  24883. };
  24884. /**
  24885. * Subdivide the content into child blocks (this block will then be empty)
  24886. */
  24887. OctreeBlock.prototype.createInnerBlocks = function () {
  24888. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  24889. };
  24890. /**
  24891. * @hidden
  24892. */
  24893. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  24894. target.blocks = new Array();
  24895. var blockSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  24896. // Segmenting space
  24897. for (var x = 0; x < 2; x++) {
  24898. for (var y = 0; y < 2; y++) {
  24899. for (var z = 0; z < 2; z++) {
  24900. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  24901. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  24902. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  24903. block.addEntries(entries);
  24904. target.blocks.push(block);
  24905. }
  24906. }
  24907. }
  24908. };
  24909. return OctreeBlock;
  24910. }());
  24911. /***/ }),
  24912. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  24913. /*!*************************************************!*\
  24914. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  24915. \*************************************************/
  24916. /*! exports provided: OctreeSceneComponent */
  24917. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24918. "use strict";
  24919. __webpack_require__.r(__webpack_exports__);
  24920. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  24921. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  24922. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24923. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  24924. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  24925. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  24926. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24927. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  24928. if (maxCapacity === void 0) { maxCapacity = 64; }
  24929. if (maxDepth === void 0) { maxDepth = 2; }
  24930. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24931. if (!component) {
  24932. component = new OctreeSceneComponent(this);
  24933. this._addComponent(component);
  24934. }
  24935. if (!this._selectionOctree) {
  24936. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  24937. }
  24938. var worldExtends = this.getWorldExtends();
  24939. // Update octree
  24940. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  24941. return this._selectionOctree;
  24942. };
  24943. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  24944. get: function () {
  24945. return this._selectionOctree;
  24946. },
  24947. enumerable: true,
  24948. configurable: true
  24949. });
  24950. /**
  24951. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  24952. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24953. * @param maxCapacity defines the maximum size of each block (64 by default)
  24954. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  24955. * @returns the new octree
  24956. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  24957. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24958. */
  24959. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  24960. if (maxCapacity === void 0) { maxCapacity = 64; }
  24961. if (maxDepth === void 0) { maxDepth = 2; }
  24962. var scene = this.getScene();
  24963. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24964. if (!component) {
  24965. component = new OctreeSceneComponent(scene);
  24966. scene._addComponent(component);
  24967. }
  24968. if (!this._submeshesOctree) {
  24969. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  24970. }
  24971. this.computeWorldMatrix(true);
  24972. var boundingInfo = this.getBoundingInfo();
  24973. // Update octree
  24974. var bbox = boundingInfo.boundingBox;
  24975. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  24976. return this._submeshesOctree;
  24977. };
  24978. /**
  24979. * Defines the octree scene component responsible to manage any octrees
  24980. * in a given scene.
  24981. */
  24982. var OctreeSceneComponent = /** @class */ (function () {
  24983. /**
  24984. * Creates a new instance of the component for the given scene
  24985. * @param scene Defines the scene to register the component in
  24986. */
  24987. function OctreeSceneComponent(scene) {
  24988. /**
  24989. * The component name helpfull to identify the component in the list of scene components.
  24990. */
  24991. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  24992. /**
  24993. * Indicates if the meshes have been checked to make sure they are isEnabled()
  24994. */
  24995. this.checksIsEnabled = true;
  24996. this._tempRay = new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](1, 1, 1));
  24997. this.scene = scene;
  24998. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  24999. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  25000. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  25001. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  25002. }
  25003. /**
  25004. * Registers the component in a given scene
  25005. */
  25006. OctreeSceneComponent.prototype.register = function () {
  25007. var _this = this;
  25008. this.scene.onMeshRemovedObservable.add(function (mesh) {
  25009. var sceneOctree = _this.scene.selectionOctree;
  25010. if (sceneOctree !== undefined && sceneOctree !== null) {
  25011. var index = sceneOctree.dynamicContent.indexOf(mesh);
  25012. if (index !== -1) {
  25013. sceneOctree.dynamicContent.splice(index, 1);
  25014. }
  25015. }
  25016. });
  25017. this.scene.onMeshImportedObservable.add(function (mesh) {
  25018. var sceneOctree = _this.scene.selectionOctree;
  25019. if (sceneOctree !== undefined && sceneOctree !== null) {
  25020. sceneOctree.addMesh(mesh);
  25021. }
  25022. });
  25023. };
  25024. /**
  25025. * Return the list of active meshes
  25026. * @returns the list of active meshes
  25027. */
  25028. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  25029. if (this.scene._selectionOctree) {
  25030. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  25031. return selection;
  25032. }
  25033. return this.scene._getDefaultMeshCandidates();
  25034. };
  25035. /**
  25036. * Return the list of active sub meshes
  25037. * @param mesh The mesh to get the candidates sub meshes from
  25038. * @returns the list of active sub meshes
  25039. */
  25040. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  25041. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  25042. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  25043. return intersections;
  25044. }
  25045. return this.scene._getDefaultSubMeshCandidates(mesh);
  25046. };
  25047. /**
  25048. * Return the list of sub meshes intersecting with a given local ray
  25049. * @param mesh defines the mesh to find the submesh for
  25050. * @param localRay defines the ray in local space
  25051. * @returns the list of intersecting sub meshes
  25052. */
  25053. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  25054. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  25055. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  25056. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  25057. return intersections;
  25058. }
  25059. return this.scene._getDefaultSubMeshCandidates(mesh);
  25060. };
  25061. /**
  25062. * Return the list of sub meshes colliding with a collider
  25063. * @param mesh defines the mesh to find the submesh for
  25064. * @param collider defines the collider to evaluate the collision against
  25065. * @returns the list of colliding sub meshes
  25066. */
  25067. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  25068. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  25069. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  25070. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  25071. return intersections;
  25072. }
  25073. return this.scene._getDefaultSubMeshCandidates(mesh);
  25074. };
  25075. /**
  25076. * Rebuilds the elements related to this component in case of
  25077. * context lost for instance.
  25078. */
  25079. OctreeSceneComponent.prototype.rebuild = function () {
  25080. // Nothing to do here.
  25081. };
  25082. /**
  25083. * Disposes the component and the associated ressources.
  25084. */
  25085. OctreeSceneComponent.prototype.dispose = function () {
  25086. // Nothing to do here.
  25087. };
  25088. return OctreeSceneComponent;
  25089. }());
  25090. /***/ }),
  25091. /***/ "./Culling/boundingBox.ts":
  25092. /*!********************************!*\
  25093. !*** ./Culling/boundingBox.ts ***!
  25094. \********************************/
  25095. /*! exports provided: BoundingBox */
  25096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25097. "use strict";
  25098. __webpack_require__.r(__webpack_exports__);
  25099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  25100. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25101. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25102. /**
  25103. * Class used to store bounding box information
  25104. */
  25105. var BoundingBox = /** @class */ (function () {
  25106. /**
  25107. * Creates a new bounding box
  25108. * @param min defines the minimum vector (in local space)
  25109. * @param max defines the maximum vector (in local space)
  25110. * @param worldMatrix defines the new world matrix
  25111. */
  25112. function BoundingBox(min, max, worldMatrix) {
  25113. /**
  25114. * Gets the 8 vectors representing the bounding box in local space
  25115. */
  25116. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25117. /**
  25118. * Gets the center of the bounding box in local space
  25119. */
  25120. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25121. /**
  25122. * Gets the center of the bounding box in world space
  25123. */
  25124. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25125. /**
  25126. * Gets the extend size in local space
  25127. */
  25128. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25129. /**
  25130. * Gets the extend size in world space
  25131. */
  25132. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25133. /**
  25134. * Gets the OBB (object bounding box) directions
  25135. */
  25136. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25137. /**
  25138. * Gets the 8 vectors representing the bounding box in world space
  25139. */
  25140. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25141. /**
  25142. * Gets the minimum vector in world space
  25143. */
  25144. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25145. /**
  25146. * Gets the maximum vector in world space
  25147. */
  25148. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25149. /**
  25150. * Gets the minimum vector in local space
  25151. */
  25152. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25153. /**
  25154. * Gets the maximum vector in local space
  25155. */
  25156. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25157. this.reConstruct(min, max, worldMatrix);
  25158. }
  25159. // Methods
  25160. /**
  25161. * Recreates the entire bounding box from scratch as if we call the constructor in place
  25162. * @param min defines the new minimum vector (in local space)
  25163. * @param max defines the new maximum vector (in local space)
  25164. * @param worldMatrix defines the new world matrix
  25165. */
  25166. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  25167. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25168. var vectors = this.vectors;
  25169. this.minimum.copyFromFloats(minX, minY, minZ);
  25170. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  25171. vectors[0].copyFromFloats(minX, minY, minZ);
  25172. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  25173. vectors[2].copyFromFloats(maxX, minY, minZ);
  25174. vectors[3].copyFromFloats(minX, maxY, minZ);
  25175. vectors[4].copyFromFloats(minX, minY, maxZ);
  25176. vectors[5].copyFromFloats(maxX, maxY, minZ);
  25177. vectors[6].copyFromFloats(minX, maxY, maxZ);
  25178. vectors[7].copyFromFloats(maxX, minY, maxZ);
  25179. // OBB
  25180. max.addToRef(min, this.center).scaleInPlace(0.5);
  25181. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  25182. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  25183. };
  25184. /**
  25185. * Scale the current bounding box by applying a scale factor
  25186. * @param factor defines the scale factor to apply
  25187. * @returns the current bounding box
  25188. */
  25189. BoundingBox.prototype.scale = function (factor) {
  25190. var tmpVectors = BoundingBox.TmpVector3;
  25191. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  25192. var len = diff.length();
  25193. diff.normalizeFromLength(len);
  25194. var distance = len * factor;
  25195. var newRadius = diff.scaleInPlace(distance * 0.5);
  25196. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  25197. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  25198. this.reConstruct(min, max, this._worldMatrix);
  25199. return this;
  25200. };
  25201. /**
  25202. * Gets the world matrix of the bounding box
  25203. * @returns a matrix
  25204. */
  25205. BoundingBox.prototype.getWorldMatrix = function () {
  25206. return this._worldMatrix;
  25207. };
  25208. /** @hidden */
  25209. BoundingBox.prototype._update = function (world) {
  25210. var minWorld = this.minimumWorld;
  25211. var maxWorld = this.maximumWorld;
  25212. var directions = this.directions;
  25213. var vectorsWorld = this.vectorsWorld;
  25214. var vectors = this.vectors;
  25215. if (!world.isIdentity()) {
  25216. minWorld.setAll(Number.MAX_VALUE);
  25217. maxWorld.setAll(-Number.MAX_VALUE);
  25218. for (var index = 0; index < 8; ++index) {
  25219. var v = vectorsWorld[index];
  25220. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  25221. minWorld.minimizeInPlace(v);
  25222. maxWorld.maximizeInPlace(v);
  25223. }
  25224. // Extend
  25225. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  25226. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  25227. }
  25228. else {
  25229. minWorld.copyFrom(this.minimum);
  25230. maxWorld.copyFrom(this.maximum);
  25231. for (var index = 0; index < 8; ++index) {
  25232. vectorsWorld[index].copyFrom(vectors[index]);
  25233. }
  25234. // Extend
  25235. this.extendSizeWorld.copyFrom(this.extendSize);
  25236. this.centerWorld.copyFrom(this.center);
  25237. }
  25238. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  25239. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  25240. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  25241. this._worldMatrix = world;
  25242. };
  25243. /**
  25244. * Tests if the bounding box is intersecting the frustum planes
  25245. * @param frustumPlanes defines the frustum planes to test
  25246. * @returns true if there is an intersection
  25247. */
  25248. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  25249. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  25250. };
  25251. /**
  25252. * Tests if the bounding box is entirely inside the frustum planes
  25253. * @param frustumPlanes defines the frustum planes to test
  25254. * @returns true if there is an inclusion
  25255. */
  25256. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25257. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  25258. };
  25259. /**
  25260. * Tests if a point is inside the bounding box
  25261. * @param point defines the point to test
  25262. * @returns true if the point is inside the bounding box
  25263. */
  25264. BoundingBox.prototype.intersectsPoint = function (point) {
  25265. var min = this.minimumWorld;
  25266. var max = this.maximumWorld;
  25267. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25268. var pointX = point.x, pointY = point.y, pointZ = point.z;
  25269. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  25270. if (maxX - pointX < delta || delta > pointX - minX) {
  25271. return false;
  25272. }
  25273. if (maxY - pointY < delta || delta > pointY - minY) {
  25274. return false;
  25275. }
  25276. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  25277. return false;
  25278. }
  25279. return true;
  25280. };
  25281. /**
  25282. * Tests if the bounding box intersects with a bounding sphere
  25283. * @param sphere defines the sphere to test
  25284. * @returns true if there is an intersection
  25285. */
  25286. BoundingBox.prototype.intersectsSphere = function (sphere) {
  25287. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  25288. };
  25289. /**
  25290. * Tests if the bounding box intersects with a box defined by a min and max vectors
  25291. * @param min defines the min vector to use
  25292. * @param max defines the max vector to use
  25293. * @returns true if there is an intersection
  25294. */
  25295. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  25296. var myMin = this.minimumWorld;
  25297. var myMax = this.maximumWorld;
  25298. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  25299. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25300. if (myMaxX < minX || myMinX > maxX) {
  25301. return false;
  25302. }
  25303. if (myMaxY < minY || myMinY > maxY) {
  25304. return false;
  25305. }
  25306. if (myMaxZ < minZ || myMinZ > maxZ) {
  25307. return false;
  25308. }
  25309. return true;
  25310. };
  25311. // Statics
  25312. /**
  25313. * Tests if two bounding boxes are intersections
  25314. * @param box0 defines the first box to test
  25315. * @param box1 defines the second box to test
  25316. * @returns true if there is an intersection
  25317. */
  25318. BoundingBox.Intersects = function (box0, box1) {
  25319. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  25320. };
  25321. /**
  25322. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  25323. * @param minPoint defines the minimum vector of the bounding box
  25324. * @param maxPoint defines the maximum vector of the bounding box
  25325. * @param sphereCenter defines the sphere center
  25326. * @param sphereRadius defines the sphere radius
  25327. * @returns true if there is an intersection
  25328. */
  25329. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  25330. var vector = BoundingBox.TmpVector3[0];
  25331. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  25332. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  25333. return (num <= (sphereRadius * sphereRadius));
  25334. };
  25335. /**
  25336. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  25337. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25338. * @param frustumPlanes defines the frustum planes to test
  25339. * @return true if there is an inclusion
  25340. */
  25341. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  25342. for (var p = 0; p < 6; ++p) {
  25343. var frustumPlane = frustumPlanes[p];
  25344. for (var i = 0; i < 8; ++i) {
  25345. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  25346. return false;
  25347. }
  25348. }
  25349. }
  25350. return true;
  25351. };
  25352. /**
  25353. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  25354. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25355. * @param frustumPlanes defines the frustum planes to test
  25356. * @return true if there is an intersection
  25357. */
  25358. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  25359. for (var p = 0; p < 6; ++p) {
  25360. var canReturnFalse = true;
  25361. var frustumPlane = frustumPlanes[p];
  25362. for (var i = 0; i < 8; ++i) {
  25363. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  25364. canReturnFalse = false;
  25365. break;
  25366. }
  25367. }
  25368. if (canReturnFalse) {
  25369. return false;
  25370. }
  25371. }
  25372. return true;
  25373. };
  25374. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25375. return BoundingBox;
  25376. }());
  25377. /***/ }),
  25378. /***/ "./Culling/boundingInfo.ts":
  25379. /*!*********************************!*\
  25380. !*** ./Culling/boundingInfo.ts ***!
  25381. \*********************************/
  25382. /*! exports provided: BoundingInfo */
  25383. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25384. "use strict";
  25385. __webpack_require__.r(__webpack_exports__);
  25386. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  25387. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25388. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25389. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  25390. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25391. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25392. var _result0 = { min: 0, max: 0 };
  25393. var _result1 = { min: 0, max: 0 };
  25394. var computeBoxExtents = function (axis, box, result) {
  25395. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  25396. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  25397. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  25398. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  25399. var r = r0 + r1 + r2;
  25400. result.min = p - r;
  25401. result.max = p + r;
  25402. };
  25403. var axisOverlap = function (axis, box0, box1) {
  25404. computeBoxExtents(axis, box0, _result0);
  25405. computeBoxExtents(axis, box1, _result1);
  25406. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  25407. };
  25408. /**
  25409. * Info for a bounding data of a mesh
  25410. */
  25411. var BoundingInfo = /** @class */ (function () {
  25412. /**
  25413. * Constructs bounding info
  25414. * @param minimum min vector of the bounding box/sphere
  25415. * @param maximum max vector of the bounding box/sphere
  25416. * @param worldMatrix defines the new world matrix
  25417. */
  25418. function BoundingInfo(minimum, maximum, worldMatrix) {
  25419. this._isLocked = false;
  25420. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  25421. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  25422. }
  25423. /**
  25424. * Recreates the entire bounding info from scratch as if we call the constructor in place
  25425. * @param min defines the new minimum vector (in local space)
  25426. * @param max defines the new maximum vector (in local space)
  25427. * @param worldMatrix defines the new world matrix
  25428. */
  25429. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  25430. this.boundingBox.reConstruct(min, max, worldMatrix);
  25431. this.boundingSphere.reConstruct(min, max, worldMatrix);
  25432. };
  25433. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  25434. /**
  25435. * min vector of the bounding box/sphere
  25436. */
  25437. get: function () {
  25438. return this.boundingBox.minimum;
  25439. },
  25440. enumerable: true,
  25441. configurable: true
  25442. });
  25443. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  25444. /**
  25445. * max vector of the bounding box/sphere
  25446. */
  25447. get: function () {
  25448. return this.boundingBox.maximum;
  25449. },
  25450. enumerable: true,
  25451. configurable: true
  25452. });
  25453. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  25454. /**
  25455. * If the info is locked and won't be updated to avoid perf overhead
  25456. */
  25457. get: function () {
  25458. return this._isLocked;
  25459. },
  25460. set: function (value) {
  25461. this._isLocked = value;
  25462. },
  25463. enumerable: true,
  25464. configurable: true
  25465. });
  25466. // Methods
  25467. /**
  25468. * Updates the bounding sphere and box
  25469. * @param world world matrix to be used to update
  25470. */
  25471. BoundingInfo.prototype.update = function (world) {
  25472. if (this._isLocked) {
  25473. return;
  25474. }
  25475. this.boundingBox._update(world);
  25476. this.boundingSphere._update(world);
  25477. };
  25478. /**
  25479. * Recreate the bounding info to be centered around a specific point given a specific extend.
  25480. * @param center New center of the bounding info
  25481. * @param extend New extend of the bounding info
  25482. * @returns the current bounding info
  25483. */
  25484. BoundingInfo.prototype.centerOn = function (center, extend) {
  25485. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  25486. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  25487. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25488. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25489. return this;
  25490. };
  25491. /**
  25492. * Scale the current bounding info by applying a scale factor
  25493. * @param factor defines the scale factor to apply
  25494. * @returns the current bounding info
  25495. */
  25496. BoundingInfo.prototype.scale = function (factor) {
  25497. this.boundingBox.scale(factor);
  25498. this.boundingSphere.scale(factor);
  25499. return this;
  25500. };
  25501. /**
  25502. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  25503. * @param frustumPlanes defines the frustum to test
  25504. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  25505. * @returns true if the bounding info is in the frustum planes
  25506. */
  25507. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  25508. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  25509. var inclusionTest = (strategy === _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION || strategy === _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY);
  25510. if (inclusionTest) {
  25511. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  25512. return true;
  25513. }
  25514. }
  25515. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  25516. return false;
  25517. }
  25518. var bSphereOnlyTest = (strategy === _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY || strategy === _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY);
  25519. if (bSphereOnlyTest) {
  25520. return true;
  25521. }
  25522. return this.boundingBox.isInFrustum(frustumPlanes);
  25523. };
  25524. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  25525. /**
  25526. * Gets the world distance between the min and max points of the bounding box
  25527. */
  25528. get: function () {
  25529. var boundingBox = this.boundingBox;
  25530. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  25531. return diag.length();
  25532. },
  25533. enumerable: true,
  25534. configurable: true
  25535. });
  25536. /**
  25537. * Checks if a cullable object (mesh...) is in the camera frustum
  25538. * Unlike isInFrustum this cheks the full bounding box
  25539. * @param frustumPlanes Camera near/planes
  25540. * @returns true if the object is in frustum otherwise false
  25541. */
  25542. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25543. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  25544. };
  25545. /** @hidden */
  25546. BoundingInfo.prototype._checkCollision = function (collider) {
  25547. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  25548. };
  25549. /**
  25550. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  25551. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25552. * @param point the point to check intersection with
  25553. * @returns if the point intersects
  25554. */
  25555. BoundingInfo.prototype.intersectsPoint = function (point) {
  25556. if (!this.boundingSphere.centerWorld) {
  25557. return false;
  25558. }
  25559. if (!this.boundingSphere.intersectsPoint(point)) {
  25560. return false;
  25561. }
  25562. if (!this.boundingBox.intersectsPoint(point)) {
  25563. return false;
  25564. }
  25565. return true;
  25566. };
  25567. /**
  25568. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  25569. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25570. * @param boundingInfo the bounding info to check intersection with
  25571. * @param precise if the intersection should be done using OBB
  25572. * @returns if the bounding info intersects
  25573. */
  25574. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  25575. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  25576. return false;
  25577. }
  25578. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  25579. return false;
  25580. }
  25581. if (!precise) {
  25582. return true;
  25583. }
  25584. var box0 = this.boundingBox;
  25585. var box1 = boundingInfo.boundingBox;
  25586. if (!axisOverlap(box0.directions[0], box0, box1)) {
  25587. return false;
  25588. }
  25589. if (!axisOverlap(box0.directions[1], box0, box1)) {
  25590. return false;
  25591. }
  25592. if (!axisOverlap(box0.directions[2], box0, box1)) {
  25593. return false;
  25594. }
  25595. if (!axisOverlap(box1.directions[0], box0, box1)) {
  25596. return false;
  25597. }
  25598. if (!axisOverlap(box1.directions[1], box0, box1)) {
  25599. return false;
  25600. }
  25601. if (!axisOverlap(box1.directions[2], box0, box1)) {
  25602. return false;
  25603. }
  25604. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  25605. return false;
  25606. }
  25607. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  25608. return false;
  25609. }
  25610. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  25611. return false;
  25612. }
  25613. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  25614. return false;
  25615. }
  25616. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  25617. return false;
  25618. }
  25619. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  25620. return false;
  25621. }
  25622. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  25623. return false;
  25624. }
  25625. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  25626. return false;
  25627. }
  25628. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  25629. return false;
  25630. }
  25631. return true;
  25632. };
  25633. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25634. return BoundingInfo;
  25635. }());
  25636. /***/ }),
  25637. /***/ "./Culling/boundingSphere.ts":
  25638. /*!***********************************!*\
  25639. !*** ./Culling/boundingSphere.ts ***!
  25640. \***********************************/
  25641. /*! exports provided: BoundingSphere */
  25642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25643. "use strict";
  25644. __webpack_require__.r(__webpack_exports__);
  25645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  25646. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25647. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25648. /**
  25649. * Class used to store bounding sphere information
  25650. */
  25651. var BoundingSphere = /** @class */ (function () {
  25652. /**
  25653. * Creates a new bounding sphere
  25654. * @param min defines the minimum vector (in local space)
  25655. * @param max defines the maximum vector (in local space)
  25656. * @param worldMatrix defines the new world matrix
  25657. */
  25658. function BoundingSphere(min, max, worldMatrix) {
  25659. /**
  25660. * Gets the center of the bounding sphere in local space
  25661. */
  25662. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25663. /**
  25664. * Gets the center of the bounding sphere in world space
  25665. */
  25666. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25667. /**
  25668. * Gets the minimum vector in local space
  25669. */
  25670. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25671. /**
  25672. * Gets the maximum vector in local space
  25673. */
  25674. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25675. this.reConstruct(min, max, worldMatrix);
  25676. }
  25677. /**
  25678. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  25679. * @param min defines the new minimum vector (in local space)
  25680. * @param max defines the new maximum vector (in local space)
  25681. * @param worldMatrix defines the new world matrix
  25682. */
  25683. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  25684. this.minimum.copyFrom(min);
  25685. this.maximum.copyFrom(max);
  25686. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  25687. max.addToRef(min, this.center).scaleInPlace(0.5);
  25688. this.radius = distance * 0.5;
  25689. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  25690. };
  25691. /**
  25692. * Scale the current bounding sphere by applying a scale factor
  25693. * @param factor defines the scale factor to apply
  25694. * @returns the current bounding box
  25695. */
  25696. BoundingSphere.prototype.scale = function (factor) {
  25697. var newRadius = this.radius * factor;
  25698. var tmpVectors = BoundingSphere.TmpVector3;
  25699. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  25700. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  25701. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  25702. this.reConstruct(min, max, this._worldMatrix);
  25703. return this;
  25704. };
  25705. /**
  25706. * Gets the world matrix of the bounding box
  25707. * @returns a matrix
  25708. */
  25709. BoundingSphere.prototype.getWorldMatrix = function () {
  25710. return this._worldMatrix;
  25711. };
  25712. // Methods
  25713. /** @hidden */
  25714. BoundingSphere.prototype._update = function (worldMatrix) {
  25715. if (!worldMatrix.isIdentity()) {
  25716. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  25717. var tempVector = BoundingSphere.TmpVector3[0];
  25718. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  25719. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  25720. }
  25721. else {
  25722. this.centerWorld.copyFrom(this.center);
  25723. this.radiusWorld = this.radius;
  25724. }
  25725. };
  25726. /**
  25727. * Tests if the bounding sphere is intersecting the frustum planes
  25728. * @param frustumPlanes defines the frustum planes to test
  25729. * @returns true if there is an intersection
  25730. */
  25731. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  25732. var center = this.centerWorld;
  25733. var radius = this.radiusWorld;
  25734. for (var i = 0; i < 6; i++) {
  25735. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  25736. return false;
  25737. }
  25738. }
  25739. return true;
  25740. };
  25741. /**
  25742. * Tests if the bounding sphere center is in between the frustum planes.
  25743. * Used for optimistic fast inclusion.
  25744. * @param frustumPlanes defines the frustum planes to test
  25745. * @returns true if the sphere center is in between the frustum planes
  25746. */
  25747. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  25748. var center = this.centerWorld;
  25749. for (var i = 0; i < 6; i++) {
  25750. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  25751. return false;
  25752. }
  25753. }
  25754. return true;
  25755. };
  25756. /**
  25757. * Tests if a point is inside the bounding sphere
  25758. * @param point defines the point to test
  25759. * @returns true if the point is inside the bounding sphere
  25760. */
  25761. BoundingSphere.prototype.intersectsPoint = function (point) {
  25762. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  25763. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  25764. return false;
  25765. }
  25766. return true;
  25767. };
  25768. // Statics
  25769. /**
  25770. * Checks if two sphere intersct
  25771. * @param sphere0 sphere 0
  25772. * @param sphere1 sphere 1
  25773. * @returns true if the speres intersect
  25774. */
  25775. BoundingSphere.Intersects = function (sphere0, sphere1) {
  25776. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  25777. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  25778. if (radiusSum * radiusSum < squareDistance) {
  25779. return false;
  25780. }
  25781. return true;
  25782. };
  25783. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25784. return BoundingSphere;
  25785. }());
  25786. /***/ }),
  25787. /***/ "./Culling/index.ts":
  25788. /*!**************************!*\
  25789. !*** ./Culling/index.ts ***!
  25790. \**************************/
  25791. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  25792. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25793. "use strict";
  25794. __webpack_require__.r(__webpack_exports__);
  25795. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  25797. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  25798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  25799. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  25801. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  25802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  25803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  25804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  25805. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  25806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  25807. /***/ }),
  25808. /***/ "./Culling/ray.ts":
  25809. /*!************************!*\
  25810. !*** ./Culling/ray.ts ***!
  25811. \************************/
  25812. /*! exports provided: Ray */
  25813. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25814. "use strict";
  25815. __webpack_require__.r(__webpack_exports__);
  25816. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  25817. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25818. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25819. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  25820. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  25821. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25822. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  25823. /**
  25824. * Class representing a ray with position and direction
  25825. */
  25826. var Ray = /** @class */ (function () {
  25827. /**
  25828. * Creates a new ray
  25829. * @param origin origin point
  25830. * @param direction direction
  25831. * @param length length of the ray
  25832. */
  25833. function Ray(
  25834. /** origin point */
  25835. origin,
  25836. /** direction */
  25837. direction,
  25838. /** length of the ray */
  25839. length) {
  25840. if (length === void 0) { length = Number.MAX_VALUE; }
  25841. this.origin = origin;
  25842. this.direction = direction;
  25843. this.length = length;
  25844. }
  25845. // Methods
  25846. /**
  25847. * Checks if the ray intersects a box
  25848. * @param minimum bound of the box
  25849. * @param maximum bound of the box
  25850. * @param intersectionTreshold extra extend to be added to the box in all direction
  25851. * @returns if the box was hit
  25852. */
  25853. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  25854. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25855. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  25856. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  25857. var d = 0.0;
  25858. var maxValue = Number.MAX_VALUE;
  25859. var inv;
  25860. var min;
  25861. var max;
  25862. var temp;
  25863. if (Math.abs(this.direction.x) < 0.0000001) {
  25864. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  25865. return false;
  25866. }
  25867. }
  25868. else {
  25869. inv = 1.0 / this.direction.x;
  25870. min = (newMinimum.x - this.origin.x) * inv;
  25871. max = (newMaximum.x - this.origin.x) * inv;
  25872. if (max === -Infinity) {
  25873. max = Infinity;
  25874. }
  25875. if (min > max) {
  25876. temp = min;
  25877. min = max;
  25878. max = temp;
  25879. }
  25880. d = Math.max(min, d);
  25881. maxValue = Math.min(max, maxValue);
  25882. if (d > maxValue) {
  25883. return false;
  25884. }
  25885. }
  25886. if (Math.abs(this.direction.y) < 0.0000001) {
  25887. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  25888. return false;
  25889. }
  25890. }
  25891. else {
  25892. inv = 1.0 / this.direction.y;
  25893. min = (newMinimum.y - this.origin.y) * inv;
  25894. max = (newMaximum.y - this.origin.y) * inv;
  25895. if (max === -Infinity) {
  25896. max = Infinity;
  25897. }
  25898. if (min > max) {
  25899. temp = min;
  25900. min = max;
  25901. max = temp;
  25902. }
  25903. d = Math.max(min, d);
  25904. maxValue = Math.min(max, maxValue);
  25905. if (d > maxValue) {
  25906. return false;
  25907. }
  25908. }
  25909. if (Math.abs(this.direction.z) < 0.0000001) {
  25910. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  25911. return false;
  25912. }
  25913. }
  25914. else {
  25915. inv = 1.0 / this.direction.z;
  25916. min = (newMinimum.z - this.origin.z) * inv;
  25917. max = (newMaximum.z - this.origin.z) * inv;
  25918. if (max === -Infinity) {
  25919. max = Infinity;
  25920. }
  25921. if (min > max) {
  25922. temp = min;
  25923. min = max;
  25924. max = temp;
  25925. }
  25926. d = Math.max(min, d);
  25927. maxValue = Math.min(max, maxValue);
  25928. if (d > maxValue) {
  25929. return false;
  25930. }
  25931. }
  25932. return true;
  25933. };
  25934. /**
  25935. * Checks if the ray intersects a box
  25936. * @param box the bounding box to check
  25937. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  25938. * @returns if the box was hit
  25939. */
  25940. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  25941. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25942. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  25943. };
  25944. /**
  25945. * If the ray hits a sphere
  25946. * @param sphere the bounding sphere to check
  25947. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  25948. * @returns true if it hits the sphere
  25949. */
  25950. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  25951. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25952. var x = sphere.center.x - this.origin.x;
  25953. var y = sphere.center.y - this.origin.y;
  25954. var z = sphere.center.z - this.origin.z;
  25955. var pyth = (x * x) + (y * y) + (z * z);
  25956. var radius = sphere.radius + intersectionTreshold;
  25957. var rr = radius * radius;
  25958. if (pyth <= rr) {
  25959. return true;
  25960. }
  25961. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  25962. if (dot < 0.0) {
  25963. return false;
  25964. }
  25965. var temp = pyth - (dot * dot);
  25966. return temp <= rr;
  25967. };
  25968. /**
  25969. * If the ray hits a triange
  25970. * @param vertex0 triangle vertex
  25971. * @param vertex1 triangle vertex
  25972. * @param vertex2 triangle vertex
  25973. * @returns intersection information if hit
  25974. */
  25975. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  25976. var edge1 = Ray.TmpVector3[0];
  25977. var edge2 = Ray.TmpVector3[1];
  25978. var pvec = Ray.TmpVector3[2];
  25979. var tvec = Ray.TmpVector3[3];
  25980. var qvec = Ray.TmpVector3[4];
  25981. vertex1.subtractToRef(vertex0, edge1);
  25982. vertex2.subtractToRef(vertex0, edge2);
  25983. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  25984. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  25985. if (det === 0) {
  25986. return null;
  25987. }
  25988. var invdet = 1 / det;
  25989. this.origin.subtractToRef(vertex0, tvec);
  25990. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  25991. if (bu < 0 || bu > 1.0) {
  25992. return null;
  25993. }
  25994. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  25995. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  25996. if (bv < 0 || bu + bv > 1.0) {
  25997. return null;
  25998. }
  25999. //check if the distance is longer than the predefined length.
  26000. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  26001. if (distance > this.length) {
  26002. return null;
  26003. }
  26004. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](bu, bv, distance);
  26005. };
  26006. /**
  26007. * Checks if ray intersects a plane
  26008. * @param plane the plane to check
  26009. * @returns the distance away it was hit
  26010. */
  26011. Ray.prototype.intersectsPlane = function (plane) {
  26012. var distance;
  26013. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  26014. if (Math.abs(result1) < 9.99999997475243E-07) {
  26015. return null;
  26016. }
  26017. else {
  26018. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  26019. distance = (-plane.d - result2) / result1;
  26020. if (distance < 0.0) {
  26021. if (distance < -9.99999997475243E-07) {
  26022. return null;
  26023. }
  26024. else {
  26025. return 0;
  26026. }
  26027. }
  26028. return distance;
  26029. }
  26030. };
  26031. /**
  26032. * Checks if ray intersects a mesh
  26033. * @param mesh the mesh to check
  26034. * @param fastCheck if only the bounding box should checked
  26035. * @returns picking info of the intersecton
  26036. */
  26037. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  26038. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  26039. mesh.getWorldMatrix().invertToRef(tm);
  26040. if (this._tmpRay) {
  26041. Ray.TransformToRef(this, tm, this._tmpRay);
  26042. }
  26043. else {
  26044. this._tmpRay = Ray.Transform(this, tm);
  26045. }
  26046. return mesh.intersects(this._tmpRay, fastCheck);
  26047. };
  26048. /**
  26049. * Checks if ray intersects a mesh
  26050. * @param meshes the meshes to check
  26051. * @param fastCheck if only the bounding box should checked
  26052. * @param results array to store result in
  26053. * @returns Array of picking infos
  26054. */
  26055. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  26056. if (results) {
  26057. results.length = 0;
  26058. }
  26059. else {
  26060. results = [];
  26061. }
  26062. for (var i = 0; i < meshes.length; i++) {
  26063. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  26064. if (pickInfo.hit) {
  26065. results.push(pickInfo);
  26066. }
  26067. }
  26068. results.sort(this._comparePickingInfo);
  26069. return results;
  26070. };
  26071. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  26072. if (pickingInfoA.distance < pickingInfoB.distance) {
  26073. return -1;
  26074. }
  26075. else if (pickingInfoA.distance > pickingInfoB.distance) {
  26076. return 1;
  26077. }
  26078. else {
  26079. return 0;
  26080. }
  26081. };
  26082. /**
  26083. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  26084. * @param sega the first point of the segment to test the intersection against
  26085. * @param segb the second point of the segment to test the intersection against
  26086. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  26087. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  26088. */
  26089. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  26090. var o = this.origin;
  26091. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  26092. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  26093. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  26094. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  26095. segb.subtractToRef(sega, u);
  26096. this.direction.scaleToRef(Ray.rayl, v);
  26097. o.addToRef(v, rsegb);
  26098. sega.subtractToRef(o, w);
  26099. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  26100. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  26101. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  26102. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  26103. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  26104. var D = a * c - b * b; // always >= 0
  26105. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  26106. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  26107. // compute the line parameters of the two closest points
  26108. if (D < Ray.smallnum) { // the lines are almost parallel
  26109. sN = 0.0; // force using point P0 on segment S1
  26110. sD = 1.0; // to prevent possible division by 0.0 later
  26111. tN = e;
  26112. tD = c;
  26113. }
  26114. else { // get the closest points on the infinite lines
  26115. sN = (b * e - c * d);
  26116. tN = (a * e - b * d);
  26117. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  26118. sN = 0.0;
  26119. tN = e;
  26120. tD = c;
  26121. }
  26122. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  26123. sN = sD;
  26124. tN = e + b;
  26125. tD = c;
  26126. }
  26127. }
  26128. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  26129. tN = 0.0;
  26130. // recompute sc for this edge
  26131. if (-d < 0.0) {
  26132. sN = 0.0;
  26133. }
  26134. else if (-d > a) {
  26135. sN = sD;
  26136. }
  26137. else {
  26138. sN = -d;
  26139. sD = a;
  26140. }
  26141. }
  26142. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  26143. tN = tD;
  26144. // recompute sc for this edge
  26145. if ((-d + b) < 0.0) {
  26146. sN = 0;
  26147. }
  26148. else if ((-d + b) > a) {
  26149. sN = sD;
  26150. }
  26151. else {
  26152. sN = (-d + b);
  26153. sD = a;
  26154. }
  26155. }
  26156. // finally do the division to get sc and tc
  26157. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  26158. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  26159. // get the difference of the two closest points
  26160. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  26161. v.scaleToRef(tc, qtc);
  26162. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  26163. u.scaleToRef(sc, qsc);
  26164. qsc.addInPlace(w);
  26165. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  26166. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  26167. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  26168. if (isIntersected) {
  26169. return qsc.length();
  26170. }
  26171. return -1;
  26172. };
  26173. /**
  26174. * Update the ray from viewport position
  26175. * @param x position
  26176. * @param y y position
  26177. * @param viewportWidth viewport width
  26178. * @param viewportHeight viewport height
  26179. * @param world world matrix
  26180. * @param view view matrix
  26181. * @param projection projection matrix
  26182. * @returns this ray updated
  26183. */
  26184. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  26185. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  26186. return this;
  26187. };
  26188. // Statics
  26189. /**
  26190. * Creates a ray with origin and direction of 0,0,0
  26191. * @returns the new ray
  26192. */
  26193. Ray.Zero = function () {
  26194. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  26195. };
  26196. /**
  26197. * Creates a new ray from screen space and viewport
  26198. * @param x position
  26199. * @param y y position
  26200. * @param viewportWidth viewport width
  26201. * @param viewportHeight viewport height
  26202. * @param world world matrix
  26203. * @param view view matrix
  26204. * @param projection projection matrix
  26205. * @returns new ray
  26206. */
  26207. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  26208. var result = Ray.Zero();
  26209. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  26210. };
  26211. /**
  26212. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  26213. * transformed to the given world matrix.
  26214. * @param origin The origin point
  26215. * @param end The end point
  26216. * @param world a matrix to transform the ray to. Default is the identity matrix.
  26217. * @returns the new ray
  26218. */
  26219. Ray.CreateNewFromTo = function (origin, end, world) {
  26220. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  26221. var direction = end.subtract(origin);
  26222. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  26223. direction.normalize();
  26224. return Ray.Transform(new Ray(origin, direction, length), world);
  26225. };
  26226. /**
  26227. * Transforms a ray by a matrix
  26228. * @param ray ray to transform
  26229. * @param matrix matrix to apply
  26230. * @returns the resulting new ray
  26231. */
  26232. Ray.Transform = function (ray, matrix) {
  26233. var result = new Ray(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0));
  26234. Ray.TransformToRef(ray, matrix, result);
  26235. return result;
  26236. };
  26237. /**
  26238. * Transforms a ray by a matrix
  26239. * @param ray ray to transform
  26240. * @param matrix matrix to apply
  26241. * @param result ray to store result in
  26242. */
  26243. Ray.TransformToRef = function (ray, matrix, result) {
  26244. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  26245. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  26246. result.length = ray.length;
  26247. var dir = result.direction;
  26248. var len = dir.length();
  26249. if (!(len === 0 || len === 1)) {
  26250. var num = 1.0 / len;
  26251. dir.x *= num;
  26252. dir.y *= num;
  26253. dir.z *= num;
  26254. result.length *= len;
  26255. }
  26256. };
  26257. /**
  26258. * Unproject a ray from screen space to object space
  26259. * @param sourceX defines the screen space x coordinate to use
  26260. * @param sourceY defines the screen space y coordinate to use
  26261. * @param viewportWidth defines the current width of the viewport
  26262. * @param viewportHeight defines the current height of the viewport
  26263. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  26264. * @param view defines the view matrix to use
  26265. * @param projection defines the projection matrix to use
  26266. */
  26267. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  26268. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  26269. world.multiplyToRef(view, matrix);
  26270. matrix.multiplyToRef(projection, matrix);
  26271. matrix.invert();
  26272. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  26273. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  26274. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  26275. nearScreenSource.z = -1.0;
  26276. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  26277. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  26278. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  26279. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  26280. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  26281. this.origin.copyFrom(nearVec3);
  26282. farVec3.subtractToRef(nearVec3, this.direction);
  26283. this.direction.normalize();
  26284. };
  26285. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  26286. Ray.smallnum = 0.00000001;
  26287. Ray.rayl = 10e8;
  26288. return Ray;
  26289. }());
  26290. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  26291. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26292. var result = Ray.Zero();
  26293. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  26294. return result;
  26295. };
  26296. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  26297. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26298. var engine = this.getEngine();
  26299. if (!camera) {
  26300. if (!this.activeCamera) {
  26301. throw new Error("Active camera not set");
  26302. }
  26303. camera = this.activeCamera;
  26304. }
  26305. var cameraViewport = camera.viewport;
  26306. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26307. // Moving coordinates to local viewport world
  26308. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26309. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26310. result.update(x, y, viewport.width, viewport.height, world ? world : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly, cameraViewSpace ? _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly : camera.getViewMatrix(), camera.getProjectionMatrix());
  26311. return this;
  26312. };
  26313. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  26314. var result = Ray.Zero();
  26315. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  26316. return result;
  26317. };
  26318. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  26319. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26320. return this;
  26321. }
  26322. var engine = this.getEngine();
  26323. if (!camera) {
  26324. if (!this.activeCamera) {
  26325. throw new Error("Active camera not set");
  26326. }
  26327. camera = this.activeCamera;
  26328. }
  26329. var cameraViewport = camera.viewport;
  26330. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26331. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26332. // Moving coordinates to local viewport world
  26333. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26334. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26335. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  26336. return this;
  26337. };
  26338. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck, trianglePredicate) {
  26339. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26340. return null;
  26341. }
  26342. var pickingInfo = null;
  26343. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26344. var mesh = this.meshes[meshIndex];
  26345. if (predicate) {
  26346. if (!predicate(mesh)) {
  26347. continue;
  26348. }
  26349. }
  26350. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26351. continue;
  26352. }
  26353. var world = mesh.getWorldMatrix();
  26354. var ray = rayFunction(world);
  26355. var result = mesh.intersects(ray, fastCheck, trianglePredicate);
  26356. if (!result || !result.hit) {
  26357. continue;
  26358. }
  26359. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  26360. continue;
  26361. }
  26362. pickingInfo = result;
  26363. if (fastCheck) {
  26364. break;
  26365. }
  26366. }
  26367. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
  26368. };
  26369. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalMultiPick = function (rayFunction, predicate, trianglePredicate) {
  26370. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26371. return null;
  26372. }
  26373. var pickingInfos = new Array();
  26374. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26375. var mesh = this.meshes[meshIndex];
  26376. if (predicate) {
  26377. if (!predicate(mesh)) {
  26378. continue;
  26379. }
  26380. }
  26381. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26382. continue;
  26383. }
  26384. var world = mesh.getWorldMatrix();
  26385. var ray = rayFunction(world);
  26386. var result = mesh.intersects(ray, false, trianglePredicate);
  26387. if (!result || !result.hit) {
  26388. continue;
  26389. }
  26390. pickingInfos.push(result);
  26391. }
  26392. return pickingInfos;
  26393. };
  26394. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  26395. var _this = this;
  26396. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26397. return null;
  26398. }
  26399. var result = this._internalPick(function (world) {
  26400. if (!_this._tempPickingRay) {
  26401. _this._tempPickingRay = Ray.Zero();
  26402. }
  26403. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  26404. return _this._tempPickingRay;
  26405. }, predicate, fastCheck, trianglePredicate);
  26406. if (result) {
  26407. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), camera || null);
  26408. }
  26409. return result;
  26410. };
  26411. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  26412. var _this = this;
  26413. var result = this._internalPick(function (world) {
  26414. if (!_this._pickWithRayInverseMatrix) {
  26415. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26416. }
  26417. world.invertToRef(_this._pickWithRayInverseMatrix);
  26418. if (!_this._cachedRayForTransform) {
  26419. _this._cachedRayForTransform = Ray.Zero();
  26420. }
  26421. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26422. return _this._cachedRayForTransform;
  26423. }, predicate, fastCheck, trianglePredicate);
  26424. if (result) {
  26425. result.ray = ray;
  26426. }
  26427. return result;
  26428. };
  26429. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  26430. var _this = this;
  26431. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate, trianglePredicate);
  26432. };
  26433. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  26434. var _this = this;
  26435. return this._internalMultiPick(function (world) {
  26436. if (!_this._pickWithRayInverseMatrix) {
  26437. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26438. }
  26439. world.invertToRef(_this._pickWithRayInverseMatrix);
  26440. if (!_this._cachedRayForTransform) {
  26441. _this._cachedRayForTransform = Ray.Zero();
  26442. }
  26443. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26444. return _this._cachedRayForTransform;
  26445. }, predicate, trianglePredicate);
  26446. };
  26447. _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRay = function (length, transform, origin) {
  26448. if (length === void 0) { length = 100; }
  26449. if (!transform) {
  26450. transform = this.getWorldMatrix();
  26451. }
  26452. if (!origin) {
  26453. origin = this.position;
  26454. }
  26455. var forward = this._scene.useRightHandedSystem ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1) : new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1);
  26456. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(forward, transform);
  26457. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Normalize(forwardWorld);
  26458. return new Ray(origin, direction, length);
  26459. };
  26460. /***/ }),
  26461. /***/ "./Debug/axesViewer.ts":
  26462. /*!*****************************!*\
  26463. !*** ./Debug/axesViewer.ts ***!
  26464. \*****************************/
  26465. /*! exports provided: AxesViewer */
  26466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26467. "use strict";
  26468. __webpack_require__.r(__webpack_exports__);
  26469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  26470. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26471. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26472. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  26473. /**
  26474. * The Axes viewer will show 3 axes in a specific point in space
  26475. */
  26476. var AxesViewer = /** @class */ (function () {
  26477. /**
  26478. * Creates a new AxesViewer
  26479. * @param scene defines the hosting scene
  26480. * @param scaleLines defines a number used to scale line length (1 by default)
  26481. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  26482. * @param xAxis defines the node hierarchy used to render the x-axis
  26483. * @param yAxis defines the node hierarchy used to render the y-axis
  26484. * @param zAxis defines the node hierarchy used to render the z-axis
  26485. */
  26486. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  26487. if (scaleLines === void 0) { scaleLines = 1; }
  26488. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  26489. this._scaleLinesFactor = 4;
  26490. this._instanced = false;
  26491. /**
  26492. * Gets or sets a number used to scale line length
  26493. */
  26494. this.scaleLines = 1;
  26495. this.scaleLines = scaleLines;
  26496. if (!xAxis) {
  26497. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26498. redColoredMaterial.disableLighting = true;
  26499. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  26500. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  26501. }
  26502. if (!yAxis) {
  26503. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26504. greenColoredMaterial.disableLighting = true;
  26505. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  26506. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  26507. }
  26508. if (!zAxis) {
  26509. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26510. blueColoredMaterial.disableLighting = true;
  26511. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  26512. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  26513. }
  26514. this._xAxis = xAxis;
  26515. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26516. this._yAxis = yAxis;
  26517. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26518. this._zAxis = zAxis;
  26519. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26520. if (renderingGroupId != null) {
  26521. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  26522. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  26523. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  26524. }
  26525. this.scene = scene;
  26526. this.update(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward());
  26527. }
  26528. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  26529. /** Gets the node hierarchy used to render x-axis */
  26530. get: function () {
  26531. return this._xAxis;
  26532. },
  26533. enumerable: true,
  26534. configurable: true
  26535. });
  26536. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  26537. /** Gets the node hierarchy used to render y-axis */
  26538. get: function () {
  26539. return this._yAxis;
  26540. },
  26541. enumerable: true,
  26542. configurable: true
  26543. });
  26544. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  26545. /** Gets the node hierarchy used to render z-axis */
  26546. get: function () {
  26547. return this._zAxis;
  26548. },
  26549. enumerable: true,
  26550. configurable: true
  26551. });
  26552. /**
  26553. * Force the viewer to update
  26554. * @param position defines the position of the viewer
  26555. * @param xaxis defines the x axis of the viewer
  26556. * @param yaxis defines the y axis of the viewer
  26557. * @param zaxis defines the z axis of the viewer
  26558. */
  26559. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  26560. this._xAxis.position.copyFrom(position);
  26561. this._xAxis.setDirection(xaxis);
  26562. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26563. this._yAxis.position.copyFrom(position);
  26564. this._yAxis.setDirection(yaxis);
  26565. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26566. this._zAxis.position.copyFrom(position);
  26567. this._zAxis.setDirection(zaxis);
  26568. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26569. };
  26570. /**
  26571. * Creates an instance of this axes viewer.
  26572. * @returns a new axes viewer with instanced meshes
  26573. */
  26574. AxesViewer.prototype.createInstance = function () {
  26575. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  26576. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  26577. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  26578. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  26579. axesViewer._instanced = true;
  26580. return axesViewer;
  26581. };
  26582. /** Releases resources */
  26583. AxesViewer.prototype.dispose = function () {
  26584. if (this._xAxis) {
  26585. this._xAxis.dispose(false, !this._instanced);
  26586. delete this._xAxis;
  26587. }
  26588. if (this._yAxis) {
  26589. this._yAxis.dispose(false, !this._instanced);
  26590. delete this._yAxis;
  26591. }
  26592. if (this._zAxis) {
  26593. this._zAxis.dispose(false, !this._instanced);
  26594. delete this._zAxis;
  26595. }
  26596. delete this.scene;
  26597. };
  26598. AxesViewer._SetRenderingGroupId = function (node, id) {
  26599. node.getChildMeshes().forEach(function (mesh) {
  26600. mesh.renderingGroupId = id;
  26601. });
  26602. };
  26603. return AxesViewer;
  26604. }());
  26605. /***/ }),
  26606. /***/ "./Debug/boneAxesViewer.ts":
  26607. /*!*********************************!*\
  26608. !*** ./Debug/boneAxesViewer.ts ***!
  26609. \*********************************/
  26610. /*! exports provided: BoneAxesViewer */
  26611. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26612. "use strict";
  26613. __webpack_require__.r(__webpack_exports__);
  26614. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  26615. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26616. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  26617. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26618. /**
  26619. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  26620. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  26621. */
  26622. var BoneAxesViewer = /** @class */ (function (_super) {
  26623. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  26624. /**
  26625. * Creates a new BoneAxesViewer
  26626. * @param scene defines the hosting scene
  26627. * @param bone defines the target bone
  26628. * @param mesh defines the target mesh
  26629. * @param scaleLines defines a scaling factor for line length (1 by default)
  26630. */
  26631. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  26632. if (scaleLines === void 0) { scaleLines = 1; }
  26633. var _this = _super.call(this, scene, scaleLines) || this;
  26634. /** Gets current position */
  26635. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26636. /** Gets direction of X axis */
  26637. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26638. /** Gets direction of Y axis */
  26639. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26640. /** Gets direction of Z axis */
  26641. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26642. _this.mesh = mesh;
  26643. _this.bone = bone;
  26644. return _this;
  26645. }
  26646. /**
  26647. * Force the viewer to update
  26648. */
  26649. BoneAxesViewer.prototype.update = function () {
  26650. if (!this.mesh || !this.bone) {
  26651. return;
  26652. }
  26653. var bone = this.bone;
  26654. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  26655. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  26656. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  26657. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  26658. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  26659. };
  26660. /** Releases resources */
  26661. BoneAxesViewer.prototype.dispose = function () {
  26662. if (this.mesh) {
  26663. this.mesh = null;
  26664. this.bone = null;
  26665. _super.prototype.dispose.call(this);
  26666. }
  26667. };
  26668. return BoneAxesViewer;
  26669. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  26670. /***/ }),
  26671. /***/ "./Debug/debugLayer.ts":
  26672. /*!*****************************!*\
  26673. !*** ./Debug/debugLayer.ts ***!
  26674. \*****************************/
  26675. /*! exports provided: DebugLayer */
  26676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26677. "use strict";
  26678. __webpack_require__.r(__webpack_exports__);
  26679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  26680. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26681. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  26682. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  26683. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  26684. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  26685. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  26686. get: function () {
  26687. if (!this._debugLayer) {
  26688. this._debugLayer = new DebugLayer(this);
  26689. }
  26690. return this._debugLayer;
  26691. },
  26692. enumerable: true,
  26693. configurable: true
  26694. });
  26695. /**
  26696. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26697. * what is happening in your scene
  26698. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26699. */
  26700. var DebugLayer = /** @class */ (function () {
  26701. /**
  26702. * Instantiates a new debug layer.
  26703. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26704. * what is happening in your scene
  26705. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26706. * @param scene Defines the scene to inspect
  26707. */
  26708. function DebugLayer(scene) {
  26709. var _this = this;
  26710. this.BJSINSPECTOR = this._getGlobalInspector();
  26711. /**
  26712. * Observable triggered when a property is changed through the inspector.
  26713. */
  26714. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  26715. this._scene = scene;
  26716. this._scene.onDisposeObservable.add(function () {
  26717. // Debug layer
  26718. if (_this._scene._debugLayer) {
  26719. _this._scene._debugLayer.hide();
  26720. }
  26721. });
  26722. }
  26723. /** Creates the inspector window. */
  26724. DebugLayer.prototype._createInspector = function (config) {
  26725. if (this.isVisible()) {
  26726. return;
  26727. }
  26728. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  26729. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  26730. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  26731. };
  26732. /**
  26733. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  26734. * @param entity defines the entity to select
  26735. * @param lineContainerTitle defines the specific block to highlight
  26736. */
  26737. DebugLayer.prototype.select = function (entity, lineContainerTitle) {
  26738. if (this.BJSINSPECTOR) {
  26739. this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(lineContainerTitle);
  26740. this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(entity);
  26741. }
  26742. };
  26743. /** Get the inspector from bundle or global */
  26744. DebugLayer.prototype._getGlobalInspector = function () {
  26745. // UMD Global name detection from Webpack Bundle UMD Name.
  26746. if (typeof INSPECTOR !== 'undefined') {
  26747. return INSPECTOR;
  26748. }
  26749. // In case of module let s check the global emitted from the Inspector entry point.
  26750. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  26751. return BABYLON;
  26752. }
  26753. return undefined;
  26754. };
  26755. /**
  26756. * Get if the inspector is visible or not.
  26757. * @returns true if visible otherwise, false
  26758. */
  26759. DebugLayer.prototype.isVisible = function () {
  26760. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  26761. };
  26762. /**
  26763. * Hide the inspector and close its window.
  26764. */
  26765. DebugLayer.prototype.hide = function () {
  26766. if (this.BJSINSPECTOR) {
  26767. this.BJSINSPECTOR.Inspector.Hide();
  26768. }
  26769. };
  26770. /**
  26771. * Launch the debugLayer.
  26772. * @param config Define the configuration of the inspector
  26773. * @return a promise fulfilled when the debug layer is visible
  26774. */
  26775. DebugLayer.prototype.show = function (config) {
  26776. var _this = this;
  26777. return new Promise(function (resolve, reject) {
  26778. if (typeof _this.BJSINSPECTOR == 'undefined') {
  26779. var inspectorUrl = config && config.inspectorURL ? config.inspectorURL : DebugLayer.InspectorURL;
  26780. // Load inspector and add it to the DOM
  26781. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(inspectorUrl, function () {
  26782. _this._createInspector(config);
  26783. resolve(_this);
  26784. });
  26785. }
  26786. else {
  26787. // Otherwise creates the inspector
  26788. _this._createInspector(config);
  26789. resolve(_this);
  26790. }
  26791. });
  26792. };
  26793. /**
  26794. * Define the url to get the inspector script from.
  26795. * By default it uses the babylonjs CDN.
  26796. * @ignoreNaming
  26797. */
  26798. DebugLayer.InspectorURL = "https://unpkg.com/babylonjs-inspector@" + _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].Version + "/babylon.inspector.bundle.js";
  26799. return DebugLayer;
  26800. }());
  26801. /***/ }),
  26802. /***/ "./Debug/index.ts":
  26803. /*!************************!*\
  26804. !*** ./Debug/index.ts ***!
  26805. \************************/
  26806. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  26807. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26808. "use strict";
  26809. __webpack_require__.r(__webpack_exports__);
  26810. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  26811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  26812. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  26813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  26814. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  26815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  26816. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  26817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  26818. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  26819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  26820. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  26821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  26822. /***/ }),
  26823. /***/ "./Debug/physicsViewer.ts":
  26824. /*!********************************!*\
  26825. !*** ./Debug/physicsViewer.ts ***!
  26826. \********************************/
  26827. /*! exports provided: PhysicsViewer */
  26828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26829. "use strict";
  26830. __webpack_require__.r(__webpack_exports__);
  26831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  26832. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26833. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  26834. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  26835. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26836. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  26837. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26838. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  26839. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26840. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  26841. /**
  26842. * Used to show the physics impostor around the specific mesh
  26843. */
  26844. var PhysicsViewer = /** @class */ (function () {
  26845. /**
  26846. * Creates a new PhysicsViewer
  26847. * @param scene defines the hosting scene
  26848. */
  26849. function PhysicsViewer(scene) {
  26850. /** @hidden */
  26851. this._impostors = [];
  26852. /** @hidden */
  26853. this._meshes = [];
  26854. /** @hidden */
  26855. this._numMeshes = 0;
  26856. this._debugMeshMeshes = new Array();
  26857. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  26858. var physicEngine = this._scene.getPhysicsEngine();
  26859. if (physicEngine) {
  26860. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  26861. }
  26862. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"](this._scene, false);
  26863. this._utilityLayer.pickUtilitySceneFirst = false;
  26864. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26865. }
  26866. /** @hidden */
  26867. PhysicsViewer.prototype._updateDebugMeshes = function () {
  26868. var plugin = this._physicsEnginePlugin;
  26869. for (var i = 0; i < this._numMeshes; i++) {
  26870. var impostor = this._impostors[i];
  26871. if (!impostor) {
  26872. continue;
  26873. }
  26874. if (impostor.isDisposed) {
  26875. this.hideImpostor(this._impostors[i--]);
  26876. }
  26877. else {
  26878. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].MeshImpostor) {
  26879. continue;
  26880. }
  26881. var mesh = this._meshes[i];
  26882. if (mesh && plugin) {
  26883. plugin.syncMeshWithImpostor(mesh, impostor);
  26884. }
  26885. }
  26886. }
  26887. };
  26888. /**
  26889. * Renders a specified physic impostor
  26890. * @param impostor defines the impostor to render
  26891. * @param targetMesh defines the mesh represented by the impostor
  26892. * @returns the new debug mesh used to render the impostor
  26893. */
  26894. PhysicsViewer.prototype.showImpostor = function (impostor, targetMesh) {
  26895. if (!this._scene) {
  26896. return null;
  26897. }
  26898. for (var i = 0; i < this._numMeshes; i++) {
  26899. if (this._impostors[i] == impostor) {
  26900. return null;
  26901. }
  26902. }
  26903. var debugMesh = this._getDebugMesh(impostor, targetMesh);
  26904. if (debugMesh) {
  26905. this._impostors[this._numMeshes] = impostor;
  26906. this._meshes[this._numMeshes] = debugMesh;
  26907. if (this._numMeshes === 0) {
  26908. this._renderFunction = this._updateDebugMeshes.bind(this);
  26909. this._scene.registerBeforeRender(this._renderFunction);
  26910. }
  26911. this._numMeshes++;
  26912. }
  26913. return debugMesh;
  26914. };
  26915. /**
  26916. * Hides a specified physic impostor
  26917. * @param impostor defines the impostor to hide
  26918. */
  26919. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  26920. if (!impostor || !this._scene || !this._utilityLayer) {
  26921. return;
  26922. }
  26923. var removed = false;
  26924. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26925. for (var i = 0; i < this._numMeshes; i++) {
  26926. if (this._impostors[i] == impostor) {
  26927. var mesh = this._meshes[i];
  26928. if (!mesh) {
  26929. continue;
  26930. }
  26931. utilityLayerScene.removeMesh(mesh);
  26932. mesh.dispose();
  26933. var index = this._debugMeshMeshes.indexOf(mesh);
  26934. if (index > -1) {
  26935. this._debugMeshMeshes.splice(index, 1);
  26936. }
  26937. this._numMeshes--;
  26938. if (this._numMeshes > 0) {
  26939. this._meshes[i] = this._meshes[this._numMeshes];
  26940. this._impostors[i] = this._impostors[this._numMeshes];
  26941. this._meshes[this._numMeshes] = null;
  26942. this._impostors[this._numMeshes] = null;
  26943. }
  26944. else {
  26945. this._meshes[0] = null;
  26946. this._impostors[0] = null;
  26947. }
  26948. removed = true;
  26949. break;
  26950. }
  26951. }
  26952. if (removed && this._numMeshes === 0) {
  26953. this._scene.unregisterBeforeRender(this._renderFunction);
  26954. }
  26955. };
  26956. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  26957. if (!this._debugMaterial) {
  26958. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]('', scene);
  26959. this._debugMaterial.wireframe = true;
  26960. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].White();
  26961. this._debugMaterial.disableLighting = true;
  26962. }
  26963. return this._debugMaterial;
  26964. };
  26965. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  26966. if (!this._debugBoxMesh) {
  26967. this._debugBoxMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  26968. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  26969. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  26970. this._debugBoxMesh.setEnabled(false);
  26971. }
  26972. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  26973. };
  26974. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  26975. if (!this._debugSphereMesh) {
  26976. this._debugSphereMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__["SphereBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  26977. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  26978. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  26979. this._debugSphereMesh.setEnabled(false);
  26980. }
  26981. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  26982. };
  26983. PhysicsViewer.prototype._getDebugCylinderMesh = function (scene) {
  26984. if (!this._debugCylinderMesh) {
  26985. this._debugCylinderMesh = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_8__["CylinderBuilder"].CreateCylinder('physicsBodyCylinderViewMesh', { diameterTop: 1, diameterBottom: 1, height: 1 }, scene);
  26986. this._debugCylinderMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  26987. this._debugCylinderMesh.material = this._getDebugMaterial(scene);
  26988. this._debugCylinderMesh.setEnabled(false);
  26989. }
  26990. return this._debugCylinderMesh.createInstance('physicsBodyBoxViewInstance');
  26991. };
  26992. PhysicsViewer.prototype._getDebugMeshMesh = function (mesh, scene) {
  26993. var wireframeOver = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](mesh.name, scene, null, mesh);
  26994. wireframeOver.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  26995. wireframeOver.setParent(mesh);
  26996. wireframeOver.material = this._getDebugMaterial(scene);
  26997. this._debugMeshMeshes.push(wireframeOver);
  26998. return wireframeOver;
  26999. };
  27000. PhysicsViewer.prototype._getDebugMesh = function (impostor, targetMesh) {
  27001. var _this = this;
  27002. if (!this._utilityLayer) {
  27003. return null;
  27004. }
  27005. // Only create child impostor debug meshes when evaluating the parent
  27006. if (targetMesh && targetMesh.parent && targetMesh.parent.physicsImpostor) {
  27007. return null;
  27008. }
  27009. var mesh = null;
  27010. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  27011. switch (impostor.type) {
  27012. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].BoxImpostor:
  27013. mesh = this._getDebugBoxMesh(utilityLayerScene);
  27014. impostor.getBoxSizeToRef(mesh.scaling);
  27015. break;
  27016. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].SphereImpostor:
  27017. mesh = this._getDebugSphereMesh(utilityLayerScene);
  27018. var radius = impostor.getRadius();
  27019. mesh.scaling.x = radius * 2;
  27020. mesh.scaling.y = radius * 2;
  27021. mesh.scaling.z = radius * 2;
  27022. break;
  27023. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].MeshImpostor:
  27024. if (targetMesh) {
  27025. mesh = this._getDebugMeshMesh(targetMesh, utilityLayerScene);
  27026. }
  27027. break;
  27028. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].NoImpostor:
  27029. if (targetMesh) {
  27030. // Handle compound impostors
  27031. var childMeshes = targetMesh.getChildMeshes().filter(function (c) { return c.physicsImpostor ? 1 : 0; });
  27032. childMeshes.forEach(function (m) {
  27033. var a = _this._getDebugBoxMesh(utilityLayerScene);
  27034. a.parent = m;
  27035. });
  27036. }
  27037. break;
  27038. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].CylinderImpostor:
  27039. mesh = this._getDebugCylinderMesh(utilityLayerScene);
  27040. var bi = impostor.object.getBoundingInfo();
  27041. mesh.scaling.x = bi.boundingBox.maximum.x - bi.boundingBox.minimum.x;
  27042. mesh.scaling.y = bi.boundingBox.maximum.y - bi.boundingBox.minimum.y;
  27043. mesh.scaling.z = bi.boundingBox.maximum.z - bi.boundingBox.minimum.z;
  27044. break;
  27045. }
  27046. return mesh;
  27047. };
  27048. /** Releases all resources */
  27049. PhysicsViewer.prototype.dispose = function () {
  27050. var count = this._numMeshes;
  27051. for (var index = 0; index < count; index++) {
  27052. this.hideImpostor(this._impostors[0]);
  27053. }
  27054. if (this._debugBoxMesh) {
  27055. this._debugBoxMesh.dispose();
  27056. }
  27057. if (this._debugSphereMesh) {
  27058. this._debugSphereMesh.dispose();
  27059. }
  27060. if (this._debugCylinderMesh) {
  27061. this._debugCylinderMesh.dispose();
  27062. }
  27063. if (this._debugMaterial) {
  27064. this._debugMaterial.dispose();
  27065. }
  27066. this._impostors.length = 0;
  27067. this._scene = null;
  27068. this._physicsEnginePlugin = null;
  27069. if (this._utilityLayer) {
  27070. this._utilityLayer.dispose();
  27071. this._utilityLayer = null;
  27072. }
  27073. };
  27074. return PhysicsViewer;
  27075. }());
  27076. /***/ }),
  27077. /***/ "./Debug/rayHelper.ts":
  27078. /*!****************************!*\
  27079. !*** ./Debug/rayHelper.ts ***!
  27080. \****************************/
  27081. /*! exports provided: RayHelper */
  27082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27083. "use strict";
  27084. __webpack_require__.r(__webpack_exports__);
  27085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  27086. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27087. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  27088. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  27089. /**
  27090. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  27091. * in order to better appreciate the issue one might have.
  27092. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  27093. */
  27094. var RayHelper = /** @class */ (function () {
  27095. /**
  27096. * Instantiate a new ray helper.
  27097. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  27098. * in order to better appreciate the issue one might have.
  27099. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  27100. * @param ray Defines the ray we are currently tryin to visualize
  27101. */
  27102. function RayHelper(ray) {
  27103. this.ray = ray;
  27104. }
  27105. /**
  27106. * Helper function to create a colored helper in a scene in one line.
  27107. * @param ray Defines the ray we are currently tryin to visualize
  27108. * @param scene Defines the scene the ray is used in
  27109. * @param color Defines the color we want to see the ray in
  27110. * @returns The newly created ray helper.
  27111. */
  27112. RayHelper.CreateAndShow = function (ray, scene, color) {
  27113. var helper = new RayHelper(ray);
  27114. helper.show(scene, color);
  27115. return helper;
  27116. };
  27117. /**
  27118. * Shows the ray we are willing to debug.
  27119. * @param scene Defines the scene the ray needs to be rendered in
  27120. * @param color Defines the color the ray needs to be rendered in
  27121. */
  27122. RayHelper.prototype.show = function (scene, color) {
  27123. if (!this._renderFunction && this.ray) {
  27124. var ray = this.ray;
  27125. this._renderFunction = this._render.bind(this);
  27126. this._scene = scene;
  27127. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  27128. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  27129. if (this._renderFunction) {
  27130. this._scene.registerBeforeRender(this._renderFunction);
  27131. }
  27132. }
  27133. if (color && this._renderLine) {
  27134. this._renderLine.color.copyFrom(color);
  27135. }
  27136. };
  27137. /**
  27138. * Hides the ray we are debugging.
  27139. */
  27140. RayHelper.prototype.hide = function () {
  27141. if (this._renderFunction && this._scene) {
  27142. this._scene.unregisterBeforeRender(this._renderFunction);
  27143. this._scene = null;
  27144. this._renderFunction = null;
  27145. if (this._renderLine) {
  27146. this._renderLine.dispose();
  27147. this._renderLine = null;
  27148. }
  27149. this._renderPoints = [];
  27150. }
  27151. };
  27152. RayHelper.prototype._render = function () {
  27153. var ray = this.ray;
  27154. if (!ray) {
  27155. return;
  27156. }
  27157. var point = this._renderPoints[1];
  27158. var len = Math.min(ray.length, 1000000);
  27159. point.copyFrom(ray.direction);
  27160. point.scaleInPlace(len);
  27161. point.addInPlace(ray.origin);
  27162. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  27163. };
  27164. /**
  27165. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  27166. * @param mesh Defines the mesh we want the helper attached to
  27167. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  27168. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  27169. * @param length Defines the length of the ray
  27170. */
  27171. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  27172. this._attachedToMesh = mesh;
  27173. var ray = this.ray;
  27174. if (!ray) {
  27175. return;
  27176. }
  27177. if (!ray.direction) {
  27178. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27179. }
  27180. if (!ray.origin) {
  27181. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27182. }
  27183. if (length) {
  27184. ray.length = length;
  27185. }
  27186. if (!meshSpaceOrigin) {
  27187. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27188. }
  27189. if (!meshSpaceDirection) {
  27190. // -1 so that this will work with Mesh.lookAt
  27191. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  27192. }
  27193. if (!this._meshSpaceDirection) {
  27194. this._meshSpaceDirection = meshSpaceDirection.clone();
  27195. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  27196. }
  27197. else {
  27198. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  27199. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  27200. }
  27201. if (!this._updateToMeshFunction) {
  27202. this._updateToMeshFunction = this._updateToMesh.bind(this);
  27203. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  27204. }
  27205. this._updateToMesh();
  27206. };
  27207. /**
  27208. * Detach the ray helper from the mesh it has previously been attached to.
  27209. */
  27210. RayHelper.prototype.detachFromMesh = function () {
  27211. if (this._attachedToMesh) {
  27212. if (this._updateToMeshFunction) {
  27213. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  27214. }
  27215. this._attachedToMesh = null;
  27216. this._updateToMeshFunction = null;
  27217. }
  27218. };
  27219. RayHelper.prototype._updateToMesh = function () {
  27220. var ray = this.ray;
  27221. if (!this._attachedToMesh || !ray) {
  27222. return;
  27223. }
  27224. if (this._attachedToMesh._isDisposed) {
  27225. this.detachFromMesh();
  27226. return;
  27227. }
  27228. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  27229. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  27230. };
  27231. /**
  27232. * Dispose the helper and release its associated resources.
  27233. */
  27234. RayHelper.prototype.dispose = function () {
  27235. this.hide();
  27236. this.detachFromMesh();
  27237. this.ray = null;
  27238. };
  27239. return RayHelper;
  27240. }());
  27241. /***/ }),
  27242. /***/ "./Debug/skeletonViewer.ts":
  27243. /*!*********************************!*\
  27244. !*** ./Debug/skeletonViewer.ts ***!
  27245. \*********************************/
  27246. /*! exports provided: SkeletonViewer */
  27247. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27248. "use strict";
  27249. __webpack_require__.r(__webpack_exports__);
  27250. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  27251. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27252. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  27253. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  27254. /**
  27255. * Class used to render a debug view of a given skeleton
  27256. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  27257. */
  27258. var SkeletonViewer = /** @class */ (function () {
  27259. /**
  27260. * Creates a new SkeletonViewer
  27261. * @param skeleton defines the skeleton to render
  27262. * @param mesh defines the mesh attached to the skeleton
  27263. * @param scene defines the hosting scene
  27264. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  27265. * @param renderingGroupId defines the rendering group id to use with the viewer
  27266. */
  27267. function SkeletonViewer(
  27268. /** defines the skeleton to render */
  27269. skeleton,
  27270. /** defines the mesh attached to the skeleton */
  27271. mesh, scene,
  27272. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  27273. autoUpdateBonesMatrices,
  27274. /** defines the rendering group id to use with the viewer */
  27275. renderingGroupId) {
  27276. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  27277. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  27278. this.skeleton = skeleton;
  27279. this.mesh = mesh;
  27280. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  27281. this.renderingGroupId = renderingGroupId;
  27282. /** Gets or sets the color used to render the skeleton */
  27283. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  27284. this._debugLines = new Array();
  27285. this._isEnabled = false;
  27286. this._scene = scene;
  27287. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  27288. this._utilityLayer.pickUtilitySceneFirst = false;
  27289. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  27290. this.update();
  27291. this._renderFunction = this.update.bind(this);
  27292. }
  27293. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  27294. /**
  27295. * Returns the mesh used to render the bones
  27296. */
  27297. get: function () {
  27298. return this._debugMesh;
  27299. },
  27300. enumerable: true,
  27301. configurable: true
  27302. });
  27303. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  27304. get: function () {
  27305. return this._isEnabled;
  27306. },
  27307. /** Gets or sets a boolean indicating if the viewer is enabled */
  27308. set: function (value) {
  27309. if (this._isEnabled === value) {
  27310. return;
  27311. }
  27312. this._isEnabled = value;
  27313. if (value) {
  27314. this._scene.registerBeforeRender(this._renderFunction);
  27315. }
  27316. else {
  27317. this._scene.unregisterBeforeRender(this._renderFunction);
  27318. }
  27319. },
  27320. enumerable: true,
  27321. configurable: true
  27322. });
  27323. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  27324. if (x === void 0) { x = 0; }
  27325. if (y === void 0) { y = 0; }
  27326. if (z === void 0) { z = 0; }
  27327. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  27328. var parentBone = bone.getParent();
  27329. tmat.copyFrom(bone.getLocalMatrix());
  27330. if (x !== 0 || y !== 0 || z !== 0) {
  27331. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  27332. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  27333. tmat2.setTranslationFromFloats(x, y, z);
  27334. tmat2.multiplyToRef(tmat, tmat);
  27335. }
  27336. if (parentBone) {
  27337. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  27338. }
  27339. tmat.multiplyToRef(meshMat, tmat);
  27340. position.x = tmat.m[12];
  27341. position.y = tmat.m[13];
  27342. position.z = tmat.m[14];
  27343. };
  27344. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  27345. var len = bones.length;
  27346. var mesh = this.mesh._effectiveMesh;
  27347. var meshPos = mesh.position;
  27348. for (var i = 0; i < len; i++) {
  27349. var bone = bones[i];
  27350. var points = this._debugLines[i];
  27351. if (!points) {
  27352. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27353. this._debugLines[i] = points;
  27354. }
  27355. this._getBonePosition(points[0], bone, meshMat);
  27356. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  27357. points[0].subtractInPlace(meshPos);
  27358. points[1].subtractInPlace(meshPos);
  27359. }
  27360. };
  27361. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  27362. var len = bones.length;
  27363. var boneNum = 0;
  27364. var mesh = this.mesh._effectiveMesh;
  27365. var meshPos = mesh.position;
  27366. for (var i = len - 1; i >= 0; i--) {
  27367. var childBone = bones[i];
  27368. var parentBone = childBone.getParent();
  27369. if (!parentBone) {
  27370. continue;
  27371. }
  27372. var points = this._debugLines[boneNum];
  27373. if (!points) {
  27374. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27375. this._debugLines[boneNum] = points;
  27376. }
  27377. childBone.getAbsolutePositionToRef(mesh, points[0]);
  27378. parentBone.getAbsolutePositionToRef(mesh, points[1]);
  27379. points[0].subtractInPlace(meshPos);
  27380. points[1].subtractInPlace(meshPos);
  27381. boneNum++;
  27382. }
  27383. };
  27384. /** Update the viewer to sync with current skeleton state */
  27385. SkeletonViewer.prototype.update = function () {
  27386. if (!this._utilityLayer) {
  27387. return;
  27388. }
  27389. if (this.autoUpdateBonesMatrices) {
  27390. this.skeleton.computeAbsoluteTransforms();
  27391. }
  27392. var mesh = this.mesh._effectiveMesh;
  27393. if (this.skeleton.bones[0].length === undefined) {
  27394. this._getLinesForBonesNoLength(this.skeleton.bones, mesh.getWorldMatrix());
  27395. }
  27396. else {
  27397. this._getLinesForBonesWithLength(this.skeleton.bones, mesh.getWorldMatrix());
  27398. }
  27399. var targetScene = this._utilityLayer.utilityLayerScene;
  27400. if (!this._debugMesh) {
  27401. this._debugMesh = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  27402. this._debugMesh.renderingGroupId = this.renderingGroupId;
  27403. }
  27404. else {
  27405. _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  27406. }
  27407. this._debugMesh.position.copyFrom(this.mesh.position);
  27408. this._debugMesh.color = this.color;
  27409. };
  27410. /** Release associated resources */
  27411. SkeletonViewer.prototype.dispose = function () {
  27412. this.isEnabled = false;
  27413. if (this._debugMesh) {
  27414. this.isEnabled = false;
  27415. this._debugMesh.dispose();
  27416. this._debugMesh = null;
  27417. }
  27418. if (this._utilityLayer) {
  27419. this._utilityLayer.dispose();
  27420. this._utilityLayer = null;
  27421. }
  27422. };
  27423. return SkeletonViewer;
  27424. }());
  27425. /***/ }),
  27426. /***/ "./Engines/Extensions/engine.multiview.ts":
  27427. /*!************************************************!*\
  27428. !*** ./Engines/Extensions/engine.multiview.ts ***!
  27429. \************************************************/
  27430. /*! no exports provided */
  27431. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27432. "use strict";
  27433. __webpack_require__.r(__webpack_exports__);
  27434. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  27435. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27436. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  27437. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  27438. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  27439. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  27440. /* harmony import */ var _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/MultiviewRenderTarget */ "./Materials/Textures/MultiviewRenderTarget.ts");
  27441. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype.createMultiviewRenderTargetTexture = function (width, height) {
  27442. var gl = this._gl;
  27443. if (!this.getCaps().multiview) {
  27444. throw "Multiview is not supported";
  27445. }
  27446. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  27447. internalTexture.width = width;
  27448. internalTexture.height = height;
  27449. internalTexture._framebuffer = gl.createFramebuffer();
  27450. internalTexture._colorTextureArray = gl.createTexture();
  27451. gl.bindTexture(gl.TEXTURE_2D_ARRAY, internalTexture._colorTextureArray);
  27452. gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.RGBA8, width, height, 2);
  27453. internalTexture._depthStencilTextureArray = gl.createTexture();
  27454. gl.bindTexture(gl.TEXTURE_2D_ARRAY, internalTexture._depthStencilTextureArray);
  27455. gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.DEPTH32F_STENCIL8, width, height, 2);
  27456. internalTexture.isReady = true;
  27457. return internalTexture;
  27458. };
  27459. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype.bindMultiviewFramebuffer = function (multiviewTexture) {
  27460. var gl = this._gl;
  27461. var ext = this.getCaps().multiview;
  27462. this.bindFramebuffer(multiviewTexture, undefined, undefined, undefined, true);
  27463. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, multiviewTexture._framebuffer);
  27464. if (multiviewTexture._colorTextureArray && multiviewTexture._depthStencilTextureArray) {
  27465. ext.framebufferTextureMultiviewWEBGL(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, multiviewTexture._colorTextureArray, 0, 0, 2);
  27466. ext.framebufferTextureMultiviewWEBGL(gl.DRAW_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, multiviewTexture._depthStencilTextureArray, 0, 0, 2);
  27467. }
  27468. else {
  27469. throw "Invalid multiview frame buffer";
  27470. }
  27471. };
  27472. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._useMultiviewToSingleView = false;
  27473. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._multiviewTexture = null;
  27474. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._resizeOrCreateMultiviewTexture = function (width, height) {
  27475. if (!this._multiviewTexture) {
  27476. this._multiviewTexture = new _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__["MultiviewRenderTarget"](this.getScene(), { width: width, height: height });
  27477. }
  27478. else if (this._multiviewTexture.getRenderWidth() != width || this._multiviewTexture.getRenderHeight() != height) {
  27479. this._multiviewTexture.dispose();
  27480. this._multiviewTexture = new _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__["MultiviewRenderTarget"](this.getScene(), { width: width, height: height });
  27481. }
  27482. };
  27483. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._transformMatrixR = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  27484. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._multiviewSceneUbo = null;
  27485. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._createMultiviewUbo = function () {
  27486. this._multiviewSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_5__["UniformBuffer"](this.getEngine(), undefined, true);
  27487. this._multiviewSceneUbo.addUniform("viewProjection", 16);
  27488. this._multiviewSceneUbo.addUniform("viewProjectionR", 16);
  27489. this._multiviewSceneUbo.addUniform("view", 16);
  27490. };
  27491. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._updateMultiviewUbo = function (viewR, projectionR) {
  27492. if (viewR && projectionR) {
  27493. viewR.multiplyToRef(projectionR, this._transformMatrixR);
  27494. }
  27495. if (viewR && projectionR) {
  27496. viewR.multiplyToRef(projectionR, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  27497. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Frustum"].GetRightPlaneToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0], this._frustumPlanes[3]); // Replace right plane by second camera right plane
  27498. }
  27499. if (this._multiviewSceneUbo) {
  27500. this._multiviewSceneUbo.updateMatrix("viewProjection", this.getTransformMatrix());
  27501. this._multiviewSceneUbo.updateMatrix("viewProjectionR", this._transformMatrixR);
  27502. this._multiviewSceneUbo.updateMatrix("view", this._viewMatrix);
  27503. this._multiviewSceneUbo.update();
  27504. }
  27505. };
  27506. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._renderMultiviewToSingleView = function (camera) {
  27507. // Multiview is only able to be displayed directly for API's such as webXR
  27508. // This displays a multiview image by rendering to the multiview image and then
  27509. // copying the result into the sub cameras instead of rendering them and proceeding as normal from there
  27510. // Render to a multiview texture
  27511. camera._resizeOrCreateMultiviewTexture((camera._rigPostProcess && camera._rigPostProcess && camera._rigPostProcess.width > 0) ? camera._rigPostProcess.width / 2 : this.getEngine().getRenderWidth(true) / 2, (camera._rigPostProcess && camera._rigPostProcess && camera._rigPostProcess.height > 0) ? camera._rigPostProcess.height : this.getEngine().getRenderHeight(true));
  27512. if (!this._multiviewSceneUbo) {
  27513. this._createMultiviewUbo();
  27514. }
  27515. camera.outputRenderTarget = camera._multiviewTexture;
  27516. this._renderForCamera(camera);
  27517. camera.outputRenderTarget = null;
  27518. // Consume the multiview texture through a shader for each eye
  27519. for (var index = 0; index < camera._rigCameras.length; index++) {
  27520. var engine = this.getEngine();
  27521. this._activeCamera = camera._rigCameras[index];
  27522. engine.setViewport(this._activeCamera.viewport);
  27523. if (this.postProcessManager) {
  27524. this.postProcessManager._prepareFrame();
  27525. this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate);
  27526. }
  27527. }
  27528. };
  27529. /***/ }),
  27530. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  27531. /*!*****************************************************!*\
  27532. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  27533. \*****************************************************/
  27534. /*! exports provided: _OcclusionDataStorage */
  27535. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27536. "use strict";
  27537. __webpack_require__.r(__webpack_exports__);
  27538. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  27539. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27540. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  27541. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  27542. /** @hidden */
  27543. var _OcclusionDataStorage = /** @class */ (function () {
  27544. function _OcclusionDataStorage() {
  27545. /** @hidden */
  27546. this.occlusionInternalRetryCounter = 0;
  27547. /** @hidden */
  27548. this.isOcclusionQueryInProgress = false;
  27549. /** @hidden */
  27550. this.isOccluded = false;
  27551. /** @hidden */
  27552. this.occlusionRetryCount = -1;
  27553. /** @hidden */
  27554. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  27555. /** @hidden */
  27556. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  27557. }
  27558. return _OcclusionDataStorage;
  27559. }());
  27560. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  27561. return this._gl.createQuery();
  27562. };
  27563. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  27564. this._gl.deleteQuery(query);
  27565. return this;
  27566. };
  27567. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  27568. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  27569. };
  27570. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  27571. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  27572. };
  27573. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  27574. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  27575. this._gl.beginQuery(glAlgorithm, query);
  27576. return this;
  27577. };
  27578. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  27579. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  27580. this._gl.endQuery(glAlgorithm);
  27581. return this;
  27582. };
  27583. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  27584. var timerQuery = this.getCaps().timerQuery;
  27585. if (timerQuery.createQueryEXT) {
  27586. return timerQuery.createQueryEXT();
  27587. }
  27588. return this.createQuery();
  27589. };
  27590. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  27591. var timerQuery = this.getCaps().timerQuery;
  27592. if (timerQuery.deleteQueryEXT) {
  27593. timerQuery.deleteQueryEXT(query);
  27594. return;
  27595. }
  27596. this.deleteQuery(query);
  27597. };
  27598. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  27599. var timerQuery = this.getCaps().timerQuery;
  27600. if (timerQuery.getQueryObjectEXT) {
  27601. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  27602. }
  27603. return this.getQueryResult(query);
  27604. };
  27605. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  27606. var timerQuery = this.getCaps().timerQuery;
  27607. if (timerQuery.getQueryObjectEXT) {
  27608. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  27609. }
  27610. return this.isQueryResultAvailable(query);
  27611. };
  27612. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  27613. var caps = this.getCaps();
  27614. var timerQuery = caps.timerQuery;
  27615. if (!timerQuery) {
  27616. return null;
  27617. }
  27618. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  27619. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  27620. if (caps.canUseTimestampForTimerQuery) {
  27621. token._startTimeQuery = this._createTimeQuery();
  27622. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  27623. }
  27624. else {
  27625. if (this._currentNonTimestampToken) {
  27626. return this._currentNonTimestampToken;
  27627. }
  27628. token._timeElapsedQuery = this._createTimeQuery();
  27629. if (timerQuery.beginQueryEXT) {
  27630. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  27631. }
  27632. else {
  27633. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  27634. }
  27635. this._currentNonTimestampToken = token;
  27636. }
  27637. return token;
  27638. };
  27639. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  27640. var caps = this.getCaps();
  27641. var timerQuery = caps.timerQuery;
  27642. if (!timerQuery || !token) {
  27643. return -1;
  27644. }
  27645. if (caps.canUseTimestampForTimerQuery) {
  27646. if (!token._startTimeQuery) {
  27647. return -1;
  27648. }
  27649. if (!token._endTimeQuery) {
  27650. token._endTimeQuery = this._createTimeQuery();
  27651. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  27652. }
  27653. }
  27654. else if (!token._timeElapsedQueryEnded) {
  27655. if (!token._timeElapsedQuery) {
  27656. return -1;
  27657. }
  27658. if (timerQuery.endQueryEXT) {
  27659. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  27660. }
  27661. else {
  27662. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  27663. }
  27664. token._timeElapsedQueryEnded = true;
  27665. }
  27666. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  27667. var available = false;
  27668. if (token._endTimeQuery) {
  27669. available = this._getTimeQueryAvailability(token._endTimeQuery);
  27670. }
  27671. else if (token._timeElapsedQuery) {
  27672. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  27673. }
  27674. if (available && !disjoint) {
  27675. var result = 0;
  27676. if (caps.canUseTimestampForTimerQuery) {
  27677. if (!token._startTimeQuery || !token._endTimeQuery) {
  27678. return -1;
  27679. }
  27680. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  27681. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  27682. result = timeEnd - timeStart;
  27683. this._deleteTimeQuery(token._startTimeQuery);
  27684. this._deleteTimeQuery(token._endTimeQuery);
  27685. token._startTimeQuery = null;
  27686. token._endTimeQuery = null;
  27687. }
  27688. else {
  27689. if (!token._timeElapsedQuery) {
  27690. return -1;
  27691. }
  27692. result = this._getTimeQueryResult(token._timeElapsedQuery);
  27693. this._deleteTimeQuery(token._timeElapsedQuery);
  27694. token._timeElapsedQuery = null;
  27695. token._timeElapsedQueryEnded = false;
  27696. this._currentNonTimestampToken = null;
  27697. }
  27698. return result;
  27699. }
  27700. return -1;
  27701. };
  27702. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  27703. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  27704. };
  27705. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  27706. get: function () {
  27707. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  27708. },
  27709. enumerable: false,
  27710. configurable: true
  27711. });
  27712. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  27713. get: function () {
  27714. if (!this.__occlusionDataStorage) {
  27715. this.__occlusionDataStorage = new _OcclusionDataStorage();
  27716. }
  27717. return this.__occlusionDataStorage;
  27718. },
  27719. enumerable: false,
  27720. configurable: true
  27721. });
  27722. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  27723. get: function () {
  27724. return this._occlusionDataStorage.isOccluded;
  27725. },
  27726. set: function (value) {
  27727. this._occlusionDataStorage.isOccluded = value;
  27728. },
  27729. enumerable: true,
  27730. configurable: true
  27731. });
  27732. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  27733. get: function () {
  27734. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  27735. },
  27736. set: function (value) {
  27737. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  27738. },
  27739. enumerable: true,
  27740. configurable: true
  27741. });
  27742. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  27743. get: function () {
  27744. return this._occlusionDataStorage.occlusionType;
  27745. },
  27746. set: function (value) {
  27747. this._occlusionDataStorage.occlusionType = value;
  27748. },
  27749. enumerable: true,
  27750. configurable: true
  27751. });
  27752. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  27753. get: function () {
  27754. return this._occlusionDataStorage.occlusionRetryCount;
  27755. },
  27756. set: function (value) {
  27757. this._occlusionDataStorage.occlusionRetryCount = value;
  27758. },
  27759. enumerable: true,
  27760. configurable: true
  27761. });
  27762. // We also need to update AbstractMesh as there is a portion of the code there
  27763. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  27764. var dataStorage = this._occlusionDataStorage;
  27765. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  27766. dataStorage.isOccluded = false;
  27767. return false;
  27768. }
  27769. var engine = this.getEngine();
  27770. if (engine.webGLVersion < 2) {
  27771. dataStorage.isOccluded = false;
  27772. return false;
  27773. }
  27774. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  27775. dataStorage.isOccluded = false;
  27776. return false;
  27777. }
  27778. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  27779. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  27780. if (isOcclusionQueryAvailable) {
  27781. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  27782. dataStorage.isOcclusionQueryInProgress = false;
  27783. dataStorage.occlusionInternalRetryCounter = 0;
  27784. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  27785. }
  27786. else {
  27787. dataStorage.occlusionInternalRetryCounter++;
  27788. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  27789. dataStorage.isOcclusionQueryInProgress = false;
  27790. dataStorage.occlusionInternalRetryCounter = 0;
  27791. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  27792. // if strict continue the last state of the object.
  27793. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  27794. }
  27795. else {
  27796. return false;
  27797. }
  27798. }
  27799. }
  27800. var scene = this.getScene();
  27801. if (scene.getBoundingBoxRenderer) {
  27802. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  27803. if (!this._occlusionQuery) {
  27804. this._occlusionQuery = engine.createQuery();
  27805. }
  27806. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  27807. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  27808. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  27809. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  27810. }
  27811. return dataStorage.isOccluded;
  27812. };
  27813. /***/ }),
  27814. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  27815. /*!********************************************************!*\
  27816. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  27817. \********************************************************/
  27818. /*! exports provided: _forceTransformFeedbackToBundle */
  27819. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27820. "use strict";
  27821. __webpack_require__.r(__webpack_exports__);
  27822. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  27823. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27824. /** @hidden */
  27825. var _forceTransformFeedbackToBundle = true;
  27826. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  27827. return this._gl.createTransformFeedback();
  27828. };
  27829. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  27830. this._gl.deleteTransformFeedback(value);
  27831. };
  27832. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  27833. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  27834. };
  27835. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  27836. if (usePoints === void 0) { usePoints = true; }
  27837. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  27838. };
  27839. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  27840. this._gl.endTransformFeedback();
  27841. };
  27842. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  27843. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  27844. };
  27845. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  27846. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  27847. };
  27848. /***/ }),
  27849. /***/ "./Engines/Extensions/index.ts":
  27850. /*!*************************************!*\
  27851. !*** ./Engines/Extensions/index.ts ***!
  27852. \*************************************/
  27853. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  27854. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27855. "use strict";
  27856. __webpack_require__.r(__webpack_exports__);
  27857. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  27858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  27859. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  27860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  27861. /***/ }),
  27862. /***/ "./Engines/constants.ts":
  27863. /*!******************************!*\
  27864. !*** ./Engines/constants.ts ***!
  27865. \******************************/
  27866. /*! exports provided: Constants */
  27867. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27868. "use strict";
  27869. __webpack_require__.r(__webpack_exports__);
  27870. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  27871. /** Defines the cross module used constants to avoid circular dependncies */
  27872. var Constants = /** @class */ (function () {
  27873. function Constants() {
  27874. }
  27875. /** Defines that alpha blending is disabled */
  27876. Constants.ALPHA_DISABLE = 0;
  27877. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27878. Constants.ALPHA_ADD = 1;
  27879. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27880. Constants.ALPHA_COMBINE = 2;
  27881. /** Defines that alpha blending to DEST - SRC * DEST */
  27882. Constants.ALPHA_SUBTRACT = 3;
  27883. /** Defines that alpha blending to SRC * DEST */
  27884. Constants.ALPHA_MULTIPLY = 4;
  27885. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27886. Constants.ALPHA_MAXIMIZED = 5;
  27887. /** Defines that alpha blending to SRC + DEST */
  27888. Constants.ALPHA_ONEONE = 6;
  27889. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27890. Constants.ALPHA_PREMULTIPLIED = 7;
  27891. /**
  27892. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27893. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27894. */
  27895. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  27896. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27897. Constants.ALPHA_INTERPOLATE = 9;
  27898. /**
  27899. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27900. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27901. */
  27902. Constants.ALPHA_SCREENMODE = 10;
  27903. /** Defines that the ressource is not delayed*/
  27904. Constants.DELAYLOADSTATE_NONE = 0;
  27905. /** Defines that the ressource was successfully delay loaded */
  27906. Constants.DELAYLOADSTATE_LOADED = 1;
  27907. /** Defines that the ressource is currently delay loading */
  27908. Constants.DELAYLOADSTATE_LOADING = 2;
  27909. /** Defines that the ressource is delayed and has not started loading */
  27910. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  27911. // Depht or Stencil test Constants.
  27912. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27913. Constants.NEVER = 0x0200;
  27914. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  27915. Constants.ALWAYS = 0x0207;
  27916. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27917. Constants.LESS = 0x0201;
  27918. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27919. Constants.EQUAL = 0x0202;
  27920. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  27921. Constants.LEQUAL = 0x0203;
  27922. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27923. Constants.GREATER = 0x0204;
  27924. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  27925. Constants.GEQUAL = 0x0206;
  27926. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  27927. Constants.NOTEQUAL = 0x0205;
  27928. // Stencil Actions Constants.
  27929. /** Passed to stencilOperation to specify that stencil value must be kept */
  27930. Constants.KEEP = 0x1E00;
  27931. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27932. Constants.REPLACE = 0x1E01;
  27933. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27934. Constants.INCR = 0x1E02;
  27935. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27936. Constants.DECR = 0x1E03;
  27937. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27938. Constants.INVERT = 0x150A;
  27939. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27940. Constants.INCR_WRAP = 0x8507;
  27941. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27942. Constants.DECR_WRAP = 0x8508;
  27943. /** Texture is not repeating outside of 0..1 UVs */
  27944. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  27945. /** Texture is repeating outside of 0..1 UVs */
  27946. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  27947. /** Texture is repeating and mirrored */
  27948. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  27949. /** ALPHA */
  27950. Constants.TEXTUREFORMAT_ALPHA = 0;
  27951. /** LUMINANCE */
  27952. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  27953. /** LUMINANCE_ALPHA */
  27954. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  27955. /** RGB */
  27956. Constants.TEXTUREFORMAT_RGB = 4;
  27957. /** RGBA */
  27958. Constants.TEXTUREFORMAT_RGBA = 5;
  27959. /** RED */
  27960. Constants.TEXTUREFORMAT_RED = 6;
  27961. /** RED (2nd reference) */
  27962. Constants.TEXTUREFORMAT_R = 6;
  27963. /** RG */
  27964. Constants.TEXTUREFORMAT_RG = 7;
  27965. /** RED_INTEGER */
  27966. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  27967. /** RED_INTEGER (2nd reference) */
  27968. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  27969. /** RG_INTEGER */
  27970. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  27971. /** RGB_INTEGER */
  27972. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  27973. /** RGBA_INTEGER */
  27974. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  27975. /** UNSIGNED_BYTE */
  27976. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  27977. /** UNSIGNED_BYTE (2nd reference) */
  27978. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  27979. /** FLOAT */
  27980. Constants.TEXTURETYPE_FLOAT = 1;
  27981. /** HALF_FLOAT */
  27982. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  27983. /** BYTE */
  27984. Constants.TEXTURETYPE_BYTE = 3;
  27985. /** SHORT */
  27986. Constants.TEXTURETYPE_SHORT = 4;
  27987. /** UNSIGNED_SHORT */
  27988. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  27989. /** INT */
  27990. Constants.TEXTURETYPE_INT = 6;
  27991. /** UNSIGNED_INT */
  27992. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  27993. /** UNSIGNED_SHORT_4_4_4_4 */
  27994. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  27995. /** UNSIGNED_SHORT_5_5_5_1 */
  27996. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  27997. /** UNSIGNED_SHORT_5_6_5 */
  27998. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  27999. /** UNSIGNED_INT_2_10_10_10_REV */
  28000. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  28001. /** UNSIGNED_INT_24_8 */
  28002. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  28003. /** UNSIGNED_INT_10F_11F_11F_REV */
  28004. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  28005. /** UNSIGNED_INT_5_9_9_9_REV */
  28006. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  28007. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28008. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  28009. /** nearest is mag = nearest and min = nearest and mip = linear */
  28010. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  28011. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28012. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  28013. /** Trilinear is mag = linear and min = linear and mip = linear */
  28014. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  28015. /** nearest is mag = nearest and min = nearest and mip = linear */
  28016. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  28017. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28018. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  28019. /** Trilinear is mag = linear and min = linear and mip = linear */
  28020. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  28021. /** mag = nearest and min = nearest and mip = nearest */
  28022. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  28023. /** mag = nearest and min = linear and mip = nearest */
  28024. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  28025. /** mag = nearest and min = linear and mip = linear */
  28026. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  28027. /** mag = nearest and min = linear and mip = none */
  28028. Constants.TEXTURE_NEAREST_LINEAR = 7;
  28029. /** mag = nearest and min = nearest and mip = none */
  28030. Constants.TEXTURE_NEAREST_NEAREST = 8;
  28031. /** mag = linear and min = nearest and mip = nearest */
  28032. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  28033. /** mag = linear and min = nearest and mip = linear */
  28034. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  28035. /** mag = linear and min = linear and mip = none */
  28036. Constants.TEXTURE_LINEAR_LINEAR = 11;
  28037. /** mag = linear and min = nearest and mip = none */
  28038. Constants.TEXTURE_LINEAR_NEAREST = 12;
  28039. /** Explicit coordinates mode */
  28040. Constants.TEXTURE_EXPLICIT_MODE = 0;
  28041. /** Spherical coordinates mode */
  28042. Constants.TEXTURE_SPHERICAL_MODE = 1;
  28043. /** Planar coordinates mode */
  28044. Constants.TEXTURE_PLANAR_MODE = 2;
  28045. /** Cubic coordinates mode */
  28046. Constants.TEXTURE_CUBIC_MODE = 3;
  28047. /** Projection coordinates mode */
  28048. Constants.TEXTURE_PROJECTION_MODE = 4;
  28049. /** Skybox coordinates mode */
  28050. Constants.TEXTURE_SKYBOX_MODE = 5;
  28051. /** Inverse Cubic coordinates mode */
  28052. Constants.TEXTURE_INVCUBIC_MODE = 6;
  28053. /** Equirectangular coordinates mode */
  28054. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  28055. /** Equirectangular Fixed coordinates mode */
  28056. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  28057. /** Equirectangular Fixed Mirrored coordinates mode */
  28058. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  28059. // Texture rescaling mode
  28060. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28061. Constants.SCALEMODE_FLOOR = 1;
  28062. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28063. Constants.SCALEMODE_NEAREST = 2;
  28064. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28065. Constants.SCALEMODE_CEILING = 3;
  28066. /**
  28067. * The dirty texture flag value
  28068. */
  28069. Constants.MATERIAL_TextureDirtyFlag = 1;
  28070. /**
  28071. * The dirty light flag value
  28072. */
  28073. Constants.MATERIAL_LightDirtyFlag = 2;
  28074. /**
  28075. * The dirty fresnel flag value
  28076. */
  28077. Constants.MATERIAL_FresnelDirtyFlag = 4;
  28078. /**
  28079. * The dirty attribute flag value
  28080. */
  28081. Constants.MATERIAL_AttributesDirtyFlag = 8;
  28082. /**
  28083. * The dirty misc flag value
  28084. */
  28085. Constants.MATERIAL_MiscDirtyFlag = 16;
  28086. /**
  28087. * The all dirty flag value
  28088. */
  28089. Constants.MATERIAL_AllDirtyFlag = 31;
  28090. /**
  28091. * Returns the triangle fill mode
  28092. */
  28093. Constants.MATERIAL_TriangleFillMode = 0;
  28094. /**
  28095. * Returns the wireframe mode
  28096. */
  28097. Constants.MATERIAL_WireFrameFillMode = 1;
  28098. /**
  28099. * Returns the point fill mode
  28100. */
  28101. Constants.MATERIAL_PointFillMode = 2;
  28102. /**
  28103. * Returns the point list draw mode
  28104. */
  28105. Constants.MATERIAL_PointListDrawMode = 3;
  28106. /**
  28107. * Returns the line list draw mode
  28108. */
  28109. Constants.MATERIAL_LineListDrawMode = 4;
  28110. /**
  28111. * Returns the line loop draw mode
  28112. */
  28113. Constants.MATERIAL_LineLoopDrawMode = 5;
  28114. /**
  28115. * Returns the line strip draw mode
  28116. */
  28117. Constants.MATERIAL_LineStripDrawMode = 6;
  28118. /**
  28119. * Returns the triangle strip draw mode
  28120. */
  28121. Constants.MATERIAL_TriangleStripDrawMode = 7;
  28122. /**
  28123. * Returns the triangle fan draw mode
  28124. */
  28125. Constants.MATERIAL_TriangleFanDrawMode = 8;
  28126. /**
  28127. * Stores the clock-wise side orientation
  28128. */
  28129. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  28130. /**
  28131. * Stores the counter clock-wise side orientation
  28132. */
  28133. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  28134. /**
  28135. * Nothing
  28136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28137. */
  28138. Constants.ACTION_NothingTrigger = 0;
  28139. /**
  28140. * On pick
  28141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28142. */
  28143. Constants.ACTION_OnPickTrigger = 1;
  28144. /**
  28145. * On left pick
  28146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28147. */
  28148. Constants.ACTION_OnLeftPickTrigger = 2;
  28149. /**
  28150. * On right pick
  28151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28152. */
  28153. Constants.ACTION_OnRightPickTrigger = 3;
  28154. /**
  28155. * On center pick
  28156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28157. */
  28158. Constants.ACTION_OnCenterPickTrigger = 4;
  28159. /**
  28160. * On pick down
  28161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28162. */
  28163. Constants.ACTION_OnPickDownTrigger = 5;
  28164. /**
  28165. * On double pick
  28166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28167. */
  28168. Constants.ACTION_OnDoublePickTrigger = 6;
  28169. /**
  28170. * On pick up
  28171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28172. */
  28173. Constants.ACTION_OnPickUpTrigger = 7;
  28174. /**
  28175. * On pick out.
  28176. * This trigger will only be raised if you also declared a OnPickDown
  28177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28178. */
  28179. Constants.ACTION_OnPickOutTrigger = 16;
  28180. /**
  28181. * On long press
  28182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28183. */
  28184. Constants.ACTION_OnLongPressTrigger = 8;
  28185. /**
  28186. * On pointer over
  28187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28188. */
  28189. Constants.ACTION_OnPointerOverTrigger = 9;
  28190. /**
  28191. * On pointer out
  28192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28193. */
  28194. Constants.ACTION_OnPointerOutTrigger = 10;
  28195. /**
  28196. * On every frame
  28197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28198. */
  28199. Constants.ACTION_OnEveryFrameTrigger = 11;
  28200. /**
  28201. * On intersection enter
  28202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28203. */
  28204. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  28205. /**
  28206. * On intersection exit
  28207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28208. */
  28209. Constants.ACTION_OnIntersectionExitTrigger = 13;
  28210. /**
  28211. * On key down
  28212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28213. */
  28214. Constants.ACTION_OnKeyDownTrigger = 14;
  28215. /**
  28216. * On key up
  28217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28218. */
  28219. Constants.ACTION_OnKeyUpTrigger = 15;
  28220. /**
  28221. * Billboard mode will only apply to Y axis
  28222. */
  28223. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  28224. /**
  28225. * Billboard mode will apply to all axes
  28226. */
  28227. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  28228. /**
  28229. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  28230. */
  28231. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  28232. /**
  28233. * Gets or sets base Assets URL
  28234. */
  28235. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  28236. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28237. * Test order :
  28238. * Is the bounding sphere outside the frustum ?
  28239. * If not, are the bounding box vertices outside the frustum ?
  28240. * It not, then the cullable object is in the frustum.
  28241. */
  28242. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  28243. /** Culling strategy : Bounding Sphere Only.
  28244. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28245. * It's also less accurate than the standard because some not visible objects can still be selected.
  28246. * Test : is the bounding sphere outside the frustum ?
  28247. * If not, then the cullable object is in the frustum.
  28248. */
  28249. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  28250. /** Culling strategy : Optimistic Inclusion.
  28251. * This in an inclusion test first, then the standard exclusion test.
  28252. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28253. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  28254. * Anyway, it's as accurate as the standard strategy.
  28255. * Test :
  28256. * Is the cullable object bounding sphere center in the frustum ?
  28257. * If not, apply the default culling strategy.
  28258. */
  28259. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  28260. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28261. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28262. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28263. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  28264. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28265. * Test :
  28266. * Is the cullable object bounding sphere center in the frustum ?
  28267. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28268. */
  28269. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  28270. /**
  28271. * No logging while loading
  28272. */
  28273. Constants.SCENELOADER_NO_LOGGING = 0;
  28274. /**
  28275. * Minimal logging while loading
  28276. */
  28277. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  28278. /**
  28279. * Summary logging while loading
  28280. */
  28281. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  28282. /**
  28283. * Detailled logging while loading
  28284. */
  28285. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  28286. return Constants;
  28287. }());
  28288. /***/ }),
  28289. /***/ "./Engines/engine.ts":
  28290. /*!***************************!*\
  28291. !*** ./Engines/engine.ts ***!
  28292. \***************************/
  28293. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  28294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28295. "use strict";
  28296. __webpack_require__.r(__webpack_exports__);
  28297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  28298. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  28299. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  28300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  28301. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  28302. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  28303. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  28304. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  28305. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  28306. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  28307. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  28308. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  28309. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  28310. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  28311. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  28312. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  28313. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  28314. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  28315. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  28316. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  28317. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  28318. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  28319. /**
  28320. * Keeps track of all the buffer info used in engine.
  28321. */
  28322. var BufferPointer = /** @class */ (function () {
  28323. function BufferPointer() {
  28324. }
  28325. return BufferPointer;
  28326. }());
  28327. /**
  28328. * Interface for attribute information associated with buffer instanciation
  28329. */
  28330. var InstancingAttributeInfo = /** @class */ (function () {
  28331. function InstancingAttributeInfo() {
  28332. }
  28333. return InstancingAttributeInfo;
  28334. }());
  28335. /**
  28336. * Define options used to create a depth texture
  28337. */
  28338. var DepthTextureCreationOptions = /** @class */ (function () {
  28339. function DepthTextureCreationOptions() {
  28340. }
  28341. return DepthTextureCreationOptions;
  28342. }());
  28343. /**
  28344. * Class used to describe the capabilities of the engine relatively to the current browser
  28345. */
  28346. var EngineCapabilities = /** @class */ (function () {
  28347. function EngineCapabilities() {
  28348. }
  28349. return EngineCapabilities;
  28350. }());
  28351. /**
  28352. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28353. */
  28354. var Engine = /** @class */ (function () {
  28355. /**
  28356. * Creates a new engine
  28357. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  28358. * @param antialias defines enable antialiasing (default: false)
  28359. * @param options defines further options to be sent to the getContext() function
  28360. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28361. */
  28362. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  28363. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  28364. var _this = this;
  28365. // Public members
  28366. /**
  28367. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28368. */
  28369. this.forcePOTTextures = false;
  28370. /**
  28371. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28372. */
  28373. this.isFullscreen = false;
  28374. /**
  28375. * Gets a boolean indicating if the pointer is currently locked
  28376. */
  28377. this.isPointerLock = false;
  28378. /**
  28379. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28380. */
  28381. this.cullBackFaces = true;
  28382. /**
  28383. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28384. */
  28385. this.renderEvenInBackground = true;
  28386. /**
  28387. * Gets or sets a boolean indicating that cache can be kept between frames
  28388. */
  28389. this.preventCacheWipeBetweenFrames = false;
  28390. /**
  28391. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28392. **/
  28393. this.enableOfflineSupport = false;
  28394. /**
  28395. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  28396. **/
  28397. this.disableManifestCheck = false;
  28398. /**
  28399. * Gets the list of created scenes
  28400. */
  28401. this.scenes = new Array();
  28402. /**
  28403. * Event raised when a new scene is created
  28404. */
  28405. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28406. /**
  28407. * Gets the list of created postprocesses
  28408. */
  28409. this.postProcesses = new Array();
  28410. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28411. this.validateShaderPrograms = false;
  28412. // Observables
  28413. /**
  28414. * Observable event triggered each time the rendering canvas is resized
  28415. */
  28416. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28417. /**
  28418. * Observable event triggered each time the canvas loses focus
  28419. */
  28420. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28421. /**
  28422. * Observable event triggered each time the canvas gains focus
  28423. */
  28424. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28425. /**
  28426. * Observable event triggered each time the canvas receives pointerout event
  28427. */
  28428. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28429. /**
  28430. * Observable event triggered before each texture is initialized
  28431. */
  28432. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28433. //WebVR
  28434. this._vrDisplay = undefined;
  28435. this._vrSupported = false;
  28436. this._vrExclusivePointerMode = false;
  28437. // Uniform buffers list
  28438. /**
  28439. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28440. */
  28441. this.disableUniformBuffers = false;
  28442. /** @hidden */
  28443. this._uniformBuffers = new Array();
  28444. // Observables
  28445. /**
  28446. * Observable raised when the engine begins a new frame
  28447. */
  28448. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28449. /**
  28450. * If set, will be used to request the next animation frame for the render loop
  28451. */
  28452. this.customAnimationFrameRequester = null;
  28453. /**
  28454. * Observable raised when the engine ends the current frame
  28455. */
  28456. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28457. /**
  28458. * Observable raised when the engine is about to compile a shader
  28459. */
  28460. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28461. /**
  28462. * Observable raised when the engine has jsut compiled a shader
  28463. */
  28464. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28465. this._windowIsBackground = false;
  28466. this._webGLVersion = 1.0;
  28467. this._highPrecisionShadersAllowed = true;
  28468. /** @hidden */
  28469. this._badOS = false;
  28470. /** @hidden */
  28471. this._badDesktopOS = false;
  28472. /**
  28473. * Observable signaled when VR display mode changes
  28474. */
  28475. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28476. /**
  28477. * Observable signaled when VR request present is complete
  28478. */
  28479. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28480. /**
  28481. * Observable signaled when VR request present starts
  28482. */
  28483. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28484. this._colorWrite = true;
  28485. /** @hidden */
  28486. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  28487. this._renderingQueueLaunched = false;
  28488. this._activeRenderLoops = new Array();
  28489. // Deterministic lockstepMaxSteps
  28490. this._deterministicLockstep = false;
  28491. this._lockstepMaxSteps = 4;
  28492. // Lost context
  28493. /**
  28494. * Observable signaled when a context lost event is raised
  28495. */
  28496. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28497. /**
  28498. * Observable signaled when a context restored event is raised
  28499. */
  28500. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28501. this._contextWasLost = false;
  28502. this._doNotHandleContextLost = false;
  28503. // FPS
  28504. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  28505. this._fps = 60;
  28506. this._deltaTime = 0;
  28507. /**
  28508. * Turn this value on if you want to pause FPS computation when in background
  28509. */
  28510. this.disablePerformanceMonitorInBackground = false;
  28511. /**
  28512. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28513. */
  28514. this.disableVertexArrayObjects = false;
  28515. // States
  28516. /** @hidden */
  28517. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_11__["_DepthCullingState"]();
  28518. /** @hidden */
  28519. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_11__["_StencilState"]();
  28520. /** @hidden */
  28521. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_11__["_AlphaState"]();
  28522. /** @hidden */
  28523. this._alphaMode = Engine.ALPHA_DISABLE;
  28524. // Cache
  28525. this._internalTexturesCache = new Array();
  28526. /** @hidden */
  28527. this._activeChannel = 0;
  28528. this._currentTextureChannel = -1;
  28529. /** @hidden */
  28530. this._boundTexturesCache = {};
  28531. this._compiledEffects = {};
  28532. this._vertexAttribArraysEnabled = [];
  28533. this._uintIndicesCurrentlySet = false;
  28534. this._currentBoundBuffer = new Array();
  28535. /** @hidden */
  28536. this._currentFramebuffer = null;
  28537. this._currentBufferPointers = new Array();
  28538. this._currentInstanceLocations = new Array();
  28539. this._currentInstanceBuffers = new Array();
  28540. this._vaoRecordInProgress = false;
  28541. this._mustWipeVertexAttributes = false;
  28542. this._nextFreeTextureSlots = new Array();
  28543. this._maxSimultaneousTextures = 0;
  28544. this._activeRequests = new Array();
  28545. // Hardware supported Compressed Textures
  28546. this._texturesSupported = new Array();
  28547. /**
  28548. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28549. */
  28550. this.premultipliedAlpha = true;
  28551. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  28552. this._onVRFullScreenTriggered = function () {
  28553. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  28554. //get the old size before we change
  28555. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  28556. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  28557. //get the width and height, change the render size
  28558. var leftEye = _this._vrDisplay.getEyeParameters('left');
  28559. _this.setHardwareScalingLevel(1);
  28560. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  28561. }
  28562. else {
  28563. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  28564. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  28565. }
  28566. };
  28567. this._unpackFlipYCached = null;
  28568. /**
  28569. * In case you are sharing the context with other applications, it might
  28570. * be interested to not cache the unpack flip y state to ensure a consistent
  28571. * value would be set.
  28572. */
  28573. this.enableUnpackFlipYCached = true;
  28574. this._boundUniforms = {};
  28575. // Register promises
  28576. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  28577. var canvas = null;
  28578. Engine.Instances.push(this);
  28579. if (!canvasOrContext) {
  28580. return;
  28581. }
  28582. options = options || {};
  28583. if (canvasOrContext.getContext) {
  28584. canvas = canvasOrContext;
  28585. this._renderingCanvas = canvas;
  28586. if (antialias != null) {
  28587. options.antialias = antialias;
  28588. }
  28589. if (options.deterministicLockstep === undefined) {
  28590. options.deterministicLockstep = false;
  28591. }
  28592. if (options.lockstepMaxSteps === undefined) {
  28593. options.lockstepMaxSteps = 4;
  28594. }
  28595. if (options.preserveDrawingBuffer === undefined) {
  28596. options.preserveDrawingBuffer = false;
  28597. }
  28598. if (options.audioEngine === undefined) {
  28599. options.audioEngine = true;
  28600. }
  28601. if (options.stencil === undefined) {
  28602. options.stencil = true;
  28603. }
  28604. if (options.premultipliedAlpha === false) {
  28605. this.premultipliedAlpha = false;
  28606. }
  28607. this._deterministicLockstep = options.deterministicLockstep;
  28608. this._lockstepMaxSteps = options.lockstepMaxSteps;
  28609. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  28610. // Exceptions
  28611. if (navigator && navigator.userAgent) {
  28612. var ua = navigator.userAgent;
  28613. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  28614. var exception = _a[_i];
  28615. var key = exception.key;
  28616. var targets = exception.targets;
  28617. var check = new RegExp(key);
  28618. if (check.test(ua)) {
  28619. if (exception.capture && exception.captureConstraint) {
  28620. var capture = exception.capture;
  28621. var constraint = exception.captureConstraint;
  28622. var regex = new RegExp(capture);
  28623. var matches = regex.exec(ua);
  28624. if (matches && matches.length > 0) {
  28625. var capturedValue = parseInt(matches[matches.length - 1]);
  28626. if (capturedValue >= constraint) {
  28627. continue;
  28628. }
  28629. }
  28630. }
  28631. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  28632. var target = targets_1[_b];
  28633. switch (target) {
  28634. case "uniformBuffer":
  28635. this.disableUniformBuffers = true;
  28636. break;
  28637. case "vao":
  28638. this.disableVertexArrayObjects = true;
  28639. break;
  28640. }
  28641. }
  28642. }
  28643. }
  28644. }
  28645. // GL
  28646. if (!options.disableWebGL2Support) {
  28647. try {
  28648. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  28649. if (this._gl) {
  28650. this._webGLVersion = 2.0;
  28651. // Prevent weird browsers to lie :-)
  28652. if (!this._gl.deleteQuery) {
  28653. this._webGLVersion = 1.0;
  28654. }
  28655. }
  28656. }
  28657. catch (e) {
  28658. // Do nothing
  28659. }
  28660. }
  28661. if (!this._gl) {
  28662. if (!canvas) {
  28663. throw new Error("The provided canvas is null or undefined.");
  28664. }
  28665. try {
  28666. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  28667. }
  28668. catch (e) {
  28669. throw new Error("WebGL not supported");
  28670. }
  28671. }
  28672. if (!this._gl) {
  28673. throw new Error("WebGL not supported");
  28674. }
  28675. // Ensures a consistent color space unpacking of textures cross browser.
  28676. this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);
  28677. this._onCanvasFocus = function () {
  28678. _this.onCanvasFocusObservable.notifyObservers(_this);
  28679. };
  28680. this._onCanvasBlur = function () {
  28681. _this.onCanvasBlurObservable.notifyObservers(_this);
  28682. };
  28683. canvas.addEventListener("focus", this._onCanvasFocus);
  28684. canvas.addEventListener("blur", this._onCanvasBlur);
  28685. this._onBlur = function () {
  28686. if (_this.disablePerformanceMonitorInBackground) {
  28687. _this._performanceMonitor.disable();
  28688. }
  28689. _this._windowIsBackground = true;
  28690. };
  28691. this._onFocus = function () {
  28692. if (_this.disablePerformanceMonitorInBackground) {
  28693. _this._performanceMonitor.enable();
  28694. }
  28695. _this._windowIsBackground = false;
  28696. };
  28697. this._onCanvasPointerOut = function (ev) {
  28698. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  28699. };
  28700. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  28701. window.addEventListener("blur", this._onBlur);
  28702. window.addEventListener("focus", this._onFocus);
  28703. }
  28704. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  28705. // Context lost
  28706. if (!this._doNotHandleContextLost) {
  28707. this._onContextLost = function (evt) {
  28708. evt.preventDefault();
  28709. _this._contextWasLost = true;
  28710. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("WebGL context lost.");
  28711. _this.onContextLostObservable.notifyObservers(_this);
  28712. };
  28713. this._onContextRestored = function () {
  28714. // Adding a timeout to avoid race condition at browser level
  28715. setTimeout(function () {
  28716. // Rebuild gl context
  28717. _this._initGLContext();
  28718. // Rebuild effects
  28719. _this._rebuildEffects();
  28720. // Rebuild textures
  28721. _this._rebuildInternalTextures();
  28722. // Rebuild buffers
  28723. _this._rebuildBuffers();
  28724. // Cache
  28725. _this.wipeCaches(true);
  28726. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("WebGL context successfully restored.");
  28727. _this.onContextRestoredObservable.notifyObservers(_this);
  28728. _this._contextWasLost = false;
  28729. }, 0);
  28730. };
  28731. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  28732. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  28733. }
  28734. if (!options.doNotHandleTouchAction) {
  28735. this._disableTouchAction();
  28736. }
  28737. }
  28738. else {
  28739. this._gl = canvasOrContext;
  28740. this._renderingCanvas = this._gl.canvas;
  28741. if (this._gl.renderbufferStorageMultisample) {
  28742. this._webGLVersion = 2.0;
  28743. }
  28744. var attributes = this._gl.getContextAttributes();
  28745. if (attributes) {
  28746. options.stencil = attributes.stencil;
  28747. }
  28748. }
  28749. if (options.useHighPrecisionFloats !== undefined) {
  28750. this._highPrecisionShadersAllowed = options.useHighPrecisionFloats;
  28751. }
  28752. // Viewport
  28753. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  28754. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  28755. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  28756. this.resize();
  28757. this._isStencilEnable = options.stencil ? true : false;
  28758. this._initGLContext();
  28759. if (canvas) {
  28760. var anyDoc_1 = document;
  28761. // Fullscreen
  28762. this._onFullscreenChange = function () {
  28763. if (anyDoc_1.fullscreen !== undefined) {
  28764. _this.isFullscreen = anyDoc_1.fullscreen;
  28765. }
  28766. else if (anyDoc_1.mozFullScreen !== undefined) {
  28767. _this.isFullscreen = anyDoc_1.mozFullScreen;
  28768. }
  28769. else if (anyDoc_1.webkitIsFullScreen !== undefined) {
  28770. _this.isFullscreen = anyDoc_1.webkitIsFullScreen;
  28771. }
  28772. else if (anyDoc_1.msIsFullScreen !== undefined) {
  28773. _this.isFullscreen = anyDoc_1.msIsFullScreen;
  28774. }
  28775. // Pointer lock
  28776. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  28777. canvas.requestPointerLock = canvas.requestPointerLock ||
  28778. canvas.msRequestPointerLock ||
  28779. canvas.mozRequestPointerLock ||
  28780. canvas.webkitRequestPointerLock;
  28781. if (canvas.requestPointerLock) {
  28782. canvas.requestPointerLock();
  28783. }
  28784. }
  28785. };
  28786. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  28787. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  28788. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  28789. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  28790. // Pointer lock
  28791. this._onPointerLockChange = function () {
  28792. _this.isPointerLock = (anyDoc_1.mozPointerLockElement === canvas ||
  28793. anyDoc_1.webkitPointerLockElement === canvas ||
  28794. anyDoc_1.msPointerLockElement === canvas ||
  28795. anyDoc_1.pointerLockElement === canvas);
  28796. };
  28797. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  28798. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  28799. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  28800. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  28801. this._onVRDisplayPointerRestricted = function () {
  28802. if (canvas) {
  28803. canvas.requestPointerLock();
  28804. }
  28805. };
  28806. this._onVRDisplayPointerUnrestricted = function () {
  28807. if (!anyDoc_1.exitPointerLock) {
  28808. return;
  28809. }
  28810. anyDoc_1.exitPointerLock();
  28811. };
  28812. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  28813. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  28814. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  28815. }
  28816. }
  28817. // Create Audio Engine if needed.
  28818. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  28819. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  28820. }
  28821. // Prepare buffer pointers
  28822. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  28823. this._currentBufferPointers[i] = new BufferPointer();
  28824. }
  28825. // Load WebVR Devices
  28826. if (options.autoEnableWebVR) {
  28827. this.initWebVR();
  28828. }
  28829. // Detect if we are running on a faulty buggy OS.
  28830. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  28831. // Detect if we are running on a faulty buggy desktop OS.
  28832. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  28833. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  28834. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  28835. }
  28836. Object.defineProperty(Engine, "Instances", {
  28837. /** Gets the list of created engines */
  28838. get: function () {
  28839. return _engineStore__WEBPACK_IMPORTED_MODULE_15__["EngineStore"].Instances;
  28840. },
  28841. enumerable: true,
  28842. configurable: true
  28843. });
  28844. Object.defineProperty(Engine, "LastCreatedEngine", {
  28845. /**
  28846. * Gets the latest created engine
  28847. */
  28848. get: function () {
  28849. return _engineStore__WEBPACK_IMPORTED_MODULE_15__["EngineStore"].LastCreatedEngine;
  28850. },
  28851. enumerable: true,
  28852. configurable: true
  28853. });
  28854. Object.defineProperty(Engine, "LastCreatedScene", {
  28855. /**
  28856. * Gets the latest created scene
  28857. */
  28858. get: function () {
  28859. return _engineStore__WEBPACK_IMPORTED_MODULE_15__["EngineStore"].LastCreatedScene;
  28860. },
  28861. enumerable: true,
  28862. configurable: true
  28863. });
  28864. /**
  28865. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28866. * @param flag defines which part of the materials must be marked as dirty
  28867. * @param predicate defines a predicate used to filter which materials should be affected
  28868. */
  28869. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  28870. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  28871. var engine = Engine.Instances[engineIndex];
  28872. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  28873. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  28874. }
  28875. }
  28876. };
  28877. Object.defineProperty(Engine, "NpmPackage", {
  28878. /**
  28879. * Returns the current npm package of the sdk
  28880. */
  28881. // Not mixed with Version for tooling purpose.
  28882. get: function () {
  28883. return "babylonjs@4.0.0-beta.3";
  28884. },
  28885. enumerable: true,
  28886. configurable: true
  28887. });
  28888. Object.defineProperty(Engine, "Version", {
  28889. /**
  28890. * Returns the current version of the framework
  28891. */
  28892. get: function () {
  28893. return "4.0.0-beta.3";
  28894. },
  28895. enumerable: true,
  28896. configurable: true
  28897. });
  28898. Object.defineProperty(Engine.prototype, "description", {
  28899. /**
  28900. * Returns a string describing the current engine
  28901. */
  28902. get: function () {
  28903. var description = "WebGL" + this.webGLVersion;
  28904. if (this._caps.parallelShaderCompile) {
  28905. description += " - Parallel shader compilation";
  28906. }
  28907. return description;
  28908. },
  28909. enumerable: true,
  28910. configurable: true
  28911. });
  28912. Object.defineProperty(Engine, "ShadersRepository", {
  28913. /**
  28914. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28915. */
  28916. get: function () {
  28917. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  28918. },
  28919. set: function (value) {
  28920. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  28921. },
  28922. enumerable: true,
  28923. configurable: true
  28924. });
  28925. /**
  28926. * Method called to create the default loading screen.
  28927. * This can be overriden in your own app.
  28928. * @param canvas The rendering canvas element
  28929. * @returns The loading screen
  28930. */
  28931. Engine.DefaultLoadingScreenFactory = function (canvas) {
  28932. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_17__["_DevTools"].WarnImport("LoadingScreen");
  28933. };
  28934. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  28935. /**
  28936. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28937. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28938. */
  28939. get: function () {
  28940. return this._vrExclusivePointerMode;
  28941. },
  28942. enumerable: true,
  28943. configurable: true
  28944. });
  28945. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  28946. /**
  28947. * Gets a boolean indicating that the engine supports uniform buffers
  28948. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28949. */
  28950. get: function () {
  28951. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  28952. },
  28953. enumerable: true,
  28954. configurable: true
  28955. });
  28956. Object.defineProperty(Engine.prototype, "_shouldUseHighPrecisionShader", {
  28957. /** @hidden */
  28958. get: function () {
  28959. return this._caps.highPrecisionShaderSupported && this._highPrecisionShadersAllowed;
  28960. },
  28961. enumerable: true,
  28962. configurable: true
  28963. });
  28964. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  28965. /**
  28966. * Gets a boolean indicating that only power of 2 textures are supported
  28967. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28968. */
  28969. get: function () {
  28970. return this._webGLVersion < 2 || this.forcePOTTextures;
  28971. },
  28972. enumerable: true,
  28973. configurable: true
  28974. });
  28975. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  28976. /**
  28977. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28978. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28979. */
  28980. get: function () {
  28981. return this._doNotHandleContextLost;
  28982. },
  28983. set: function (value) {
  28984. this._doNotHandleContextLost = value;
  28985. },
  28986. enumerable: true,
  28987. configurable: true
  28988. });
  28989. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  28990. /**
  28991. * Gets the performance monitor attached to this engine
  28992. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28993. */
  28994. get: function () {
  28995. return this._performanceMonitor;
  28996. },
  28997. enumerable: true,
  28998. configurable: true
  28999. });
  29000. Object.defineProperty(Engine.prototype, "texturesSupported", {
  29001. /**
  29002. * Gets the list of texture formats supported
  29003. */
  29004. get: function () {
  29005. return this._texturesSupported;
  29006. },
  29007. enumerable: true,
  29008. configurable: true
  29009. });
  29010. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  29011. /**
  29012. * Gets the list of texture formats in use
  29013. */
  29014. get: function () {
  29015. return this._textureFormatInUse;
  29016. },
  29017. enumerable: true,
  29018. configurable: true
  29019. });
  29020. Object.defineProperty(Engine.prototype, "currentViewport", {
  29021. /**
  29022. * Gets the current viewport
  29023. */
  29024. get: function () {
  29025. return this._cachedViewport;
  29026. },
  29027. enumerable: true,
  29028. configurable: true
  29029. });
  29030. Object.defineProperty(Engine.prototype, "emptyTexture", {
  29031. /**
  29032. * Gets the default empty texture
  29033. */
  29034. get: function () {
  29035. if (!this._emptyTexture) {
  29036. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  29037. }
  29038. return this._emptyTexture;
  29039. },
  29040. enumerable: true,
  29041. configurable: true
  29042. });
  29043. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  29044. /**
  29045. * Gets the default empty 3D texture
  29046. */
  29047. get: function () {
  29048. if (!this._emptyTexture3D) {
  29049. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  29050. }
  29051. return this._emptyTexture3D;
  29052. },
  29053. enumerable: true,
  29054. configurable: true
  29055. });
  29056. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  29057. /**
  29058. * Gets the default empty cube texture
  29059. */
  29060. get: function () {
  29061. if (!this._emptyCubeTexture) {
  29062. var faceData = new Uint8Array(4);
  29063. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  29064. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  29065. }
  29066. return this._emptyCubeTexture;
  29067. },
  29068. enumerable: true,
  29069. configurable: true
  29070. });
  29071. Engine.prototype._disableTouchAction = function () {
  29072. if (!this._renderingCanvas) {
  29073. return;
  29074. }
  29075. this._renderingCanvas.setAttribute("touch-action", "none");
  29076. this._renderingCanvas.style.touchAction = "none";
  29077. this._renderingCanvas.style.msTouchAction = "none";
  29078. };
  29079. Engine.prototype._rebuildInternalTextures = function () {
  29080. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  29081. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  29082. var internalTexture = currentState_1[_i];
  29083. internalTexture._rebuild();
  29084. }
  29085. };
  29086. Engine.prototype._rebuildEffects = function () {
  29087. for (var key in this._compiledEffects) {
  29088. var effect = this._compiledEffects[key];
  29089. effect._prepareEffect();
  29090. }
  29091. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  29092. };
  29093. /**
  29094. * Gets a boolean indicating if all created effects are ready
  29095. * @returns true if all effects are ready
  29096. */
  29097. Engine.prototype.areAllEffectsReady = function () {
  29098. for (var key in this._compiledEffects) {
  29099. var effect = this._compiledEffects[key];
  29100. if (!effect.isReady()) {
  29101. return false;
  29102. }
  29103. }
  29104. return true;
  29105. };
  29106. Engine.prototype._rebuildBuffers = function () {
  29107. // Index / Vertex
  29108. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  29109. var scene = _a[_i];
  29110. scene.resetCachedMaterial();
  29111. scene._rebuildGeometries();
  29112. scene._rebuildTextures();
  29113. }
  29114. // Uniforms
  29115. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  29116. var uniformBuffer = _c[_b];
  29117. uniformBuffer._rebuild();
  29118. }
  29119. };
  29120. Engine.prototype._initGLContext = function () {
  29121. // Caps
  29122. this._caps = new EngineCapabilities();
  29123. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  29124. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  29125. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  29126. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  29127. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  29128. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  29129. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  29130. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  29131. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  29132. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  29133. // Infos
  29134. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  29135. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  29136. if (rendererInfo != null) {
  29137. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  29138. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  29139. }
  29140. if (!this._glVendor) {
  29141. this._glVendor = "Unknown vendor";
  29142. }
  29143. if (!this._glRenderer) {
  29144. this._glRenderer = "Unknown renderer";
  29145. }
  29146. // Constants
  29147. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  29148. if (this._gl.RGBA16F !== 0x881A) {
  29149. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  29150. }
  29151. if (this._gl.RGBA32F !== 0x8814) {
  29152. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  29153. }
  29154. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  29155. this._gl.DEPTH24_STENCIL8 = 35056;
  29156. }
  29157. // Extensions
  29158. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  29159. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  29160. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  29161. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  29162. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  29163. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  29164. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  29165. this._caps.textureAnisotropicFilterExtension = this._gl.getExtension('EXT_texture_filter_anisotropic') || this._gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic') || this._gl.getExtension('MOZ_EXT_texture_filter_anisotropic');
  29166. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  29167. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  29168. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  29169. this._caps.highPrecisionShaderSupported = false;
  29170. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  29171. if (this._caps.timerQuery) {
  29172. if (this._webGLVersion === 1) {
  29173. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  29174. }
  29175. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  29176. }
  29177. // Checks if some of the format renders first to allow the use of webgl inspector.
  29178. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  29179. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  29180. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  29181. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  29182. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  29183. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  29184. if (this._webGLVersion > 1) {
  29185. this._gl.HALF_FLOAT_OES = 0x140B;
  29186. }
  29187. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  29188. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  29189. this._caps.multiview = this._gl.getExtension('WEBGL_multiview');
  29190. // Draw buffers
  29191. if (this._webGLVersion > 1) {
  29192. this._caps.drawBuffersExtension = true;
  29193. }
  29194. else {
  29195. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  29196. if (drawBuffersExtension !== null) {
  29197. this._caps.drawBuffersExtension = true;
  29198. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  29199. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  29200. for (var i = 0; i < 16; i++) {
  29201. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  29202. }
  29203. }
  29204. else {
  29205. this._caps.drawBuffersExtension = false;
  29206. }
  29207. }
  29208. // Shader compiler threads
  29209. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  29210. // Depth Texture
  29211. if (this._webGLVersion > 1) {
  29212. this._caps.depthTextureExtension = true;
  29213. }
  29214. else {
  29215. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  29216. if (depthTextureExtension != null) {
  29217. this._caps.depthTextureExtension = true;
  29218. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  29219. }
  29220. }
  29221. // Vertex array object
  29222. if (this.disableVertexArrayObjects) {
  29223. this._caps.vertexArrayObject = false;
  29224. }
  29225. else if (this._webGLVersion > 1) {
  29226. this._caps.vertexArrayObject = true;
  29227. }
  29228. else {
  29229. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  29230. if (vertexArrayObjectExtension != null) {
  29231. this._caps.vertexArrayObject = true;
  29232. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  29233. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  29234. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  29235. }
  29236. else {
  29237. this._caps.vertexArrayObject = false;
  29238. }
  29239. }
  29240. // Instances count
  29241. if (this._webGLVersion > 1) {
  29242. this._caps.instancedArrays = true;
  29243. }
  29244. else {
  29245. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  29246. if (instanceExtension != null) {
  29247. this._caps.instancedArrays = true;
  29248. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  29249. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  29250. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  29251. }
  29252. else {
  29253. this._caps.instancedArrays = false;
  29254. }
  29255. }
  29256. // Intelligently add supported compressed formats in order to check for.
  29257. // Check for ASTC support first as it is most powerful and to be very cross platform.
  29258. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  29259. // Likely no hardware which supports both PVR & DXT, so order matters little.
  29260. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  29261. if (this._caps.astc) {
  29262. this.texturesSupported.push('-astc.ktx');
  29263. }
  29264. if (this._caps.s3tc) {
  29265. this.texturesSupported.push('-dxt.ktx');
  29266. }
  29267. if (this._caps.pvrtc) {
  29268. this.texturesSupported.push('-pvrtc.ktx');
  29269. }
  29270. if (this._caps.etc2) {
  29271. this.texturesSupported.push('-etc2.ktx');
  29272. }
  29273. if (this._caps.etc1) {
  29274. this.texturesSupported.push('-etc1.ktx');
  29275. }
  29276. if (this._gl.getShaderPrecisionFormat) {
  29277. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  29278. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  29279. if (vertex_highp && fragment_highp) {
  29280. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  29281. }
  29282. }
  29283. // Depth buffer
  29284. this.setDepthBuffer(true);
  29285. this.setDepthFunctionToLessOrEqual();
  29286. this.setDepthWrite(true);
  29287. // Texture maps
  29288. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  29289. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  29290. this._nextFreeTextureSlots.push(slot);
  29291. }
  29292. };
  29293. Object.defineProperty(Engine.prototype, "webGLVersion", {
  29294. /**
  29295. * Gets version of the current webGL context
  29296. */
  29297. get: function () {
  29298. return this._webGLVersion;
  29299. },
  29300. enumerable: true,
  29301. configurable: true
  29302. });
  29303. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  29304. /**
  29305. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29306. */
  29307. get: function () {
  29308. return this._isStencilEnable;
  29309. },
  29310. enumerable: true,
  29311. configurable: true
  29312. });
  29313. Engine.prototype._prepareWorkingCanvas = function () {
  29314. if (this._workingCanvas) {
  29315. return;
  29316. }
  29317. this._workingCanvas = document.createElement("canvas");
  29318. var context = this._workingCanvas.getContext("2d");
  29319. if (context) {
  29320. this._workingContext = context;
  29321. }
  29322. };
  29323. /**
  29324. * Reset the texture cache to empty state
  29325. */
  29326. Engine.prototype.resetTextureCache = function () {
  29327. for (var key in this._boundTexturesCache) {
  29328. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  29329. continue;
  29330. }
  29331. this._boundTexturesCache[key] = null;
  29332. }
  29333. this._currentTextureChannel = -1;
  29334. };
  29335. /**
  29336. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  29337. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29338. * @returns true if engine is in deterministic lock step mode
  29339. */
  29340. Engine.prototype.isDeterministicLockStep = function () {
  29341. return this._deterministicLockstep;
  29342. };
  29343. /**
  29344. * Gets the max steps when engine is running in deterministic lock step
  29345. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29346. * @returns the max steps
  29347. */
  29348. Engine.prototype.getLockstepMaxSteps = function () {
  29349. return this._lockstepMaxSteps;
  29350. };
  29351. /**
  29352. * Gets an object containing information about the current webGL context
  29353. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29354. */
  29355. Engine.prototype.getGlInfo = function () {
  29356. return {
  29357. vendor: this._glVendor,
  29358. renderer: this._glRenderer,
  29359. version: this._glVersion
  29360. };
  29361. };
  29362. /**
  29363. * Gets current aspect ratio
  29364. * @param camera defines the camera to use to get the aspect ratio
  29365. * @param useScreen defines if screen size must be used (or the current render target if any)
  29366. * @returns a number defining the aspect ratio
  29367. */
  29368. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  29369. if (useScreen === void 0) { useScreen = false; }
  29370. var viewport = camera.viewport;
  29371. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  29372. };
  29373. /**
  29374. * Gets current screen aspect ratio
  29375. * @returns a number defining the aspect ratio
  29376. */
  29377. Engine.prototype.getScreenAspectRatio = function () {
  29378. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  29379. };
  29380. /**
  29381. * Gets the current render width
  29382. * @param useScreen defines if screen size must be used (or the current render target if any)
  29383. * @returns a number defining the current render width
  29384. */
  29385. Engine.prototype.getRenderWidth = function (useScreen) {
  29386. if (useScreen === void 0) { useScreen = false; }
  29387. if (!useScreen && this._currentRenderTarget) {
  29388. return this._currentRenderTarget.width;
  29389. }
  29390. return this._gl.drawingBufferWidth;
  29391. };
  29392. /**
  29393. * Gets the current render height
  29394. * @param useScreen defines if screen size must be used (or the current render target if any)
  29395. * @returns a number defining the current render height
  29396. */
  29397. Engine.prototype.getRenderHeight = function (useScreen) {
  29398. if (useScreen === void 0) { useScreen = false; }
  29399. if (!useScreen && this._currentRenderTarget) {
  29400. return this._currentRenderTarget.height;
  29401. }
  29402. return this._gl.drawingBufferHeight;
  29403. };
  29404. /**
  29405. * Gets the HTML canvas attached with the current webGL context
  29406. * @returns a HTML canvas
  29407. */
  29408. Engine.prototype.getRenderingCanvas = function () {
  29409. return this._renderingCanvas;
  29410. };
  29411. /**
  29412. * Gets the client rect of the HTML canvas attached with the current webGL context
  29413. * @returns a client rectanglee
  29414. */
  29415. Engine.prototype.getRenderingCanvasClientRect = function () {
  29416. if (!this._renderingCanvas) {
  29417. return null;
  29418. }
  29419. return this._renderingCanvas.getBoundingClientRect();
  29420. };
  29421. /**
  29422. * Defines the hardware scaling level.
  29423. * By default the hardware scaling level is computed from the window device ratio.
  29424. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  29425. * @param level defines the level to use
  29426. */
  29427. Engine.prototype.setHardwareScalingLevel = function (level) {
  29428. this._hardwareScalingLevel = level;
  29429. this.resize();
  29430. };
  29431. /**
  29432. * Gets the current hardware scaling level.
  29433. * By default the hardware scaling level is computed from the window device ratio.
  29434. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  29435. * @returns a number indicating the current hardware scaling level
  29436. */
  29437. Engine.prototype.getHardwareScalingLevel = function () {
  29438. return this._hardwareScalingLevel;
  29439. };
  29440. /**
  29441. * Gets the list of loaded textures
  29442. * @returns an array containing all loaded textures
  29443. */
  29444. Engine.prototype.getLoadedTexturesCache = function () {
  29445. return this._internalTexturesCache;
  29446. };
  29447. /**
  29448. * Gets the object containing all engine capabilities
  29449. * @returns the EngineCapabilities object
  29450. */
  29451. Engine.prototype.getCaps = function () {
  29452. return this._caps;
  29453. };
  29454. /**
  29455. * Gets the current depth function
  29456. * @returns a number defining the depth function
  29457. */
  29458. Engine.prototype.getDepthFunction = function () {
  29459. return this._depthCullingState.depthFunc;
  29460. };
  29461. /**
  29462. * Sets the current depth function
  29463. * @param depthFunc defines the function to use
  29464. */
  29465. Engine.prototype.setDepthFunction = function (depthFunc) {
  29466. this._depthCullingState.depthFunc = depthFunc;
  29467. };
  29468. /**
  29469. * Sets the current depth function to GREATER
  29470. */
  29471. Engine.prototype.setDepthFunctionToGreater = function () {
  29472. this._depthCullingState.depthFunc = this._gl.GREATER;
  29473. };
  29474. /**
  29475. * Sets the current depth function to GEQUAL
  29476. */
  29477. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  29478. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  29479. };
  29480. /**
  29481. * Sets the current depth function to LESS
  29482. */
  29483. Engine.prototype.setDepthFunctionToLess = function () {
  29484. this._depthCullingState.depthFunc = this._gl.LESS;
  29485. };
  29486. /**
  29487. * Caches the the state of the stencil buffer
  29488. */
  29489. Engine.prototype.cacheStencilState = function () {
  29490. this._cachedStencilBuffer = this.getStencilBuffer();
  29491. this._cachedStencilFunction = this.getStencilFunction();
  29492. this._cachedStencilMask = this.getStencilMask();
  29493. this._cachedStencilOperationPass = this.getStencilOperationPass();
  29494. this._cachedStencilOperationFail = this.getStencilOperationFail();
  29495. this._cachedStencilOperationDepthFail = this.getStencilOperationDepthFail();
  29496. this._cachedStencilReference = this.getStencilFunctionReference();
  29497. };
  29498. /**
  29499. * Restores the state of the stencil buffer
  29500. */
  29501. Engine.prototype.restoreStencilState = function () {
  29502. this.setStencilFunction(this._cachedStencilFunction);
  29503. this.setStencilMask(this._cachedStencilMask);
  29504. this.setStencilBuffer(this._cachedStencilBuffer);
  29505. this.setStencilOperationPass(this._cachedStencilOperationPass);
  29506. this.setStencilOperationFail(this._cachedStencilOperationFail);
  29507. this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail);
  29508. this.setStencilFunctionReference(this._cachedStencilReference);
  29509. };
  29510. /**
  29511. * Sets the current depth function to LEQUAL
  29512. */
  29513. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  29514. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  29515. };
  29516. /**
  29517. * Gets a boolean indicating if stencil buffer is enabled
  29518. * @returns the current stencil buffer state
  29519. */
  29520. Engine.prototype.getStencilBuffer = function () {
  29521. return this._stencilState.stencilTest;
  29522. };
  29523. /**
  29524. * Enable or disable the stencil buffer
  29525. * @param enable defines if the stencil buffer must be enabled or disabled
  29526. */
  29527. Engine.prototype.setStencilBuffer = function (enable) {
  29528. this._stencilState.stencilTest = enable;
  29529. };
  29530. /**
  29531. * Gets the current stencil mask
  29532. * @returns a number defining the new stencil mask to use
  29533. */
  29534. Engine.prototype.getStencilMask = function () {
  29535. return this._stencilState.stencilMask;
  29536. };
  29537. /**
  29538. * Sets the current stencil mask
  29539. * @param mask defines the new stencil mask to use
  29540. */
  29541. Engine.prototype.setStencilMask = function (mask) {
  29542. this._stencilState.stencilMask = mask;
  29543. };
  29544. /**
  29545. * Gets the current stencil function
  29546. * @returns a number defining the stencil function to use
  29547. */
  29548. Engine.prototype.getStencilFunction = function () {
  29549. return this._stencilState.stencilFunc;
  29550. };
  29551. /**
  29552. * Gets the current stencil reference value
  29553. * @returns a number defining the stencil reference value to use
  29554. */
  29555. Engine.prototype.getStencilFunctionReference = function () {
  29556. return this._stencilState.stencilFuncRef;
  29557. };
  29558. /**
  29559. * Gets the current stencil mask
  29560. * @returns a number defining the stencil mask to use
  29561. */
  29562. Engine.prototype.getStencilFunctionMask = function () {
  29563. return this._stencilState.stencilFuncMask;
  29564. };
  29565. /**
  29566. * Sets the current stencil function
  29567. * @param stencilFunc defines the new stencil function to use
  29568. */
  29569. Engine.prototype.setStencilFunction = function (stencilFunc) {
  29570. this._stencilState.stencilFunc = stencilFunc;
  29571. };
  29572. /**
  29573. * Sets the current stencil reference
  29574. * @param reference defines the new stencil reference to use
  29575. */
  29576. Engine.prototype.setStencilFunctionReference = function (reference) {
  29577. this._stencilState.stencilFuncRef = reference;
  29578. };
  29579. /**
  29580. * Sets the current stencil mask
  29581. * @param mask defines the new stencil mask to use
  29582. */
  29583. Engine.prototype.setStencilFunctionMask = function (mask) {
  29584. this._stencilState.stencilFuncMask = mask;
  29585. };
  29586. /**
  29587. * Gets the current stencil operation when stencil fails
  29588. * @returns a number defining stencil operation to use when stencil fails
  29589. */
  29590. Engine.prototype.getStencilOperationFail = function () {
  29591. return this._stencilState.stencilOpStencilFail;
  29592. };
  29593. /**
  29594. * Gets the current stencil operation when depth fails
  29595. * @returns a number defining stencil operation to use when depth fails
  29596. */
  29597. Engine.prototype.getStencilOperationDepthFail = function () {
  29598. return this._stencilState.stencilOpDepthFail;
  29599. };
  29600. /**
  29601. * Gets the current stencil operation when stencil passes
  29602. * @returns a number defining stencil operation to use when stencil passes
  29603. */
  29604. Engine.prototype.getStencilOperationPass = function () {
  29605. return this._stencilState.stencilOpStencilDepthPass;
  29606. };
  29607. /**
  29608. * Sets the stencil operation to use when stencil fails
  29609. * @param operation defines the stencil operation to use when stencil fails
  29610. */
  29611. Engine.prototype.setStencilOperationFail = function (operation) {
  29612. this._stencilState.stencilOpStencilFail = operation;
  29613. };
  29614. /**
  29615. * Sets the stencil operation to use when depth fails
  29616. * @param operation defines the stencil operation to use when depth fails
  29617. */
  29618. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  29619. this._stencilState.stencilOpDepthFail = operation;
  29620. };
  29621. /**
  29622. * Sets the stencil operation to use when stencil passes
  29623. * @param operation defines the stencil operation to use when stencil passes
  29624. */
  29625. Engine.prototype.setStencilOperationPass = function (operation) {
  29626. this._stencilState.stencilOpStencilDepthPass = operation;
  29627. };
  29628. /**
  29629. * Sets a boolean indicating if the dithering state is enabled or disabled
  29630. * @param value defines the dithering state
  29631. */
  29632. Engine.prototype.setDitheringState = function (value) {
  29633. if (value) {
  29634. this._gl.enable(this._gl.DITHER);
  29635. }
  29636. else {
  29637. this._gl.disable(this._gl.DITHER);
  29638. }
  29639. };
  29640. /**
  29641. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29642. * @param value defines the rasterizer state
  29643. */
  29644. Engine.prototype.setRasterizerState = function (value) {
  29645. if (value) {
  29646. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  29647. }
  29648. else {
  29649. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  29650. }
  29651. };
  29652. /**
  29653. * stop executing a render loop function and remove it from the execution array
  29654. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29655. */
  29656. Engine.prototype.stopRenderLoop = function (renderFunction) {
  29657. if (!renderFunction) {
  29658. this._activeRenderLoops = [];
  29659. return;
  29660. }
  29661. var index = this._activeRenderLoops.indexOf(renderFunction);
  29662. if (index >= 0) {
  29663. this._activeRenderLoops.splice(index, 1);
  29664. }
  29665. };
  29666. /** @hidden */
  29667. Engine.prototype._renderLoop = function () {
  29668. if (!this._contextWasLost) {
  29669. var shouldRender = true;
  29670. if (!this.renderEvenInBackground && this._windowIsBackground) {
  29671. shouldRender = false;
  29672. }
  29673. if (shouldRender) {
  29674. // Start new frame
  29675. this.beginFrame();
  29676. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  29677. var renderFunction = this._activeRenderLoops[index];
  29678. renderFunction();
  29679. }
  29680. // Present
  29681. this.endFrame();
  29682. }
  29683. }
  29684. if (this._activeRenderLoops.length > 0) {
  29685. // Register new frame
  29686. if (this.customAnimationFrameRequester) {
  29687. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  29688. this._frameHandler = this.customAnimationFrameRequester.requestID;
  29689. }
  29690. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29691. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  29692. }
  29693. else {
  29694. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  29695. }
  29696. }
  29697. else {
  29698. this._renderingQueueLaunched = false;
  29699. }
  29700. };
  29701. /**
  29702. * Register and execute a render loop. The engine can have more than one render function
  29703. * @param renderFunction defines the function to continuously execute
  29704. */
  29705. Engine.prototype.runRenderLoop = function (renderFunction) {
  29706. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  29707. return;
  29708. }
  29709. this._activeRenderLoops.push(renderFunction);
  29710. if (!this._renderingQueueLaunched) {
  29711. this._renderingQueueLaunched = true;
  29712. this._bindedRenderFunction = this._renderLoop.bind(this);
  29713. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  29714. }
  29715. };
  29716. /**
  29717. * Toggle full screen mode
  29718. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29719. */
  29720. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  29721. if (this.isFullscreen) {
  29722. this.exitFullscreen();
  29723. }
  29724. else {
  29725. this.enterFullscreen(requestPointerLock);
  29726. }
  29727. };
  29728. /**
  29729. * Enters full screen mode
  29730. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29731. */
  29732. Engine.prototype.enterFullscreen = function (requestPointerLock) {
  29733. if (!this.isFullscreen) {
  29734. this._pointerLockRequested = requestPointerLock;
  29735. if (this._renderingCanvas) {
  29736. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  29737. }
  29738. }
  29739. };
  29740. /**
  29741. * Exits full screen mode
  29742. */
  29743. Engine.prototype.exitFullscreen = function () {
  29744. if (this.isFullscreen) {
  29745. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  29746. }
  29747. };
  29748. /**
  29749. * Clear the current render buffer or the current render target (if any is set up)
  29750. * @param color defines the color to use
  29751. * @param backBuffer defines if the back buffer must be cleared
  29752. * @param depth defines if the depth buffer must be cleared
  29753. * @param stencil defines if the stencil buffer must be cleared
  29754. */
  29755. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  29756. if (stencil === void 0) { stencil = false; }
  29757. this.applyStates();
  29758. var mode = 0;
  29759. if (backBuffer && color) {
  29760. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  29761. mode |= this._gl.COLOR_BUFFER_BIT;
  29762. }
  29763. if (depth) {
  29764. this._gl.clearDepth(1.0);
  29765. mode |= this._gl.DEPTH_BUFFER_BIT;
  29766. }
  29767. if (stencil) {
  29768. this._gl.clearStencil(0);
  29769. mode |= this._gl.STENCIL_BUFFER_BIT;
  29770. }
  29771. this._gl.clear(mode);
  29772. };
  29773. /**
  29774. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29775. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29776. * @param y defines the y-coordinate of the corner of the clear rectangle
  29777. * @param width defines the width of the clear rectangle
  29778. * @param height defines the height of the clear rectangle
  29779. * @param clearColor defines the clear color
  29780. */
  29781. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  29782. this.enableScissor(x, y, width, height);
  29783. this.clear(clearColor, true, true, true);
  29784. this.disableScissor();
  29785. };
  29786. /**
  29787. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29788. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29789. * @param y defines the y-coordinate of the corner of the clear rectangle
  29790. * @param width defines the width of the clear rectangle
  29791. * @param height defines the height of the clear rectangle
  29792. */
  29793. Engine.prototype.enableScissor = function (x, y, width, height) {
  29794. var gl = this._gl;
  29795. // Change state
  29796. gl.enable(gl.SCISSOR_TEST);
  29797. gl.scissor(x, y, width, height);
  29798. };
  29799. /**
  29800. * Disable previously set scissor test rectangle
  29801. */
  29802. Engine.prototype.disableScissor = function () {
  29803. var gl = this._gl;
  29804. gl.disable(gl.SCISSOR_TEST);
  29805. };
  29806. /** @hidden */
  29807. Engine.prototype._viewport = function (x, y, width, height) {
  29808. if (x !== this._viewportCached.x ||
  29809. y !== this._viewportCached.y ||
  29810. width !== this._viewportCached.z ||
  29811. height !== this._viewportCached.w) {
  29812. this._viewportCached.x = x;
  29813. this._viewportCached.y = y;
  29814. this._viewportCached.z = width;
  29815. this._viewportCached.w = height;
  29816. this._gl.viewport(x, y, width, height);
  29817. }
  29818. };
  29819. /**
  29820. * Set the WebGL's viewport
  29821. * @param viewport defines the viewport element to be used
  29822. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29823. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29824. */
  29825. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  29826. var width = requiredWidth || this.getRenderWidth();
  29827. var height = requiredHeight || this.getRenderHeight();
  29828. var x = viewport.x || 0;
  29829. var y = viewport.y || 0;
  29830. this._cachedViewport = viewport;
  29831. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  29832. };
  29833. /**
  29834. * Directly set the WebGL Viewport
  29835. * @param x defines the x coordinate of the viewport (in screen space)
  29836. * @param y defines the y coordinate of the viewport (in screen space)
  29837. * @param width defines the width of the viewport (in screen space)
  29838. * @param height defines the height of the viewport (in screen space)
  29839. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state
  29840. */
  29841. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  29842. var currentViewport = this._cachedViewport;
  29843. this._cachedViewport = null;
  29844. this._viewport(x, y, width, height);
  29845. return currentViewport;
  29846. };
  29847. /**
  29848. * Begin a new frame
  29849. */
  29850. Engine.prototype.beginFrame = function () {
  29851. this.onBeginFrameObservable.notifyObservers(this);
  29852. this._measureFps();
  29853. };
  29854. /**
  29855. * Enf the current frame
  29856. */
  29857. Engine.prototype.endFrame = function () {
  29858. // Force a flush in case we are using a bad OS.
  29859. if (this._badOS) {
  29860. this.flushFramebuffer();
  29861. }
  29862. // Submit frame to the vr device, if enabled
  29863. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29864. // TODO: We should only submit the frame if we read frameData successfully.
  29865. try {
  29866. this._vrDisplay.submitFrame();
  29867. }
  29868. catch (e) {
  29869. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].Warn("webVR submitFrame has had an unexpected failure: " + e);
  29870. }
  29871. }
  29872. this.onEndFrameObservable.notifyObservers(this);
  29873. };
  29874. /**
  29875. * Resize the view according to the canvas' size
  29876. */
  29877. Engine.prototype.resize = function () {
  29878. // We're not resizing the size of the canvas while in VR mode & presenting
  29879. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  29880. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  29881. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  29882. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  29883. }
  29884. };
  29885. /**
  29886. * Force a specific size of the canvas
  29887. * @param width defines the new canvas' width
  29888. * @param height defines the new canvas' height
  29889. */
  29890. Engine.prototype.setSize = function (width, height) {
  29891. if (!this._renderingCanvas) {
  29892. return;
  29893. }
  29894. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  29895. return;
  29896. }
  29897. this._renderingCanvas.width = width;
  29898. this._renderingCanvas.height = height;
  29899. for (var index = 0; index < this.scenes.length; index++) {
  29900. var scene = this.scenes[index];
  29901. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  29902. var cam = scene.cameras[camIndex];
  29903. cam._currentRenderId = 0;
  29904. }
  29905. }
  29906. if (this.onResizeObservable.hasObservers) {
  29907. this.onResizeObservable.notifyObservers(this);
  29908. }
  29909. };
  29910. // WebVR functions
  29911. /**
  29912. * Gets a boolean indicating if a webVR device was detected
  29913. * @returns true if a webVR device was detected
  29914. */
  29915. Engine.prototype.isVRDevicePresent = function () {
  29916. return !!this._vrDisplay;
  29917. };
  29918. /**
  29919. * Gets the current webVR device
  29920. * @returns the current webVR device (or null)
  29921. */
  29922. Engine.prototype.getVRDevice = function () {
  29923. return this._vrDisplay;
  29924. };
  29925. /**
  29926. * Initializes a webVR display and starts listening to display change events
  29927. * The onVRDisplayChangedObservable will be notified upon these changes
  29928. * @returns The onVRDisplayChangedObservable
  29929. */
  29930. Engine.prototype.initWebVR = function () {
  29931. this.initWebVRAsync();
  29932. return this.onVRDisplayChangedObservable;
  29933. };
  29934. /**
  29935. * Initializes a webVR display and starts listening to display change events
  29936. * The onVRDisplayChangedObservable will be notified upon these changes
  29937. * @returns A promise containing a VRDisplay and if vr is supported
  29938. */
  29939. Engine.prototype.initWebVRAsync = function () {
  29940. var _this = this;
  29941. var notifyObservers = function () {
  29942. var eventArgs = {
  29943. vrDisplay: _this._vrDisplay,
  29944. vrSupported: _this._vrSupported
  29945. };
  29946. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  29947. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  29948. };
  29949. if (!this._onVrDisplayConnect) {
  29950. this._onVrDisplayConnect = function (event) {
  29951. _this._vrDisplay = event.display;
  29952. notifyObservers();
  29953. };
  29954. this._onVrDisplayDisconnect = function () {
  29955. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  29956. _this._vrDisplay = undefined;
  29957. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  29958. notifyObservers();
  29959. };
  29960. this._onVrDisplayPresentChange = function () {
  29961. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  29962. };
  29963. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  29964. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  29965. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  29966. }
  29967. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  29968. this._webVRInitPromise.then(notifyObservers);
  29969. return this._webVRInitPromise;
  29970. };
  29971. /**
  29972. * Call this function to switch to webVR mode
  29973. * Will do nothing if webVR is not supported or if there is no webVR device
  29974. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29975. */
  29976. Engine.prototype.enableVR = function () {
  29977. var _this = this;
  29978. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  29979. var onResolved = function () {
  29980. _this.onVRRequestPresentComplete.notifyObservers(true);
  29981. _this._onVRFullScreenTriggered();
  29982. };
  29983. var onRejected = function () {
  29984. _this.onVRRequestPresentComplete.notifyObservers(false);
  29985. };
  29986. this.onVRRequestPresentStart.notifyObservers(this);
  29987. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  29988. }
  29989. };
  29990. /**
  29991. * Call this function to leave webVR mode
  29992. * Will do nothing if webVR is not supported or if there is no webVR device
  29993. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29994. */
  29995. Engine.prototype.disableVR = function () {
  29996. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29997. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  29998. }
  29999. };
  30000. Engine.prototype._getVRDisplaysAsync = function () {
  30001. var _this = this;
  30002. return new Promise(function (res) {
  30003. if (navigator.getVRDisplays) {
  30004. navigator.getVRDisplays().then(function (devices) {
  30005. _this._vrSupported = true;
  30006. // note that devices may actually be an empty array. This is fine;
  30007. // we expect this._vrDisplay to be undefined in this case.
  30008. _this._vrDisplay = devices[0];
  30009. res({
  30010. vrDisplay: _this._vrDisplay,
  30011. vrSupported: _this._vrSupported
  30012. });
  30013. });
  30014. }
  30015. else {
  30016. _this._vrDisplay = undefined;
  30017. _this._vrSupported = false;
  30018. res({
  30019. vrDisplay: _this._vrDisplay,
  30020. vrSupported: _this._vrSupported
  30021. });
  30022. }
  30023. });
  30024. };
  30025. /**
  30026. * Binds the frame buffer to the specified texture.
  30027. * @param texture The texture to render to or null for the default canvas
  30028. * @param faceIndex The face of the texture to render to in case of cube texture
  30029. * @param requiredWidth The width of the target to render to
  30030. * @param requiredHeight The height of the target to render to
  30031. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30032. * @param depthStencilTexture The depth stencil texture to use to render
  30033. * @param lodLevel defines le lod level to bind to the frame buffer
  30034. */
  30035. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  30036. if (lodLevel === void 0) { lodLevel = 0; }
  30037. if (this._currentRenderTarget) {
  30038. this.unBindFramebuffer(this._currentRenderTarget);
  30039. }
  30040. this._currentRenderTarget = texture;
  30041. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  30042. var gl = this._gl;
  30043. if (texture.isCube) {
  30044. if (faceIndex === undefined) {
  30045. faceIndex = 0;
  30046. }
  30047. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  30048. if (depthStencilTexture) {
  30049. if (depthStencilTexture._generateStencilBuffer) {
  30050. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  30051. }
  30052. else {
  30053. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  30054. }
  30055. }
  30056. }
  30057. if (this._cachedViewport && !forceFullscreenViewport) {
  30058. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  30059. }
  30060. else {
  30061. if (!requiredWidth) {
  30062. requiredWidth = texture.width;
  30063. if (lodLevel) {
  30064. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  30065. }
  30066. }
  30067. if (!requiredHeight) {
  30068. requiredHeight = texture.height;
  30069. if (lodLevel) {
  30070. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  30071. }
  30072. }
  30073. this._viewport(0, 0, requiredWidth, requiredHeight);
  30074. }
  30075. this.wipeCaches();
  30076. };
  30077. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  30078. if (this._currentFramebuffer !== framebuffer) {
  30079. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  30080. this._currentFramebuffer = framebuffer;
  30081. }
  30082. };
  30083. /**
  30084. * Unbind the current render target texture from the webGL context
  30085. * @param texture defines the render target texture to unbind
  30086. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30087. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30088. */
  30089. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  30090. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  30091. this._currentRenderTarget = null;
  30092. // If MSAA, we need to bitblt back to main texture
  30093. var gl = this._gl;
  30094. if (texture._MSAAFramebuffer) {
  30095. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  30096. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  30097. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  30098. }
  30099. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  30100. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  30101. gl.generateMipmap(gl.TEXTURE_2D);
  30102. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30103. }
  30104. if (onBeforeUnbind) {
  30105. if (texture._MSAAFramebuffer) {
  30106. // Bind the correct framebuffer
  30107. this.bindUnboundFramebuffer(texture._framebuffer);
  30108. }
  30109. onBeforeUnbind();
  30110. }
  30111. this.bindUnboundFramebuffer(null);
  30112. };
  30113. /**
  30114. * Unbind a list of render target textures from the webGL context
  30115. * This is used only when drawBuffer extension or webGL2 are active
  30116. * @param textures defines the render target textures to unbind
  30117. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30118. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30119. */
  30120. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  30121. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  30122. this._currentRenderTarget = null;
  30123. // If MSAA, we need to bitblt back to main texture
  30124. var gl = this._gl;
  30125. if (textures[0]._MSAAFramebuffer) {
  30126. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  30127. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  30128. var attachments = textures[0]._attachments;
  30129. if (!attachments) {
  30130. attachments = new Array(textures.length);
  30131. textures[0]._attachments = attachments;
  30132. }
  30133. for (var i = 0; i < textures.length; i++) {
  30134. var texture = textures[i];
  30135. for (var j = 0; j < attachments.length; j++) {
  30136. attachments[j] = gl.NONE;
  30137. }
  30138. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  30139. gl.readBuffer(attachments[i]);
  30140. gl.drawBuffers(attachments);
  30141. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  30142. }
  30143. for (var i = 0; i < attachments.length; i++) {
  30144. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  30145. }
  30146. gl.drawBuffers(attachments);
  30147. }
  30148. for (var i = 0; i < textures.length; i++) {
  30149. var texture = textures[i];
  30150. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  30151. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  30152. gl.generateMipmap(gl.TEXTURE_2D);
  30153. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30154. }
  30155. }
  30156. if (onBeforeUnbind) {
  30157. if (textures[0]._MSAAFramebuffer) {
  30158. // Bind the correct framebuffer
  30159. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  30160. }
  30161. onBeforeUnbind();
  30162. }
  30163. this.bindUnboundFramebuffer(null);
  30164. };
  30165. /**
  30166. * Force the mipmap generation for the given render target texture
  30167. * @param texture defines the render target texture to use
  30168. */
  30169. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  30170. if (texture.generateMipMaps) {
  30171. var gl = this._gl;
  30172. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  30173. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  30174. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  30175. }
  30176. };
  30177. /**
  30178. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30179. */
  30180. Engine.prototype.flushFramebuffer = function () {
  30181. this._gl.flush();
  30182. };
  30183. /**
  30184. * Unbind the current render target and bind the default framebuffer
  30185. */
  30186. Engine.prototype.restoreDefaultFramebuffer = function () {
  30187. if (this._currentRenderTarget) {
  30188. this.unBindFramebuffer(this._currentRenderTarget);
  30189. }
  30190. else {
  30191. this.bindUnboundFramebuffer(null);
  30192. }
  30193. if (this._cachedViewport) {
  30194. this.setViewport(this._cachedViewport);
  30195. }
  30196. this.wipeCaches();
  30197. };
  30198. // UBOs
  30199. /**
  30200. * Create an uniform buffer
  30201. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30202. * @param elements defines the content of the uniform buffer
  30203. * @returns the webGL uniform buffer
  30204. */
  30205. Engine.prototype.createUniformBuffer = function (elements) {
  30206. var ubo = this._gl.createBuffer();
  30207. if (!ubo) {
  30208. throw new Error("Unable to create uniform buffer");
  30209. }
  30210. this.bindUniformBuffer(ubo);
  30211. if (elements instanceof Float32Array) {
  30212. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  30213. }
  30214. else {
  30215. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  30216. }
  30217. this.bindUniformBuffer(null);
  30218. ubo.references = 1;
  30219. return ubo;
  30220. };
  30221. /**
  30222. * Create a dynamic uniform buffer
  30223. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30224. * @param elements defines the content of the uniform buffer
  30225. * @returns the webGL uniform buffer
  30226. */
  30227. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  30228. var ubo = this._gl.createBuffer();
  30229. if (!ubo) {
  30230. throw new Error("Unable to create dynamic uniform buffer");
  30231. }
  30232. this.bindUniformBuffer(ubo);
  30233. if (elements instanceof Float32Array) {
  30234. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  30235. }
  30236. else {
  30237. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  30238. }
  30239. this.bindUniformBuffer(null);
  30240. ubo.references = 1;
  30241. return ubo;
  30242. };
  30243. /**
  30244. * Update an existing uniform buffer
  30245. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30246. * @param uniformBuffer defines the target uniform buffer
  30247. * @param elements defines the content to update
  30248. * @param offset defines the offset in the uniform buffer where update should start
  30249. * @param count defines the size of the data to update
  30250. */
  30251. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  30252. this.bindUniformBuffer(uniformBuffer);
  30253. if (offset === undefined) {
  30254. offset = 0;
  30255. }
  30256. if (count === undefined) {
  30257. if (elements instanceof Float32Array) {
  30258. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  30259. }
  30260. else {
  30261. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  30262. }
  30263. }
  30264. else {
  30265. if (elements instanceof Float32Array) {
  30266. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  30267. }
  30268. else {
  30269. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  30270. }
  30271. }
  30272. this.bindUniformBuffer(null);
  30273. };
  30274. // VBOs
  30275. Engine.prototype._resetVertexBufferBinding = function () {
  30276. this.bindArrayBuffer(null);
  30277. this._cachedVertexBuffers = null;
  30278. };
  30279. /**
  30280. * Creates a vertex buffer
  30281. * @param data the data for the vertex buffer
  30282. * @returns the new WebGL static buffer
  30283. */
  30284. Engine.prototype.createVertexBuffer = function (data) {
  30285. var vbo = this._gl.createBuffer();
  30286. if (!vbo) {
  30287. throw new Error("Unable to create vertex buffer");
  30288. }
  30289. this.bindArrayBuffer(vbo);
  30290. if (data instanceof Array) {
  30291. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  30292. }
  30293. else {
  30294. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  30295. }
  30296. this._resetVertexBufferBinding();
  30297. vbo.references = 1;
  30298. return vbo;
  30299. };
  30300. /**
  30301. * Creates a dynamic vertex buffer
  30302. * @param data the data for the dynamic vertex buffer
  30303. * @returns the new WebGL dynamic buffer
  30304. */
  30305. Engine.prototype.createDynamicVertexBuffer = function (data) {
  30306. var vbo = this._gl.createBuffer();
  30307. if (!vbo) {
  30308. throw new Error("Unable to create dynamic vertex buffer");
  30309. }
  30310. this.bindArrayBuffer(vbo);
  30311. if (data instanceof Array) {
  30312. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  30313. }
  30314. else {
  30315. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  30316. }
  30317. this._resetVertexBufferBinding();
  30318. vbo.references = 1;
  30319. return vbo;
  30320. };
  30321. /**
  30322. * Update a dynamic index buffer
  30323. * @param indexBuffer defines the target index buffer
  30324. * @param indices defines the data to update
  30325. * @param offset defines the offset in the target index buffer where update should start
  30326. */
  30327. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  30328. if (offset === void 0) { offset = 0; }
  30329. // Force cache update
  30330. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  30331. this.bindIndexBuffer(indexBuffer);
  30332. var arrayBuffer;
  30333. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  30334. arrayBuffer = indices;
  30335. }
  30336. else {
  30337. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  30338. }
  30339. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  30340. this._resetIndexBufferBinding();
  30341. };
  30342. /**
  30343. * Updates a dynamic vertex buffer.
  30344. * @param vertexBuffer the vertex buffer to update
  30345. * @param data the data used to update the vertex buffer
  30346. * @param byteOffset the byte offset of the data
  30347. * @param byteLength the byte length of the data
  30348. */
  30349. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  30350. this.bindArrayBuffer(vertexBuffer);
  30351. if (byteOffset === undefined) {
  30352. byteOffset = 0;
  30353. }
  30354. if (byteLength === undefined) {
  30355. if (data instanceof Array) {
  30356. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  30357. }
  30358. else {
  30359. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  30360. }
  30361. }
  30362. else {
  30363. if (data instanceof Array) {
  30364. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  30365. }
  30366. else {
  30367. if (data instanceof ArrayBuffer) {
  30368. data = new Uint8Array(data, byteOffset, byteLength);
  30369. }
  30370. else {
  30371. var offset = data.byteOffset + byteOffset;
  30372. if (offset || byteLength !== data.byteLength) {
  30373. data = new Uint8Array(data.buffer, offset, byteLength);
  30374. }
  30375. }
  30376. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30377. }
  30378. }
  30379. this._resetVertexBufferBinding();
  30380. };
  30381. Engine.prototype._resetIndexBufferBinding = function () {
  30382. this.bindIndexBuffer(null);
  30383. this._cachedIndexBuffer = null;
  30384. };
  30385. /**
  30386. * Creates a new index buffer
  30387. * @param indices defines the content of the index buffer
  30388. * @param updatable defines if the index buffer must be updatable
  30389. * @returns a new webGL buffer
  30390. */
  30391. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  30392. var vbo = this._gl.createBuffer();
  30393. if (!vbo) {
  30394. throw new Error("Unable to create index buffer");
  30395. }
  30396. this.bindIndexBuffer(vbo);
  30397. // Check for 32 bits indices
  30398. var arrayBuffer;
  30399. var need32Bits = false;
  30400. if (indices instanceof Uint16Array) {
  30401. arrayBuffer = indices;
  30402. }
  30403. else {
  30404. //check 32 bit support
  30405. if (this._caps.uintIndices) {
  30406. if (indices instanceof Uint32Array) {
  30407. arrayBuffer = indices;
  30408. need32Bits = true;
  30409. }
  30410. else {
  30411. //number[] or Int32Array, check if 32 bit is necessary
  30412. for (var index = 0; index < indices.length; index++) {
  30413. if (indices[index] > 65535) {
  30414. need32Bits = true;
  30415. break;
  30416. }
  30417. }
  30418. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  30419. }
  30420. }
  30421. else {
  30422. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  30423. arrayBuffer = new Uint16Array(indices);
  30424. }
  30425. }
  30426. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  30427. this._resetIndexBufferBinding();
  30428. vbo.references = 1;
  30429. vbo.is32Bits = need32Bits;
  30430. return vbo;
  30431. };
  30432. /**
  30433. * Bind a webGL buffer to the webGL context
  30434. * @param buffer defines the buffer to bind
  30435. */
  30436. Engine.prototype.bindArrayBuffer = function (buffer) {
  30437. if (!this._vaoRecordInProgress) {
  30438. this._unbindVertexArrayObject();
  30439. }
  30440. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  30441. };
  30442. /**
  30443. * Bind an uniform buffer to the current webGL context
  30444. * @param buffer defines the buffer to bind
  30445. */
  30446. Engine.prototype.bindUniformBuffer = function (buffer) {
  30447. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  30448. };
  30449. /**
  30450. * Bind a buffer to the current webGL context at a given location
  30451. * @param buffer defines the buffer to bind
  30452. * @param location defines the index where to bind the buffer
  30453. */
  30454. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  30455. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  30456. };
  30457. /**
  30458. * Bind a specific block at a given index in a specific shader program
  30459. * @param shaderProgram defines the shader program
  30460. * @param blockName defines the block name
  30461. * @param index defines the index where to bind the block
  30462. */
  30463. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  30464. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  30465. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  30466. };
  30467. Engine.prototype.bindIndexBuffer = function (buffer) {
  30468. if (!this._vaoRecordInProgress) {
  30469. this._unbindVertexArrayObject();
  30470. }
  30471. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  30472. };
  30473. Engine.prototype.bindBuffer = function (buffer, target) {
  30474. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  30475. this._gl.bindBuffer(target, buffer);
  30476. this._currentBoundBuffer[target] = buffer;
  30477. }
  30478. };
  30479. /**
  30480. * update the bound buffer with the given data
  30481. * @param data defines the data to update
  30482. */
  30483. Engine.prototype.updateArrayBuffer = function (data) {
  30484. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30485. };
  30486. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  30487. var pointer = this._currentBufferPointers[indx];
  30488. var changed = false;
  30489. if (!pointer.active) {
  30490. changed = true;
  30491. pointer.active = true;
  30492. pointer.index = indx;
  30493. pointer.size = size;
  30494. pointer.type = type;
  30495. pointer.normalized = normalized;
  30496. pointer.stride = stride;
  30497. pointer.offset = offset;
  30498. pointer.buffer = buffer;
  30499. }
  30500. else {
  30501. if (pointer.buffer !== buffer) {
  30502. pointer.buffer = buffer;
  30503. changed = true;
  30504. }
  30505. if (pointer.size !== size) {
  30506. pointer.size = size;
  30507. changed = true;
  30508. }
  30509. if (pointer.type !== type) {
  30510. pointer.type = type;
  30511. changed = true;
  30512. }
  30513. if (pointer.normalized !== normalized) {
  30514. pointer.normalized = normalized;
  30515. changed = true;
  30516. }
  30517. if (pointer.stride !== stride) {
  30518. pointer.stride = stride;
  30519. changed = true;
  30520. }
  30521. if (pointer.offset !== offset) {
  30522. pointer.offset = offset;
  30523. changed = true;
  30524. }
  30525. }
  30526. if (changed || this._vaoRecordInProgress) {
  30527. this.bindArrayBuffer(buffer);
  30528. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  30529. }
  30530. };
  30531. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  30532. if (indexBuffer == null) {
  30533. return;
  30534. }
  30535. if (this._cachedIndexBuffer !== indexBuffer) {
  30536. this._cachedIndexBuffer = indexBuffer;
  30537. this.bindIndexBuffer(indexBuffer);
  30538. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  30539. }
  30540. };
  30541. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  30542. var attributes = effect.getAttributesNames();
  30543. if (!this._vaoRecordInProgress) {
  30544. this._unbindVertexArrayObject();
  30545. }
  30546. this.unbindAllAttributes();
  30547. for (var index = 0; index < attributes.length; index++) {
  30548. var order = effect.getAttributeLocation(index);
  30549. if (order >= 0) {
  30550. var vertexBuffer = vertexBuffers[attributes[index]];
  30551. if (!vertexBuffer) {
  30552. continue;
  30553. }
  30554. this._gl.enableVertexAttribArray(order);
  30555. if (!this._vaoRecordInProgress) {
  30556. this._vertexAttribArraysEnabled[order] = true;
  30557. }
  30558. var buffer = vertexBuffer.getBuffer();
  30559. if (buffer) {
  30560. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  30561. if (vertexBuffer.getIsInstanced()) {
  30562. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  30563. if (!this._vaoRecordInProgress) {
  30564. this._currentInstanceLocations.push(order);
  30565. this._currentInstanceBuffers.push(buffer);
  30566. }
  30567. }
  30568. }
  30569. }
  30570. }
  30571. };
  30572. /**
  30573. * Records a vertex array object
  30574. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30575. * @param vertexBuffers defines the list of vertex buffers to store
  30576. * @param indexBuffer defines the index buffer to store
  30577. * @param effect defines the effect to store
  30578. * @returns the new vertex array object
  30579. */
  30580. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  30581. var vao = this._gl.createVertexArray();
  30582. this._vaoRecordInProgress = true;
  30583. this._gl.bindVertexArray(vao);
  30584. this._mustWipeVertexAttributes = true;
  30585. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  30586. this.bindIndexBuffer(indexBuffer);
  30587. this._vaoRecordInProgress = false;
  30588. this._gl.bindVertexArray(null);
  30589. return vao;
  30590. };
  30591. /**
  30592. * Bind a specific vertex array object
  30593. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30594. * @param vertexArrayObject defines the vertex array object to bind
  30595. * @param indexBuffer defines the index buffer to bind
  30596. */
  30597. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  30598. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  30599. this._cachedVertexArrayObject = vertexArrayObject;
  30600. this._gl.bindVertexArray(vertexArrayObject);
  30601. this._cachedVertexBuffers = null;
  30602. this._cachedIndexBuffer = null;
  30603. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  30604. this._mustWipeVertexAttributes = true;
  30605. }
  30606. };
  30607. /**
  30608. * Bind webGl buffers directly to the webGL context
  30609. * @param vertexBuffer defines the vertex buffer to bind
  30610. * @param indexBuffer defines the index buffer to bind
  30611. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30612. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30613. * @param effect defines the effect associated with the vertex buffer
  30614. */
  30615. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  30616. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  30617. this._cachedVertexBuffers = vertexBuffer;
  30618. this._cachedEffectForVertexBuffers = effect;
  30619. var attributesCount = effect.getAttributesCount();
  30620. this._unbindVertexArrayObject();
  30621. this.unbindAllAttributes();
  30622. var offset = 0;
  30623. for (var index = 0; index < attributesCount; index++) {
  30624. if (index < vertexDeclaration.length) {
  30625. var order = effect.getAttributeLocation(index);
  30626. if (order >= 0) {
  30627. this._gl.enableVertexAttribArray(order);
  30628. this._vertexAttribArraysEnabled[order] = true;
  30629. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  30630. }
  30631. offset += vertexDeclaration[index] * 4;
  30632. }
  30633. }
  30634. }
  30635. this._bindIndexBufferWithCache(indexBuffer);
  30636. };
  30637. Engine.prototype._unbindVertexArrayObject = function () {
  30638. if (!this._cachedVertexArrayObject) {
  30639. return;
  30640. }
  30641. this._cachedVertexArrayObject = null;
  30642. this._gl.bindVertexArray(null);
  30643. };
  30644. /**
  30645. * Bind a list of vertex buffers to the webGL context
  30646. * @param vertexBuffers defines the list of vertex buffers to bind
  30647. * @param indexBuffer defines the index buffer to bind
  30648. * @param effect defines the effect associated with the vertex buffers
  30649. */
  30650. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  30651. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  30652. this._cachedVertexBuffers = vertexBuffers;
  30653. this._cachedEffectForVertexBuffers = effect;
  30654. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  30655. }
  30656. this._bindIndexBufferWithCache(indexBuffer);
  30657. };
  30658. /**
  30659. * Unbind all instance attributes
  30660. */
  30661. Engine.prototype.unbindInstanceAttributes = function () {
  30662. var boundBuffer;
  30663. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  30664. var instancesBuffer = this._currentInstanceBuffers[i];
  30665. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  30666. boundBuffer = instancesBuffer;
  30667. this.bindArrayBuffer(instancesBuffer);
  30668. }
  30669. var offsetLocation = this._currentInstanceLocations[i];
  30670. this._gl.vertexAttribDivisor(offsetLocation, 0);
  30671. }
  30672. this._currentInstanceBuffers.length = 0;
  30673. this._currentInstanceLocations.length = 0;
  30674. };
  30675. /**
  30676. * Release and free the memory of a vertex array object
  30677. * @param vao defines the vertex array object to delete
  30678. */
  30679. Engine.prototype.releaseVertexArrayObject = function (vao) {
  30680. this._gl.deleteVertexArray(vao);
  30681. };
  30682. /** @hidden */
  30683. Engine.prototype._releaseBuffer = function (buffer) {
  30684. buffer.references--;
  30685. if (buffer.references === 0) {
  30686. this._gl.deleteBuffer(buffer);
  30687. return true;
  30688. }
  30689. return false;
  30690. };
  30691. /**
  30692. * Creates a webGL buffer to use with instanciation
  30693. * @param capacity defines the size of the buffer
  30694. * @returns the webGL buffer
  30695. */
  30696. Engine.prototype.createInstancesBuffer = function (capacity) {
  30697. var buffer = this._gl.createBuffer();
  30698. if (!buffer) {
  30699. throw new Error("Unable to create instance buffer");
  30700. }
  30701. buffer.capacity = capacity;
  30702. this.bindArrayBuffer(buffer);
  30703. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  30704. return buffer;
  30705. };
  30706. /**
  30707. * Delete a webGL buffer used with instanciation
  30708. * @param buffer defines the webGL buffer to delete
  30709. */
  30710. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  30711. this._gl.deleteBuffer(buffer);
  30712. };
  30713. /**
  30714. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30715. * @param instancesBuffer defines the webGL buffer to update and bind
  30716. * @param data defines the data to store in the buffer
  30717. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30718. */
  30719. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  30720. this.bindArrayBuffer(instancesBuffer);
  30721. if (data) {
  30722. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30723. }
  30724. if (offsetLocations[0].index !== undefined) {
  30725. var stride = 0;
  30726. for (var i = 0; i < offsetLocations.length; i++) {
  30727. var ai = offsetLocations[i];
  30728. stride += ai.attributeSize * 4;
  30729. }
  30730. for (var i = 0; i < offsetLocations.length; i++) {
  30731. var ai = offsetLocations[i];
  30732. if (!this._vertexAttribArraysEnabled[ai.index]) {
  30733. this._gl.enableVertexAttribArray(ai.index);
  30734. this._vertexAttribArraysEnabled[ai.index] = true;
  30735. }
  30736. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  30737. this._gl.vertexAttribDivisor(ai.index, 1);
  30738. this._currentInstanceLocations.push(ai.index);
  30739. this._currentInstanceBuffers.push(instancesBuffer);
  30740. }
  30741. }
  30742. else {
  30743. for (var index = 0; index < 4; index++) {
  30744. var offsetLocation = offsetLocations[index];
  30745. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  30746. this._gl.enableVertexAttribArray(offsetLocation);
  30747. this._vertexAttribArraysEnabled[offsetLocation] = true;
  30748. }
  30749. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  30750. this._gl.vertexAttribDivisor(offsetLocation, 1);
  30751. this._currentInstanceLocations.push(offsetLocation);
  30752. this._currentInstanceBuffers.push(instancesBuffer);
  30753. }
  30754. }
  30755. };
  30756. /**
  30757. * Apply all cached states (depth, culling, stencil and alpha)
  30758. */
  30759. Engine.prototype.applyStates = function () {
  30760. this._depthCullingState.apply(this._gl);
  30761. this._stencilState.apply(this._gl);
  30762. this._alphaState.apply(this._gl);
  30763. };
  30764. /**
  30765. * Send a draw order
  30766. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30767. * @param indexStart defines the starting index
  30768. * @param indexCount defines the number of index to draw
  30769. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30770. */
  30771. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  30772. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  30773. };
  30774. /**
  30775. * Draw a list of points
  30776. * @param verticesStart defines the index of first vertex to draw
  30777. * @param verticesCount defines the count of vertices to draw
  30778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30779. */
  30780. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  30781. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  30782. };
  30783. /**
  30784. * Draw a list of unindexed primitives
  30785. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30786. * @param verticesStart defines the index of first vertex to draw
  30787. * @param verticesCount defines the count of vertices to draw
  30788. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30789. */
  30790. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  30791. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  30792. };
  30793. /**
  30794. * Draw a list of indexed primitives
  30795. * @param fillMode defines the primitive to use
  30796. * @param indexStart defines the starting index
  30797. * @param indexCount defines the number of index to draw
  30798. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30799. */
  30800. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  30801. // Apply states
  30802. this.applyStates();
  30803. this._drawCalls.addCount(1, false);
  30804. // Render
  30805. var drawMode = this._drawMode(fillMode);
  30806. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  30807. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  30808. if (instancesCount) {
  30809. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  30810. }
  30811. else {
  30812. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  30813. }
  30814. };
  30815. /**
  30816. * Draw a list of unindexed primitives
  30817. * @param fillMode defines the primitive to use
  30818. * @param verticesStart defines the index of first vertex to draw
  30819. * @param verticesCount defines the count of vertices to draw
  30820. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30821. */
  30822. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  30823. // Apply states
  30824. this.applyStates();
  30825. this._drawCalls.addCount(1, false);
  30826. var drawMode = this._drawMode(fillMode);
  30827. if (instancesCount) {
  30828. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  30829. }
  30830. else {
  30831. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  30832. }
  30833. };
  30834. Engine.prototype._drawMode = function (fillMode) {
  30835. switch (fillMode) {
  30836. // Triangle views
  30837. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  30838. return this._gl.TRIANGLES;
  30839. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  30840. return this._gl.POINTS;
  30841. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  30842. return this._gl.LINES;
  30843. // Draw modes
  30844. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  30845. return this._gl.POINTS;
  30846. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  30847. return this._gl.LINES;
  30848. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  30849. return this._gl.LINE_LOOP;
  30850. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  30851. return this._gl.LINE_STRIP;
  30852. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  30853. return this._gl.TRIANGLE_STRIP;
  30854. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  30855. return this._gl.TRIANGLE_FAN;
  30856. default:
  30857. return this._gl.TRIANGLES;
  30858. }
  30859. };
  30860. // Shaders
  30861. /** @hidden */
  30862. Engine.prototype._releaseEffect = function (effect) {
  30863. if (this._compiledEffects[effect._key]) {
  30864. delete this._compiledEffects[effect._key];
  30865. this._deleteProgram(effect.getProgram());
  30866. }
  30867. };
  30868. /** @hidden */
  30869. Engine.prototype._deleteProgram = function (program) {
  30870. if (program) {
  30871. program.__SPECTOR_rebuildProgram = null;
  30872. if (program.transformFeedback) {
  30873. this.deleteTransformFeedback(program.transformFeedback);
  30874. program.transformFeedback = null;
  30875. }
  30876. this._gl.deleteProgram(program);
  30877. }
  30878. };
  30879. /**
  30880. * Create a new effect (used to store vertex/fragment shaders)
  30881. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30882. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30883. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30884. * @param samplers defines an array of string used to represent textures
  30885. * @param defines defines the string containing the defines to use to compile the shaders
  30886. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30887. * @param onCompiled defines a function to call when the effect creation is successful
  30888. * @param onError defines a function to call when the effect creation has failed
  30889. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30890. * @returns the new Effect
  30891. */
  30892. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  30893. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  30894. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  30895. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  30896. if (this._compiledEffects[name]) {
  30897. var compiledEffect = this._compiledEffects[name];
  30898. if (onCompiled && compiledEffect.isReady()) {
  30899. onCompiled(compiledEffect);
  30900. }
  30901. return compiledEffect;
  30902. }
  30903. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  30904. effect._key = name;
  30905. this._compiledEffects[name] = effect;
  30906. return effect;
  30907. };
  30908. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  30909. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  30910. };
  30911. Engine.prototype._compileRawShader = function (source, type) {
  30912. var gl = this._gl;
  30913. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  30914. if (!shader) {
  30915. throw new Error("Something went wrong while compile the shader.");
  30916. }
  30917. gl.shaderSource(shader, source);
  30918. gl.compileShader(shader);
  30919. return shader;
  30920. };
  30921. /**
  30922. * Directly creates a webGL program
  30923. * @param vertexCode defines the vertex shader code to use
  30924. * @param fragmentCode defines the fragment shader code to use
  30925. * @param context defines the webGL context to use (if not set, the current one will be used)
  30926. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30927. * @returns the new webGL program
  30928. */
  30929. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  30930. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30931. context = context || this._gl;
  30932. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  30933. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  30934. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30935. };
  30936. /**
  30937. * Creates a webGL program
  30938. * @param vertexCode defines the vertex shader code to use
  30939. * @param fragmentCode defines the fragment shader code to use
  30940. * @param defines defines the string containing the defines to use to compile the shaders
  30941. * @param context defines the webGL context to use (if not set, the current one will be used)
  30942. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30943. * @returns the new webGL program
  30944. */
  30945. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  30946. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30947. context = context || this._gl;
  30948. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  30949. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  30950. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  30951. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  30952. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30953. this.onAfterShaderCompilationObservable.notifyObservers(this);
  30954. return program;
  30955. };
  30956. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  30957. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30958. var shaderProgram = context.createProgram();
  30959. if (!shaderProgram) {
  30960. throw new Error("Unable to create program");
  30961. }
  30962. if (this._caps.parallelShaderCompile) {
  30963. shaderProgram.isParallelCompiled = true;
  30964. }
  30965. context.attachShader(shaderProgram, vertexShader);
  30966. context.attachShader(shaderProgram, fragmentShader);
  30967. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30968. var transformFeedback = this.createTransformFeedback();
  30969. this.bindTransformFeedback(transformFeedback);
  30970. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  30971. shaderProgram.transformFeedback = transformFeedback;
  30972. }
  30973. context.linkProgram(shaderProgram);
  30974. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30975. this.bindTransformFeedback(null);
  30976. }
  30977. shaderProgram.context = context;
  30978. shaderProgram.vertexShader = vertexShader;
  30979. shaderProgram.fragmentShader = fragmentShader;
  30980. if (!shaderProgram.isParallelCompiled) {
  30981. this._finalizeProgram(shaderProgram);
  30982. }
  30983. return shaderProgram;
  30984. };
  30985. Engine.prototype._finalizeProgram = function (shaderProgram) {
  30986. var context = shaderProgram.context;
  30987. var vertexShader = shaderProgram.vertexShader;
  30988. var fragmentShader = shaderProgram.fragmentShader;
  30989. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  30990. if (!linked) { // Get more info
  30991. // Vertex
  30992. if (!this._gl.getShaderParameter(vertexShader, this._gl.COMPILE_STATUS)) {
  30993. var log = this._gl.getShaderInfoLog(vertexShader);
  30994. if (log) {
  30995. throw new Error(log);
  30996. }
  30997. }
  30998. // Fragment
  30999. if (!this._gl.getShaderParameter(fragmentShader, this._gl.COMPILE_STATUS)) {
  31000. var log = this._gl.getShaderInfoLog(fragmentShader);
  31001. if (log) {
  31002. throw new Error(log);
  31003. }
  31004. }
  31005. var error = context.getProgramInfoLog(shaderProgram);
  31006. if (error) {
  31007. throw new Error(error);
  31008. }
  31009. }
  31010. if (this.validateShaderPrograms) {
  31011. context.validateProgram(shaderProgram);
  31012. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  31013. if (!validated) {
  31014. var error = context.getProgramInfoLog(shaderProgram);
  31015. if (error) {
  31016. throw new Error(error);
  31017. }
  31018. }
  31019. }
  31020. context.deleteShader(vertexShader);
  31021. context.deleteShader(fragmentShader);
  31022. shaderProgram.context = undefined;
  31023. shaderProgram.vertexShader = undefined;
  31024. shaderProgram.fragmentShader = undefined;
  31025. if (shaderProgram.onCompiled) {
  31026. shaderProgram.onCompiled();
  31027. shaderProgram.onCompiled = undefined;
  31028. }
  31029. };
  31030. /** @hidden */
  31031. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  31032. if (!shaderProgram.isParallelCompiled) {
  31033. return true;
  31034. }
  31035. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  31036. this._finalizeProgram(shaderProgram);
  31037. return true;
  31038. }
  31039. return false;
  31040. };
  31041. /** @hidden */
  31042. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  31043. if (!shaderProgram.isParallelCompiled) {
  31044. action();
  31045. return;
  31046. }
  31047. shaderProgram.onCompiled = action;
  31048. };
  31049. /**
  31050. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31051. * @param shaderProgram defines the webGL program to use
  31052. * @param uniformsNames defines the list of uniform names
  31053. * @returns an array of webGL uniform locations
  31054. */
  31055. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  31056. var results = new Array();
  31057. for (var index = 0; index < uniformsNames.length; index++) {
  31058. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  31059. }
  31060. return results;
  31061. };
  31062. /**
  31063. * Gets the lsit of active attributes for a given webGL program
  31064. * @param shaderProgram defines the webGL program to use
  31065. * @param attributesNames defines the list of attribute names to get
  31066. * @returns an array of indices indicating the offset of each attribute
  31067. */
  31068. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  31069. var results = [];
  31070. for (var index = 0; index < attributesNames.length; index++) {
  31071. try {
  31072. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  31073. }
  31074. catch (e) {
  31075. results.push(-1);
  31076. }
  31077. }
  31078. return results;
  31079. };
  31080. /**
  31081. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31082. * @param effect defines the effect to activate
  31083. */
  31084. Engine.prototype.enableEffect = function (effect) {
  31085. if (!effect || effect === this._currentEffect) {
  31086. return;
  31087. }
  31088. // Use program
  31089. this.bindSamplers(effect);
  31090. this._currentEffect = effect;
  31091. if (effect.onBind) {
  31092. effect.onBind(effect);
  31093. }
  31094. if (effect._onBindObservable) {
  31095. effect._onBindObservable.notifyObservers(effect);
  31096. }
  31097. };
  31098. /**
  31099. * Set the value of an uniform to an array of int32
  31100. * @param uniform defines the webGL uniform location where to store the value
  31101. * @param array defines the array of int32 to store
  31102. */
  31103. Engine.prototype.setIntArray = function (uniform, array) {
  31104. if (!uniform) {
  31105. return;
  31106. }
  31107. this._gl.uniform1iv(uniform, array);
  31108. };
  31109. /**
  31110. * Set the value of an uniform to an array of int32 (stored as vec2)
  31111. * @param uniform defines the webGL uniform location where to store the value
  31112. * @param array defines the array of int32 to store
  31113. */
  31114. Engine.prototype.setIntArray2 = function (uniform, array) {
  31115. if (!uniform || array.length % 2 !== 0) {
  31116. return;
  31117. }
  31118. this._gl.uniform2iv(uniform, array);
  31119. };
  31120. /**
  31121. * Set the value of an uniform to an array of int32 (stored as vec3)
  31122. * @param uniform defines the webGL uniform location where to store the value
  31123. * @param array defines the array of int32 to store
  31124. */
  31125. Engine.prototype.setIntArray3 = function (uniform, array) {
  31126. if (!uniform || array.length % 3 !== 0) {
  31127. return;
  31128. }
  31129. this._gl.uniform3iv(uniform, array);
  31130. };
  31131. /**
  31132. * Set the value of an uniform to an array of int32 (stored as vec4)
  31133. * @param uniform defines the webGL uniform location where to store the value
  31134. * @param array defines the array of int32 to store
  31135. */
  31136. Engine.prototype.setIntArray4 = function (uniform, array) {
  31137. if (!uniform || array.length % 4 !== 0) {
  31138. return;
  31139. }
  31140. this._gl.uniform4iv(uniform, array);
  31141. };
  31142. /**
  31143. * Set the value of an uniform to an array of float32
  31144. * @param uniform defines the webGL uniform location where to store the value
  31145. * @param array defines the array of float32 to store
  31146. */
  31147. Engine.prototype.setFloatArray = function (uniform, array) {
  31148. if (!uniform) {
  31149. return;
  31150. }
  31151. this._gl.uniform1fv(uniform, array);
  31152. };
  31153. /**
  31154. * Set the value of an uniform to an array of float32 (stored as vec2)
  31155. * @param uniform defines the webGL uniform location where to store the value
  31156. * @param array defines the array of float32 to store
  31157. */
  31158. Engine.prototype.setFloatArray2 = function (uniform, array) {
  31159. if (!uniform || array.length % 2 !== 0) {
  31160. return;
  31161. }
  31162. this._gl.uniform2fv(uniform, array);
  31163. };
  31164. /**
  31165. * Set the value of an uniform to an array of float32 (stored as vec3)
  31166. * @param uniform defines the webGL uniform location where to store the value
  31167. * @param array defines the array of float32 to store
  31168. */
  31169. Engine.prototype.setFloatArray3 = function (uniform, array) {
  31170. if (!uniform || array.length % 3 !== 0) {
  31171. return;
  31172. }
  31173. this._gl.uniform3fv(uniform, array);
  31174. };
  31175. /**
  31176. * Set the value of an uniform to an array of float32 (stored as vec4)
  31177. * @param uniform defines the webGL uniform location where to store the value
  31178. * @param array defines the array of float32 to store
  31179. */
  31180. Engine.prototype.setFloatArray4 = function (uniform, array) {
  31181. if (!uniform || array.length % 4 !== 0) {
  31182. return;
  31183. }
  31184. this._gl.uniform4fv(uniform, array);
  31185. };
  31186. /**
  31187. * Set the value of an uniform to an array of number
  31188. * @param uniform defines the webGL uniform location where to store the value
  31189. * @param array defines the array of number to store
  31190. */
  31191. Engine.prototype.setArray = function (uniform, array) {
  31192. if (!uniform) {
  31193. return;
  31194. }
  31195. this._gl.uniform1fv(uniform, array);
  31196. };
  31197. /**
  31198. * Set the value of an uniform to an array of number (stored as vec2)
  31199. * @param uniform defines the webGL uniform location where to store the value
  31200. * @param array defines the array of number to store
  31201. */
  31202. Engine.prototype.setArray2 = function (uniform, array) {
  31203. if (!uniform || array.length % 2 !== 0) {
  31204. return;
  31205. }
  31206. this._gl.uniform2fv(uniform, array);
  31207. };
  31208. /**
  31209. * Set the value of an uniform to an array of number (stored as vec3)
  31210. * @param uniform defines the webGL uniform location where to store the value
  31211. * @param array defines the array of number to store
  31212. */
  31213. Engine.prototype.setArray3 = function (uniform, array) {
  31214. if (!uniform || array.length % 3 !== 0) {
  31215. return;
  31216. }
  31217. this._gl.uniform3fv(uniform, array);
  31218. };
  31219. /**
  31220. * Set the value of an uniform to an array of number (stored as vec4)
  31221. * @param uniform defines the webGL uniform location where to store the value
  31222. * @param array defines the array of number to store
  31223. */
  31224. Engine.prototype.setArray4 = function (uniform, array) {
  31225. if (!uniform || array.length % 4 !== 0) {
  31226. return;
  31227. }
  31228. this._gl.uniform4fv(uniform, array);
  31229. };
  31230. /**
  31231. * Set the value of an uniform to an array of float32 (stored as matrices)
  31232. * @param uniform defines the webGL uniform location where to store the value
  31233. * @param matrices defines the array of float32 to store
  31234. */
  31235. Engine.prototype.setMatrices = function (uniform, matrices) {
  31236. if (!uniform) {
  31237. return;
  31238. }
  31239. this._gl.uniformMatrix4fv(uniform, false, matrices);
  31240. };
  31241. /**
  31242. * Set the value of an uniform to a matrix
  31243. * @param uniform defines the webGL uniform location where to store the value
  31244. * @param matrix defines the matrix to store
  31245. */
  31246. Engine.prototype.setMatrix = function (uniform, matrix) {
  31247. if (!uniform) {
  31248. return;
  31249. }
  31250. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  31251. };
  31252. /**
  31253. * Set the value of an uniform to a matrix (3x3)
  31254. * @param uniform defines the webGL uniform location where to store the value
  31255. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31256. */
  31257. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  31258. if (!uniform) {
  31259. return;
  31260. }
  31261. this._gl.uniformMatrix3fv(uniform, false, matrix);
  31262. };
  31263. /**
  31264. * Set the value of an uniform to a matrix (2x2)
  31265. * @param uniform defines the webGL uniform location where to store the value
  31266. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31267. */
  31268. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  31269. if (!uniform) {
  31270. return;
  31271. }
  31272. this._gl.uniformMatrix2fv(uniform, false, matrix);
  31273. };
  31274. /**
  31275. * Set the value of an uniform to a number (int)
  31276. * @param uniform defines the webGL uniform location where to store the value
  31277. * @param value defines the int number to store
  31278. */
  31279. Engine.prototype.setInt = function (uniform, value) {
  31280. if (!uniform) {
  31281. return;
  31282. }
  31283. this._gl.uniform1i(uniform, value);
  31284. };
  31285. /**
  31286. * Set the value of an uniform to a number (float)
  31287. * @param uniform defines the webGL uniform location where to store the value
  31288. * @param value defines the float number to store
  31289. */
  31290. Engine.prototype.setFloat = function (uniform, value) {
  31291. if (!uniform) {
  31292. return;
  31293. }
  31294. this._gl.uniform1f(uniform, value);
  31295. };
  31296. /**
  31297. * Set the value of an uniform to a vec2
  31298. * @param uniform defines the webGL uniform location where to store the value
  31299. * @param x defines the 1st component of the value
  31300. * @param y defines the 2nd component of the value
  31301. */
  31302. Engine.prototype.setFloat2 = function (uniform, x, y) {
  31303. if (!uniform) {
  31304. return;
  31305. }
  31306. this._gl.uniform2f(uniform, x, y);
  31307. };
  31308. /**
  31309. * Set the value of an uniform to a vec3
  31310. * @param uniform defines the webGL uniform location where to store the value
  31311. * @param x defines the 1st component of the value
  31312. * @param y defines the 2nd component of the value
  31313. * @param z defines the 3rd component of the value
  31314. */
  31315. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  31316. if (!uniform) {
  31317. return;
  31318. }
  31319. this._gl.uniform3f(uniform, x, y, z);
  31320. };
  31321. /**
  31322. * Set the value of an uniform to a boolean
  31323. * @param uniform defines the webGL uniform location where to store the value
  31324. * @param bool defines the boolean to store
  31325. */
  31326. Engine.prototype.setBool = function (uniform, bool) {
  31327. if (!uniform) {
  31328. return;
  31329. }
  31330. this._gl.uniform1i(uniform, bool);
  31331. };
  31332. /**
  31333. * Set the value of an uniform to a vec4
  31334. * @param uniform defines the webGL uniform location where to store the value
  31335. * @param x defines the 1st component of the value
  31336. * @param y defines the 2nd component of the value
  31337. * @param z defines the 3rd component of the value
  31338. * @param w defines the 4th component of the value
  31339. */
  31340. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  31341. if (!uniform) {
  31342. return;
  31343. }
  31344. this._gl.uniform4f(uniform, x, y, z, w);
  31345. };
  31346. /**
  31347. * Set the value of an uniform to a Color3
  31348. * @param uniform defines the webGL uniform location where to store the value
  31349. * @param color3 defines the color to store
  31350. */
  31351. Engine.prototype.setColor3 = function (uniform, color3) {
  31352. if (!uniform) {
  31353. return;
  31354. }
  31355. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  31356. };
  31357. /**
  31358. * Set the value of an uniform to a Color3 and an alpha value
  31359. * @param uniform defines the webGL uniform location where to store the value
  31360. * @param color3 defines the color to store
  31361. * @param alpha defines the alpha component to store
  31362. */
  31363. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  31364. if (!uniform) {
  31365. return;
  31366. }
  31367. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  31368. };
  31369. /**
  31370. * Sets a Color4 on a uniform variable
  31371. * @param uniform defines the uniform location
  31372. * @param color4 defines the value to be set
  31373. */
  31374. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  31375. if (!uniform) {
  31376. return;
  31377. }
  31378. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  31379. };
  31380. // States
  31381. /**
  31382. * Set various states to the webGL context
  31383. * @param culling defines backface culling state
  31384. * @param zOffset defines the value to apply to zOffset (0 by default)
  31385. * @param force defines if states must be applied even if cache is up to date
  31386. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31387. */
  31388. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  31389. if (zOffset === void 0) { zOffset = 0; }
  31390. if (reverseSide === void 0) { reverseSide = false; }
  31391. // Culling
  31392. if (this._depthCullingState.cull !== culling || force) {
  31393. this._depthCullingState.cull = culling;
  31394. }
  31395. // Cull face
  31396. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  31397. if (this._depthCullingState.cullFace !== cullFace || force) {
  31398. this._depthCullingState.cullFace = cullFace;
  31399. }
  31400. // Z offset
  31401. this.setZOffset(zOffset);
  31402. // Front face
  31403. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  31404. if (this._depthCullingState.frontFace !== frontFace || force) {
  31405. this._depthCullingState.frontFace = frontFace;
  31406. }
  31407. };
  31408. /**
  31409. * Set the z offset to apply to current rendering
  31410. * @param value defines the offset to apply
  31411. */
  31412. Engine.prototype.setZOffset = function (value) {
  31413. this._depthCullingState.zOffset = value;
  31414. };
  31415. /**
  31416. * Gets the current value of the zOffset
  31417. * @returns the current zOffset state
  31418. */
  31419. Engine.prototype.getZOffset = function () {
  31420. return this._depthCullingState.zOffset;
  31421. };
  31422. /**
  31423. * Enable or disable depth buffering
  31424. * @param enable defines the state to set
  31425. */
  31426. Engine.prototype.setDepthBuffer = function (enable) {
  31427. this._depthCullingState.depthTest = enable;
  31428. };
  31429. /**
  31430. * Gets a boolean indicating if depth writing is enabled
  31431. * @returns the current depth writing state
  31432. */
  31433. Engine.prototype.getDepthWrite = function () {
  31434. return this._depthCullingState.depthMask;
  31435. };
  31436. /**
  31437. * Enable or disable depth writing
  31438. * @param enable defines the state to set
  31439. */
  31440. Engine.prototype.setDepthWrite = function (enable) {
  31441. this._depthCullingState.depthMask = enable;
  31442. };
  31443. /**
  31444. * Enable or disable color writing
  31445. * @param enable defines the state to set
  31446. */
  31447. Engine.prototype.setColorWrite = function (enable) {
  31448. this._gl.colorMask(enable, enable, enable, enable);
  31449. this._colorWrite = enable;
  31450. };
  31451. /**
  31452. * Gets a boolean indicating if color writing is enabled
  31453. * @returns the current color writing state
  31454. */
  31455. Engine.prototype.getColorWrite = function () {
  31456. return this._colorWrite;
  31457. };
  31458. /**
  31459. * Sets alpha constants used by some alpha blending modes
  31460. * @param r defines the red component
  31461. * @param g defines the green component
  31462. * @param b defines the blue component
  31463. * @param a defines the alpha component
  31464. */
  31465. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  31466. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  31467. };
  31468. /**
  31469. * Sets the current alpha mode
  31470. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31471. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31472. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31473. */
  31474. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  31475. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  31476. if (this._alphaMode === mode) {
  31477. return;
  31478. }
  31479. switch (mode) {
  31480. case Engine.ALPHA_DISABLE:
  31481. this._alphaState.alphaBlend = false;
  31482. break;
  31483. case Engine.ALPHA_PREMULTIPLIED:
  31484. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  31485. this._alphaState.alphaBlend = true;
  31486. break;
  31487. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  31488. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  31489. this._alphaState.alphaBlend = true;
  31490. break;
  31491. case Engine.ALPHA_COMBINE:
  31492. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  31493. this._alphaState.alphaBlend = true;
  31494. break;
  31495. case Engine.ALPHA_ONEONE:
  31496. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  31497. this._alphaState.alphaBlend = true;
  31498. break;
  31499. case Engine.ALPHA_ADD:
  31500. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  31501. this._alphaState.alphaBlend = true;
  31502. break;
  31503. case Engine.ALPHA_SUBTRACT:
  31504. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  31505. this._alphaState.alphaBlend = true;
  31506. break;
  31507. case Engine.ALPHA_MULTIPLY:
  31508. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  31509. this._alphaState.alphaBlend = true;
  31510. break;
  31511. case Engine.ALPHA_MAXIMIZED:
  31512. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  31513. this._alphaState.alphaBlend = true;
  31514. break;
  31515. case Engine.ALPHA_INTERPOLATE:
  31516. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  31517. this._alphaState.alphaBlend = true;
  31518. break;
  31519. case Engine.ALPHA_SCREENMODE:
  31520. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  31521. this._alphaState.alphaBlend = true;
  31522. break;
  31523. }
  31524. if (!noDepthWriteChange) {
  31525. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  31526. }
  31527. this._alphaMode = mode;
  31528. };
  31529. /**
  31530. * Gets the current alpha mode
  31531. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31532. * @returns the current alpha mode
  31533. */
  31534. Engine.prototype.getAlphaMode = function () {
  31535. return this._alphaMode;
  31536. };
  31537. // Textures
  31538. /**
  31539. * Clears the list of texture accessible through engine.
  31540. * This can help preventing texture load conflict due to name collision.
  31541. */
  31542. Engine.prototype.clearInternalTexturesCache = function () {
  31543. this._internalTexturesCache = [];
  31544. };
  31545. /**
  31546. * Force the entire cache to be cleared
  31547. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31548. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31549. */
  31550. Engine.prototype.wipeCaches = function (bruteForce) {
  31551. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  31552. return;
  31553. }
  31554. this._currentEffect = null;
  31555. this._viewportCached.x = 0;
  31556. this._viewportCached.y = 0;
  31557. this._viewportCached.z = 0;
  31558. this._viewportCached.w = 0;
  31559. if (bruteForce) {
  31560. this.resetTextureCache();
  31561. this._currentProgram = null;
  31562. this._stencilState.reset();
  31563. this._depthCullingState.reset();
  31564. this.setDepthFunctionToLessOrEqual();
  31565. this._alphaState.reset();
  31566. this._unpackFlipYCached = null;
  31567. }
  31568. this._resetVertexBufferBinding();
  31569. this._cachedIndexBuffer = null;
  31570. this._cachedEffectForVertexBuffers = null;
  31571. this._unbindVertexArrayObject();
  31572. this.bindIndexBuffer(null);
  31573. };
  31574. /**
  31575. * Set the compressed texture format to use, based on the formats you have, and the formats
  31576. * supported by the hardware / browser.
  31577. *
  31578. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31579. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31580. * to API arguments needed to compressed textures. This puts the burden on the container
  31581. * generator to house the arcane code for determining these for current & future formats.
  31582. *
  31583. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31584. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31585. *
  31586. * Note: The result of this call is not taken into account when a texture is base64.
  31587. *
  31588. * @param formatsAvailable defines the list of those format families you have created
  31589. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31590. *
  31591. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31592. * @returns The extension selected.
  31593. */
  31594. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  31595. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  31596. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  31597. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  31598. return this._textureFormatInUse = this._texturesSupported[i];
  31599. }
  31600. }
  31601. }
  31602. // actively set format to nothing, to allow this to be called more than once
  31603. // and possibly fail the 2nd time
  31604. this._textureFormatInUse = null;
  31605. return null;
  31606. };
  31607. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  31608. var gl = this._gl;
  31609. var magFilter = gl.NEAREST;
  31610. var minFilter = gl.NEAREST;
  31611. switch (samplingMode) {
  31612. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  31613. magFilter = gl.LINEAR;
  31614. if (generateMipMaps) {
  31615. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  31616. }
  31617. else {
  31618. minFilter = gl.LINEAR;
  31619. }
  31620. break;
  31621. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  31622. magFilter = gl.LINEAR;
  31623. if (generateMipMaps) {
  31624. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  31625. }
  31626. else {
  31627. minFilter = gl.LINEAR;
  31628. }
  31629. break;
  31630. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  31631. magFilter = gl.NEAREST;
  31632. if (generateMipMaps) {
  31633. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  31634. }
  31635. else {
  31636. minFilter = gl.NEAREST;
  31637. }
  31638. break;
  31639. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  31640. magFilter = gl.NEAREST;
  31641. if (generateMipMaps) {
  31642. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  31643. }
  31644. else {
  31645. minFilter = gl.NEAREST;
  31646. }
  31647. break;
  31648. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  31649. magFilter = gl.NEAREST;
  31650. if (generateMipMaps) {
  31651. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  31652. }
  31653. else {
  31654. minFilter = gl.LINEAR;
  31655. }
  31656. break;
  31657. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  31658. magFilter = gl.NEAREST;
  31659. if (generateMipMaps) {
  31660. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  31661. }
  31662. else {
  31663. minFilter = gl.LINEAR;
  31664. }
  31665. break;
  31666. case Engine.TEXTURE_NEAREST_LINEAR:
  31667. magFilter = gl.NEAREST;
  31668. minFilter = gl.LINEAR;
  31669. break;
  31670. case Engine.TEXTURE_NEAREST_NEAREST:
  31671. magFilter = gl.NEAREST;
  31672. minFilter = gl.NEAREST;
  31673. break;
  31674. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  31675. magFilter = gl.LINEAR;
  31676. if (generateMipMaps) {
  31677. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  31678. }
  31679. else {
  31680. minFilter = gl.NEAREST;
  31681. }
  31682. break;
  31683. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  31684. magFilter = gl.LINEAR;
  31685. if (generateMipMaps) {
  31686. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  31687. }
  31688. else {
  31689. minFilter = gl.NEAREST;
  31690. }
  31691. break;
  31692. case Engine.TEXTURE_LINEAR_LINEAR:
  31693. magFilter = gl.LINEAR;
  31694. minFilter = gl.LINEAR;
  31695. break;
  31696. case Engine.TEXTURE_LINEAR_NEAREST:
  31697. magFilter = gl.LINEAR;
  31698. minFilter = gl.NEAREST;
  31699. break;
  31700. }
  31701. return {
  31702. min: minFilter,
  31703. mag: magFilter
  31704. };
  31705. };
  31706. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  31707. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  31708. var img;
  31709. var onload = function () {
  31710. loadedImages[index] = img;
  31711. loadedImages._internalCount++;
  31712. if (scene) {
  31713. scene._removePendingData(img);
  31714. }
  31715. if (loadedImages._internalCount === 6) {
  31716. onfinish(loadedImages);
  31717. }
  31718. };
  31719. var onerror = function (message, exception) {
  31720. if (scene) {
  31721. scene._removePendingData(img);
  31722. }
  31723. if (onErrorCallBack) {
  31724. onErrorCallBack(message, exception);
  31725. }
  31726. };
  31727. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  31728. if (scene) {
  31729. scene._addPendingData(img);
  31730. }
  31731. };
  31732. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  31733. if (onError === void 0) { onError = null; }
  31734. var loadedImages = [];
  31735. loadedImages._internalCount = 0;
  31736. for (var index = 0; index < 6; index++) {
  31737. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  31738. }
  31739. };
  31740. /** @hidden */
  31741. Engine.prototype._createTexture = function () {
  31742. var texture = this._gl.createTexture();
  31743. if (!texture) {
  31744. throw new Error("Unable to create texture");
  31745. }
  31746. return texture;
  31747. };
  31748. /**
  31749. * Usually called from Texture.ts.
  31750. * Passed information to create a WebGLTexture
  31751. * @param urlArg defines a value which contains one of the following:
  31752. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31753. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31754. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31755. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31756. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  31757. * @param scene needed for loading to the correct scene
  31758. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31759. * @param onLoad optional callback to be called upon successful completion
  31760. * @param onError optional callback to be called upon failure
  31761. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  31762. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31763. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31764. * @param forcedExtension defines the extension to use to pick the right loader
  31765. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31766. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31767. */
  31768. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  31769. var _this = this;
  31770. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  31771. if (onLoad === void 0) { onLoad = null; }
  31772. if (onError === void 0) { onError = null; }
  31773. if (buffer === void 0) { buffer = null; }
  31774. if (fallback === void 0) { fallback = null; }
  31775. if (format === void 0) { format = null; }
  31776. if (forcedExtension === void 0) { forcedExtension = null; }
  31777. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31778. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  31779. var fromData = url.substr(0, 5) === "data:";
  31780. var fromBlob = url.substr(0, 5) === "blob:";
  31781. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  31782. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_URL);
  31783. // establish the file extension, if possible
  31784. var lastDot = url.lastIndexOf('.');
  31785. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  31786. var loader = null;
  31787. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31788. var availableLoader = _a[_i];
  31789. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  31790. loader = availableLoader;
  31791. break;
  31792. }
  31793. }
  31794. if (loader) {
  31795. url = loader.transformUrl(url, this._textureFormatInUse);
  31796. }
  31797. if (scene) {
  31798. scene._addPendingData(texture);
  31799. }
  31800. texture.url = url;
  31801. texture.generateMipMaps = !noMipmap;
  31802. texture.samplingMode = samplingMode;
  31803. texture.invertY = invertY;
  31804. if (!this._doNotHandleContextLost) {
  31805. // Keep a link to the buffer only if we plan to handle context lost
  31806. texture._buffer = buffer;
  31807. }
  31808. var onLoadObserver = null;
  31809. if (onLoad && !fallback) {
  31810. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  31811. }
  31812. if (!fallback) {
  31813. this._internalTexturesCache.push(texture);
  31814. }
  31815. var onInternalError = function (message, exception) {
  31816. if (scene) {
  31817. scene._removePendingData(texture);
  31818. }
  31819. var customFallback = false;
  31820. if (loader) {
  31821. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  31822. if (fallbackUrl) {
  31823. // Add Back
  31824. customFallback = true;
  31825. excludeLoaders.push(loader);
  31826. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].Warn(loader.constructor.name + " failed when trying to load " + texture.url + ", falling back to the next supported loader");
  31827. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  31828. }
  31829. }
  31830. if (!customFallback) {
  31831. if (onLoadObserver) {
  31832. texture.onLoadedObservable.remove(onLoadObserver);
  31833. }
  31834. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  31835. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  31836. }
  31837. }
  31838. if (onError) {
  31839. onError(message || "Unknown error", exception);
  31840. }
  31841. };
  31842. // processing for non-image formats
  31843. if (loader) {
  31844. var callback = function (data) {
  31845. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  31846. if (loadFailed) {
  31847. onInternalError("TextureLoader failed to load data");
  31848. }
  31849. else {
  31850. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  31851. done();
  31852. return false;
  31853. }, samplingMode);
  31854. }
  31855. });
  31856. };
  31857. if (!buffer) {
  31858. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  31859. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  31860. });
  31861. }
  31862. else {
  31863. callback(buffer);
  31864. }
  31865. }
  31866. else {
  31867. var onload = function (img) {
  31868. if (fromBlob && !_this._doNotHandleContextLost) {
  31869. // We need to store the image if we need to rebuild the texture
  31870. // in case of a webgl context lost
  31871. texture._buffer = img;
  31872. }
  31873. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  31874. var gl = _this._gl;
  31875. var isPot = (img.width === potWidth && img.height === potHeight);
  31876. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  31877. if (isPot) {
  31878. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  31879. return false;
  31880. }
  31881. var maxTextureSize = _this._caps.maxTextureSize;
  31882. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  31883. _this._prepareWorkingCanvas();
  31884. if (!_this._workingCanvas || !_this._workingContext) {
  31885. return false;
  31886. }
  31887. _this._workingCanvas.width = potWidth;
  31888. _this._workingCanvas.height = potHeight;
  31889. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  31890. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  31891. texture.width = potWidth;
  31892. texture.height = potHeight;
  31893. return false;
  31894. }
  31895. else {
  31896. // Using shaders when possible to rescale because canvas.drawImage is lossy
  31897. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_TEMP);
  31898. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  31899. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  31900. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  31901. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  31902. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31903. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31904. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  31905. _this._releaseTexture(source_1);
  31906. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31907. continuationCallback();
  31908. });
  31909. }
  31910. return true;
  31911. }, samplingMode);
  31912. };
  31913. if (!fromData || isBase64) {
  31914. if (buffer instanceof HTMLImageElement) {
  31915. onload(buffer);
  31916. }
  31917. else {
  31918. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  31919. }
  31920. }
  31921. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  31922. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  31923. }
  31924. else {
  31925. onload(buffer);
  31926. }
  31927. }
  31928. return texture;
  31929. };
  31930. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  31931. var _this = this;
  31932. var rtt = this.createRenderTargetTexture({
  31933. width: destination.width,
  31934. height: destination.height,
  31935. }, {
  31936. generateMipMaps: false,
  31937. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  31938. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  31939. generateDepthBuffer: false,
  31940. generateStencilBuffer: false
  31941. });
  31942. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  31943. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  31944. }
  31945. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  31946. _this._rescalePostProcess.onApply = function (effect) {
  31947. effect._bindTexture("textureSampler", source);
  31948. };
  31949. var hostingScene = scene;
  31950. if (!hostingScene) {
  31951. hostingScene = _this.scenes[_this.scenes.length - 1];
  31952. }
  31953. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  31954. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  31955. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  31956. _this.unBindFramebuffer(rtt);
  31957. _this._releaseTexture(rtt);
  31958. if (onComplete) {
  31959. onComplete();
  31960. }
  31961. });
  31962. };
  31963. /**
  31964. * Update a raw texture
  31965. * @param texture defines the texture to update
  31966. * @param data defines the data to store in the texture
  31967. * @param format defines the format of the data
  31968. * @param invertY defines if data must be stored with Y axis inverted
  31969. * @param compression defines the compression used (null by default)
  31970. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31971. */
  31972. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  31973. if (compression === void 0) { compression = null; }
  31974. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31975. if (!texture) {
  31976. return;
  31977. }
  31978. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  31979. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  31980. // babylon's internalFormat but gl's texImage2D format
  31981. var internalFormat = this._getInternalFormat(format);
  31982. var textureType = this._getWebGLTextureType(type);
  31983. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31984. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31985. if (!this._doNotHandleContextLost) {
  31986. texture._bufferView = data;
  31987. texture.format = format;
  31988. texture.type = type;
  31989. texture.invertY = invertY;
  31990. texture._compression = compression;
  31991. }
  31992. if (texture.width % 4 !== 0) {
  31993. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  31994. }
  31995. if (compression && data) {
  31996. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  31997. }
  31998. else {
  31999. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  32000. }
  32001. if (texture.generateMipMaps) {
  32002. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32003. }
  32004. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32005. // this.resetTextureCache();
  32006. texture.isReady = true;
  32007. };
  32008. /**
  32009. * Creates a raw texture
  32010. * @param data defines the data to store in the texture
  32011. * @param width defines the width of the texture
  32012. * @param height defines the height of the texture
  32013. * @param format defines the format of the data
  32014. * @param generateMipMaps defines if the engine should generate the mip levels
  32015. * @param invertY defines if data must be stored with Y axis inverted
  32016. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32017. * @param compression defines the compression used (null by default)
  32018. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32019. * @returns the raw texture inside an InternalTexture
  32020. */
  32021. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  32022. if (compression === void 0) { compression = null; }
  32023. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32024. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_RAW);
  32025. texture.baseWidth = width;
  32026. texture.baseHeight = height;
  32027. texture.width = width;
  32028. texture.height = height;
  32029. texture.format = format;
  32030. texture.generateMipMaps = generateMipMaps;
  32031. texture.samplingMode = samplingMode;
  32032. texture.invertY = invertY;
  32033. texture._compression = compression;
  32034. texture.type = type;
  32035. if (!this._doNotHandleContextLost) {
  32036. texture._bufferView = data;
  32037. }
  32038. this.updateRawTexture(texture, data, format, invertY, compression, type);
  32039. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  32040. // Filters
  32041. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32042. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  32043. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32044. if (generateMipMaps) {
  32045. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32046. }
  32047. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32048. this._internalTexturesCache.push(texture);
  32049. return texture;
  32050. };
  32051. /** @hidden */
  32052. Engine.prototype._unpackFlipY = function (value) {
  32053. if (this._unpackFlipYCached !== value) {
  32054. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  32055. if (this.enableUnpackFlipYCached) {
  32056. this._unpackFlipYCached = value;
  32057. }
  32058. }
  32059. };
  32060. /** @hidden */
  32061. Engine.prototype._getUnpackAlignement = function () {
  32062. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  32063. };
  32064. /**
  32065. * Creates a dynamic texture
  32066. * @param width defines the width of the texture
  32067. * @param height defines the height of the texture
  32068. * @param generateMipMaps defines if the engine should generate the mip levels
  32069. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32070. * @returns the dynamic texture inside an InternalTexture
  32071. */
  32072. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  32073. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_DYNAMIC);
  32074. texture.baseWidth = width;
  32075. texture.baseHeight = height;
  32076. if (generateMipMaps) {
  32077. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  32078. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  32079. }
  32080. // this.resetTextureCache();
  32081. texture.width = width;
  32082. texture.height = height;
  32083. texture.isReady = false;
  32084. texture.generateMipMaps = generateMipMaps;
  32085. texture.samplingMode = samplingMode;
  32086. this.updateTextureSamplingMode(samplingMode, texture);
  32087. this._internalTexturesCache.push(texture);
  32088. return texture;
  32089. };
  32090. /**
  32091. * Update the sampling mode of a given texture
  32092. * @param samplingMode defines the required sampling mode
  32093. * @param texture defines the texture to update
  32094. */
  32095. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  32096. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  32097. if (texture.isCube) {
  32098. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  32099. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32100. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32101. }
  32102. else if (texture.is3D) {
  32103. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  32104. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32105. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32106. }
  32107. else {
  32108. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  32109. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32110. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32111. }
  32112. texture.samplingMode = samplingMode;
  32113. };
  32114. /**
  32115. * Update the content of a dynamic texture
  32116. * @param texture defines the texture to update
  32117. * @param canvas defines the canvas containing the source
  32118. * @param invertY defines if data must be stored with Y axis inverted
  32119. * @param premulAlpha defines if alpha is stored as premultiplied
  32120. * @param format defines the format of the data
  32121. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32122. */
  32123. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  32124. if (premulAlpha === void 0) { premulAlpha = false; }
  32125. if (forceBindTexture === void 0) { forceBindTexture = false; }
  32126. if (!texture) {
  32127. return;
  32128. }
  32129. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  32130. this._unpackFlipY(invertY);
  32131. if (premulAlpha) {
  32132. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  32133. }
  32134. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  32135. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  32136. if (texture.generateMipMaps) {
  32137. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32138. }
  32139. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32140. if (premulAlpha) {
  32141. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  32142. }
  32143. texture.isReady = true;
  32144. };
  32145. /**
  32146. * Update a video texture
  32147. * @param texture defines the texture to update
  32148. * @param video defines the video element to use
  32149. * @param invertY defines if data must be stored with Y axis inverted
  32150. */
  32151. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  32152. if (!texture || texture._isDisabled) {
  32153. return;
  32154. }
  32155. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  32156. this._unpackFlipY(!invertY); // Video are upside down by default
  32157. try {
  32158. // Testing video texture support
  32159. if (this._videoTextureSupported === undefined) {
  32160. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  32161. if (this._gl.getError() !== 0) {
  32162. this._videoTextureSupported = false;
  32163. }
  32164. else {
  32165. this._videoTextureSupported = true;
  32166. }
  32167. }
  32168. // Copy video through the current working canvas if video texture is not supported
  32169. if (!this._videoTextureSupported) {
  32170. if (!texture._workingCanvas) {
  32171. texture._workingCanvas = document.createElement("canvas");
  32172. var context = texture._workingCanvas.getContext("2d");
  32173. if (!context) {
  32174. throw new Error("Unable to get 2d context");
  32175. }
  32176. texture._workingContext = context;
  32177. texture._workingCanvas.width = texture.width;
  32178. texture._workingCanvas.height = texture.height;
  32179. }
  32180. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  32181. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  32182. }
  32183. else {
  32184. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  32185. }
  32186. if (texture.generateMipMaps) {
  32187. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32188. }
  32189. if (!wasPreviouslyBound) {
  32190. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32191. }
  32192. // this.resetTextureCache();
  32193. texture.isReady = true;
  32194. }
  32195. catch (ex) {
  32196. // Something unexpected
  32197. // Let's disable the texture
  32198. texture._isDisabled = true;
  32199. }
  32200. };
  32201. /**
  32202. * Updates a depth texture Comparison Mode and Function.
  32203. * If the comparison Function is equal to 0, the mode will be set to none.
  32204. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32205. * @param texture The texture to set the comparison function for
  32206. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32207. */
  32208. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  32209. if (this.webGLVersion === 1) {
  32210. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Error("WebGL 1 does not support texture comparison.");
  32211. return;
  32212. }
  32213. var gl = this._gl;
  32214. if (texture.isCube) {
  32215. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  32216. if (comparisonFunction === 0) {
  32217. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  32218. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  32219. }
  32220. else {
  32221. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  32222. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  32223. }
  32224. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32225. }
  32226. else {
  32227. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  32228. if (comparisonFunction === 0) {
  32229. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  32230. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  32231. }
  32232. else {
  32233. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  32234. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  32235. }
  32236. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32237. }
  32238. texture._comparisonFunction = comparisonFunction;
  32239. };
  32240. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  32241. var width = size.width || size;
  32242. var height = size.height || size;
  32243. internalTexture.baseWidth = width;
  32244. internalTexture.baseHeight = height;
  32245. internalTexture.width = width;
  32246. internalTexture.height = height;
  32247. internalTexture.isReady = true;
  32248. internalTexture.samples = 1;
  32249. internalTexture.generateMipMaps = false;
  32250. internalTexture._generateDepthBuffer = true;
  32251. internalTexture._generateStencilBuffer = generateStencil;
  32252. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32253. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32254. internalTexture._comparisonFunction = comparisonFunction;
  32255. var gl = this._gl;
  32256. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32257. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  32258. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  32259. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  32260. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32261. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32262. if (comparisonFunction === 0) {
  32263. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  32264. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  32265. }
  32266. else {
  32267. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  32268. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  32269. }
  32270. };
  32271. /**
  32272. * Creates a depth stencil texture.
  32273. * This is only available in WebGL 2 or with the depth texture extension available.
  32274. * @param size The size of face edge in the texture.
  32275. * @param options The options defining the texture.
  32276. * @returns The texture
  32277. */
  32278. Engine.prototype.createDepthStencilTexture = function (size, options) {
  32279. if (options.isCube) {
  32280. var width = size.width || size;
  32281. return this._createDepthStencilCubeTexture(width, options);
  32282. }
  32283. else {
  32284. return this._createDepthStencilTexture(size, options);
  32285. }
  32286. };
  32287. /**
  32288. * Creates a depth stencil texture.
  32289. * This is only available in WebGL 2 or with the depth texture extension available.
  32290. * @param size The size of face edge in the texture.
  32291. * @param options The options defining the texture.
  32292. * @returns The texture
  32293. */
  32294. Engine.prototype._createDepthStencilTexture = function (size, options) {
  32295. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  32296. if (!this._caps.depthTextureExtension) {
  32297. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  32298. return internalTexture;
  32299. }
  32300. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  32301. var gl = this._gl;
  32302. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  32303. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  32304. if (this.webGLVersion > 1) {
  32305. if (internalOptions.generateStencil) {
  32306. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  32307. }
  32308. else {
  32309. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  32310. }
  32311. }
  32312. else {
  32313. if (internalOptions.generateStencil) {
  32314. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  32315. }
  32316. else {
  32317. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  32318. }
  32319. }
  32320. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32321. return internalTexture;
  32322. };
  32323. /**
  32324. * Creates a depth stencil cube texture.
  32325. * This is only available in WebGL 2.
  32326. * @param size The size of face edge in the cube texture.
  32327. * @param options The options defining the cube texture.
  32328. * @returns The cube texture
  32329. */
  32330. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  32331. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_UNKNOWN);
  32332. internalTexture.isCube = true;
  32333. if (this.webGLVersion === 1) {
  32334. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  32335. return internalTexture;
  32336. }
  32337. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  32338. var gl = this._gl;
  32339. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  32340. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  32341. // Create the depth/stencil buffer
  32342. for (var face = 0; face < 6; face++) {
  32343. if (internalOptions.generateStencil) {
  32344. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH24_STENCIL8, size, size, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  32345. }
  32346. else {
  32347. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  32348. }
  32349. }
  32350. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32351. return internalTexture;
  32352. };
  32353. /**
  32354. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32355. * @param renderTarget The render target to set the frame buffer for
  32356. */
  32357. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  32358. // Create the framebuffer
  32359. var internalTexture = renderTarget.getInternalTexture();
  32360. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  32361. return;
  32362. }
  32363. var gl = this._gl;
  32364. var depthStencilTexture = renderTarget.depthStencilTexture;
  32365. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  32366. if (depthStencilTexture.isCube) {
  32367. if (depthStencilTexture._generateStencilBuffer) {
  32368. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  32369. }
  32370. else {
  32371. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  32372. }
  32373. }
  32374. else {
  32375. if (depthStencilTexture._generateStencilBuffer) {
  32376. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  32377. }
  32378. else {
  32379. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  32380. }
  32381. }
  32382. this.bindUnboundFramebuffer(null);
  32383. };
  32384. /**
  32385. * Creates a new render target texture
  32386. * @param size defines the size of the texture
  32387. * @param options defines the options used to create the texture
  32388. * @returns a new render target texture stored in an InternalTexture
  32389. */
  32390. Engine.prototype.createRenderTargetTexture = function (size, options) {
  32391. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_16__["RenderTargetCreationOptions"]();
  32392. if (options !== undefined && typeof options === "object") {
  32393. fullOptions.generateMipMaps = options.generateMipMaps;
  32394. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  32395. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  32396. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  32397. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  32398. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  32399. }
  32400. else {
  32401. fullOptions.generateMipMaps = options;
  32402. fullOptions.generateDepthBuffer = true;
  32403. fullOptions.generateStencilBuffer = false;
  32404. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32405. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  32406. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  32407. }
  32408. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32409. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32410. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32411. }
  32412. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32413. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32414. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32415. }
  32416. var gl = this._gl;
  32417. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_RENDERTARGET);
  32418. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32419. var width = size.width || size;
  32420. var height = size.height || size;
  32421. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  32422. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32423. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32424. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  32425. }
  32426. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32427. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32428. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32429. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32430. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  32431. // Create the framebuffer
  32432. var currentFrameBuffer = this._currentFramebuffer;
  32433. var framebuffer = gl.createFramebuffer();
  32434. this.bindUnboundFramebuffer(framebuffer);
  32435. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  32436. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  32437. if (fullOptions.generateMipMaps) {
  32438. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32439. }
  32440. // Unbind
  32441. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32442. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32443. this.bindUnboundFramebuffer(currentFrameBuffer);
  32444. texture._framebuffer = framebuffer;
  32445. texture.baseWidth = width;
  32446. texture.baseHeight = height;
  32447. texture.width = width;
  32448. texture.height = height;
  32449. texture.isReady = true;
  32450. texture.samples = 1;
  32451. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  32452. texture.samplingMode = fullOptions.samplingMode;
  32453. texture.type = fullOptions.type;
  32454. texture.format = fullOptions.format;
  32455. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  32456. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  32457. // this.resetTextureCache();
  32458. this._internalTexturesCache.push(texture);
  32459. return texture;
  32460. };
  32461. /**
  32462. * Create a multi render target texture
  32463. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  32464. * @param size defines the size of the texture
  32465. * @param options defines the creation options
  32466. * @returns the cube texture as an InternalTexture
  32467. */
  32468. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  32469. var generateMipMaps = false;
  32470. var generateDepthBuffer = true;
  32471. var generateStencilBuffer = false;
  32472. var generateDepthTexture = false;
  32473. var textureCount = 1;
  32474. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  32475. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  32476. var types = new Array();
  32477. var samplingModes = new Array();
  32478. if (options !== undefined) {
  32479. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  32480. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  32481. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  32482. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  32483. textureCount = options.textureCount || 1;
  32484. if (options.types) {
  32485. types = options.types;
  32486. }
  32487. if (options.samplingModes) {
  32488. samplingModes = options.samplingModes;
  32489. }
  32490. }
  32491. var gl = this._gl;
  32492. // Create the framebuffer
  32493. var framebuffer = gl.createFramebuffer();
  32494. this.bindUnboundFramebuffer(framebuffer);
  32495. var width = size.width || size;
  32496. var height = size.height || size;
  32497. var textures = [];
  32498. var attachments = [];
  32499. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  32500. for (var i = 0; i < textureCount; i++) {
  32501. var samplingMode = samplingModes[i] || defaultSamplingMode;
  32502. var type = types[i] || defaultType;
  32503. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32504. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32505. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32506. }
  32507. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32508. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32509. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32510. }
  32511. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32512. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32513. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32514. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  32515. }
  32516. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  32517. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  32518. textures.push(texture);
  32519. attachments.push(attachment);
  32520. gl.activeTexture(gl["TEXTURE" + i]);
  32521. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  32522. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32523. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32524. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32525. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32526. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  32527. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  32528. if (generateMipMaps) {
  32529. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32530. }
  32531. // Unbind
  32532. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32533. texture._framebuffer = framebuffer;
  32534. texture._depthStencilBuffer = depthStencilBuffer;
  32535. texture.baseWidth = width;
  32536. texture.baseHeight = height;
  32537. texture.width = width;
  32538. texture.height = height;
  32539. texture.isReady = true;
  32540. texture.samples = 1;
  32541. texture.generateMipMaps = generateMipMaps;
  32542. texture.samplingMode = samplingMode;
  32543. texture.type = type;
  32544. texture._generateDepthBuffer = generateDepthBuffer;
  32545. texture._generateStencilBuffer = generateStencilBuffer;
  32546. texture._attachments = attachments;
  32547. this._internalTexturesCache.push(texture);
  32548. }
  32549. if (generateDepthTexture && this._caps.depthTextureExtension) {
  32550. // Depth texture
  32551. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  32552. gl.activeTexture(gl.TEXTURE0);
  32553. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  32554. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32555. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32556. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32557. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32558. gl.texImage2D(gl.TEXTURE_2D, 0, this.webGLVersion < 2 ? gl.DEPTH_COMPONENT : gl.DEPTH_COMPONENT16, width, height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_SHORT, null);
  32559. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  32560. depthTexture._framebuffer = framebuffer;
  32561. depthTexture.baseWidth = width;
  32562. depthTexture.baseHeight = height;
  32563. depthTexture.width = width;
  32564. depthTexture.height = height;
  32565. depthTexture.isReady = true;
  32566. depthTexture.samples = 1;
  32567. depthTexture.generateMipMaps = generateMipMaps;
  32568. depthTexture.samplingMode = gl.NEAREST;
  32569. depthTexture._generateDepthBuffer = generateDepthBuffer;
  32570. depthTexture._generateStencilBuffer = generateStencilBuffer;
  32571. textures.push(depthTexture);
  32572. this._internalTexturesCache.push(depthTexture);
  32573. }
  32574. gl.drawBuffers(attachments);
  32575. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32576. this.bindUnboundFramebuffer(null);
  32577. this.resetTextureCache();
  32578. return textures;
  32579. };
  32580. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  32581. if (samples === void 0) { samples = 1; }
  32582. var depthStencilBuffer = null;
  32583. var gl = this._gl;
  32584. // Create the depth/stencil buffer
  32585. if (generateStencilBuffer) {
  32586. depthStencilBuffer = gl.createRenderbuffer();
  32587. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  32588. if (samples > 1) {
  32589. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  32590. }
  32591. else {
  32592. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  32593. }
  32594. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  32595. }
  32596. else if (generateDepthBuffer) {
  32597. depthStencilBuffer = gl.createRenderbuffer();
  32598. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  32599. if (samples > 1) {
  32600. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  32601. }
  32602. else {
  32603. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  32604. }
  32605. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  32606. }
  32607. return depthStencilBuffer;
  32608. };
  32609. /**
  32610. * Updates the sample count of a render target texture
  32611. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32612. * @param texture defines the texture to update
  32613. * @param samples defines the sample count to set
  32614. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32615. */
  32616. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  32617. if (this.webGLVersion < 2 || !texture) {
  32618. return 1;
  32619. }
  32620. if (texture.samples === samples) {
  32621. return samples;
  32622. }
  32623. var gl = this._gl;
  32624. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  32625. // Dispose previous render buffers
  32626. if (texture._depthStencilBuffer) {
  32627. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32628. texture._depthStencilBuffer = null;
  32629. }
  32630. if (texture._MSAAFramebuffer) {
  32631. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32632. texture._MSAAFramebuffer = null;
  32633. }
  32634. if (texture._MSAARenderBuffer) {
  32635. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  32636. texture._MSAARenderBuffer = null;
  32637. }
  32638. if (samples > 1) {
  32639. var framebuffer = gl.createFramebuffer();
  32640. if (!framebuffer) {
  32641. throw new Error("Unable to create multi sampled framebuffer");
  32642. }
  32643. texture._MSAAFramebuffer = framebuffer;
  32644. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  32645. var colorRenderbuffer = gl.createRenderbuffer();
  32646. if (!colorRenderbuffer) {
  32647. throw new Error("Unable to create multi sampled framebuffer");
  32648. }
  32649. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  32650. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  32651. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  32652. texture._MSAARenderBuffer = colorRenderbuffer;
  32653. }
  32654. else {
  32655. this.bindUnboundFramebuffer(texture._framebuffer);
  32656. }
  32657. texture.samples = samples;
  32658. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  32659. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32660. this.bindUnboundFramebuffer(null);
  32661. return samples;
  32662. };
  32663. /**
  32664. * Update the sample count for a given multiple render target texture
  32665. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32666. * @param textures defines the textures to update
  32667. * @param samples defines the sample count to set
  32668. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32669. */
  32670. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  32671. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  32672. return 1;
  32673. }
  32674. if (textures[0].samples === samples) {
  32675. return samples;
  32676. }
  32677. var gl = this._gl;
  32678. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  32679. // Dispose previous render buffers
  32680. if (textures[0]._depthStencilBuffer) {
  32681. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  32682. textures[0]._depthStencilBuffer = null;
  32683. }
  32684. if (textures[0]._MSAAFramebuffer) {
  32685. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  32686. textures[0]._MSAAFramebuffer = null;
  32687. }
  32688. for (var i = 0; i < textures.length; i++) {
  32689. if (textures[i]._MSAARenderBuffer) {
  32690. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  32691. textures[i]._MSAARenderBuffer = null;
  32692. }
  32693. }
  32694. if (samples > 1) {
  32695. var framebuffer = gl.createFramebuffer();
  32696. if (!framebuffer) {
  32697. throw new Error("Unable to create multi sampled framebuffer");
  32698. }
  32699. this.bindUnboundFramebuffer(framebuffer);
  32700. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  32701. var attachments = [];
  32702. for (var i = 0; i < textures.length; i++) {
  32703. var texture = textures[i];
  32704. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  32705. var colorRenderbuffer = gl.createRenderbuffer();
  32706. if (!colorRenderbuffer) {
  32707. throw new Error("Unable to create multi sampled framebuffer");
  32708. }
  32709. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  32710. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  32711. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  32712. texture._MSAAFramebuffer = framebuffer;
  32713. texture._MSAARenderBuffer = colorRenderbuffer;
  32714. texture.samples = samples;
  32715. texture._depthStencilBuffer = depthStencilBuffer;
  32716. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32717. attachments.push(attachment);
  32718. }
  32719. gl.drawBuffers(attachments);
  32720. }
  32721. else {
  32722. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  32723. }
  32724. this.bindUnboundFramebuffer(null);
  32725. return samples;
  32726. };
  32727. /** @hidden */
  32728. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  32729. if (faceIndex === void 0) { faceIndex = 0; }
  32730. if (lod === void 0) { lod = 0; }
  32731. var gl = this._gl;
  32732. var target = gl.TEXTURE_2D;
  32733. if (texture.isCube) {
  32734. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32735. }
  32736. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  32737. };
  32738. /** @hidden */
  32739. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  32740. if (faceIndex === void 0) { faceIndex = 0; }
  32741. if (lod === void 0) { lod = 0; }
  32742. var gl = this._gl;
  32743. var textureType = this._getWebGLTextureType(texture.type);
  32744. var format = this._getInternalFormat(texture.format);
  32745. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  32746. this._unpackFlipY(texture.invertY);
  32747. var target = gl.TEXTURE_2D;
  32748. if (texture.isCube) {
  32749. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32750. }
  32751. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  32752. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  32753. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  32754. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  32755. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  32756. };
  32757. /** @hidden */
  32758. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  32759. if (faceIndex === void 0) { faceIndex = 0; }
  32760. if (lod === void 0) { lod = 0; }
  32761. var gl = this._gl;
  32762. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32763. this._bindTextureDirectly(bindTarget, texture, true);
  32764. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  32765. this._bindTextureDirectly(bindTarget, null, true);
  32766. };
  32767. /** @hidden */
  32768. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  32769. if (faceIndex === void 0) { faceIndex = 0; }
  32770. if (lod === void 0) { lod = 0; }
  32771. var gl = this._gl;
  32772. var textureType = this._getWebGLTextureType(texture.type);
  32773. var format = this._getInternalFormat(texture.format);
  32774. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  32775. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32776. this._bindTextureDirectly(bindTarget, texture, true);
  32777. this._unpackFlipY(texture.invertY);
  32778. var target = gl.TEXTURE_2D;
  32779. if (texture.isCube) {
  32780. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32781. }
  32782. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  32783. this._bindTextureDirectly(bindTarget, null, true);
  32784. };
  32785. /**
  32786. * Creates a new render target cube texture
  32787. * @param size defines the size of the texture
  32788. * @param options defines the options used to create the texture
  32789. * @returns a new render target cube texture stored in an InternalTexture
  32790. */
  32791. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  32792. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ generateMipMaps: true, generateDepthBuffer: true, generateStencilBuffer: false, type: Engine.TEXTURETYPE_UNSIGNED_INT, samplingMode: Engine.TEXTURE_TRILINEAR_SAMPLINGMODE, format: Engine.TEXTUREFORMAT_RGBA }, options);
  32793. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  32794. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32795. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32796. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32797. }
  32798. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32799. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32800. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32801. }
  32802. var gl = this._gl;
  32803. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_RENDERTARGET);
  32804. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32805. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  32806. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32807. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32808. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  32809. }
  32810. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32811. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32812. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32813. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32814. for (var face = 0; face < 6; face++) {
  32815. gl.texImage2D((gl.TEXTURE_CUBE_MAP_POSITIVE_X + face), 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), size, size, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  32816. }
  32817. // Create the framebuffer
  32818. var framebuffer = gl.createFramebuffer();
  32819. this.bindUnboundFramebuffer(framebuffer);
  32820. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  32821. // MipMaps
  32822. if (fullOptions.generateMipMaps) {
  32823. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32824. }
  32825. // Unbind
  32826. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32827. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32828. this.bindUnboundFramebuffer(null);
  32829. texture._framebuffer = framebuffer;
  32830. texture.width = size;
  32831. texture.height = size;
  32832. texture.isReady = true;
  32833. texture.isCube = true;
  32834. texture.samples = 1;
  32835. texture.generateMipMaps = fullOptions.generateMipMaps;
  32836. texture.samplingMode = fullOptions.samplingMode;
  32837. texture.type = fullOptions.type;
  32838. texture.format = fullOptions.format;
  32839. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  32840. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  32841. this._internalTexturesCache.push(texture);
  32842. return texture;
  32843. };
  32844. /**
  32845. * Creates a cube texture
  32846. * @param rootUrl defines the url where the files to load is located
  32847. * @param scene defines the current scene
  32848. * @param files defines the list of files to load (1 per face)
  32849. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  32850. * @param onLoad defines an optional callback raised when the texture is loaded
  32851. * @param onError defines an optional callback raised if there is an issue to load the texture
  32852. * @param format defines the format of the data
  32853. * @param forcedExtension defines the extension to use to pick the right loader
  32854. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  32855. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  32856. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  32857. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  32858. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  32859. * @returns the cube texture as an InternalTexture
  32860. */
  32861. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  32862. var _this = this;
  32863. if (onLoad === void 0) { onLoad = null; }
  32864. if (onError === void 0) { onError = null; }
  32865. if (forcedExtension === void 0) { forcedExtension = null; }
  32866. if (createPolynomials === void 0) { createPolynomials = false; }
  32867. if (lodScale === void 0) { lodScale = 0; }
  32868. if (lodOffset === void 0) { lodOffset = 0; }
  32869. if (fallback === void 0) { fallback = null; }
  32870. if (excludeLoaders === void 0) { excludeLoaders = []; }
  32871. var gl = this._gl;
  32872. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_CUBE);
  32873. texture.isCube = true;
  32874. texture.url = rootUrl;
  32875. texture.generateMipMaps = !noMipmap;
  32876. texture._lodGenerationScale = lodScale;
  32877. texture._lodGenerationOffset = lodOffset;
  32878. if (!this._doNotHandleContextLost) {
  32879. texture._extension = forcedExtension;
  32880. texture._files = files;
  32881. }
  32882. var lastDot = rootUrl.lastIndexOf('.');
  32883. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  32884. var loader = null;
  32885. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  32886. var availableLoader = _a[_i];
  32887. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  32888. loader = availableLoader;
  32889. break;
  32890. }
  32891. }
  32892. var onInternalError = function (request, exception) {
  32893. if (loader) {
  32894. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  32895. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn(loader.constructor.name + " failed when trying to load " + texture.url + ", falling back to the next supported loader");
  32896. if (fallbackUrl) {
  32897. excludeLoaders.push(loader);
  32898. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  32899. return;
  32900. }
  32901. }
  32902. if (onError && request) {
  32903. onError(request.status + " " + request.statusText, exception);
  32904. }
  32905. };
  32906. if (loader) {
  32907. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  32908. var onloaddata = function (data) {
  32909. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32910. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  32911. };
  32912. if (files && files.length === 6) {
  32913. if (loader.supportCascades) {
  32914. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  32915. }
  32916. else {
  32917. if (onError) {
  32918. onError("Textures type does not support cascades.");
  32919. }
  32920. else {
  32921. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Texture loader does not support cascades.");
  32922. }
  32923. }
  32924. }
  32925. else {
  32926. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  32927. }
  32928. }
  32929. else {
  32930. if (!files) {
  32931. throw new Error("Cannot load cubemap because files were not defined");
  32932. }
  32933. this._cascadeLoadImgs(scene, function (imgs) {
  32934. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  32935. var height = width;
  32936. _this._prepareWorkingCanvas();
  32937. if (!_this._workingCanvas || !_this._workingContext) {
  32938. return;
  32939. }
  32940. _this._workingCanvas.width = width;
  32941. _this._workingCanvas.height = height;
  32942. var faces = [
  32943. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  32944. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  32945. ];
  32946. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32947. _this._unpackFlipY(false);
  32948. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  32949. for (var index = 0; index < faces.length; index++) {
  32950. if (imgs[index].width !== width || imgs[index].height !== height) {
  32951. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  32952. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  32953. }
  32954. else {
  32955. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, imgs[index]);
  32956. }
  32957. }
  32958. if (!noMipmap) {
  32959. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32960. }
  32961. _this._setCubeMapTextureParams(!noMipmap);
  32962. texture.width = width;
  32963. texture.height = height;
  32964. texture.isReady = true;
  32965. if (format) {
  32966. texture.format = format;
  32967. }
  32968. texture.onLoadedObservable.notifyObservers(texture);
  32969. texture.onLoadedObservable.clear();
  32970. if (onLoad) {
  32971. onLoad();
  32972. }
  32973. }, files, onError);
  32974. }
  32975. this._internalTexturesCache.push(texture);
  32976. return texture;
  32977. };
  32978. /**
  32979. * @hidden
  32980. */
  32981. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  32982. var gl = this._gl;
  32983. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  32984. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  32985. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32986. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32987. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32988. // this.resetTextureCache();
  32989. };
  32990. /**
  32991. * Update a raw cube texture
  32992. * @param texture defines the texture to udpdate
  32993. * @param data defines the data to store
  32994. * @param format defines the data format
  32995. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32996. * @param invertY defines if data must be stored with Y axis inverted
  32997. * @param compression defines the compression used (null by default)
  32998. * @param level defines which level of the texture to update
  32999. */
  33000. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  33001. if (compression === void 0) { compression = null; }
  33002. if (level === void 0) { level = 0; }
  33003. texture._bufferViewArray = data;
  33004. texture.format = format;
  33005. texture.type = type;
  33006. texture.invertY = invertY;
  33007. texture._compression = compression;
  33008. var gl = this._gl;
  33009. var textureType = this._getWebGLTextureType(type);
  33010. var internalFormat = this._getInternalFormat(format);
  33011. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  33012. var needConversion = false;
  33013. if (internalFormat === gl.RGB) {
  33014. internalFormat = gl.RGBA;
  33015. needConversion = true;
  33016. }
  33017. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  33018. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  33019. if (texture.width % 4 !== 0) {
  33020. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  33021. }
  33022. // Data are known to be in +X +Y +Z -X -Y -Z
  33023. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  33024. var faceData = data[faceIndex];
  33025. if (compression) {
  33026. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  33027. }
  33028. else {
  33029. if (needConversion) {
  33030. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  33031. }
  33032. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  33033. }
  33034. }
  33035. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  33036. if (isPot && texture.generateMipMaps && level === 0) {
  33037. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  33038. }
  33039. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33040. // this.resetTextureCache();
  33041. texture.isReady = true;
  33042. };
  33043. /**
  33044. * Creates a new raw cube texture
  33045. * @param data defines the array of data to use to create each face
  33046. * @param size defines the size of the textures
  33047. * @param format defines the format of the data
  33048. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  33049. * @param generateMipMaps defines if the engine should generate the mip levels
  33050. * @param invertY defines if data must be stored with Y axis inverted
  33051. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33052. * @param compression defines the compression used (null by default)
  33053. * @returns the cube texture as an InternalTexture
  33054. */
  33055. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  33056. if (compression === void 0) { compression = null; }
  33057. var gl = this._gl;
  33058. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_CUBERAW);
  33059. texture.isCube = true;
  33060. texture.format = format;
  33061. texture.type = type;
  33062. if (!this._doNotHandleContextLost) {
  33063. texture._bufferViewArray = data;
  33064. }
  33065. var textureType = this._getWebGLTextureType(type);
  33066. var internalFormat = this._getInternalFormat(format);
  33067. if (internalFormat === gl.RGB) {
  33068. internalFormat = gl.RGBA;
  33069. }
  33070. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  33071. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  33072. generateMipMaps = false;
  33073. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  33074. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
  33075. }
  33076. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  33077. generateMipMaps = false;
  33078. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  33079. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
  33080. }
  33081. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  33082. generateMipMaps = false;
  33083. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  33084. }
  33085. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  33086. generateMipMaps = false;
  33087. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  33088. }
  33089. var width = size;
  33090. var height = width;
  33091. texture.width = width;
  33092. texture.height = height;
  33093. // Double check on POT to generate Mips.
  33094. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  33095. if (!isPot) {
  33096. generateMipMaps = false;
  33097. }
  33098. // Upload data if needed. The texture won't be ready until then.
  33099. if (data) {
  33100. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  33101. }
  33102. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  33103. // Filters
  33104. if (data && generateMipMaps) {
  33105. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  33106. }
  33107. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  33108. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  33109. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  33110. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  33111. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  33112. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  33113. texture.generateMipMaps = generateMipMaps;
  33114. return texture;
  33115. };
  33116. /**
  33117. * Creates a new raw cube texture from a specified url
  33118. * @param url defines the url where the data is located
  33119. * @param scene defines the current scene
  33120. * @param size defines the size of the textures
  33121. * @param format defines the format of the data
  33122. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  33123. * @param noMipmap defines if the engine should avoid generating the mip levels
  33124. * @param callback defines a callback used to extract texture data from loaded data
  33125. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  33126. * @param onLoad defines a callback called when texture is loaded
  33127. * @param onError defines a callback called if there is an error
  33128. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33129. * @param invertY defines if data must be stored with Y axis inverted
  33130. * @returns the cube texture as an InternalTexture
  33131. */
  33132. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  33133. var _this = this;
  33134. if (onLoad === void 0) { onLoad = null; }
  33135. if (onError === void 0) { onError = null; }
  33136. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  33137. if (invertY === void 0) { invertY = false; }
  33138. var gl = this._gl;
  33139. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  33140. scene._addPendingData(texture);
  33141. texture.url = url;
  33142. this._internalTexturesCache.push(texture);
  33143. var onerror = function (request, exception) {
  33144. scene._removePendingData(texture);
  33145. if (onError && request) {
  33146. onError(request.status + " " + request.statusText, exception);
  33147. }
  33148. };
  33149. var internalCallback = function (data) {
  33150. var width = texture.width;
  33151. var faceDataArrays = callback(data);
  33152. if (!faceDataArrays) {
  33153. return;
  33154. }
  33155. if (mipmapGenerator) {
  33156. var textureType = _this._getWebGLTextureType(type);
  33157. var internalFormat = _this._getInternalFormat(format);
  33158. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  33159. var needConversion = false;
  33160. if (internalFormat === gl.RGB) {
  33161. internalFormat = gl.RGBA;
  33162. needConversion = true;
  33163. }
  33164. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  33165. _this._unpackFlipY(false);
  33166. var mipData = mipmapGenerator(faceDataArrays);
  33167. for (var level = 0; level < mipData.length; level++) {
  33168. var mipSize = width >> level;
  33169. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  33170. var mipFaceData = mipData[level][faceIndex];
  33171. if (needConversion) {
  33172. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  33173. }
  33174. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  33175. }
  33176. }
  33177. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  33178. }
  33179. else {
  33180. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  33181. }
  33182. texture.isReady = true;
  33183. // this.resetTextureCache();
  33184. scene._removePendingData(texture);
  33185. if (onLoad) {
  33186. onLoad();
  33187. }
  33188. };
  33189. this._loadFile(url, function (data) {
  33190. internalCallback(data);
  33191. }, undefined, scene.offlineProvider, true, onerror);
  33192. return texture;
  33193. };
  33194. /**
  33195. * Update a raw 3D texture
  33196. * @param texture defines the texture to update
  33197. * @param data defines the data to store
  33198. * @param format defines the data format
  33199. * @param invertY defines if data must be stored with Y axis inverted
  33200. * @param compression defines the used compression (can be null)
  33201. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  33202. */
  33203. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  33204. if (compression === void 0) { compression = null; }
  33205. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  33206. var internalType = this._getWebGLTextureType(textureType);
  33207. var internalFormat = this._getInternalFormat(format);
  33208. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  33209. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  33210. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  33211. if (!this._doNotHandleContextLost) {
  33212. texture._bufferView = data;
  33213. texture.format = format;
  33214. texture.invertY = invertY;
  33215. texture._compression = compression;
  33216. }
  33217. if (texture.width % 4 !== 0) {
  33218. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  33219. }
  33220. if (compression && data) {
  33221. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  33222. }
  33223. else {
  33224. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  33225. }
  33226. if (texture.generateMipMaps) {
  33227. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  33228. }
  33229. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33230. // this.resetTextureCache();
  33231. texture.isReady = true;
  33232. };
  33233. /**
  33234. * Creates a new raw 3D texture
  33235. * @param data defines the data used to create the texture
  33236. * @param width defines the width of the texture
  33237. * @param height defines the height of the texture
  33238. * @param depth defines the depth of the texture
  33239. * @param format defines the format of the texture
  33240. * @param generateMipMaps defines if the engine must generate mip levels
  33241. * @param invertY defines if data must be stored with Y axis inverted
  33242. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33243. * @param compression defines the compressed used (can be null)
  33244. * @param textureType defines the compressed used (can be null)
  33245. * @returns a new raw 3D texture (stored in an InternalTexture)
  33246. */
  33247. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  33248. if (compression === void 0) { compression = null; }
  33249. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  33250. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_RAW3D);
  33251. texture.baseWidth = width;
  33252. texture.baseHeight = height;
  33253. texture.baseDepth = depth;
  33254. texture.width = width;
  33255. texture.height = height;
  33256. texture.depth = depth;
  33257. texture.format = format;
  33258. texture.type = textureType;
  33259. texture.generateMipMaps = generateMipMaps;
  33260. texture.samplingMode = samplingMode;
  33261. texture.is3D = true;
  33262. if (!this._doNotHandleContextLost) {
  33263. texture._bufferView = data;
  33264. }
  33265. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  33266. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  33267. // Filters
  33268. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  33269. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  33270. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  33271. if (generateMipMaps) {
  33272. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  33273. }
  33274. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33275. this._internalTexturesCache.push(texture);
  33276. return texture;
  33277. };
  33278. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  33279. var gl = this._gl;
  33280. if (!gl) {
  33281. return;
  33282. }
  33283. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  33284. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  33285. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  33286. if (!noMipmap && !isCompressed) {
  33287. gl.generateMipmap(gl.TEXTURE_2D);
  33288. }
  33289. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  33290. // this.resetTextureCache();
  33291. if (scene) {
  33292. scene._removePendingData(texture);
  33293. }
  33294. texture.onLoadedObservable.notifyObservers(texture);
  33295. texture.onLoadedObservable.clear();
  33296. };
  33297. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  33298. var _this = this;
  33299. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  33300. var maxTextureSize = this.getCaps().maxTextureSize;
  33301. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  33302. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  33303. var gl = this._gl;
  33304. if (!gl) {
  33305. return;
  33306. }
  33307. if (!texture._webGLTexture) {
  33308. // this.resetTextureCache();
  33309. if (scene) {
  33310. scene._removePendingData(texture);
  33311. }
  33312. return;
  33313. }
  33314. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  33315. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  33316. texture.baseWidth = width;
  33317. texture.baseHeight = height;
  33318. texture.width = potWidth;
  33319. texture.height = potHeight;
  33320. texture.isReady = true;
  33321. if (processFunction(potWidth, potHeight, function () {
  33322. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  33323. })) {
  33324. // Returning as texture needs extra async steps
  33325. return;
  33326. }
  33327. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  33328. };
  33329. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  33330. // Create new RGBA data container.
  33331. var rgbaData;
  33332. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  33333. rgbaData = new Float32Array(width * height * 4);
  33334. }
  33335. else {
  33336. rgbaData = new Uint32Array(width * height * 4);
  33337. }
  33338. // Convert each pixel.
  33339. for (var x = 0; x < width; x++) {
  33340. for (var y = 0; y < height; y++) {
  33341. var index = (y * width + x) * 3;
  33342. var newIndex = (y * width + x) * 4;
  33343. // Map Old Value to new value.
  33344. rgbaData[newIndex + 0] = rgbData[index + 0];
  33345. rgbaData[newIndex + 1] = rgbData[index + 1];
  33346. rgbaData[newIndex + 2] = rgbData[index + 2];
  33347. // Add fully opaque alpha channel.
  33348. rgbaData[newIndex + 3] = 1;
  33349. }
  33350. }
  33351. return rgbaData;
  33352. };
  33353. /** @hidden */
  33354. Engine.prototype._releaseFramebufferObjects = function (texture) {
  33355. var gl = this._gl;
  33356. if (texture._framebuffer) {
  33357. gl.deleteFramebuffer(texture._framebuffer);
  33358. texture._framebuffer = null;
  33359. }
  33360. if (texture._depthStencilBuffer) {
  33361. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  33362. texture._depthStencilBuffer = null;
  33363. }
  33364. if (texture._MSAAFramebuffer) {
  33365. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  33366. texture._MSAAFramebuffer = null;
  33367. }
  33368. if (texture._MSAARenderBuffer) {
  33369. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  33370. texture._MSAARenderBuffer = null;
  33371. }
  33372. };
  33373. /** @hidden */
  33374. Engine.prototype._releaseTexture = function (texture) {
  33375. var gl = this._gl;
  33376. this._releaseFramebufferObjects(texture);
  33377. gl.deleteTexture(texture._webGLTexture);
  33378. // Unbind channels
  33379. this.unbindAllTextures();
  33380. var index = this._internalTexturesCache.indexOf(texture);
  33381. if (index !== -1) {
  33382. this._internalTexturesCache.splice(index, 1);
  33383. }
  33384. // Integrated fixed lod samplers.
  33385. if (texture._lodTextureHigh) {
  33386. texture._lodTextureHigh.dispose();
  33387. }
  33388. if (texture._lodTextureMid) {
  33389. texture._lodTextureMid.dispose();
  33390. }
  33391. if (texture._lodTextureLow) {
  33392. texture._lodTextureLow.dispose();
  33393. }
  33394. // Set output texture of post process to null if the texture has been released/disposed
  33395. this.scenes.forEach(function (scene) {
  33396. scene.postProcesses.forEach(function (postProcess) {
  33397. if (postProcess._outputTexture == texture) {
  33398. postProcess._outputTexture = null;
  33399. }
  33400. });
  33401. scene.cameras.forEach(function (camera) {
  33402. camera._postProcesses.forEach(function (postProcess) {
  33403. if (postProcess) {
  33404. if (postProcess._outputTexture == texture) {
  33405. postProcess._outputTexture = null;
  33406. }
  33407. }
  33408. });
  33409. });
  33410. });
  33411. };
  33412. Engine.prototype.setProgram = function (program) {
  33413. if (this._currentProgram !== program) {
  33414. this._gl.useProgram(program);
  33415. this._currentProgram = program;
  33416. }
  33417. };
  33418. /**
  33419. * Binds an effect to the webGL context
  33420. * @param effect defines the effect to bind
  33421. */
  33422. Engine.prototype.bindSamplers = function (effect) {
  33423. this.setProgram(effect.getProgram());
  33424. var samplers = effect.getSamplers();
  33425. for (var index = 0; index < samplers.length; index++) {
  33426. var uniform = effect.getUniform(samplers[index]);
  33427. if (uniform) {
  33428. this._boundUniforms[index] = uniform;
  33429. }
  33430. }
  33431. this._currentEffect = null;
  33432. };
  33433. Engine.prototype._activateCurrentTexture = function () {
  33434. if (this._currentTextureChannel !== this._activeChannel) {
  33435. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  33436. this._currentTextureChannel = this._activeChannel;
  33437. }
  33438. };
  33439. /** @hidden */
  33440. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  33441. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  33442. if (force === void 0) { force = false; }
  33443. var wasPreviouslyBound = false;
  33444. var isTextureForRendering = texture && texture._associatedChannel > -1;
  33445. if (forTextureDataUpdate && isTextureForRendering) {
  33446. this._activeChannel = texture._associatedChannel;
  33447. }
  33448. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  33449. if (currentTextureBound !== texture || force) {
  33450. this._activateCurrentTexture();
  33451. if (texture && texture.isMultiview) {
  33452. this._gl.bindTexture(target, texture ? texture._colorTextureArray : null);
  33453. }
  33454. else {
  33455. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  33456. }
  33457. this._boundTexturesCache[this._activeChannel] = texture;
  33458. if (texture) {
  33459. texture._associatedChannel = this._activeChannel;
  33460. }
  33461. }
  33462. else if (forTextureDataUpdate) {
  33463. wasPreviouslyBound = true;
  33464. this._activateCurrentTexture();
  33465. }
  33466. if (isTextureForRendering && !forTextureDataUpdate) {
  33467. this._bindSamplerUniformToChannel(texture._associatedChannel, this._activeChannel);
  33468. }
  33469. return wasPreviouslyBound;
  33470. };
  33471. /** @hidden */
  33472. Engine.prototype._bindTexture = function (channel, texture) {
  33473. if (channel === undefined) {
  33474. return;
  33475. }
  33476. if (texture) {
  33477. texture._associatedChannel = channel;
  33478. }
  33479. this._activeChannel = channel;
  33480. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  33481. };
  33482. /**
  33483. * Sets a texture to the webGL context from a postprocess
  33484. * @param channel defines the channel to use
  33485. * @param postProcess defines the source postprocess
  33486. */
  33487. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  33488. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  33489. };
  33490. /**
  33491. * Binds the output of the passed in post process to the texture channel specified
  33492. * @param channel The channel the texture should be bound to
  33493. * @param postProcess The post process which's output should be bound
  33494. */
  33495. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  33496. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  33497. };
  33498. /**
  33499. * Unbind all textures from the webGL context
  33500. */
  33501. Engine.prototype.unbindAllTextures = function () {
  33502. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  33503. this._activeChannel = channel;
  33504. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33505. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33506. if (this.webGLVersion > 1) {
  33507. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33508. }
  33509. }
  33510. };
  33511. /**
  33512. * Sets a texture to the according uniform.
  33513. * @param channel The texture channel
  33514. * @param uniform The uniform to set
  33515. * @param texture The texture to apply
  33516. */
  33517. Engine.prototype.setTexture = function (channel, uniform, texture) {
  33518. if (channel === undefined) {
  33519. return;
  33520. }
  33521. if (uniform) {
  33522. this._boundUniforms[channel] = uniform;
  33523. }
  33524. this._setTexture(channel, texture);
  33525. };
  33526. /**
  33527. * Sets a depth stencil texture from a render target to the according uniform.
  33528. * @param channel The texture channel
  33529. * @param uniform The uniform to set
  33530. * @param texture The render target texture containing the depth stencil texture to apply
  33531. */
  33532. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  33533. if (channel === undefined) {
  33534. return;
  33535. }
  33536. if (uniform) {
  33537. this._boundUniforms[channel] = uniform;
  33538. }
  33539. if (!texture || !texture.depthStencilTexture) {
  33540. this._setTexture(channel, null);
  33541. }
  33542. else {
  33543. this._setTexture(channel, texture, false, true);
  33544. }
  33545. };
  33546. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  33547. var uniform = this._boundUniforms[sourceSlot];
  33548. if (uniform._currentState === destination) {
  33549. return;
  33550. }
  33551. this._gl.uniform1i(uniform, destination);
  33552. uniform._currentState = destination;
  33553. };
  33554. Engine.prototype._getTextureWrapMode = function (mode) {
  33555. switch (mode) {
  33556. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  33557. return this._gl.REPEAT;
  33558. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  33559. return this._gl.CLAMP_TO_EDGE;
  33560. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  33561. return this._gl.MIRRORED_REPEAT;
  33562. }
  33563. return this._gl.REPEAT;
  33564. };
  33565. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  33566. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  33567. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  33568. // Not ready?
  33569. if (!texture) {
  33570. if (this._boundTexturesCache[channel] != null) {
  33571. this._activeChannel = channel;
  33572. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33573. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33574. if (this.webGLVersion > 1) {
  33575. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33576. }
  33577. }
  33578. return false;
  33579. }
  33580. // Video
  33581. if (texture.video) {
  33582. this._activeChannel = channel;
  33583. texture.update();
  33584. }
  33585. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  33586. texture.delayLoad();
  33587. return false;
  33588. }
  33589. var internalTexture;
  33590. if (depthStencilTexture) {
  33591. internalTexture = texture.depthStencilTexture;
  33592. }
  33593. else if (texture.isReady()) {
  33594. internalTexture = texture.getInternalTexture();
  33595. }
  33596. else if (texture.isCube) {
  33597. internalTexture = this.emptyCubeTexture;
  33598. }
  33599. else if (texture.is3D) {
  33600. internalTexture = this.emptyTexture3D;
  33601. }
  33602. else {
  33603. internalTexture = this.emptyTexture;
  33604. }
  33605. if (!isPartOfTextureArray && internalTexture) {
  33606. internalTexture._associatedChannel = channel;
  33607. }
  33608. var needToBind = true;
  33609. if (this._boundTexturesCache[channel] === internalTexture) {
  33610. if (!isPartOfTextureArray) {
  33611. this._bindSamplerUniformToChannel(internalTexture._associatedChannel, channel);
  33612. }
  33613. needToBind = false;
  33614. }
  33615. this._activeChannel = channel;
  33616. if (internalTexture && internalTexture.isMultiview) {
  33617. if (needToBind) {
  33618. this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, internalTexture, isPartOfTextureArray);
  33619. }
  33620. }
  33621. else if (internalTexture && internalTexture.is3D) {
  33622. if (needToBind) {
  33623. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  33624. }
  33625. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33626. internalTexture._cachedWrapU = texture.wrapU;
  33627. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33628. }
  33629. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33630. internalTexture._cachedWrapV = texture.wrapV;
  33631. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33632. }
  33633. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  33634. internalTexture._cachedWrapR = texture.wrapR;
  33635. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  33636. }
  33637. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  33638. }
  33639. else if (internalTexture && internalTexture.isCube) {
  33640. if (needToBind) {
  33641. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  33642. }
  33643. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  33644. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  33645. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  33646. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  33647. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  33648. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  33649. }
  33650. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  33651. }
  33652. else {
  33653. if (needToBind) {
  33654. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  33655. }
  33656. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33657. internalTexture._cachedWrapU = texture.wrapU;
  33658. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33659. }
  33660. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33661. internalTexture._cachedWrapV = texture.wrapV;
  33662. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33663. }
  33664. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  33665. }
  33666. return true;
  33667. };
  33668. /**
  33669. * Sets an array of texture to the webGL context
  33670. * @param channel defines the channel where the texture array must be set
  33671. * @param uniform defines the associated uniform location
  33672. * @param textures defines the array of textures to bind
  33673. */
  33674. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  33675. if (channel === undefined || !uniform) {
  33676. return;
  33677. }
  33678. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  33679. this._textureUnits = new Int32Array(textures.length);
  33680. }
  33681. for (var i = 0; i < textures.length; i++) {
  33682. var texture = textures[i].getInternalTexture();
  33683. if (texture) {
  33684. this._textureUnits[channel + i] = channel + i;
  33685. texture._associatedChannel = channel + i;
  33686. }
  33687. else {
  33688. this._textureUnits[channel + i] = -1;
  33689. }
  33690. }
  33691. this._gl.uniform1iv(uniform, this._textureUnits);
  33692. for (var index = 0; index < textures.length; index++) {
  33693. this._setTexture(this._textureUnits[index], textures[index], true);
  33694. }
  33695. };
  33696. /** @hidden */
  33697. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  33698. var internalTexture = texture.getInternalTexture();
  33699. if (!internalTexture) {
  33700. return;
  33701. }
  33702. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  33703. var value = texture.anisotropicFilteringLevel;
  33704. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  33705. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  33706. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  33707. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  33708. }
  33709. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  33710. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  33711. internalTexture._cachedAnisotropicFilteringLevel = value;
  33712. }
  33713. };
  33714. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  33715. this._bindTextureDirectly(target, texture, true, true);
  33716. this._gl.texParameterf(target, parameter, value);
  33717. };
  33718. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  33719. if (texture) {
  33720. this._bindTextureDirectly(target, texture, true, true);
  33721. }
  33722. this._gl.texParameteri(target, parameter, value);
  33723. };
  33724. /**
  33725. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33726. * @param x defines the x coordinate of the rectangle where pixels must be read
  33727. * @param y defines the y coordinate of the rectangle where pixels must be read
  33728. * @param width defines the width of the rectangle where pixels must be read
  33729. * @param height defines the height of the rectangle where pixels must be read
  33730. * @returns a Uint8Array containing RGBA colors
  33731. */
  33732. Engine.prototype.readPixels = function (x, y, width, height) {
  33733. var data = new Uint8Array(height * width * 4);
  33734. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  33735. return data;
  33736. };
  33737. /**
  33738. * Add an externaly attached data from its key.
  33739. * This method call will fail and return false, if such key already exists.
  33740. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33741. * @param key the unique key that identifies the data
  33742. * @param data the data object to associate to the key for this Engine instance
  33743. * @return true if no such key were already present and the data was added successfully, false otherwise
  33744. */
  33745. Engine.prototype.addExternalData = function (key, data) {
  33746. if (!this._externalData) {
  33747. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33748. }
  33749. return this._externalData.add(key, data);
  33750. };
  33751. /**
  33752. * Get an externaly attached data from its key
  33753. * @param key the unique key that identifies the data
  33754. * @return the associated data, if present (can be null), or undefined if not present
  33755. */
  33756. Engine.prototype.getExternalData = function (key) {
  33757. if (!this._externalData) {
  33758. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33759. }
  33760. return this._externalData.get(key);
  33761. };
  33762. /**
  33763. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33764. * @param key the unique key that identifies the data
  33765. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33766. * @return the associated data, can be null if the factory returned null.
  33767. */
  33768. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  33769. if (!this._externalData) {
  33770. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33771. }
  33772. return this._externalData.getOrAddWithFactory(key, factory);
  33773. };
  33774. /**
  33775. * Remove an externaly attached data from the Engine instance
  33776. * @param key the unique key that identifies the data
  33777. * @return true if the data was successfully removed, false if it doesn't exist
  33778. */
  33779. Engine.prototype.removeExternalData = function (key) {
  33780. if (!this._externalData) {
  33781. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33782. }
  33783. return this._externalData.remove(key);
  33784. };
  33785. /**
  33786. * Unbind all vertex attributes from the webGL context
  33787. */
  33788. Engine.prototype.unbindAllAttributes = function () {
  33789. if (this._mustWipeVertexAttributes) {
  33790. this._mustWipeVertexAttributes = false;
  33791. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  33792. this._gl.disableVertexAttribArray(i);
  33793. this._vertexAttribArraysEnabled[i] = false;
  33794. this._currentBufferPointers[i].active = false;
  33795. }
  33796. return;
  33797. }
  33798. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  33799. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  33800. continue;
  33801. }
  33802. this._gl.disableVertexAttribArray(i);
  33803. this._vertexAttribArraysEnabled[i] = false;
  33804. this._currentBufferPointers[i].active = false;
  33805. }
  33806. };
  33807. /**
  33808. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  33809. */
  33810. Engine.prototype.releaseEffects = function () {
  33811. for (var name in this._compiledEffects) {
  33812. this._deleteProgram(this._compiledEffects[name]._program);
  33813. }
  33814. this._compiledEffects = {};
  33815. };
  33816. /**
  33817. * Dispose and release all associated resources
  33818. */
  33819. Engine.prototype.dispose = function () {
  33820. this.hideLoadingUI();
  33821. this.stopRenderLoop();
  33822. this.onNewSceneAddedObservable.clear();
  33823. // Release postProcesses
  33824. while (this.postProcesses.length) {
  33825. this.postProcesses[0].dispose();
  33826. }
  33827. // Empty texture
  33828. if (this._emptyTexture) {
  33829. this._releaseTexture(this._emptyTexture);
  33830. this._emptyTexture = null;
  33831. }
  33832. if (this._emptyCubeTexture) {
  33833. this._releaseTexture(this._emptyCubeTexture);
  33834. this._emptyCubeTexture = null;
  33835. }
  33836. // Rescale PP
  33837. if (this._rescalePostProcess) {
  33838. this._rescalePostProcess.dispose();
  33839. }
  33840. // Release scenes
  33841. while (this.scenes.length) {
  33842. this.scenes[0].dispose();
  33843. }
  33844. // Release audio engine
  33845. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  33846. Engine.audioEngine.dispose();
  33847. }
  33848. // Release effects
  33849. this.releaseEffects();
  33850. // Unbind
  33851. this.unbindAllAttributes();
  33852. this._boundUniforms = [];
  33853. if (this._dummyFramebuffer) {
  33854. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  33855. }
  33856. //WebVR
  33857. this.disableVR();
  33858. // Events
  33859. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  33860. window.removeEventListener("blur", this._onBlur);
  33861. window.removeEventListener("focus", this._onFocus);
  33862. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  33863. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  33864. if (this._renderingCanvas) {
  33865. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  33866. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  33867. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  33868. if (!this._doNotHandleContextLost) {
  33869. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  33870. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  33871. }
  33872. }
  33873. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  33874. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  33875. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  33876. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  33877. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  33878. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  33879. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  33880. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  33881. if (this._onVrDisplayConnect) {
  33882. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  33883. if (this._onVrDisplayDisconnect) {
  33884. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  33885. }
  33886. if (this._onVrDisplayPresentChange) {
  33887. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  33888. }
  33889. this._onVrDisplayConnect = null;
  33890. this._onVrDisplayDisconnect = null;
  33891. }
  33892. }
  33893. // Remove from Instances
  33894. var index = Engine.Instances.indexOf(this);
  33895. if (index >= 0) {
  33896. Engine.Instances.splice(index, 1);
  33897. }
  33898. this._workingCanvas = null;
  33899. this._workingContext = null;
  33900. this._currentBufferPointers = [];
  33901. this._renderingCanvas = null;
  33902. this._currentProgram = null;
  33903. this._bindedRenderFunction = null;
  33904. this.onResizeObservable.clear();
  33905. this.onCanvasBlurObservable.clear();
  33906. this.onCanvasFocusObservable.clear();
  33907. this.onCanvasPointerOutObservable.clear();
  33908. this.onBeginFrameObservable.clear();
  33909. this.onEndFrameObservable.clear();
  33910. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  33911. // Abort active requests
  33912. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  33913. var request = _a[_i];
  33914. request.abort();
  33915. }
  33916. };
  33917. // Loading screen
  33918. /**
  33919. * Display the loading screen
  33920. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33921. */
  33922. Engine.prototype.displayLoadingUI = function () {
  33923. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  33924. return;
  33925. }
  33926. var loadingScreen = this.loadingScreen;
  33927. if (loadingScreen) {
  33928. loadingScreen.displayLoadingUI();
  33929. }
  33930. };
  33931. /**
  33932. * Hide the loading screen
  33933. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33934. */
  33935. Engine.prototype.hideLoadingUI = function () {
  33936. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  33937. return;
  33938. }
  33939. var loadingScreen = this.loadingScreen;
  33940. if (loadingScreen) {
  33941. loadingScreen.hideLoadingUI();
  33942. }
  33943. };
  33944. Object.defineProperty(Engine.prototype, "loadingScreen", {
  33945. /**
  33946. * Gets the current loading screen object
  33947. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33948. */
  33949. get: function () {
  33950. if (!this._loadingScreen && this._renderingCanvas) {
  33951. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  33952. }
  33953. return this._loadingScreen;
  33954. },
  33955. /**
  33956. * Sets the current loading screen object
  33957. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33958. */
  33959. set: function (loadingScreen) {
  33960. this._loadingScreen = loadingScreen;
  33961. },
  33962. enumerable: true,
  33963. configurable: true
  33964. });
  33965. Object.defineProperty(Engine.prototype, "loadingUIText", {
  33966. /**
  33967. * Sets the current loading screen text
  33968. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33969. */
  33970. set: function (text) {
  33971. this.loadingScreen.loadingUIText = text;
  33972. },
  33973. enumerable: true,
  33974. configurable: true
  33975. });
  33976. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  33977. /**
  33978. * Sets the current loading screen background color
  33979. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33980. */
  33981. set: function (color) {
  33982. this.loadingScreen.loadingUIBackgroundColor = color;
  33983. },
  33984. enumerable: true,
  33985. configurable: true
  33986. });
  33987. /**
  33988. * Attach a new callback raised when context lost event is fired
  33989. * @param callback defines the callback to call
  33990. */
  33991. Engine.prototype.attachContextLostEvent = function (callback) {
  33992. if (this._renderingCanvas) {
  33993. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  33994. }
  33995. };
  33996. /**
  33997. * Attach a new callback raised when context restored event is fired
  33998. * @param callback defines the callback to call
  33999. */
  34000. Engine.prototype.attachContextRestoredEvent = function (callback) {
  34001. if (this._renderingCanvas) {
  34002. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  34003. }
  34004. };
  34005. /**
  34006. * Gets the source code of the vertex shader associated with a specific webGL program
  34007. * @param program defines the program to use
  34008. * @returns a string containing the source code of the vertex shader associated with the program
  34009. */
  34010. Engine.prototype.getVertexShaderSource = function (program) {
  34011. var shaders = this._gl.getAttachedShaders(program);
  34012. if (!shaders) {
  34013. return null;
  34014. }
  34015. return this._gl.getShaderSource(shaders[0]);
  34016. };
  34017. /**
  34018. * Gets the source code of the fragment shader associated with a specific webGL program
  34019. * @param program defines the program to use
  34020. * @returns a string containing the source code of the fragment shader associated with the program
  34021. */
  34022. Engine.prototype.getFragmentShaderSource = function (program) {
  34023. var shaders = this._gl.getAttachedShaders(program);
  34024. if (!shaders) {
  34025. return null;
  34026. }
  34027. return this._gl.getShaderSource(shaders[1]);
  34028. };
  34029. /**
  34030. * Get the current error code of the webGL context
  34031. * @returns the error code
  34032. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34033. */
  34034. Engine.prototype.getError = function () {
  34035. return this._gl.getError();
  34036. };
  34037. // FPS
  34038. /**
  34039. * Gets the current framerate
  34040. * @returns a number representing the framerate
  34041. */
  34042. Engine.prototype.getFps = function () {
  34043. return this._fps;
  34044. };
  34045. /**
  34046. * Gets the time spent between current and previous frame
  34047. * @returns a number representing the delta time in ms
  34048. */
  34049. Engine.prototype.getDeltaTime = function () {
  34050. return this._deltaTime;
  34051. };
  34052. Engine.prototype._measureFps = function () {
  34053. this._performanceMonitor.sampleFrame();
  34054. this._fps = this._performanceMonitor.averageFPS;
  34055. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  34056. };
  34057. /** @hidden */
  34058. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  34059. if (faceIndex === void 0) { faceIndex = -1; }
  34060. if (level === void 0) { level = 0; }
  34061. if (buffer === void 0) { buffer = null; }
  34062. var gl = this._gl;
  34063. if (!this._dummyFramebuffer) {
  34064. var dummy = gl.createFramebuffer();
  34065. if (!dummy) {
  34066. throw new Error("Unable to create dummy framebuffer");
  34067. }
  34068. this._dummyFramebuffer = dummy;
  34069. }
  34070. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  34071. if (faceIndex > -1) {
  34072. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  34073. }
  34074. else {
  34075. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  34076. }
  34077. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  34078. switch (readType) {
  34079. case gl.UNSIGNED_BYTE:
  34080. if (!buffer) {
  34081. buffer = new Uint8Array(4 * width * height);
  34082. }
  34083. readType = gl.UNSIGNED_BYTE;
  34084. break;
  34085. default:
  34086. if (!buffer) {
  34087. buffer = new Float32Array(4 * width * height);
  34088. }
  34089. readType = gl.FLOAT;
  34090. break;
  34091. }
  34092. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  34093. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  34094. return buffer;
  34095. };
  34096. Engine.prototype._canRenderToFloatFramebuffer = function () {
  34097. if (this._webGLVersion > 1) {
  34098. return this._caps.colorBufferFloat;
  34099. }
  34100. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  34101. };
  34102. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  34103. if (this._webGLVersion > 1) {
  34104. return this._caps.colorBufferFloat;
  34105. }
  34106. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  34107. };
  34108. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  34109. Engine.prototype._canRenderToFramebuffer = function (type) {
  34110. var gl = this._gl;
  34111. //clear existing errors
  34112. while (gl.getError() !== gl.NO_ERROR) { }
  34113. var successful = true;
  34114. var texture = gl.createTexture();
  34115. gl.bindTexture(gl.TEXTURE_2D, texture);
  34116. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  34117. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  34118. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  34119. var fb = gl.createFramebuffer();
  34120. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  34121. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  34122. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  34123. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  34124. successful = successful && (gl.getError() === gl.NO_ERROR);
  34125. //try render by clearing frame buffer's color buffer
  34126. if (successful) {
  34127. gl.clear(gl.COLOR_BUFFER_BIT);
  34128. successful = successful && (gl.getError() === gl.NO_ERROR);
  34129. }
  34130. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  34131. if (successful) {
  34132. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  34133. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  34134. var readFormat = gl.RGBA;
  34135. var readType = gl.UNSIGNED_BYTE;
  34136. var buffer = new Uint8Array(4);
  34137. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  34138. successful = successful && (gl.getError() === gl.NO_ERROR);
  34139. }
  34140. //clean up
  34141. gl.deleteTexture(texture);
  34142. gl.deleteFramebuffer(fb);
  34143. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  34144. //clear accumulated errors
  34145. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  34146. return successful;
  34147. };
  34148. /** @hidden */
  34149. Engine.prototype._getWebGLTextureType = function (type) {
  34150. if (this._webGLVersion === 1) {
  34151. switch (type) {
  34152. case Engine.TEXTURETYPE_FLOAT:
  34153. return this._gl.FLOAT;
  34154. case Engine.TEXTURETYPE_HALF_FLOAT:
  34155. return this._gl.HALF_FLOAT_OES;
  34156. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  34157. return this._gl.UNSIGNED_BYTE;
  34158. }
  34159. return this._gl.UNSIGNED_BYTE;
  34160. }
  34161. switch (type) {
  34162. case Engine.TEXTURETYPE_BYTE:
  34163. return this._gl.BYTE;
  34164. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  34165. return this._gl.UNSIGNED_BYTE;
  34166. case Engine.TEXTURETYPE_SHORT:
  34167. return this._gl.SHORT;
  34168. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  34169. return this._gl.UNSIGNED_SHORT;
  34170. case Engine.TEXTURETYPE_INT:
  34171. return this._gl.INT;
  34172. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  34173. return this._gl.UNSIGNED_INT;
  34174. case Engine.TEXTURETYPE_FLOAT:
  34175. return this._gl.FLOAT;
  34176. case Engine.TEXTURETYPE_HALF_FLOAT:
  34177. return this._gl.HALF_FLOAT;
  34178. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  34179. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  34180. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  34181. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  34182. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  34183. return this._gl.UNSIGNED_SHORT_5_6_5;
  34184. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  34185. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  34186. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  34187. return this._gl.UNSIGNED_INT_24_8;
  34188. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  34189. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  34190. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  34191. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  34192. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  34193. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  34194. }
  34195. return this._gl.UNSIGNED_BYTE;
  34196. };
  34197. Engine.prototype._getInternalFormat = function (format) {
  34198. var internalFormat = this._gl.RGBA;
  34199. switch (format) {
  34200. case Engine.TEXTUREFORMAT_ALPHA:
  34201. internalFormat = this._gl.ALPHA;
  34202. break;
  34203. case Engine.TEXTUREFORMAT_LUMINANCE:
  34204. internalFormat = this._gl.LUMINANCE;
  34205. break;
  34206. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  34207. internalFormat = this._gl.LUMINANCE_ALPHA;
  34208. break;
  34209. case Engine.TEXTUREFORMAT_RED:
  34210. internalFormat = this._gl.RED;
  34211. break;
  34212. case Engine.TEXTUREFORMAT_RG:
  34213. internalFormat = this._gl.RG;
  34214. break;
  34215. case Engine.TEXTUREFORMAT_RGB:
  34216. internalFormat = this._gl.RGB;
  34217. break;
  34218. case Engine.TEXTUREFORMAT_RGBA:
  34219. internalFormat = this._gl.RGBA;
  34220. break;
  34221. }
  34222. if (this._webGLVersion > 1) {
  34223. switch (format) {
  34224. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34225. internalFormat = this._gl.RED_INTEGER;
  34226. break;
  34227. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34228. internalFormat = this._gl.RG_INTEGER;
  34229. break;
  34230. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34231. internalFormat = this._gl.RGB_INTEGER;
  34232. break;
  34233. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34234. internalFormat = this._gl.RGBA_INTEGER;
  34235. break;
  34236. }
  34237. }
  34238. return internalFormat;
  34239. };
  34240. /** @hidden */
  34241. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  34242. if (this._webGLVersion === 1) {
  34243. if (format !== undefined) {
  34244. switch (format) {
  34245. case Engine.TEXTUREFORMAT_ALPHA:
  34246. return this._gl.ALPHA;
  34247. case Engine.TEXTUREFORMAT_LUMINANCE:
  34248. return this._gl.LUMINANCE;
  34249. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  34250. return this._gl.LUMINANCE_ALPHA;
  34251. }
  34252. }
  34253. return this._gl.RGBA;
  34254. }
  34255. switch (type) {
  34256. case Engine.TEXTURETYPE_BYTE:
  34257. switch (format) {
  34258. case Engine.TEXTUREFORMAT_RED:
  34259. return this._gl.R8_SNORM;
  34260. case Engine.TEXTUREFORMAT_RG:
  34261. return this._gl.RG8_SNORM;
  34262. case Engine.TEXTUREFORMAT_RGB:
  34263. return this._gl.RGB8_SNORM;
  34264. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34265. return this._gl.R8I;
  34266. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34267. return this._gl.RG8I;
  34268. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34269. return this._gl.RGB8I;
  34270. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34271. return this._gl.RGBA8I;
  34272. default:
  34273. return this._gl.RGBA8_SNORM;
  34274. }
  34275. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  34276. switch (format) {
  34277. case Engine.TEXTUREFORMAT_RED:
  34278. return this._gl.R8;
  34279. case Engine.TEXTUREFORMAT_RG:
  34280. return this._gl.RG8;
  34281. case Engine.TEXTUREFORMAT_RGB:
  34282. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  34283. case Engine.TEXTUREFORMAT_RGBA:
  34284. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  34285. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34286. return this._gl.R8UI;
  34287. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34288. return this._gl.RG8UI;
  34289. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34290. return this._gl.RGB8UI;
  34291. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34292. return this._gl.RGBA8UI;
  34293. default:
  34294. return this._gl.RGBA8;
  34295. }
  34296. case Engine.TEXTURETYPE_SHORT:
  34297. switch (format) {
  34298. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34299. return this._gl.R16I;
  34300. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34301. return this._gl.RG16I;
  34302. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34303. return this._gl.RGB16I;
  34304. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34305. return this._gl.RGBA16I;
  34306. default:
  34307. return this._gl.RGBA16I;
  34308. }
  34309. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  34310. switch (format) {
  34311. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34312. return this._gl.R16UI;
  34313. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34314. return this._gl.RG16UI;
  34315. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34316. return this._gl.RGB16UI;
  34317. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34318. return this._gl.RGBA16UI;
  34319. default:
  34320. return this._gl.RGBA16UI;
  34321. }
  34322. case Engine.TEXTURETYPE_INT:
  34323. switch (format) {
  34324. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34325. return this._gl.R32I;
  34326. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34327. return this._gl.RG32I;
  34328. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34329. return this._gl.RGB32I;
  34330. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34331. return this._gl.RGBA32I;
  34332. default:
  34333. return this._gl.RGBA32I;
  34334. }
  34335. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  34336. switch (format) {
  34337. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34338. return this._gl.R32UI;
  34339. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34340. return this._gl.RG32UI;
  34341. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34342. return this._gl.RGB32UI;
  34343. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34344. return this._gl.RGBA32UI;
  34345. default:
  34346. return this._gl.RGBA32UI;
  34347. }
  34348. case Engine.TEXTURETYPE_FLOAT:
  34349. switch (format) {
  34350. case Engine.TEXTUREFORMAT_RED:
  34351. return this._gl.R32F; // By default. Other possibility is R16F.
  34352. case Engine.TEXTUREFORMAT_RG:
  34353. return this._gl.RG32F; // By default. Other possibility is RG16F.
  34354. case Engine.TEXTUREFORMAT_RGB:
  34355. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  34356. case Engine.TEXTUREFORMAT_RGBA:
  34357. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  34358. default:
  34359. return this._gl.RGBA32F;
  34360. }
  34361. case Engine.TEXTURETYPE_HALF_FLOAT:
  34362. switch (format) {
  34363. case Engine.TEXTUREFORMAT_RED:
  34364. return this._gl.R16F;
  34365. case Engine.TEXTUREFORMAT_RG:
  34366. return this._gl.RG16F;
  34367. case Engine.TEXTUREFORMAT_RGB:
  34368. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  34369. case Engine.TEXTUREFORMAT_RGBA:
  34370. return this._gl.RGBA16F;
  34371. default:
  34372. return this._gl.RGBA16F;
  34373. }
  34374. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  34375. return this._gl.RGB565;
  34376. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  34377. return this._gl.R11F_G11F_B10F;
  34378. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  34379. return this._gl.RGB9_E5;
  34380. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  34381. return this._gl.RGBA4;
  34382. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  34383. return this._gl.RGB5_A1;
  34384. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  34385. switch (format) {
  34386. case Engine.TEXTUREFORMAT_RGBA:
  34387. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  34388. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34389. return this._gl.RGB10_A2UI;
  34390. default:
  34391. return this._gl.RGB10_A2;
  34392. }
  34393. }
  34394. return this._gl.RGBA8;
  34395. };
  34396. /** @hidden */
  34397. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  34398. if (type === Engine.TEXTURETYPE_FLOAT) {
  34399. return this._gl.RGBA32F;
  34400. }
  34401. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  34402. return this._gl.RGBA16F;
  34403. }
  34404. return this._gl.RGBA8;
  34405. };
  34406. /** @hidden */
  34407. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  34408. var _this = this;
  34409. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  34410. this._activeRequests.push(request);
  34411. request.onCompleteObservable.add(function (request) {
  34412. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  34413. });
  34414. return request;
  34415. };
  34416. /** @hidden */
  34417. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  34418. var _this = this;
  34419. return new Promise(function (resolve, reject) {
  34420. _this._loadFile(url, function (data) {
  34421. resolve(data);
  34422. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  34423. reject(exception);
  34424. });
  34425. });
  34426. };
  34427. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  34428. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  34429. var onload = function (data) {
  34430. loadedFiles[index] = data;
  34431. loadedFiles._internalCount++;
  34432. if (loadedFiles._internalCount === 6) {
  34433. onfinish(loadedFiles);
  34434. }
  34435. };
  34436. var onerror = function (request, exception) {
  34437. if (onErrorCallBack && request) {
  34438. onErrorCallBack(request.status + " " + request.statusText, exception);
  34439. }
  34440. };
  34441. this._loadFile(url, onload, undefined, undefined, true, onerror);
  34442. };
  34443. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  34444. if (onError === void 0) { onError = null; }
  34445. var loadedFiles = [];
  34446. loadedFiles._internalCount = 0;
  34447. for (var index = 0; index < 6; index++) {
  34448. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  34449. }
  34450. };
  34451. // Statics
  34452. /**
  34453. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  34454. * @returns true if the engine can be created
  34455. * @ignorenaming
  34456. */
  34457. Engine.isSupported = function () {
  34458. try {
  34459. var tempcanvas = document.createElement("canvas");
  34460. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  34461. return gl != null && !!window.WebGLRenderingContext;
  34462. }
  34463. catch (e) {
  34464. return false;
  34465. }
  34466. };
  34467. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34468. Engine.ExceptionList = [
  34469. { key: "Chrome\/63\.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  34470. { key: "Firefox\/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34471. { key: "Firefox\/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34472. { key: "Chrome\/72.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  34473. { key: "Chrome\/73.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  34474. { key: "Chrome\/74.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  34475. { key: "Mac OS.+Chrome\/71", capture: null, captureConstraint: null, targets: ["vao"] },
  34476. { key: "Mac OS.+Chrome\/72", capture: null, captureConstraint: null, targets: ["vao"] }
  34477. ];
  34478. /**
  34479. * Hidden
  34480. */
  34481. Engine._TextureLoaders = [];
  34482. // Const statics
  34483. /** Defines that alpha blending is disabled */
  34484. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE;
  34485. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34486. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_ADD;
  34487. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34488. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE;
  34489. /** Defines that alpha blending to DEST - SRC * DEST */
  34490. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_SUBTRACT;
  34491. /** Defines that alpha blending to SRC * DEST */
  34492. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_MULTIPLY;
  34493. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34494. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_MAXIMIZED;
  34495. /** Defines that alpha blending to SRC + DEST */
  34496. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_ONEONE;
  34497. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34498. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_PREMULTIPLIED;
  34499. /**
  34500. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34501. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34502. */
  34503. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  34504. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34505. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_INTERPOLATE;
  34506. /**
  34507. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34508. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34509. */
  34510. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_SCREENMODE;
  34511. /** Defines that the ressource is not delayed*/
  34512. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DELAYLOADSTATE_NONE;
  34513. /** Defines that the ressource was successfully delay loaded */
  34514. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DELAYLOADSTATE_LOADED;
  34515. /** Defines that the ressource is currently delay loading */
  34516. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DELAYLOADSTATE_LOADING;
  34517. /** Defines that the ressource is delayed and has not started loading */
  34518. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DELAYLOADSTATE_NOTLOADED;
  34519. // Depht or Stencil test Constants.
  34520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34521. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].NEVER;
  34522. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  34523. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALWAYS;
  34524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34525. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].LESS;
  34526. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34527. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].EQUAL;
  34528. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  34529. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].LEQUAL;
  34530. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34531. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].GREATER;
  34532. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  34533. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].GEQUAL;
  34534. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  34535. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].NOTEQUAL;
  34536. // Stencil Actions Constants.
  34537. /** Passed to stencilOperation to specify that stencil value must be kept */
  34538. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].KEEP;
  34539. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34540. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].REPLACE;
  34541. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34542. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].INCR;
  34543. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34544. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DECR;
  34545. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34546. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].INVERT;
  34547. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34548. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].INCR_WRAP;
  34549. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34550. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DECR_WRAP;
  34551. /** Texture is not repeating outside of 0..1 UVs */
  34552. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  34553. /** Texture is repeating outside of 0..1 UVs */
  34554. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  34555. /** Texture is repeating and mirrored */
  34556. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  34557. /** ALPHA */
  34558. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_ALPHA;
  34559. /** LUMINANCE */
  34560. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_LUMINANCE;
  34561. /** LUMINANCE_ALPHA */
  34562. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  34563. /** RGB */
  34564. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RGB;
  34565. /** RGBA */
  34566. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RGBA;
  34567. /** RED */
  34568. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RED;
  34569. /** RED (2nd reference) */
  34570. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_R;
  34571. /** RG */
  34572. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RG;
  34573. /** RED_INTEGER */
  34574. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  34575. /** RED_INTEGER (2nd reference) */
  34576. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_R_INTEGER;
  34577. /** RG_INTEGER */
  34578. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  34579. /** RGB_INTEGER */
  34580. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  34581. /** RGBA_INTEGER */
  34582. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  34583. /** UNSIGNED_BYTE */
  34584. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  34585. /** UNSIGNED_BYTE (2nd reference) */
  34586. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34587. /** FLOAT */
  34588. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_FLOAT;
  34589. /** HALF_FLOAT */
  34590. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_HALF_FLOAT;
  34591. /** BYTE */
  34592. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_BYTE;
  34593. /** SHORT */
  34594. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_SHORT;
  34595. /** UNSIGNED_SHORT */
  34596. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  34597. /** INT */
  34598. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_INT;
  34599. /** UNSIGNED_INT */
  34600. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  34601. /** UNSIGNED_SHORT_4_4_4_4 */
  34602. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  34603. /** UNSIGNED_SHORT_5_5_5_1 */
  34604. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  34605. /** UNSIGNED_SHORT_5_6_5 */
  34606. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  34607. /** UNSIGNED_INT_2_10_10_10_REV */
  34608. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  34609. /** UNSIGNED_INT_24_8 */
  34610. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  34611. /** UNSIGNED_INT_10F_11F_11F_REV */
  34612. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  34613. /** UNSIGNED_INT_5_9_9_9_REV */
  34614. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  34615. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34616. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  34617. /** nearest is mag = nearest and min = nearest and mip = linear */
  34618. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  34619. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34620. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  34621. /** Trilinear is mag = linear and min = linear and mip = linear */
  34622. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34623. /** nearest is mag = nearest and min = nearest and mip = linear */
  34624. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  34625. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34626. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  34627. /** Trilinear is mag = linear and min = linear and mip = linear */
  34628. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  34629. /** mag = nearest and min = nearest and mip = nearest */
  34630. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  34631. /** mag = nearest and min = linear and mip = nearest */
  34632. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  34633. /** mag = nearest and min = linear and mip = linear */
  34634. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  34635. /** mag = nearest and min = linear and mip = none */
  34636. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_LINEAR;
  34637. /** mag = nearest and min = nearest and mip = none */
  34638. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_NEAREST;
  34639. /** mag = linear and min = nearest and mip = nearest */
  34640. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  34641. /** mag = linear and min = nearest and mip = linear */
  34642. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  34643. /** mag = linear and min = linear and mip = none */
  34644. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_LINEAR;
  34645. /** mag = linear and min = nearest and mip = none */
  34646. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_NEAREST;
  34647. /** Explicit coordinates mode */
  34648. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_EXPLICIT_MODE;
  34649. /** Spherical coordinates mode */
  34650. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_SPHERICAL_MODE;
  34651. /** Planar coordinates mode */
  34652. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_PLANAR_MODE;
  34653. /** Cubic coordinates mode */
  34654. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_CUBIC_MODE;
  34655. /** Projection coordinates mode */
  34656. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_PROJECTION_MODE;
  34657. /** Skybox coordinates mode */
  34658. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_SKYBOX_MODE;
  34659. /** Inverse Cubic coordinates mode */
  34660. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_INVCUBIC_MODE;
  34661. /** Equirectangular coordinates mode */
  34662. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  34663. /** Equirectangular Fixed coordinates mode */
  34664. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  34665. /** Equirectangular Fixed Mirrored coordinates mode */
  34666. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  34667. // Texture rescaling mode
  34668. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34669. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].SCALEMODE_FLOOR;
  34670. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34671. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].SCALEMODE_NEAREST;
  34672. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34673. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].SCALEMODE_CEILING;
  34674. // Updatable statics so stick with vars here
  34675. /**
  34676. * Gets or sets the epsilon value used by collision engine
  34677. */
  34678. Engine.CollisionsEpsilon = 0.001;
  34679. /**
  34680. * Method called to create the default rescale post process on each engine.
  34681. */
  34682. Engine._RescalePostProcessFactory = null;
  34683. return Engine;
  34684. }());
  34685. /***/ }),
  34686. /***/ "./Engines/engineStore.ts":
  34687. /*!********************************!*\
  34688. !*** ./Engines/engineStore.ts ***!
  34689. \********************************/
  34690. /*! exports provided: EngineStore */
  34691. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34692. "use strict";
  34693. __webpack_require__.r(__webpack_exports__);
  34694. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  34695. /**
  34696. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34697. * during the life time of the application.
  34698. */
  34699. var EngineStore = /** @class */ (function () {
  34700. function EngineStore() {
  34701. }
  34702. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  34703. /**
  34704. * Gets the latest created engine
  34705. */
  34706. get: function () {
  34707. if (this.Instances.length === 0) {
  34708. return null;
  34709. }
  34710. return this.Instances[this.Instances.length - 1];
  34711. },
  34712. enumerable: true,
  34713. configurable: true
  34714. });
  34715. Object.defineProperty(EngineStore, "LastCreatedScene", {
  34716. /**
  34717. * Gets the latest created scene
  34718. */
  34719. get: function () {
  34720. var lastCreatedEngine = this.LastCreatedEngine;
  34721. if (!lastCreatedEngine) {
  34722. return null;
  34723. }
  34724. if (lastCreatedEngine.scenes.length === 0) {
  34725. return null;
  34726. }
  34727. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  34728. },
  34729. enumerable: true,
  34730. configurable: true
  34731. });
  34732. /** Gets the list of created engines */
  34733. EngineStore.Instances = new Array();
  34734. return EngineStore;
  34735. }());
  34736. /***/ }),
  34737. /***/ "./Engines/index.ts":
  34738. /*!**************************!*\
  34739. !*** ./Engines/index.ts ***!
  34740. \**************************/
  34741. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  34742. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34743. "use strict";
  34744. __webpack_require__.r(__webpack_exports__);
  34745. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  34747. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  34748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  34749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  34750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  34751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  34752. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  34753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  34754. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  34755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  34756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  34757. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  34758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  34759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  34760. /***/ }),
  34761. /***/ "./Engines/nullEngine.ts":
  34762. /*!*******************************!*\
  34763. !*** ./Engines/nullEngine.ts ***!
  34764. \*******************************/
  34765. /*! exports provided: NullEngineOptions, NullEngine */
  34766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34767. "use strict";
  34768. __webpack_require__.r(__webpack_exports__);
  34769. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  34770. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  34771. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34772. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  34773. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  34774. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  34775. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  34776. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34777. /**
  34778. * Options to create the null engine
  34779. */
  34780. var NullEngineOptions = /** @class */ (function () {
  34781. function NullEngineOptions() {
  34782. /**
  34783. * Render width (Default: 512)
  34784. */
  34785. this.renderWidth = 512;
  34786. /**
  34787. * Render height (Default: 256)
  34788. */
  34789. this.renderHeight = 256;
  34790. /**
  34791. * Texture size (Default: 512)
  34792. */
  34793. this.textureSize = 512;
  34794. /**
  34795. * If delta time between frames should be constant
  34796. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34797. */
  34798. this.deterministicLockstep = false;
  34799. /**
  34800. * Maximum about of steps between frames (Default: 4)
  34801. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34802. */
  34803. this.lockstepMaxSteps = 4;
  34804. }
  34805. return NullEngineOptions;
  34806. }());
  34807. /**
  34808. * The null engine class provides support for headless version of babylon.js.
  34809. * This can be used in server side scenario or for testing purposes
  34810. */
  34811. var NullEngine = /** @class */ (function (_super) {
  34812. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  34813. function NullEngine(options) {
  34814. if (options === void 0) { options = new NullEngineOptions(); }
  34815. var _this = _super.call(this, null) || this;
  34816. if (options.deterministicLockstep === undefined) {
  34817. options.deterministicLockstep = false;
  34818. }
  34819. if (options.lockstepMaxSteps === undefined) {
  34820. options.lockstepMaxSteps = 4;
  34821. }
  34822. _this._options = options;
  34823. // Init caps
  34824. // We consider we are on a webgl1 capable device
  34825. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  34826. _this._caps.maxTexturesImageUnits = 16;
  34827. _this._caps.maxVertexTextureImageUnits = 16;
  34828. _this._caps.maxTextureSize = 512;
  34829. _this._caps.maxCubemapTextureSize = 512;
  34830. _this._caps.maxRenderTextureSize = 512;
  34831. _this._caps.maxVertexAttribs = 16;
  34832. _this._caps.maxVaryingVectors = 16;
  34833. _this._caps.maxFragmentUniformVectors = 16;
  34834. _this._caps.maxVertexUniformVectors = 16;
  34835. // Extensions
  34836. _this._caps.standardDerivatives = false;
  34837. _this._caps.astc = null;
  34838. _this._caps.s3tc = null;
  34839. _this._caps.pvrtc = null;
  34840. _this._caps.etc1 = null;
  34841. _this._caps.etc2 = null;
  34842. _this._caps.textureAnisotropicFilterExtension = null;
  34843. _this._caps.maxAnisotropy = 0;
  34844. _this._caps.uintIndices = false;
  34845. _this._caps.fragmentDepthSupported = false;
  34846. _this._caps.highPrecisionShaderSupported = true;
  34847. _this._caps.colorBufferFloat = false;
  34848. _this._caps.textureFloat = false;
  34849. _this._caps.textureFloatLinearFiltering = false;
  34850. _this._caps.textureFloatRender = false;
  34851. _this._caps.textureHalfFloat = false;
  34852. _this._caps.textureHalfFloatLinearFiltering = false;
  34853. _this._caps.textureHalfFloatRender = false;
  34854. _this._caps.textureLOD = false;
  34855. _this._caps.drawBuffersExtension = false;
  34856. _this._caps.depthTextureExtension = false;
  34857. _this._caps.vertexArrayObject = false;
  34858. _this._caps.instancedArrays = false;
  34859. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  34860. // Wrappers
  34861. var theCurrentGlobal = (typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : window);
  34862. if (typeof URL === "undefined") {
  34863. theCurrentGlobal.URL = {
  34864. createObjectURL: function () { },
  34865. revokeObjectURL: function () { }
  34866. };
  34867. }
  34868. if (typeof Blob === "undefined") {
  34869. theCurrentGlobal.Blob = function () { };
  34870. }
  34871. return _this;
  34872. }
  34873. /**
  34874. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34875. */
  34876. NullEngine.prototype.isDeterministicLockStep = function () {
  34877. return this._options.deterministicLockstep;
  34878. };
  34879. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  34880. NullEngine.prototype.getLockstepMaxSteps = function () {
  34881. return this._options.lockstepMaxSteps;
  34882. };
  34883. /**
  34884. * Sets hardware scaling, used to save performance if needed
  34885. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34886. */
  34887. NullEngine.prototype.getHardwareScalingLevel = function () {
  34888. return 1.0;
  34889. };
  34890. NullEngine.prototype.createVertexBuffer = function (vertices) {
  34891. return {
  34892. capacity: 0,
  34893. references: 1,
  34894. is32Bits: false
  34895. };
  34896. };
  34897. NullEngine.prototype.createIndexBuffer = function (indices) {
  34898. return {
  34899. capacity: 0,
  34900. references: 1,
  34901. is32Bits: false
  34902. };
  34903. };
  34904. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  34905. if (stencil === void 0) { stencil = false; }
  34906. };
  34907. NullEngine.prototype.getRenderWidth = function (useScreen) {
  34908. if (useScreen === void 0) { useScreen = false; }
  34909. if (!useScreen && this._currentRenderTarget) {
  34910. return this._currentRenderTarget.width;
  34911. }
  34912. return this._options.renderWidth;
  34913. };
  34914. NullEngine.prototype.getRenderHeight = function (useScreen) {
  34915. if (useScreen === void 0) { useScreen = false; }
  34916. if (!useScreen && this._currentRenderTarget) {
  34917. return this._currentRenderTarget.height;
  34918. }
  34919. return this._options.renderHeight;
  34920. };
  34921. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  34922. this._cachedViewport = viewport;
  34923. };
  34924. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  34925. return {
  34926. transformFeedback: null,
  34927. __SPECTOR_rebuildProgram: null,
  34928. isParallelCompiled: false
  34929. };
  34930. };
  34931. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  34932. return [];
  34933. };
  34934. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  34935. return [];
  34936. };
  34937. NullEngine.prototype.bindSamplers = function (effect) {
  34938. this._currentEffect = null;
  34939. };
  34940. NullEngine.prototype.enableEffect = function (effect) {
  34941. this._currentEffect = effect;
  34942. if (effect.onBind) {
  34943. effect.onBind(effect);
  34944. }
  34945. if (effect._onBindObservable) {
  34946. effect._onBindObservable.notifyObservers(effect);
  34947. }
  34948. };
  34949. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  34950. if (zOffset === void 0) { zOffset = 0; }
  34951. if (reverseSide === void 0) { reverseSide = false; }
  34952. };
  34953. NullEngine.prototype.setIntArray = function (uniform, array) {
  34954. };
  34955. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  34956. };
  34957. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  34958. };
  34959. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  34960. };
  34961. NullEngine.prototype.setFloatArray = function (uniform, array) {
  34962. };
  34963. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  34964. };
  34965. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  34966. };
  34967. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  34968. };
  34969. NullEngine.prototype.setArray = function (uniform, array) {
  34970. };
  34971. NullEngine.prototype.setArray2 = function (uniform, array) {
  34972. };
  34973. NullEngine.prototype.setArray3 = function (uniform, array) {
  34974. };
  34975. NullEngine.prototype.setArray4 = function (uniform, array) {
  34976. };
  34977. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  34978. };
  34979. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  34980. };
  34981. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  34982. };
  34983. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  34984. };
  34985. NullEngine.prototype.setFloat = function (uniform, value) {
  34986. };
  34987. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  34988. };
  34989. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  34990. };
  34991. NullEngine.prototype.setBool = function (uniform, bool) {
  34992. };
  34993. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  34994. };
  34995. NullEngine.prototype.setColor3 = function (uniform, color3) {
  34996. };
  34997. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  34998. };
  34999. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  35000. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  35001. if (this._alphaMode === mode) {
  35002. return;
  35003. }
  35004. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  35005. if (!noDepthWriteChange) {
  35006. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  35007. }
  35008. this._alphaMode = mode;
  35009. };
  35010. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  35011. };
  35012. NullEngine.prototype.wipeCaches = function (bruteForce) {
  35013. if (this.preventCacheWipeBetweenFrames) {
  35014. return;
  35015. }
  35016. this.resetTextureCache();
  35017. this._currentEffect = null;
  35018. if (bruteForce) {
  35019. this._currentProgram = null;
  35020. this._stencilState.reset();
  35021. this._depthCullingState.reset();
  35022. this._alphaState.reset();
  35023. }
  35024. this._cachedVertexBuffers = null;
  35025. this._cachedIndexBuffer = null;
  35026. this._cachedEffectForVertexBuffers = null;
  35027. };
  35028. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  35029. };
  35030. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  35031. };
  35032. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  35033. };
  35034. /** @hidden */
  35035. NullEngine.prototype._createTexture = function () {
  35036. return {};
  35037. };
  35038. /** @hidden */
  35039. NullEngine.prototype._releaseTexture = function (texture) {
  35040. };
  35041. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  35042. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  35043. if (onLoad === void 0) { onLoad = null; }
  35044. if (onError === void 0) { onError = null; }
  35045. if (buffer === void 0) { buffer = null; }
  35046. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  35047. var url = String(urlArg);
  35048. texture.url = url;
  35049. texture.generateMipMaps = !noMipmap;
  35050. texture.samplingMode = samplingMode;
  35051. texture.invertY = invertY;
  35052. texture.baseWidth = this._options.textureSize;
  35053. texture.baseHeight = this._options.textureSize;
  35054. texture.width = this._options.textureSize;
  35055. texture.height = this._options.textureSize;
  35056. if (format) {
  35057. texture.format = format;
  35058. }
  35059. texture.isReady = true;
  35060. if (onLoad) {
  35061. onLoad();
  35062. }
  35063. this._internalTexturesCache.push(texture);
  35064. return texture;
  35065. };
  35066. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  35067. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  35068. if (options !== undefined && typeof options === "object") {
  35069. fullOptions.generateMipMaps = options.generateMipMaps;
  35070. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  35071. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  35072. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  35073. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  35074. }
  35075. else {
  35076. fullOptions.generateMipMaps = options;
  35077. fullOptions.generateDepthBuffer = true;
  35078. fullOptions.generateStencilBuffer = false;
  35079. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  35080. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  35081. }
  35082. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  35083. var width = size.width || size;
  35084. var height = size.height || size;
  35085. texture._depthStencilBuffer = {};
  35086. texture._framebuffer = {};
  35087. texture.baseWidth = width;
  35088. texture.baseHeight = height;
  35089. texture.width = width;
  35090. texture.height = height;
  35091. texture.isReady = true;
  35092. texture.samples = 1;
  35093. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  35094. texture.samplingMode = fullOptions.samplingMode;
  35095. texture.type = fullOptions.type;
  35096. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  35097. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  35098. this._internalTexturesCache.push(texture);
  35099. return texture;
  35100. };
  35101. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  35102. texture.samplingMode = samplingMode;
  35103. };
  35104. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  35105. if (this._currentRenderTarget) {
  35106. this.unBindFramebuffer(this._currentRenderTarget);
  35107. }
  35108. this._currentRenderTarget = texture;
  35109. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  35110. if (this._cachedViewport && !forceFullscreenViewport) {
  35111. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  35112. }
  35113. };
  35114. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  35115. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  35116. this._currentRenderTarget = null;
  35117. if (onBeforeUnbind) {
  35118. if (texture._MSAAFramebuffer) {
  35119. this._currentFramebuffer = texture._framebuffer;
  35120. }
  35121. onBeforeUnbind();
  35122. }
  35123. this._currentFramebuffer = null;
  35124. };
  35125. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  35126. var vbo = {
  35127. capacity: 1,
  35128. references: 1,
  35129. is32Bits: false
  35130. };
  35131. return vbo;
  35132. };
  35133. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  35134. if (premulAlpha === void 0) { premulAlpha = false; }
  35135. };
  35136. NullEngine.prototype.areAllEffectsReady = function () {
  35137. return true;
  35138. };
  35139. /**
  35140. * @hidden
  35141. * Get the current error code of the webGL context
  35142. * @returns the error code
  35143. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35144. */
  35145. NullEngine.prototype.getError = function () {
  35146. return 0;
  35147. };
  35148. /** @hidden */
  35149. NullEngine.prototype._getUnpackAlignement = function () {
  35150. return 1;
  35151. };
  35152. /** @hidden */
  35153. NullEngine.prototype._unpackFlipY = function (value) {
  35154. };
  35155. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  35156. if (offset === void 0) { offset = 0; }
  35157. };
  35158. /**
  35159. * Updates a dynamic vertex buffer.
  35160. * @param vertexBuffer the vertex buffer to update
  35161. * @param data the data used to update the vertex buffer
  35162. * @param byteOffset the byte offset of the data (optional)
  35163. * @param byteLength the byte length of the data (optional)
  35164. */
  35165. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  35166. };
  35167. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  35168. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  35169. this._boundTexturesCache[this._activeChannel] = texture;
  35170. return true;
  35171. }
  35172. return false;
  35173. };
  35174. /** @hidden */
  35175. NullEngine.prototype._bindTexture = function (channel, texture) {
  35176. if (channel < 0) {
  35177. return;
  35178. }
  35179. this._bindTextureDirectly(0, texture);
  35180. };
  35181. /** @hidden */
  35182. NullEngine.prototype._releaseBuffer = function (buffer) {
  35183. buffer.references--;
  35184. if (buffer.references === 0) {
  35185. return true;
  35186. }
  35187. return false;
  35188. };
  35189. NullEngine.prototype.releaseEffects = function () {
  35190. };
  35191. NullEngine.prototype.displayLoadingUI = function () {
  35192. };
  35193. NullEngine.prototype.hideLoadingUI = function () {
  35194. };
  35195. /** @hidden */
  35196. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  35197. if (faceIndex === void 0) { faceIndex = 0; }
  35198. if (lod === void 0) { lod = 0; }
  35199. };
  35200. /** @hidden */
  35201. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  35202. if (faceIndex === void 0) { faceIndex = 0; }
  35203. if (lod === void 0) { lod = 0; }
  35204. };
  35205. /** @hidden */
  35206. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  35207. if (faceIndex === void 0) { faceIndex = 0; }
  35208. if (lod === void 0) { lod = 0; }
  35209. };
  35210. /** @hidden */
  35211. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  35212. if (faceIndex === void 0) { faceIndex = 0; }
  35213. if (lod === void 0) { lod = 0; }
  35214. };
  35215. return NullEngine;
  35216. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  35217. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  35218. /***/ }),
  35219. /***/ "./Events/clipboardEvents.ts":
  35220. /*!***********************************!*\
  35221. !*** ./Events/clipboardEvents.ts ***!
  35222. \***********************************/
  35223. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  35224. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35225. "use strict";
  35226. __webpack_require__.r(__webpack_exports__);
  35227. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  35228. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  35229. /**
  35230. * Gather the list of clipboard event types as constants.
  35231. */
  35232. var ClipboardEventTypes = /** @class */ (function () {
  35233. function ClipboardEventTypes() {
  35234. }
  35235. /**
  35236. * The clipboard event is fired when a copy command is active (pressed).
  35237. */
  35238. ClipboardEventTypes.COPY = 0x01; //
  35239. /**
  35240. * The clipboard event is fired when a cut command is active (pressed).
  35241. */
  35242. ClipboardEventTypes.CUT = 0x02;
  35243. /**
  35244. * The clipboard event is fired when a paste command is active (pressed).
  35245. */
  35246. ClipboardEventTypes.PASTE = 0x03;
  35247. return ClipboardEventTypes;
  35248. }());
  35249. /**
  35250. * This class is used to store clipboard related info for the onClipboardObservable event.
  35251. */
  35252. var ClipboardInfo = /** @class */ (function () {
  35253. /**
  35254. *Creates an instance of ClipboardInfo.
  35255. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  35256. * @param event Defines the related dom event
  35257. */
  35258. function ClipboardInfo(
  35259. /**
  35260. * Defines the type of event (BABYLON.ClipboardEventTypes)
  35261. */
  35262. type,
  35263. /**
  35264. * Defines the related dom event
  35265. */
  35266. event) {
  35267. this.type = type;
  35268. this.event = event;
  35269. }
  35270. /**
  35271. * Get the clipboard event's type from the keycode.
  35272. * @param keyCode Defines the keyCode for the current keyboard event.
  35273. * @return {number}
  35274. */
  35275. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  35276. var charCode = keyCode;
  35277. //TODO: add codes for extended ASCII
  35278. switch (charCode) {
  35279. case 67: return ClipboardEventTypes.COPY;
  35280. case 86: return ClipboardEventTypes.PASTE;
  35281. case 88: return ClipboardEventTypes.CUT;
  35282. default: return -1;
  35283. }
  35284. };
  35285. return ClipboardInfo;
  35286. }());
  35287. /***/ }),
  35288. /***/ "./Events/index.ts":
  35289. /*!*************************!*\
  35290. !*** ./Events/index.ts ***!
  35291. \*************************/
  35292. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  35293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35294. "use strict";
  35295. __webpack_require__.r(__webpack_exports__);
  35296. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  35297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  35298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  35299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  35300. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  35301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  35302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  35303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  35304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  35305. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  35306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  35307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  35308. /***/ }),
  35309. /***/ "./Events/keyboardEvents.ts":
  35310. /*!**********************************!*\
  35311. !*** ./Events/keyboardEvents.ts ***!
  35312. \**********************************/
  35313. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  35314. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35315. "use strict";
  35316. __webpack_require__.r(__webpack_exports__);
  35317. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  35318. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  35319. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  35320. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35321. /**
  35322. * Gather the list of keyboard event types as constants.
  35323. */
  35324. var KeyboardEventTypes = /** @class */ (function () {
  35325. function KeyboardEventTypes() {
  35326. }
  35327. /**
  35328. * The keydown event is fired when a key becomes active (pressed).
  35329. */
  35330. KeyboardEventTypes.KEYDOWN = 0x01;
  35331. /**
  35332. * The keyup event is fired when a key has been released.
  35333. */
  35334. KeyboardEventTypes.KEYUP = 0x02;
  35335. return KeyboardEventTypes;
  35336. }());
  35337. /**
  35338. * This class is used to store keyboard related info for the onKeyboardObservable event.
  35339. */
  35340. var KeyboardInfo = /** @class */ (function () {
  35341. /**
  35342. * Instantiates a new keyboard info.
  35343. * This class is used to store keyboard related info for the onKeyboardObservable event.
  35344. * @param type Defines the type of event (KeyboardEventTypes)
  35345. * @param event Defines the related dom event
  35346. */
  35347. function KeyboardInfo(
  35348. /**
  35349. * Defines the type of event (KeyboardEventTypes)
  35350. */
  35351. type,
  35352. /**
  35353. * Defines the related dom event
  35354. */
  35355. event) {
  35356. this.type = type;
  35357. this.event = event;
  35358. }
  35359. return KeyboardInfo;
  35360. }());
  35361. /**
  35362. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  35363. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  35364. */
  35365. var KeyboardInfoPre = /** @class */ (function (_super) {
  35366. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  35367. /**
  35368. * Instantiates a new keyboard pre info.
  35369. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  35370. * @param type Defines the type of event (KeyboardEventTypes)
  35371. * @param event Defines the related dom event
  35372. */
  35373. function KeyboardInfoPre(
  35374. /**
  35375. * Defines the type of event (KeyboardEventTypes)
  35376. */
  35377. type,
  35378. /**
  35379. * Defines the related dom event
  35380. */
  35381. event) {
  35382. var _this = _super.call(this, type, event) || this;
  35383. _this.type = type;
  35384. _this.event = event;
  35385. _this.skipOnPointerObservable = false;
  35386. return _this;
  35387. }
  35388. return KeyboardInfoPre;
  35389. }(KeyboardInfo));
  35390. /***/ }),
  35391. /***/ "./Events/pointerEvents.ts":
  35392. /*!*********************************!*\
  35393. !*** ./Events/pointerEvents.ts ***!
  35394. \*********************************/
  35395. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  35396. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35397. "use strict";
  35398. __webpack_require__.r(__webpack_exports__);
  35399. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  35400. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  35401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  35402. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  35403. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35404. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  35405. /**
  35406. * Gather the list of pointer event types as constants.
  35407. */
  35408. var PointerEventTypes = /** @class */ (function () {
  35409. function PointerEventTypes() {
  35410. }
  35411. /**
  35412. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  35413. */
  35414. PointerEventTypes.POINTERDOWN = 0x01;
  35415. /**
  35416. * The pointerup event is fired when a pointer is no longer active.
  35417. */
  35418. PointerEventTypes.POINTERUP = 0x02;
  35419. /**
  35420. * The pointermove event is fired when a pointer changes coordinates.
  35421. */
  35422. PointerEventTypes.POINTERMOVE = 0x04;
  35423. /**
  35424. * The pointerwheel event is fired when a mouse wheel has been rotated.
  35425. */
  35426. PointerEventTypes.POINTERWHEEL = 0x08;
  35427. /**
  35428. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  35429. */
  35430. PointerEventTypes.POINTERPICK = 0x10;
  35431. /**
  35432. * The pointertap event is fired when a the object has been touched and released without drag.
  35433. */
  35434. PointerEventTypes.POINTERTAP = 0x20;
  35435. /**
  35436. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  35437. */
  35438. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  35439. return PointerEventTypes;
  35440. }());
  35441. /**
  35442. * Base class of pointer info types.
  35443. */
  35444. var PointerInfoBase = /** @class */ (function () {
  35445. /**
  35446. * Instantiates the base class of pointers info.
  35447. * @param type Defines the type of event (PointerEventTypes)
  35448. * @param event Defines the related dom event
  35449. */
  35450. function PointerInfoBase(
  35451. /**
  35452. * Defines the type of event (PointerEventTypes)
  35453. */
  35454. type,
  35455. /**
  35456. * Defines the related dom event
  35457. */
  35458. event) {
  35459. this.type = type;
  35460. this.event = event;
  35461. }
  35462. return PointerInfoBase;
  35463. }());
  35464. /**
  35465. * This class is used to store pointer related info for the onPrePointerObservable event.
  35466. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  35467. */
  35468. var PointerInfoPre = /** @class */ (function (_super) {
  35469. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  35470. /**
  35471. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  35472. * @param type Defines the type of event (PointerEventTypes)
  35473. * @param event Defines the related dom event
  35474. * @param localX Defines the local x coordinates of the pointer when the event occured
  35475. * @param localY Defines the local y coordinates of the pointer when the event occured
  35476. */
  35477. function PointerInfoPre(type, event, localX, localY) {
  35478. var _this = _super.call(this, type, event) || this;
  35479. /**
  35480. * Ray from a pointer if availible (eg. 6dof controller)
  35481. */
  35482. _this.ray = null;
  35483. _this.skipOnPointerObservable = false;
  35484. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  35485. return _this;
  35486. }
  35487. return PointerInfoPre;
  35488. }(PointerInfoBase));
  35489. /**
  35490. * This type contains all the data related to a pointer event in Babylon.js.
  35491. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  35492. */
  35493. var PointerInfo = /** @class */ (function (_super) {
  35494. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  35495. /**
  35496. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  35497. * @param type Defines the type of event (PointerEventTypes)
  35498. * @param event Defines the related dom event
  35499. * @param pickInfo Defines the picking info associated to the info (if any)\
  35500. */
  35501. function PointerInfo(type, event,
  35502. /**
  35503. * Defines the picking info associated to the info (if any)\
  35504. */
  35505. pickInfo) {
  35506. var _this = _super.call(this, type, event) || this;
  35507. _this.pickInfo = pickInfo;
  35508. return _this;
  35509. }
  35510. return PointerInfo;
  35511. }(PointerInfoBase));
  35512. /***/ }),
  35513. /***/ "./Gamepads/Controllers/daydreamController.ts":
  35514. /*!****************************************************!*\
  35515. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  35516. \****************************************************/
  35517. /*! exports provided: DaydreamController */
  35518. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35519. "use strict";
  35520. __webpack_require__.r(__webpack_exports__);
  35521. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  35522. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35523. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  35524. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35525. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35526. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35527. /**
  35528. * Google Daydream controller
  35529. */
  35530. var DaydreamController = /** @class */ (function (_super) {
  35531. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  35532. /**
  35533. * Creates a new DaydreamController from a gamepad
  35534. * @param vrGamepad the gamepad that the controller should be created from
  35535. */
  35536. function DaydreamController(vrGamepad) {
  35537. var _this = _super.call(this, vrGamepad) || this;
  35538. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  35539. return _this;
  35540. }
  35541. /**
  35542. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35543. * @param scene scene in which to add meshes
  35544. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35545. */
  35546. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35547. var _this = this;
  35548. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  35549. _this._defaultModel = newMeshes[1];
  35550. _this.attachToMesh(_this._defaultModel);
  35551. if (meshLoaded) {
  35552. meshLoaded(_this._defaultModel);
  35553. }
  35554. });
  35555. };
  35556. /**
  35557. * Called once for each button that changed state since the last frame
  35558. * @param buttonIdx Which button index changed
  35559. * @param state New state of the button
  35560. * @param changes Which properties on the state changed since last frame
  35561. */
  35562. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35563. // Daydream controller only has 1 GamepadButton (on the trackpad).
  35564. if (buttonIdx === 0) {
  35565. var observable = this.onTriggerStateChangedObservable;
  35566. if (observable) {
  35567. observable.notifyObservers(state);
  35568. }
  35569. }
  35570. else {
  35571. // If the app or home buttons are ever made available
  35572. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  35573. }
  35574. };
  35575. /**
  35576. * Base Url for the controller model.
  35577. */
  35578. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35579. /**
  35580. * File name for the controller model.
  35581. */
  35582. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  35583. /**
  35584. * Gamepad Id prefix used to identify Daydream Controller.
  35585. */
  35586. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  35587. return DaydreamController;
  35588. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35589. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35590. canCreate: function (gamepadInfo) {
  35591. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  35592. },
  35593. create: function (gamepadInfo) {
  35594. return new DaydreamController(gamepadInfo);
  35595. }
  35596. });
  35597. /***/ }),
  35598. /***/ "./Gamepads/Controllers/gearVRController.ts":
  35599. /*!**************************************************!*\
  35600. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  35601. \**************************************************/
  35602. /*! exports provided: GearVRController */
  35603. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35604. "use strict";
  35605. __webpack_require__.r(__webpack_exports__);
  35606. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  35607. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35608. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35609. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  35610. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35611. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35612. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35613. /**
  35614. * Gear VR Controller
  35615. */
  35616. var GearVRController = /** @class */ (function (_super) {
  35617. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  35618. /**
  35619. * Creates a new GearVRController from a gamepad
  35620. * @param vrGamepad the gamepad that the controller should be created from
  35621. */
  35622. function GearVRController(vrGamepad) {
  35623. var _this = _super.call(this, vrGamepad) || this;
  35624. _this._buttonIndexToObservableNameMap = [
  35625. 'onPadStateChangedObservable',
  35626. 'onTriggerStateChangedObservable' // Trigger
  35627. ];
  35628. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  35629. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  35630. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  35631. _this._disableTrackPosition(_this._calculatedPosition);
  35632. return _this;
  35633. }
  35634. /**
  35635. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35636. * @param scene scene in which to add meshes
  35637. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35638. */
  35639. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35640. var _this = this;
  35641. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  35642. // Offset the controller so it will rotate around the users wrist
  35643. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  35644. newMeshes[1].parent = mesh;
  35645. newMeshes[1].position.z = -0.15;
  35646. _this._defaultModel = mesh;
  35647. _this.attachToMesh(_this._defaultModel);
  35648. if (meshLoaded) {
  35649. meshLoaded(_this._defaultModel);
  35650. }
  35651. });
  35652. };
  35653. /**
  35654. * Called once for each button that changed state since the last frame
  35655. * @param buttonIdx Which button index changed
  35656. * @param state New state of the button
  35657. * @param changes Which properties on the state changed since last frame
  35658. */
  35659. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35660. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  35661. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  35662. // Only emit events for buttons that we know how to map from index to observable
  35663. var observable = this[observableName];
  35664. if (observable) {
  35665. observable.notifyObservers(state);
  35666. }
  35667. }
  35668. };
  35669. /**
  35670. * Base Url for the controller model.
  35671. */
  35672. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35673. /**
  35674. * File name for the controller model.
  35675. */
  35676. GearVRController.MODEL_FILENAME = 'generic.babylon';
  35677. /**
  35678. * Gamepad Id prefix used to identify this controller.
  35679. */
  35680. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  35681. return GearVRController;
  35682. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  35683. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35684. canCreate: function (gamepadInfo) {
  35685. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  35686. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  35687. },
  35688. create: function (gamepadInfo) {
  35689. return new GearVRController(gamepadInfo);
  35690. }
  35691. });
  35692. /***/ }),
  35693. /***/ "./Gamepads/Controllers/genericController.ts":
  35694. /*!***************************************************!*\
  35695. !*** ./Gamepads/Controllers/genericController.ts ***!
  35696. \***************************************************/
  35697. /*! exports provided: GenericController */
  35698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35699. "use strict";
  35700. __webpack_require__.r(__webpack_exports__);
  35701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  35702. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35703. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35704. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35705. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35706. /**
  35707. * Generic Controller
  35708. */
  35709. var GenericController = /** @class */ (function (_super) {
  35710. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  35711. /**
  35712. * Creates a new GenericController from a gamepad
  35713. * @param vrGamepad the gamepad that the controller should be created from
  35714. */
  35715. function GenericController(vrGamepad) {
  35716. return _super.call(this, vrGamepad) || this;
  35717. }
  35718. /**
  35719. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35720. * @param scene scene in which to add meshes
  35721. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35722. */
  35723. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35724. var _this = this;
  35725. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  35726. _this._defaultModel = newMeshes[1];
  35727. _this.attachToMesh(_this._defaultModel);
  35728. if (meshLoaded) {
  35729. meshLoaded(_this._defaultModel);
  35730. }
  35731. });
  35732. };
  35733. /**
  35734. * Called once for each button that changed state since the last frame
  35735. * @param buttonIdx Which button index changed
  35736. * @param state New state of the button
  35737. * @param changes Which properties on the state changed since last frame
  35738. */
  35739. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35740. console.log("Button id: " + buttonIdx + "state: ");
  35741. console.dir(state);
  35742. };
  35743. /**
  35744. * Base Url for the controller model.
  35745. */
  35746. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35747. /**
  35748. * File name for the controller model.
  35749. */
  35750. GenericController.MODEL_FILENAME = 'generic.babylon';
  35751. return GenericController;
  35752. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  35753. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  35754. /***/ }),
  35755. /***/ "./Gamepads/Controllers/index.ts":
  35756. /*!***************************************!*\
  35757. !*** ./Gamepads/Controllers/index.ts ***!
  35758. \***************************************/
  35759. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  35760. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35761. "use strict";
  35762. __webpack_require__.r(__webpack_exports__);
  35763. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  35764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  35765. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  35766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  35767. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  35768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  35769. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  35770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  35771. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  35773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  35774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  35775. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  35776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  35777. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  35779. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  35780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  35781. /***/ }),
  35782. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  35783. /*!*******************************************************!*\
  35784. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  35785. \*******************************************************/
  35786. /*! exports provided: OculusTouchController */
  35787. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35788. "use strict";
  35789. __webpack_require__.r(__webpack_exports__);
  35790. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  35791. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35792. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35793. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35794. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35795. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35796. /**
  35797. * Oculus Touch Controller
  35798. */
  35799. var OculusTouchController = /** @class */ (function (_super) {
  35800. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  35801. /**
  35802. * Creates a new OculusTouchController from a gamepad
  35803. * @param vrGamepad the gamepad that the controller should be created from
  35804. */
  35805. function OculusTouchController(vrGamepad) {
  35806. var _this = _super.call(this, vrGamepad) || this;
  35807. /**
  35808. * Fired when the secondary trigger on this controller is modified
  35809. */
  35810. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35811. /**
  35812. * Fired when the thumb rest on this controller is modified
  35813. */
  35814. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35815. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  35816. return _this;
  35817. }
  35818. /**
  35819. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35820. * @param scene scene in which to add meshes
  35821. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35822. */
  35823. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35824. var _this = this;
  35825. var meshName;
  35826. // Hand
  35827. if (this.hand === 'left') {
  35828. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  35829. }
  35830. else { // Right is the default if no hand is specified
  35831. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  35832. }
  35833. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  35834. /*
  35835. Parent Mesh name: oculus_touch_left
  35836. - body
  35837. - trigger
  35838. - thumbstick
  35839. - grip
  35840. - button_y
  35841. - button_x
  35842. - button_enter
  35843. */
  35844. _this._defaultModel = newMeshes[1];
  35845. _this.attachToMesh(_this._defaultModel);
  35846. if (meshLoaded) {
  35847. meshLoaded(_this._defaultModel);
  35848. }
  35849. });
  35850. };
  35851. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  35852. /**
  35853. * Fired when the A button on this controller is modified
  35854. */
  35855. get: function () {
  35856. if (this.hand === 'right') {
  35857. return this.onMainButtonStateChangedObservable;
  35858. }
  35859. else {
  35860. throw new Error('No A button on left hand');
  35861. }
  35862. },
  35863. enumerable: true,
  35864. configurable: true
  35865. });
  35866. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  35867. /**
  35868. * Fired when the B button on this controller is modified
  35869. */
  35870. get: function () {
  35871. if (this.hand === 'right') {
  35872. return this.onSecondaryButtonStateChangedObservable;
  35873. }
  35874. else {
  35875. throw new Error('No B button on left hand');
  35876. }
  35877. },
  35878. enumerable: true,
  35879. configurable: true
  35880. });
  35881. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  35882. /**
  35883. * Fired when the X button on this controller is modified
  35884. */
  35885. get: function () {
  35886. if (this.hand === 'left') {
  35887. return this.onMainButtonStateChangedObservable;
  35888. }
  35889. else {
  35890. throw new Error('No X button on right hand');
  35891. }
  35892. },
  35893. enumerable: true,
  35894. configurable: true
  35895. });
  35896. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  35897. /**
  35898. * Fired when the Y button on this controller is modified
  35899. */
  35900. get: function () {
  35901. if (this.hand === 'left') {
  35902. return this.onSecondaryButtonStateChangedObservable;
  35903. }
  35904. else {
  35905. throw new Error('No Y button on right hand');
  35906. }
  35907. },
  35908. enumerable: true,
  35909. configurable: true
  35910. });
  35911. /**
  35912. * Called once for each button that changed state since the last frame
  35913. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  35914. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  35915. * 2) secondary trigger (same)
  35916. * 3) A (right) X (left), touch, pressed = value
  35917. * 4) B / Y
  35918. * 5) thumb rest
  35919. * @param buttonIdx Which button index changed
  35920. * @param state New state of the button
  35921. * @param changes Which properties on the state changed since last frame
  35922. */
  35923. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35924. var notifyObject = state; //{ state: state, changes: changes };
  35925. var triggerDirection = this.hand === 'right' ? -1 : 1;
  35926. switch (buttonIdx) {
  35927. case 0:
  35928. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35929. return;
  35930. case 1: // index trigger
  35931. if (this._defaultModel) {
  35932. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  35933. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  35934. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  35935. }
  35936. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35937. return;
  35938. case 2: // secondary trigger
  35939. if (this._defaultModel) {
  35940. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  35941. }
  35942. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  35943. return;
  35944. case 3:
  35945. if (this._defaultModel) {
  35946. if (notifyObject.pressed) {
  35947. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  35948. }
  35949. else {
  35950. (this._defaultModel.getChildren()[1]).position.y = 0;
  35951. }
  35952. }
  35953. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35954. return;
  35955. case 4:
  35956. if (this._defaultModel) {
  35957. if (notifyObject.pressed) {
  35958. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35959. }
  35960. else {
  35961. (this._defaultModel.getChildren()[2]).position.y = 0;
  35962. }
  35963. }
  35964. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35965. return;
  35966. case 5:
  35967. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  35968. return;
  35969. }
  35970. };
  35971. /**
  35972. * Base Url for the controller model.
  35973. */
  35974. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  35975. /**
  35976. * File name for the left controller model.
  35977. */
  35978. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  35979. /**
  35980. * File name for the right controller model.
  35981. */
  35982. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  35983. return OculusTouchController;
  35984. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35985. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35986. canCreate: function (gamepadInfo) {
  35987. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  35988. },
  35989. create: function (gamepadInfo) {
  35990. return new OculusTouchController(gamepadInfo);
  35991. }
  35992. });
  35993. /***/ }),
  35994. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  35995. /*!*******************************************************!*\
  35996. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  35997. \*******************************************************/
  35998. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  35999. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36000. "use strict";
  36001. __webpack_require__.r(__webpack_exports__);
  36002. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  36003. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  36004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  36005. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36006. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36007. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  36008. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  36009. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  36010. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  36011. /**
  36012. * Defines the types of pose enabled controllers that are supported
  36013. */
  36014. var PoseEnabledControllerType;
  36015. (function (PoseEnabledControllerType) {
  36016. /**
  36017. * HTC Vive
  36018. */
  36019. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  36020. /**
  36021. * Oculus Rift
  36022. */
  36023. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  36024. /**
  36025. * Windows mixed reality
  36026. */
  36027. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  36028. /**
  36029. * Samsung gear VR
  36030. */
  36031. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  36032. /**
  36033. * Google Daydream
  36034. */
  36035. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  36036. /**
  36037. * Generic
  36038. */
  36039. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  36040. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  36041. /**
  36042. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  36043. */
  36044. var PoseEnabledControllerHelper = /** @class */ (function () {
  36045. function PoseEnabledControllerHelper() {
  36046. }
  36047. /**
  36048. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  36049. * @param vrGamepad the gamepad to initialized
  36050. * @returns a vr controller of the type the gamepad identified as
  36051. */
  36052. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  36053. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  36054. var factory = _a[_i];
  36055. if (factory.canCreate(vrGamepad)) {
  36056. return factory.create(vrGamepad);
  36057. }
  36058. }
  36059. if (this._DefaultControllerFactory) {
  36060. return this._DefaultControllerFactory(vrGamepad);
  36061. }
  36062. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  36063. };
  36064. /** @hidden */
  36065. PoseEnabledControllerHelper._ControllerFactories = [];
  36066. /** @hidden */
  36067. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  36068. return PoseEnabledControllerHelper;
  36069. }());
  36070. /**
  36071. * Defines the PoseEnabledController object that contains state of a vr capable controller
  36072. */
  36073. var PoseEnabledController = /** @class */ (function (_super) {
  36074. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  36075. /**
  36076. * Creates a new PoseEnabledController from a gamepad
  36077. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  36078. */
  36079. function PoseEnabledController(browserGamepad) {
  36080. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  36081. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  36082. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36083. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36084. /**
  36085. * The device position in babylon space
  36086. */
  36087. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36088. /**
  36089. * The device rotation in babylon space
  36090. */
  36091. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36092. /**
  36093. * The scale factor of the device in babylon space
  36094. */
  36095. _this.deviceScaleFactor = 1;
  36096. // Used to convert 6dof controllers to 3dof
  36097. _this._trackPosition = true;
  36098. _this._maxRotationDistFromHeadset = Math.PI / 5;
  36099. _this._draggedRoomRotation = 0;
  36100. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36101. /**
  36102. * Internal, matrix used to convert room space to babylon space
  36103. * @hidden
  36104. */
  36105. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  36106. /**
  36107. * Node to be used when casting a ray from the controller
  36108. * @hidden
  36109. */
  36110. _this._pointingPoseNode = null;
  36111. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  36112. /**
  36113. * @hidden
  36114. */
  36115. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36116. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  36117. _this.controllerType = PoseEnabledControllerType.GENERIC;
  36118. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36119. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36120. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36121. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36122. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  36123. return _this;
  36124. }
  36125. /**
  36126. * @hidden
  36127. */
  36128. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  36129. if (this._trackPosition) {
  36130. this._calculatedPosition.copyFrom(fixedPosition);
  36131. this._trackPosition = false;
  36132. }
  36133. };
  36134. /**
  36135. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  36136. */
  36137. PoseEnabledController.prototype.update = function () {
  36138. _super.prototype.update.call(this);
  36139. this._updatePoseAndMesh();
  36140. };
  36141. /**
  36142. * Updates only the pose device and mesh without doing any button event checking
  36143. */
  36144. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  36145. var pose = this.browserGamepad.pose;
  36146. this.updateFromDevice(pose);
  36147. if (!this._trackPosition && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera.devicePosition) {
  36148. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  36149. camera._computeDevicePosition();
  36150. this._deviceToWorld.setTranslation(camera.devicePosition);
  36151. if (camera.deviceRotationQuaternion) {
  36152. var camera = camera;
  36153. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  36154. // Find the radian distance away that the headset is from the controllers rotation
  36155. var distanceAway = Math.atan2(Math.sin(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0].y - this._draggedRoomRotation), Math.cos(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0].y - this._draggedRoomRotation));
  36156. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  36157. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  36158. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  36159. this._draggedRoomRotation += rotationAmount;
  36160. // Rotate controller around headset
  36161. var sin = Math.sin(-rotationAmount);
  36162. var cos = Math.cos(-rotationAmount);
  36163. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  36164. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  36165. }
  36166. }
  36167. }
  36168. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  36169. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  36170. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  36171. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  36172. if (this._mesh) {
  36173. this._mesh.position.copyFrom(this.devicePosition);
  36174. if (this._mesh.rotationQuaternion) {
  36175. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  36176. }
  36177. }
  36178. };
  36179. /**
  36180. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  36181. * @param poseData raw pose fromthe device
  36182. */
  36183. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  36184. if (poseData) {
  36185. this.rawPose = poseData;
  36186. if (poseData.position) {
  36187. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  36188. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  36189. this._deviceRoomPosition.z *= -1;
  36190. }
  36191. if (this._trackPosition) {
  36192. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  36193. }
  36194. this._calculatedPosition.addInPlace(this.position);
  36195. }
  36196. var pose = this.rawPose;
  36197. if (poseData.orientation && pose.orientation) {
  36198. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  36199. if (this._mesh) {
  36200. if (this._mesh.getScene().useRightHandedSystem) {
  36201. this._deviceRoomRotationQuaternion.z *= -1;
  36202. this._deviceRoomRotationQuaternion.w *= -1;
  36203. }
  36204. else {
  36205. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  36206. }
  36207. }
  36208. // if the camera is set, rotate to the camera's rotation
  36209. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  36210. }
  36211. }
  36212. };
  36213. /**
  36214. * Attaches a mesh to the controller
  36215. * @param mesh the mesh to be attached
  36216. */
  36217. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  36218. if (this._mesh) {
  36219. this._mesh.parent = null;
  36220. }
  36221. this._mesh = mesh;
  36222. if (this._poseControlledCamera) {
  36223. this._mesh.parent = this._poseControlledCamera;
  36224. }
  36225. if (!this._mesh.rotationQuaternion) {
  36226. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36227. }
  36228. // Sync controller mesh and pointing pose node's state with controller, this is done to avoid a frame where position is 0,0,0 when attaching mesh
  36229. this._updatePoseAndMesh();
  36230. if (this._pointingPoseNode) {
  36231. var parents = [];
  36232. var obj = this._pointingPoseNode;
  36233. while (obj.parent) {
  36234. parents.push(obj.parent);
  36235. obj = obj.parent;
  36236. }
  36237. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  36238. }
  36239. this._meshAttachedObservable.notifyObservers(mesh);
  36240. };
  36241. /**
  36242. * Attaches the controllers mesh to a camera
  36243. * @param camera the camera the mesh should be attached to
  36244. */
  36245. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  36246. this._poseControlledCamera = camera;
  36247. if (this._mesh) {
  36248. this._mesh.parent = this._poseControlledCamera;
  36249. }
  36250. };
  36251. /**
  36252. * Disposes of the controller
  36253. */
  36254. PoseEnabledController.prototype.dispose = function () {
  36255. if (this._mesh) {
  36256. this._mesh.dispose();
  36257. }
  36258. this._mesh = null;
  36259. _super.prototype.dispose.call(this);
  36260. };
  36261. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  36262. /**
  36263. * The mesh that is attached to the controller
  36264. */
  36265. get: function () {
  36266. return this._mesh;
  36267. },
  36268. enumerable: true,
  36269. configurable: true
  36270. });
  36271. /**
  36272. * Gets the ray of the controller in the direction the controller is pointing
  36273. * @param length the length the resulting ray should be
  36274. * @returns a ray in the direction the controller is pointing
  36275. */
  36276. PoseEnabledController.prototype.getForwardRay = function (length) {
  36277. if (length === void 0) { length = 100; }
  36278. if (!this.mesh) {
  36279. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 1), length);
  36280. }
  36281. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  36282. var origin = m.getTranslation();
  36283. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  36284. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  36285. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  36286. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  36287. };
  36288. /**
  36289. * Name of the child mesh that can be used to cast a ray from the controller
  36290. */
  36291. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  36292. return PoseEnabledController;
  36293. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  36294. /***/ }),
  36295. /***/ "./Gamepads/Controllers/viveController.ts":
  36296. /*!************************************************!*\
  36297. !*** ./Gamepads/Controllers/viveController.ts ***!
  36298. \************************************************/
  36299. /*! exports provided: ViveController */
  36300. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36301. "use strict";
  36302. __webpack_require__.r(__webpack_exports__);
  36303. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  36304. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36305. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  36306. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  36307. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36308. /**
  36309. * Vive Controller
  36310. */
  36311. var ViveController = /** @class */ (function (_super) {
  36312. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  36313. /**
  36314. * Creates a new ViveController from a gamepad
  36315. * @param vrGamepad the gamepad that the controller should be created from
  36316. */
  36317. function ViveController(vrGamepad) {
  36318. var _this = _super.call(this, vrGamepad) || this;
  36319. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  36320. _this._invertLeftStickY = true;
  36321. return _this;
  36322. }
  36323. /**
  36324. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36325. * @param scene scene in which to add meshes
  36326. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36327. */
  36328. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  36329. var _this = this;
  36330. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  36331. /*
  36332. Parent Mesh name: ViveWand
  36333. - body
  36334. - r_gripper
  36335. - l_gripper
  36336. - menu_button
  36337. - system_button
  36338. - trackpad
  36339. - trigger
  36340. - LED
  36341. */
  36342. _this._defaultModel = newMeshes[1];
  36343. _this.attachToMesh(_this._defaultModel);
  36344. if (meshLoaded) {
  36345. meshLoaded(_this._defaultModel);
  36346. }
  36347. });
  36348. };
  36349. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  36350. /**
  36351. * Fired when the left button on this controller is modified
  36352. */
  36353. get: function () {
  36354. return this.onMainButtonStateChangedObservable;
  36355. },
  36356. enumerable: true,
  36357. configurable: true
  36358. });
  36359. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  36360. /**
  36361. * Fired when the right button on this controller is modified
  36362. */
  36363. get: function () {
  36364. return this.onMainButtonStateChangedObservable;
  36365. },
  36366. enumerable: true,
  36367. configurable: true
  36368. });
  36369. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  36370. /**
  36371. * Fired when the menu button on this controller is modified
  36372. */
  36373. get: function () {
  36374. return this.onSecondaryButtonStateChangedObservable;
  36375. },
  36376. enumerable: true,
  36377. configurable: true
  36378. });
  36379. /**
  36380. * Called once for each button that changed state since the last frame
  36381. * Vive mapping:
  36382. * 0: touchpad
  36383. * 1: trigger
  36384. * 2: left AND right buttons
  36385. * 3: menu button
  36386. * @param buttonIdx Which button index changed
  36387. * @param state New state of the button
  36388. * @param changes Which properties on the state changed since last frame
  36389. */
  36390. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36391. var notifyObject = state; //{ state: state, changes: changes };
  36392. switch (buttonIdx) {
  36393. case 0:
  36394. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  36395. return;
  36396. case 1: // index trigger
  36397. if (this._defaultModel) {
  36398. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  36399. }
  36400. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  36401. return;
  36402. case 2: // left AND right button
  36403. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  36404. return;
  36405. case 3:
  36406. if (this._defaultModel) {
  36407. if (notifyObject.pressed) {
  36408. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  36409. }
  36410. else {
  36411. (this._defaultModel.getChildren()[2]).position.y = 0;
  36412. }
  36413. }
  36414. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  36415. return;
  36416. }
  36417. };
  36418. /**
  36419. * Base Url for the controller model.
  36420. */
  36421. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  36422. /**
  36423. * File name for the controller model.
  36424. */
  36425. ViveController.MODEL_FILENAME = 'wand.babylon';
  36426. return ViveController;
  36427. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  36428. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36429. canCreate: function (gamepadInfo) {
  36430. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  36431. },
  36432. create: function (gamepadInfo) {
  36433. return new ViveController(gamepadInfo);
  36434. }
  36435. });
  36436. /***/ }),
  36437. /***/ "./Gamepads/Controllers/webVRController.ts":
  36438. /*!*************************************************!*\
  36439. !*** ./Gamepads/Controllers/webVRController.ts ***!
  36440. \*************************************************/
  36441. /*! exports provided: WebVRController */
  36442. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36443. "use strict";
  36444. __webpack_require__.r(__webpack_exports__);
  36445. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  36446. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36447. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36448. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36449. /**
  36450. * Defines the WebVRController object that represents controllers tracked in 3D space
  36451. */
  36452. var WebVRController = /** @class */ (function (_super) {
  36453. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  36454. /**
  36455. * Creates a new WebVRController from a gamepad
  36456. * @param vrGamepad the gamepad that the WebVRController should be created from
  36457. */
  36458. function WebVRController(vrGamepad) {
  36459. var _this = _super.call(this, vrGamepad) || this;
  36460. // Observables
  36461. /**
  36462. * Fired when the trigger state has changed
  36463. */
  36464. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36465. /**
  36466. * Fired when the main button state has changed
  36467. */
  36468. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36469. /**
  36470. * Fired when the secondary button state has changed
  36471. */
  36472. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36473. /**
  36474. * Fired when the pad state has changed
  36475. */
  36476. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36477. /**
  36478. * Fired when controllers stick values have changed
  36479. */
  36480. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36481. /**
  36482. * X and Y axis corrisponding to the controllers joystick
  36483. */
  36484. _this.pad = { x: 0, y: 0 };
  36485. // avoid GC, store state in a tmp object
  36486. _this._changes = {
  36487. pressChanged: false,
  36488. touchChanged: false,
  36489. valueChanged: false,
  36490. changed: false
  36491. };
  36492. _this._buttons = new Array(vrGamepad.buttons.length);
  36493. _this.hand = vrGamepad.hand;
  36494. return _this;
  36495. }
  36496. /**
  36497. * Fired when a controller button's state has changed
  36498. * @param callback the callback containing the button that was modified
  36499. */
  36500. WebVRController.prototype.onButtonStateChange = function (callback) {
  36501. this._onButtonStateChange = callback;
  36502. };
  36503. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  36504. /**
  36505. * The default controller model for the controller
  36506. */
  36507. get: function () {
  36508. return this._defaultModel;
  36509. },
  36510. enumerable: true,
  36511. configurable: true
  36512. });
  36513. /**
  36514. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  36515. */
  36516. WebVRController.prototype.update = function () {
  36517. _super.prototype.update.call(this);
  36518. for (var index = 0; index < this._buttons.length; index++) {
  36519. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  36520. }
  36521. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  36522. this.pad.x = this.leftStick.x;
  36523. this.pad.y = this.leftStick.y;
  36524. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  36525. }
  36526. };
  36527. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  36528. if (!newState) {
  36529. newState = {
  36530. pressed: false,
  36531. touched: false,
  36532. value: 0
  36533. };
  36534. }
  36535. if (!currentState) {
  36536. this._buttons[buttonIndex] = {
  36537. pressed: newState.pressed,
  36538. touched: newState.touched,
  36539. value: newState.value
  36540. };
  36541. return;
  36542. }
  36543. this._checkChanges(newState, currentState);
  36544. if (this._changes.changed) {
  36545. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  36546. this._handleButtonChange(buttonIndex, newState, this._changes);
  36547. }
  36548. this._buttons[buttonIndex].pressed = newState.pressed;
  36549. this._buttons[buttonIndex].touched = newState.touched;
  36550. // oculus triggers are never 0, thou not touched.
  36551. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  36552. };
  36553. WebVRController.prototype._checkChanges = function (newState, currentState) {
  36554. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  36555. this._changes.touchChanged = newState.touched !== currentState.touched;
  36556. this._changes.valueChanged = newState.value !== currentState.value;
  36557. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  36558. return this._changes;
  36559. };
  36560. /**
  36561. * Disposes of th webVRCOntroller
  36562. */
  36563. WebVRController.prototype.dispose = function () {
  36564. _super.prototype.dispose.call(this);
  36565. this.onTriggerStateChangedObservable.clear();
  36566. this.onMainButtonStateChangedObservable.clear();
  36567. this.onSecondaryButtonStateChangedObservable.clear();
  36568. this.onPadStateChangedObservable.clear();
  36569. this.onPadValuesChangedObservable.clear();
  36570. };
  36571. return WebVRController;
  36572. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  36573. /***/ }),
  36574. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  36575. /*!*********************************************************!*\
  36576. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  36577. \*********************************************************/
  36578. /*! exports provided: WindowsMotionController */
  36579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36580. "use strict";
  36581. __webpack_require__.r(__webpack_exports__);
  36582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  36583. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36584. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  36585. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36586. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  36587. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  36588. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  36589. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  36590. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  36591. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  36592. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36593. /**
  36594. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  36595. */
  36596. var LoadedMeshInfo = /** @class */ (function () {
  36597. function LoadedMeshInfo() {
  36598. /**
  36599. * Map of the button meshes contained in the controller
  36600. */
  36601. this.buttonMeshes = {};
  36602. /**
  36603. * Map of the axis meshes contained in the controller
  36604. */
  36605. this.axisMeshes = {};
  36606. }
  36607. return LoadedMeshInfo;
  36608. }());
  36609. /**
  36610. * Defines the WindowsMotionController object that the state of the windows motion controller
  36611. */
  36612. var WindowsMotionController = /** @class */ (function (_super) {
  36613. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  36614. /**
  36615. * Creates a new WindowsMotionController from a gamepad
  36616. * @param vrGamepad the gamepad that the controller should be created from
  36617. */
  36618. function WindowsMotionController(vrGamepad) {
  36619. var _this = _super.call(this, vrGamepad) || this;
  36620. _this._mapping = {
  36621. // Semantic button names
  36622. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  36623. // A mapping of the button name to glTF model node name
  36624. // that should be transformed by button value.
  36625. buttonMeshNames: {
  36626. 'trigger': 'SELECT',
  36627. 'menu': 'MENU',
  36628. 'grip': 'GRASP',
  36629. 'thumbstick': 'THUMBSTICK_PRESS',
  36630. 'trackpad': 'TOUCHPAD_PRESS'
  36631. },
  36632. // This mapping is used to translate from the Motion Controller to Babylon semantics
  36633. buttonObservableNames: {
  36634. 'trigger': 'onTriggerStateChangedObservable',
  36635. 'menu': 'onSecondaryButtonStateChangedObservable',
  36636. 'grip': 'onMainButtonStateChangedObservable',
  36637. 'thumbstick': 'onPadStateChangedObservable',
  36638. 'trackpad': 'onTrackpadChangedObservable'
  36639. },
  36640. // A mapping of the axis name to glTF model node name
  36641. // that should be transformed by axis value.
  36642. // This array mirrors the browserGamepad.axes array, such that
  36643. // the mesh corresponding to axis 0 is in this array index 0.
  36644. axisMeshNames: [
  36645. 'THUMBSTICK_X',
  36646. 'THUMBSTICK_Y',
  36647. 'TOUCHPAD_TOUCH_X',
  36648. 'TOUCHPAD_TOUCH_Y'
  36649. ],
  36650. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  36651. };
  36652. /**
  36653. * Fired when the trackpad on this controller is clicked
  36654. */
  36655. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36656. /**
  36657. * Fired when the trackpad on this controller is modified
  36658. */
  36659. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36660. /**
  36661. * The current x and y values of this controller's trackpad
  36662. */
  36663. _this.trackpad = { x: 0, y: 0 };
  36664. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  36665. _this._loadedMeshInfo = null;
  36666. return _this;
  36667. }
  36668. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  36669. /**
  36670. * Fired when the trigger on this controller is modified
  36671. */
  36672. get: function () {
  36673. return this.onTriggerStateChangedObservable;
  36674. },
  36675. enumerable: true,
  36676. configurable: true
  36677. });
  36678. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  36679. /**
  36680. * Fired when the menu button on this controller is modified
  36681. */
  36682. get: function () {
  36683. return this.onSecondaryButtonStateChangedObservable;
  36684. },
  36685. enumerable: true,
  36686. configurable: true
  36687. });
  36688. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  36689. /**
  36690. * Fired when the grip button on this controller is modified
  36691. */
  36692. get: function () {
  36693. return this.onMainButtonStateChangedObservable;
  36694. },
  36695. enumerable: true,
  36696. configurable: true
  36697. });
  36698. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  36699. /**
  36700. * Fired when the thumbstick button on this controller is modified
  36701. */
  36702. get: function () {
  36703. return this.onPadStateChangedObservable;
  36704. },
  36705. enumerable: true,
  36706. configurable: true
  36707. });
  36708. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  36709. /**
  36710. * Fired when the touchpad button on this controller is modified
  36711. */
  36712. get: function () {
  36713. return this.onTrackpadChangedObservable;
  36714. },
  36715. enumerable: true,
  36716. configurable: true
  36717. });
  36718. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  36719. /**
  36720. * Fired when the touchpad values on this controller are modified
  36721. */
  36722. get: function () {
  36723. return this.onTrackpadValuesChangedObservable;
  36724. },
  36725. enumerable: true,
  36726. configurable: true
  36727. });
  36728. WindowsMotionController.prototype._updateTrackpad = function () {
  36729. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  36730. this.trackpad.x = this.browserGamepad["axes"][2];
  36731. this.trackpad.y = this.browserGamepad["axes"][3];
  36732. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  36733. }
  36734. };
  36735. /**
  36736. * Called once per frame by the engine.
  36737. */
  36738. WindowsMotionController.prototype.update = function () {
  36739. _super.prototype.update.call(this);
  36740. if (this.browserGamepad.axes) {
  36741. this._updateTrackpad();
  36742. // Only need to animate axes if there is a loaded mesh
  36743. if (this._loadedMeshInfo) {
  36744. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  36745. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  36746. }
  36747. }
  36748. }
  36749. };
  36750. /**
  36751. * Called once for each button that changed state since the last frame
  36752. * @param buttonIdx Which button index changed
  36753. * @param state New state of the button
  36754. * @param changes Which properties on the state changed since last frame
  36755. */
  36756. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36757. var buttonName = this._mapping.buttons[buttonIdx];
  36758. if (!buttonName) {
  36759. return;
  36760. }
  36761. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  36762. this._updateTrackpad();
  36763. // Only emit events for buttons that we know how to map from index to name
  36764. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  36765. if (observable) {
  36766. observable.notifyObservers(state);
  36767. }
  36768. this._lerpButtonTransform(buttonName, state.value);
  36769. };
  36770. /**
  36771. * Moves the buttons on the controller mesh based on their current state
  36772. * @param buttonName the name of the button to move
  36773. * @param buttonValue the value of the button which determines the buttons new position
  36774. */
  36775. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  36776. // If there is no loaded mesh, there is nothing to transform.
  36777. if (!this._loadedMeshInfo) {
  36778. return;
  36779. }
  36780. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  36781. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36782. return;
  36783. }
  36784. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  36785. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  36786. };
  36787. /**
  36788. * Moves the axis on the controller mesh based on its current state
  36789. * @param axis the index of the axis
  36790. * @param axisValue the value of the axis which determines the meshes new position
  36791. * @hidden
  36792. */
  36793. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  36794. if (!this._loadedMeshInfo) {
  36795. return;
  36796. }
  36797. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  36798. if (!meshInfo) {
  36799. return;
  36800. }
  36801. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36802. return;
  36803. }
  36804. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  36805. var lerpValue = axisValue * 0.5 + 0.5;
  36806. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  36807. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  36808. };
  36809. /**
  36810. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36811. * @param scene scene in which to add meshes
  36812. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36813. */
  36814. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  36815. var _this = this;
  36816. if (forceDefault === void 0) { forceDefault = false; }
  36817. var path;
  36818. var filename;
  36819. // Checking if GLB loader is present
  36820. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  36821. // Determine the device specific folder based on the ID suffix
  36822. var device = 'default';
  36823. if (this.id && !forceDefault) {
  36824. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  36825. device = ((match && match[0]) || device);
  36826. }
  36827. // Hand
  36828. if (this.hand === 'left') {
  36829. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  36830. }
  36831. else { // Right is the default if no hand is specified
  36832. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  36833. }
  36834. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  36835. }
  36836. else {
  36837. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("You need to reference GLTF loader to load Windows Motion Controllers model. Falling back to generic models");
  36838. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  36839. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  36840. }
  36841. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  36842. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  36843. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  36844. if (!_this._loadedMeshInfo) {
  36845. return;
  36846. }
  36847. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  36848. _this.attachToMesh(_this._defaultModel);
  36849. if (meshLoaded) {
  36850. meshLoaded(_this._defaultModel);
  36851. }
  36852. }, null, function (scene, message) {
  36853. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  36854. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  36855. if (!forceDefault) {
  36856. _this.initControllerMesh(scene, meshLoaded, true);
  36857. }
  36858. });
  36859. };
  36860. /**
  36861. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  36862. * can be transformed by button presses and axes values, based on this._mapping.
  36863. *
  36864. * @param scene scene in which the meshes exist
  36865. * @param meshes list of meshes that make up the controller model to process
  36866. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  36867. */
  36868. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  36869. var loadedMeshInfo = null;
  36870. // Create a new mesh to contain the glTF hierarchy
  36871. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  36872. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  36873. var childMesh = null;
  36874. for (var i = 0; i < meshes.length; i++) {
  36875. var mesh = meshes[i];
  36876. if (!mesh.parent) {
  36877. // Exclude controller meshes from picking results
  36878. mesh.isPickable = false;
  36879. // Handle root node, attach to the new parentMesh
  36880. childMesh = mesh;
  36881. break;
  36882. }
  36883. }
  36884. if (childMesh) {
  36885. childMesh.setParent(parentMesh);
  36886. // Create our mesh info. Note that this method will always return non-null.
  36887. loadedMeshInfo = this.createMeshInfo(parentMesh);
  36888. }
  36889. else {
  36890. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  36891. }
  36892. return loadedMeshInfo;
  36893. };
  36894. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  36895. var loadedMeshInfo = new LoadedMeshInfo();
  36896. var i;
  36897. loadedMeshInfo.rootNode = rootNode;
  36898. // Reset the caches
  36899. loadedMeshInfo.buttonMeshes = {};
  36900. loadedMeshInfo.axisMeshes = {};
  36901. // Button Meshes
  36902. for (i = 0; i < this._mapping.buttons.length; i++) {
  36903. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  36904. if (!buttonMeshName) {
  36905. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  36906. continue;
  36907. }
  36908. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  36909. if (!buttonMesh) {
  36910. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  36911. continue;
  36912. }
  36913. var buttonMeshInfo = {
  36914. index: i,
  36915. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  36916. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  36917. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  36918. };
  36919. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  36920. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  36921. }
  36922. else {
  36923. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  36924. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  36925. '(VALUE: ' + !!buttonMeshInfo.value +
  36926. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  36927. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  36928. ')');
  36929. }
  36930. }
  36931. // Axis Meshes
  36932. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  36933. var axisMeshName = this._mapping.axisMeshNames[i];
  36934. if (!axisMeshName) {
  36935. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  36936. continue;
  36937. }
  36938. var axisMesh = getChildByName(rootNode, axisMeshName);
  36939. if (!axisMesh) {
  36940. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  36941. continue;
  36942. }
  36943. var axisMeshInfo = {
  36944. index: i,
  36945. value: getImmediateChildByName(axisMesh, 'VALUE'),
  36946. min: getImmediateChildByName(axisMesh, 'MIN'),
  36947. max: getImmediateChildByName(axisMesh, 'MAX')
  36948. };
  36949. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  36950. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  36951. }
  36952. else {
  36953. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  36954. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  36955. '(VALUE: ' + !!axisMeshInfo.value +
  36956. ', MIN: ' + !!axisMeshInfo.min +
  36957. ', MAX:' + !!axisMeshInfo.max +
  36958. ')');
  36959. }
  36960. }
  36961. // Pointing Ray
  36962. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  36963. if (!loadedMeshInfo.pointingPoseNode) {
  36964. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  36965. }
  36966. else {
  36967. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  36968. }
  36969. return loadedMeshInfo;
  36970. // Look through all children recursively. This will return null if no mesh exists with the given name.
  36971. function getChildByName(node, name) {
  36972. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  36973. }
  36974. // Look through only immediate children. This will return null if no mesh exists with the given name.
  36975. function getImmediateChildByName(node, name) {
  36976. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  36977. }
  36978. };
  36979. /**
  36980. * Gets the ray of the controller in the direction the controller is pointing
  36981. * @param length the length the resulting ray should be
  36982. * @returns a ray in the direction the controller is pointing
  36983. */
  36984. WindowsMotionController.prototype.getForwardRay = function (length) {
  36985. if (length === void 0) { length = 100; }
  36986. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  36987. return _super.prototype.getForwardRay.call(this, length);
  36988. }
  36989. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  36990. var origin = m.getTranslation();
  36991. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  36992. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  36993. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  36994. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  36995. };
  36996. /**
  36997. * Disposes of the controller
  36998. */
  36999. WindowsMotionController.prototype.dispose = function () {
  37000. _super.prototype.dispose.call(this);
  37001. this.onTrackpadChangedObservable.clear();
  37002. };
  37003. /**
  37004. * The base url used to load the left and right controller models
  37005. */
  37006. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  37007. /**
  37008. * The name of the left controller model file
  37009. */
  37010. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  37011. /**
  37012. * The name of the right controller model file
  37013. */
  37014. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  37015. /**
  37016. * The controller name prefix for this controller type
  37017. */
  37018. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  37019. /**
  37020. * The controller id pattern for this controller type
  37021. */
  37022. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  37023. return WindowsMotionController;
  37024. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  37025. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  37026. canCreate: function (gamepadInfo) {
  37027. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  37028. },
  37029. create: function (gamepadInfo) {
  37030. return new WindowsMotionController(gamepadInfo);
  37031. }
  37032. });
  37033. /***/ }),
  37034. /***/ "./Gamepads/gamepad.ts":
  37035. /*!*****************************!*\
  37036. !*** ./Gamepads/gamepad.ts ***!
  37037. \*****************************/
  37038. /*! exports provided: StickValues, Gamepad, GenericPad */
  37039. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37040. "use strict";
  37041. __webpack_require__.r(__webpack_exports__);
  37042. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  37043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  37044. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  37045. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37046. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37047. /**
  37048. * Represents a gamepad control stick position
  37049. */
  37050. var StickValues = /** @class */ (function () {
  37051. /**
  37052. * Initializes the gamepad x and y control stick values
  37053. * @param x The x component of the gamepad control stick value
  37054. * @param y The y component of the gamepad control stick value
  37055. */
  37056. function StickValues(
  37057. /**
  37058. * The x component of the control stick
  37059. */
  37060. x,
  37061. /**
  37062. * The y component of the control stick
  37063. */
  37064. y) {
  37065. this.x = x;
  37066. this.y = y;
  37067. }
  37068. return StickValues;
  37069. }());
  37070. /**
  37071. * Represents a gamepad
  37072. */
  37073. var Gamepad = /** @class */ (function () {
  37074. /**
  37075. * Initializes the gamepad
  37076. * @param id The id of the gamepad
  37077. * @param index The index of the gamepad
  37078. * @param browserGamepad The browser gamepad
  37079. * @param leftStickX The x component of the left joystick
  37080. * @param leftStickY The y component of the left joystick
  37081. * @param rightStickX The x component of the right joystick
  37082. * @param rightStickY The y component of the right joystick
  37083. */
  37084. function Gamepad(
  37085. /**
  37086. * The id of the gamepad
  37087. */
  37088. id,
  37089. /**
  37090. * The index of the gamepad
  37091. */
  37092. index,
  37093. /**
  37094. * The browser gamepad
  37095. */
  37096. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  37097. if (leftStickX === void 0) { leftStickX = 0; }
  37098. if (leftStickY === void 0) { leftStickY = 1; }
  37099. if (rightStickX === void 0) { rightStickX = 2; }
  37100. if (rightStickY === void 0) { rightStickY = 3; }
  37101. this.id = id;
  37102. this.index = index;
  37103. this.browserGamepad = browserGamepad;
  37104. this._leftStick = { x: 0, y: 0 };
  37105. this._rightStick = { x: 0, y: 0 };
  37106. /** @hidden */
  37107. this._isConnected = true;
  37108. /**
  37109. * Specifies whether the left control stick should be Y-inverted
  37110. */
  37111. this._invertLeftStickY = false;
  37112. this.type = Gamepad.GAMEPAD;
  37113. this._leftStickAxisX = leftStickX;
  37114. this._leftStickAxisY = leftStickY;
  37115. this._rightStickAxisX = rightStickX;
  37116. this._rightStickAxisY = rightStickY;
  37117. if (this.browserGamepad.axes.length >= 2) {
  37118. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  37119. }
  37120. if (this.browserGamepad.axes.length >= 4) {
  37121. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  37122. }
  37123. }
  37124. Object.defineProperty(Gamepad.prototype, "isConnected", {
  37125. /**
  37126. * Specifies if the gamepad has been connected
  37127. */
  37128. get: function () {
  37129. return this._isConnected;
  37130. },
  37131. enumerable: true,
  37132. configurable: true
  37133. });
  37134. /**
  37135. * Callback triggered when the left joystick has changed
  37136. * @param callback
  37137. */
  37138. Gamepad.prototype.onleftstickchanged = function (callback) {
  37139. this._onleftstickchanged = callback;
  37140. };
  37141. /**
  37142. * Callback triggered when the right joystick has changed
  37143. * @param callback
  37144. */
  37145. Gamepad.prototype.onrightstickchanged = function (callback) {
  37146. this._onrightstickchanged = callback;
  37147. };
  37148. Object.defineProperty(Gamepad.prototype, "leftStick", {
  37149. /**
  37150. * Gets the left joystick
  37151. */
  37152. get: function () {
  37153. return this._leftStick;
  37154. },
  37155. /**
  37156. * Sets the left joystick values
  37157. */
  37158. set: function (newValues) {
  37159. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  37160. this._onleftstickchanged(newValues);
  37161. }
  37162. this._leftStick = newValues;
  37163. },
  37164. enumerable: true,
  37165. configurable: true
  37166. });
  37167. Object.defineProperty(Gamepad.prototype, "rightStick", {
  37168. /**
  37169. * Gets the right joystick
  37170. */
  37171. get: function () {
  37172. return this._rightStick;
  37173. },
  37174. /**
  37175. * Sets the right joystick value
  37176. */
  37177. set: function (newValues) {
  37178. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  37179. this._onrightstickchanged(newValues);
  37180. }
  37181. this._rightStick = newValues;
  37182. },
  37183. enumerable: true,
  37184. configurable: true
  37185. });
  37186. /**
  37187. * Updates the gamepad joystick positions
  37188. */
  37189. Gamepad.prototype.update = function () {
  37190. if (this._leftStick) {
  37191. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  37192. if (this._invertLeftStickY) {
  37193. this.leftStick.y *= -1;
  37194. }
  37195. }
  37196. if (this._rightStick) {
  37197. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  37198. }
  37199. };
  37200. /**
  37201. * Disposes the gamepad
  37202. */
  37203. Gamepad.prototype.dispose = function () {
  37204. };
  37205. /**
  37206. * Represents a gamepad controller
  37207. */
  37208. Gamepad.GAMEPAD = 0;
  37209. /**
  37210. * Represents a generic controller
  37211. */
  37212. Gamepad.GENERIC = 1;
  37213. /**
  37214. * Represents an XBox controller
  37215. */
  37216. Gamepad.XBOX = 2;
  37217. /**
  37218. * Represents a pose-enabled controller
  37219. */
  37220. Gamepad.POSE_ENABLED = 3;
  37221. return Gamepad;
  37222. }());
  37223. /**
  37224. * Represents a generic gamepad
  37225. */
  37226. var GenericPad = /** @class */ (function (_super) {
  37227. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  37228. /**
  37229. * Initializes the generic gamepad
  37230. * @param id The id of the generic gamepad
  37231. * @param index The index of the generic gamepad
  37232. * @param browserGamepad The browser gamepad
  37233. */
  37234. function GenericPad(id, index, browserGamepad) {
  37235. var _this = _super.call(this, id, index, browserGamepad) || this;
  37236. /**
  37237. * Observable triggered when a button has been pressed
  37238. */
  37239. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37240. /**
  37241. * Observable triggered when a button has been released
  37242. */
  37243. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37244. _this.type = Gamepad.GENERIC;
  37245. _this._buttons = new Array(browserGamepad.buttons.length);
  37246. return _this;
  37247. }
  37248. /**
  37249. * Callback triggered when a button has been pressed
  37250. * @param callback Called when a button has been pressed
  37251. */
  37252. GenericPad.prototype.onbuttondown = function (callback) {
  37253. this._onbuttondown = callback;
  37254. };
  37255. /**
  37256. * Callback triggered when a button has been released
  37257. * @param callback Called when a button has been released
  37258. */
  37259. GenericPad.prototype.onbuttonup = function (callback) {
  37260. this._onbuttonup = callback;
  37261. };
  37262. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  37263. if (newValue !== currentValue) {
  37264. if (newValue === 1) {
  37265. if (this._onbuttondown) {
  37266. this._onbuttondown(buttonIndex);
  37267. }
  37268. this.onButtonDownObservable.notifyObservers(buttonIndex);
  37269. }
  37270. if (newValue === 0) {
  37271. if (this._onbuttonup) {
  37272. this._onbuttonup(buttonIndex);
  37273. }
  37274. this.onButtonUpObservable.notifyObservers(buttonIndex);
  37275. }
  37276. }
  37277. return newValue;
  37278. };
  37279. /**
  37280. * Updates the generic gamepad
  37281. */
  37282. GenericPad.prototype.update = function () {
  37283. _super.prototype.update.call(this);
  37284. for (var index = 0; index < this._buttons.length; index++) {
  37285. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  37286. }
  37287. };
  37288. /**
  37289. * Disposes the generic gamepad
  37290. */
  37291. GenericPad.prototype.dispose = function () {
  37292. _super.prototype.dispose.call(this);
  37293. this.onButtonDownObservable.clear();
  37294. this.onButtonUpObservable.clear();
  37295. };
  37296. return GenericPad;
  37297. }(Gamepad));
  37298. /***/ }),
  37299. /***/ "./Gamepads/gamepadManager.ts":
  37300. /*!************************************!*\
  37301. !*** ./Gamepads/gamepadManager.ts ***!
  37302. \************************************/
  37303. /*! exports provided: GamepadManager */
  37304. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37305. "use strict";
  37306. __webpack_require__.r(__webpack_exports__);
  37307. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  37308. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  37309. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37310. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  37311. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  37312. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  37313. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  37314. /**
  37315. * Manager for handling gamepads
  37316. */
  37317. var GamepadManager = /** @class */ (function () {
  37318. /**
  37319. * Initializes the gamepad manager
  37320. * @param _scene BabylonJS scene
  37321. */
  37322. function GamepadManager(_scene) {
  37323. var _this = this;
  37324. this._scene = _scene;
  37325. this._babylonGamepads = [];
  37326. this._oneGamepadConnected = false;
  37327. /** @hidden */
  37328. this._isMonitoring = false;
  37329. /**
  37330. * observable to be triggered when the gamepad controller has been disconnected
  37331. */
  37332. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37333. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  37334. this._gamepadEventSupported = false;
  37335. }
  37336. else {
  37337. this._gamepadEventSupported = 'GamepadEvent' in window;
  37338. this._gamepadSupport = (navigator.getGamepads ||
  37339. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  37340. }
  37341. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  37342. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  37343. for (var i in _this._babylonGamepads) {
  37344. var gamepad = _this._babylonGamepads[i];
  37345. if (gamepad && gamepad._isConnected) {
  37346. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  37347. }
  37348. }
  37349. });
  37350. this._onGamepadConnectedEvent = function (evt) {
  37351. var gamepad = evt.gamepad;
  37352. if (gamepad.index in _this._babylonGamepads) {
  37353. if (_this._babylonGamepads[gamepad.index].isConnected) {
  37354. return;
  37355. }
  37356. }
  37357. var newGamepad;
  37358. if (_this._babylonGamepads[gamepad.index]) {
  37359. newGamepad = _this._babylonGamepads[gamepad.index];
  37360. newGamepad.browserGamepad = gamepad;
  37361. newGamepad._isConnected = true;
  37362. }
  37363. else {
  37364. newGamepad = _this._addNewGamepad(gamepad);
  37365. }
  37366. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  37367. _this._startMonitoringGamepads();
  37368. };
  37369. this._onGamepadDisconnectedEvent = function (evt) {
  37370. var gamepad = evt.gamepad;
  37371. // Remove the gamepad from the list of gamepads to monitor.
  37372. for (var i in _this._babylonGamepads) {
  37373. if (_this._babylonGamepads[i].index === gamepad.index) {
  37374. var disconnectedGamepad = _this._babylonGamepads[i];
  37375. disconnectedGamepad._isConnected = false;
  37376. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  37377. break;
  37378. }
  37379. }
  37380. };
  37381. if (this._gamepadSupport) {
  37382. //first add already-connected gamepads
  37383. this._updateGamepadObjects();
  37384. if (this._babylonGamepads.length) {
  37385. this._startMonitoringGamepads();
  37386. }
  37387. // Checking if the gamepad connected event is supported (like in Firefox)
  37388. if (this._gamepadEventSupported) {
  37389. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  37390. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  37391. }
  37392. else {
  37393. this._startMonitoringGamepads();
  37394. }
  37395. }
  37396. }
  37397. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  37398. /**
  37399. * The gamepads in the game pad manager
  37400. */
  37401. get: function () {
  37402. return this._babylonGamepads;
  37403. },
  37404. enumerable: true,
  37405. configurable: true
  37406. });
  37407. /**
  37408. * Get the gamepad controllers based on type
  37409. * @param type The type of gamepad controller
  37410. * @returns Nullable gamepad
  37411. */
  37412. GamepadManager.prototype.getGamepadByType = function (type) {
  37413. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  37414. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  37415. var gamepad = _a[_i];
  37416. if (gamepad && gamepad.type === type) {
  37417. return gamepad;
  37418. }
  37419. }
  37420. return null;
  37421. };
  37422. /**
  37423. * Disposes the gamepad manager
  37424. */
  37425. GamepadManager.prototype.dispose = function () {
  37426. if (this._gamepadEventSupported) {
  37427. if (this._onGamepadConnectedEvent) {
  37428. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  37429. }
  37430. if (this._onGamepadDisconnectedEvent) {
  37431. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  37432. }
  37433. this._onGamepadConnectedEvent = null;
  37434. this._onGamepadDisconnectedEvent = null;
  37435. }
  37436. this._babylonGamepads.forEach(function (gamepad) {
  37437. gamepad.dispose();
  37438. });
  37439. this.onGamepadConnectedObservable.clear();
  37440. this.onGamepadDisconnectedObservable.clear();
  37441. this._oneGamepadConnected = false;
  37442. this._stopMonitoringGamepads();
  37443. this._babylonGamepads = [];
  37444. };
  37445. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  37446. if (!this._oneGamepadConnected) {
  37447. this._oneGamepadConnected = true;
  37448. }
  37449. var newGamepad;
  37450. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  37451. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  37452. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  37453. }
  37454. // if pose is supported, use the (WebVR) pose enabled controller
  37455. else if (gamepad.pose) {
  37456. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  37457. }
  37458. else {
  37459. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  37460. }
  37461. this._babylonGamepads[newGamepad.index] = newGamepad;
  37462. return newGamepad;
  37463. };
  37464. GamepadManager.prototype._startMonitoringGamepads = function () {
  37465. if (!this._isMonitoring) {
  37466. this._isMonitoring = true;
  37467. //back-comp
  37468. if (!this._scene) {
  37469. this._checkGamepadsStatus();
  37470. }
  37471. }
  37472. };
  37473. GamepadManager.prototype._stopMonitoringGamepads = function () {
  37474. this._isMonitoring = false;
  37475. };
  37476. /** @hidden */
  37477. GamepadManager.prototype._checkGamepadsStatus = function () {
  37478. var _this = this;
  37479. // Hack to be compatible Chrome
  37480. this._updateGamepadObjects();
  37481. for (var i in this._babylonGamepads) {
  37482. var gamepad = this._babylonGamepads[i];
  37483. if (!gamepad || !gamepad.isConnected) {
  37484. continue;
  37485. }
  37486. gamepad.update();
  37487. }
  37488. if (this._isMonitoring && !this._scene) {
  37489. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  37490. }
  37491. };
  37492. // This function is called only on Chrome, which does not properly support
  37493. // connection/disconnection events and forces you to recopy again the gamepad object
  37494. GamepadManager.prototype._updateGamepadObjects = function () {
  37495. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  37496. for (var i = 0; i < gamepads.length; i++) {
  37497. var gamepad = gamepads[i];
  37498. if (gamepad) {
  37499. if (!this._babylonGamepads[gamepad.index]) {
  37500. var newGamepad = this._addNewGamepad(gamepad);
  37501. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  37502. }
  37503. else {
  37504. // Forced to copy again this object for Chrome for unknown reason
  37505. this._babylonGamepads[i].browserGamepad = gamepad;
  37506. if (!this._babylonGamepads[i].isConnected) {
  37507. this._babylonGamepads[i]._isConnected = true;
  37508. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  37509. }
  37510. }
  37511. }
  37512. }
  37513. };
  37514. return GamepadManager;
  37515. }());
  37516. /***/ }),
  37517. /***/ "./Gamepads/gamepadSceneComponent.ts":
  37518. /*!*******************************************!*\
  37519. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  37520. \*******************************************/
  37521. /*! exports provided: GamepadSystemSceneComponent */
  37522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37523. "use strict";
  37524. __webpack_require__.r(__webpack_exports__);
  37525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  37526. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  37527. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  37528. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37529. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  37530. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  37531. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  37532. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  37533. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  37534. get: function () {
  37535. if (!this._gamepadManager) {
  37536. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  37537. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  37538. if (!component) {
  37539. component = new GamepadSystemSceneComponent(this);
  37540. this._addComponent(component);
  37541. }
  37542. }
  37543. return this._gamepadManager;
  37544. },
  37545. enumerable: true,
  37546. configurable: true
  37547. });
  37548. /**
  37549. * Adds a gamepad to the free camera inputs manager
  37550. */
  37551. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  37552. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  37553. return this;
  37554. };
  37555. /**
  37556. * Adds a gamepad to the arc rotate camera inputs manager
  37557. */
  37558. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  37559. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  37560. return this;
  37561. };
  37562. /**
  37563. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37564. */
  37565. var GamepadSystemSceneComponent = /** @class */ (function () {
  37566. /**
  37567. * Creates a new instance of the component for the given scene
  37568. * @param scene Defines the scene to register the component in
  37569. */
  37570. function GamepadSystemSceneComponent(scene) {
  37571. /**
  37572. * The component name helpfull to identify the component in the list of scene components.
  37573. */
  37574. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  37575. this.scene = scene;
  37576. }
  37577. /**
  37578. * Registers the component in a given scene
  37579. */
  37580. GamepadSystemSceneComponent.prototype.register = function () {
  37581. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  37582. };
  37583. /**
  37584. * Rebuilds the elements related to this component in case of
  37585. * context lost for instance.
  37586. */
  37587. GamepadSystemSceneComponent.prototype.rebuild = function () {
  37588. // Nothing to do for gamepads
  37589. };
  37590. /**
  37591. * Disposes the component and the associated ressources
  37592. */
  37593. GamepadSystemSceneComponent.prototype.dispose = function () {
  37594. var gamepadManager = this.scene._gamepadManager;
  37595. if (gamepadManager) {
  37596. gamepadManager.dispose();
  37597. this.scene._gamepadManager = null;
  37598. }
  37599. };
  37600. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  37601. var gamepadManager = this.scene._gamepadManager;
  37602. if (gamepadManager && gamepadManager._isMonitoring) {
  37603. gamepadManager._checkGamepadsStatus();
  37604. }
  37605. };
  37606. return GamepadSystemSceneComponent;
  37607. }());
  37608. /***/ }),
  37609. /***/ "./Gamepads/index.ts":
  37610. /*!***************************!*\
  37611. !*** ./Gamepads/index.ts ***!
  37612. \***************************/
  37613. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad */
  37614. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37615. "use strict";
  37616. __webpack_require__.r(__webpack_exports__);
  37617. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  37618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  37619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  37620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  37621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  37622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  37623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  37624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  37625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  37626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  37627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  37628. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  37629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  37630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  37631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  37632. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  37634. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  37635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  37636. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  37637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  37638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  37639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  37640. /***/ }),
  37641. /***/ "./Gamepads/xboxGamepad.ts":
  37642. /*!*********************************!*\
  37643. !*** ./Gamepads/xboxGamepad.ts ***!
  37644. \*********************************/
  37645. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  37646. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37647. "use strict";
  37648. __webpack_require__.r(__webpack_exports__);
  37649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  37650. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  37651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  37652. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37653. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37654. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  37655. /**
  37656. * Defines supported buttons for XBox360 compatible gamepads
  37657. */
  37658. var Xbox360Button;
  37659. (function (Xbox360Button) {
  37660. /** A */
  37661. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  37662. /** B */
  37663. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  37664. /** X */
  37665. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  37666. /** Y */
  37667. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  37668. /** Start */
  37669. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  37670. /** Back */
  37671. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  37672. /** Left button */
  37673. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  37674. /** Right button */
  37675. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  37676. /** Left stick */
  37677. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  37678. /** Right stick */
  37679. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  37680. })(Xbox360Button || (Xbox360Button = {}));
  37681. /** Defines values for XBox360 DPad */
  37682. var Xbox360Dpad;
  37683. (function (Xbox360Dpad) {
  37684. /** Up */
  37685. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  37686. /** Down */
  37687. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  37688. /** Left */
  37689. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  37690. /** Right */
  37691. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  37692. })(Xbox360Dpad || (Xbox360Dpad = {}));
  37693. /**
  37694. * Defines a XBox360 gamepad
  37695. */
  37696. var Xbox360Pad = /** @class */ (function (_super) {
  37697. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  37698. /**
  37699. * Creates a new XBox360 gamepad object
  37700. * @param id defines the id of this gamepad
  37701. * @param index defines its index
  37702. * @param gamepad defines the internal HTML gamepad object
  37703. * @param xboxOne defines if it is a XBox One gamepad
  37704. */
  37705. function Xbox360Pad(id, index, gamepad, xboxOne) {
  37706. if (xboxOne === void 0) { xboxOne = false; }
  37707. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  37708. _this._leftTrigger = 0;
  37709. _this._rightTrigger = 0;
  37710. /** Observable raised when a button is pressed */
  37711. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37712. /** Observable raised when a button is released */
  37713. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37714. /** Observable raised when a pad is pressed */
  37715. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37716. /** Observable raised when a pad is released */
  37717. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37718. _this._buttonA = 0;
  37719. _this._buttonB = 0;
  37720. _this._buttonX = 0;
  37721. _this._buttonY = 0;
  37722. _this._buttonBack = 0;
  37723. _this._buttonStart = 0;
  37724. _this._buttonLB = 0;
  37725. _this._buttonRB = 0;
  37726. _this._buttonLeftStick = 0;
  37727. _this._buttonRightStick = 0;
  37728. _this._dPadUp = 0;
  37729. _this._dPadDown = 0;
  37730. _this._dPadLeft = 0;
  37731. _this._dPadRight = 0;
  37732. _this._isXboxOnePad = false;
  37733. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  37734. _this._isXboxOnePad = xboxOne;
  37735. return _this;
  37736. }
  37737. /**
  37738. * Defines the callback to call when left trigger is pressed
  37739. * @param callback defines the callback to use
  37740. */
  37741. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  37742. this._onlefttriggerchanged = callback;
  37743. };
  37744. /**
  37745. * Defines the callback to call when right trigger is pressed
  37746. * @param callback defines the callback to use
  37747. */
  37748. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  37749. this._onrighttriggerchanged = callback;
  37750. };
  37751. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  37752. /**
  37753. * Gets the left trigger value
  37754. */
  37755. get: function () {
  37756. return this._leftTrigger;
  37757. },
  37758. /**
  37759. * Sets the left trigger value
  37760. */
  37761. set: function (newValue) {
  37762. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  37763. this._onlefttriggerchanged(newValue);
  37764. }
  37765. this._leftTrigger = newValue;
  37766. },
  37767. enumerable: true,
  37768. configurable: true
  37769. });
  37770. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  37771. /**
  37772. * Gets the right trigger value
  37773. */
  37774. get: function () {
  37775. return this._rightTrigger;
  37776. },
  37777. /**
  37778. * Sets the right trigger value
  37779. */
  37780. set: function (newValue) {
  37781. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  37782. this._onrighttriggerchanged(newValue);
  37783. }
  37784. this._rightTrigger = newValue;
  37785. },
  37786. enumerable: true,
  37787. configurable: true
  37788. });
  37789. /**
  37790. * Defines the callback to call when a button is pressed
  37791. * @param callback defines the callback to use
  37792. */
  37793. Xbox360Pad.prototype.onbuttondown = function (callback) {
  37794. this._onbuttondown = callback;
  37795. };
  37796. /**
  37797. * Defines the callback to call when a button is released
  37798. * @param callback defines the callback to use
  37799. */
  37800. Xbox360Pad.prototype.onbuttonup = function (callback) {
  37801. this._onbuttonup = callback;
  37802. };
  37803. /**
  37804. * Defines the callback to call when a pad is pressed
  37805. * @param callback defines the callback to use
  37806. */
  37807. Xbox360Pad.prototype.ondpaddown = function (callback) {
  37808. this._ondpaddown = callback;
  37809. };
  37810. /**
  37811. * Defines the callback to call when a pad is released
  37812. * @param callback defines the callback to use
  37813. */
  37814. Xbox360Pad.prototype.ondpadup = function (callback) {
  37815. this._ondpadup = callback;
  37816. };
  37817. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  37818. if (newValue !== currentValue) {
  37819. if (newValue === 1) {
  37820. if (this._onbuttondown) {
  37821. this._onbuttondown(buttonType);
  37822. }
  37823. this.onButtonDownObservable.notifyObservers(buttonType);
  37824. }
  37825. if (newValue === 0) {
  37826. if (this._onbuttonup) {
  37827. this._onbuttonup(buttonType);
  37828. }
  37829. this.onButtonUpObservable.notifyObservers(buttonType);
  37830. }
  37831. }
  37832. return newValue;
  37833. };
  37834. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  37835. if (newValue !== currentValue) {
  37836. if (newValue === 1) {
  37837. if (this._ondpaddown) {
  37838. this._ondpaddown(buttonType);
  37839. }
  37840. this.onPadDownObservable.notifyObservers(buttonType);
  37841. }
  37842. if (newValue === 0) {
  37843. if (this._ondpadup) {
  37844. this._ondpadup(buttonType);
  37845. }
  37846. this.onPadUpObservable.notifyObservers(buttonType);
  37847. }
  37848. }
  37849. return newValue;
  37850. };
  37851. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  37852. /**
  37853. * Gets the value of the `A` button
  37854. */
  37855. get: function () {
  37856. return this._buttonA;
  37857. },
  37858. /**
  37859. * Sets the value of the `A` button
  37860. */
  37861. set: function (value) {
  37862. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  37863. },
  37864. enumerable: true,
  37865. configurable: true
  37866. });
  37867. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  37868. /**
  37869. * Gets the value of the `B` button
  37870. */
  37871. get: function () {
  37872. return this._buttonB;
  37873. },
  37874. /**
  37875. * Sets the value of the `B` button
  37876. */
  37877. set: function (value) {
  37878. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  37879. },
  37880. enumerable: true,
  37881. configurable: true
  37882. });
  37883. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  37884. /**
  37885. * Gets the value of the `X` button
  37886. */
  37887. get: function () {
  37888. return this._buttonX;
  37889. },
  37890. /**
  37891. * Sets the value of the `X` button
  37892. */
  37893. set: function (value) {
  37894. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  37895. },
  37896. enumerable: true,
  37897. configurable: true
  37898. });
  37899. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  37900. /**
  37901. * Gets the value of the `Y` button
  37902. */
  37903. get: function () {
  37904. return this._buttonY;
  37905. },
  37906. /**
  37907. * Sets the value of the `Y` button
  37908. */
  37909. set: function (value) {
  37910. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  37911. },
  37912. enumerable: true,
  37913. configurable: true
  37914. });
  37915. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  37916. /**
  37917. * Gets the value of the `Start` button
  37918. */
  37919. get: function () {
  37920. return this._buttonStart;
  37921. },
  37922. /**
  37923. * Sets the value of the `Start` button
  37924. */
  37925. set: function (value) {
  37926. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  37927. },
  37928. enumerable: true,
  37929. configurable: true
  37930. });
  37931. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  37932. /**
  37933. * Gets the value of the `Back` button
  37934. */
  37935. get: function () {
  37936. return this._buttonBack;
  37937. },
  37938. /**
  37939. * Sets the value of the `Back` button
  37940. */
  37941. set: function (value) {
  37942. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  37943. },
  37944. enumerable: true,
  37945. configurable: true
  37946. });
  37947. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  37948. /**
  37949. * Gets the value of the `Left` button
  37950. */
  37951. get: function () {
  37952. return this._buttonLB;
  37953. },
  37954. /**
  37955. * Sets the value of the `Left` button
  37956. */
  37957. set: function (value) {
  37958. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  37959. },
  37960. enumerable: true,
  37961. configurable: true
  37962. });
  37963. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  37964. /**
  37965. * Gets the value of the `Right` button
  37966. */
  37967. get: function () {
  37968. return this._buttonRB;
  37969. },
  37970. /**
  37971. * Sets the value of the `Right` button
  37972. */
  37973. set: function (value) {
  37974. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  37975. },
  37976. enumerable: true,
  37977. configurable: true
  37978. });
  37979. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  37980. /**
  37981. * Gets the value of the Left joystick
  37982. */
  37983. get: function () {
  37984. return this._buttonLeftStick;
  37985. },
  37986. /**
  37987. * Sets the value of the Left joystick
  37988. */
  37989. set: function (value) {
  37990. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  37991. },
  37992. enumerable: true,
  37993. configurable: true
  37994. });
  37995. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  37996. /**
  37997. * Gets the value of the Right joystick
  37998. */
  37999. get: function () {
  38000. return this._buttonRightStick;
  38001. },
  38002. /**
  38003. * Sets the value of the Right joystick
  38004. */
  38005. set: function (value) {
  38006. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  38007. },
  38008. enumerable: true,
  38009. configurable: true
  38010. });
  38011. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  38012. /**
  38013. * Gets the value of D-pad up
  38014. */
  38015. get: function () {
  38016. return this._dPadUp;
  38017. },
  38018. /**
  38019. * Sets the value of D-pad up
  38020. */
  38021. set: function (value) {
  38022. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  38023. },
  38024. enumerable: true,
  38025. configurable: true
  38026. });
  38027. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  38028. /**
  38029. * Gets the value of D-pad down
  38030. */
  38031. get: function () {
  38032. return this._dPadDown;
  38033. },
  38034. /**
  38035. * Sets the value of D-pad down
  38036. */
  38037. set: function (value) {
  38038. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  38039. },
  38040. enumerable: true,
  38041. configurable: true
  38042. });
  38043. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  38044. /**
  38045. * Gets the value of D-pad left
  38046. */
  38047. get: function () {
  38048. return this._dPadLeft;
  38049. },
  38050. /**
  38051. * Sets the value of D-pad left
  38052. */
  38053. set: function (value) {
  38054. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  38055. },
  38056. enumerable: true,
  38057. configurable: true
  38058. });
  38059. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  38060. /**
  38061. * Gets the value of D-pad right
  38062. */
  38063. get: function () {
  38064. return this._dPadRight;
  38065. },
  38066. /**
  38067. * Sets the value of D-pad right
  38068. */
  38069. set: function (value) {
  38070. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  38071. },
  38072. enumerable: true,
  38073. configurable: true
  38074. });
  38075. /**
  38076. * Force the gamepad to synchronize with device values
  38077. */
  38078. Xbox360Pad.prototype.update = function () {
  38079. _super.prototype.update.call(this);
  38080. if (this._isXboxOnePad) {
  38081. this.buttonA = this.browserGamepad.buttons[0].value;
  38082. this.buttonB = this.browserGamepad.buttons[1].value;
  38083. this.buttonX = this.browserGamepad.buttons[2].value;
  38084. this.buttonY = this.browserGamepad.buttons[3].value;
  38085. this.buttonLB = this.browserGamepad.buttons[4].value;
  38086. this.buttonRB = this.browserGamepad.buttons[5].value;
  38087. this.leftTrigger = this.browserGamepad.axes[2];
  38088. this.rightTrigger = this.browserGamepad.axes[5];
  38089. this.buttonBack = this.browserGamepad.buttons[9].value;
  38090. this.buttonStart = this.browserGamepad.buttons[8].value;
  38091. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  38092. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  38093. this.dPadUp = this.browserGamepad.buttons[11].value;
  38094. this.dPadDown = this.browserGamepad.buttons[12].value;
  38095. this.dPadLeft = this.browserGamepad.buttons[13].value;
  38096. this.dPadRight = this.browserGamepad.buttons[14].value;
  38097. }
  38098. else {
  38099. this.buttonA = this.browserGamepad.buttons[0].value;
  38100. this.buttonB = this.browserGamepad.buttons[1].value;
  38101. this.buttonX = this.browserGamepad.buttons[2].value;
  38102. this.buttonY = this.browserGamepad.buttons[3].value;
  38103. this.buttonLB = this.browserGamepad.buttons[4].value;
  38104. this.buttonRB = this.browserGamepad.buttons[5].value;
  38105. this.leftTrigger = this.browserGamepad.buttons[6].value;
  38106. this.rightTrigger = this.browserGamepad.buttons[7].value;
  38107. this.buttonBack = this.browserGamepad.buttons[8].value;
  38108. this.buttonStart = this.browserGamepad.buttons[9].value;
  38109. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  38110. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  38111. this.dPadUp = this.browserGamepad.buttons[12].value;
  38112. this.dPadDown = this.browserGamepad.buttons[13].value;
  38113. this.dPadLeft = this.browserGamepad.buttons[14].value;
  38114. this.dPadRight = this.browserGamepad.buttons[15].value;
  38115. }
  38116. };
  38117. /**
  38118. * Disposes the gamepad
  38119. */
  38120. Xbox360Pad.prototype.dispose = function () {
  38121. _super.prototype.dispose.call(this);
  38122. this.onButtonDownObservable.clear();
  38123. this.onButtonUpObservable.clear();
  38124. this.onPadDownObservable.clear();
  38125. this.onPadUpObservable.clear();
  38126. };
  38127. return Xbox360Pad;
  38128. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  38129. /***/ }),
  38130. /***/ "./Gizmos/axisDragGizmo.ts":
  38131. /*!*********************************!*\
  38132. !*** ./Gizmos/axisDragGizmo.ts ***!
  38133. \*********************************/
  38134. /*! exports provided: AxisDragGizmo */
  38135. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38136. "use strict";
  38137. __webpack_require__.r(__webpack_exports__);
  38138. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  38139. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38140. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38141. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38142. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  38143. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  38144. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38145. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38146. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38147. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38148. /**
  38149. * Single axis drag gizmo
  38150. */
  38151. var AxisDragGizmo = /** @class */ (function (_super) {
  38152. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  38153. /**
  38154. * Creates an AxisDragGizmo
  38155. * @param gizmoLayer The utility layer the gizmo will be added to
  38156. * @param dragAxis The axis which the gizmo will be able to drag on
  38157. * @param color The color of the gizmo
  38158. */
  38159. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  38160. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38161. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38162. var _this = _super.call(this, gizmoLayer) || this;
  38163. _this._pointerObserver = null;
  38164. /**
  38165. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38166. */
  38167. _this.snapDistance = 0;
  38168. /**
  38169. * Event that fires each time the gizmo snaps to a new location.
  38170. * * snapDistance is the the change in distance
  38171. */
  38172. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38173. // Create Material
  38174. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38175. coloredMaterial.diffuseColor = color;
  38176. coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  38177. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38178. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38179. // Build mesh on root node
  38180. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  38181. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  38182. arrow.scaling.scaleInPlace(1 / 3);
  38183. arrow.parent = _this._rootMesh;
  38184. var currentSnapDragDistance = 0;
  38185. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38186. var tmpSnapEvent = { snapDistance: 0 };
  38187. // Add drag behavior to handle events when the gizmo is dragged
  38188. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38189. _this.dragBehavior.moveAttached = false;
  38190. _this._rootMesh.addBehavior(_this.dragBehavior);
  38191. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38192. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38193. _this.dragBehavior.onDragObservable.add(function (event) {
  38194. if (_this.attachedMesh) {
  38195. // Convert delta to local translation if it has a parent
  38196. if (_this.attachedMesh.parent) {
  38197. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  38198. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  38199. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  38200. }
  38201. else {
  38202. localDelta.copyFrom(event.delta);
  38203. }
  38204. // Snapping logic
  38205. if (_this.snapDistance == 0) {
  38206. _this.attachedMesh.position.addInPlace(localDelta);
  38207. }
  38208. else {
  38209. currentSnapDragDistance += event.dragDistance;
  38210. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38211. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38212. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38213. localDelta.normalizeToRef(tmpVector);
  38214. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  38215. _this.attachedMesh.position.addInPlace(tmpVector);
  38216. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  38217. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38218. }
  38219. }
  38220. }
  38221. });
  38222. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38223. if (_this._customMeshSet) {
  38224. return;
  38225. }
  38226. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38227. var material = isHovered ? hoverMaterial : coloredMaterial;
  38228. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38229. m.material = material;
  38230. if (m.color) {
  38231. m.color = material.diffuseColor;
  38232. }
  38233. });
  38234. });
  38235. var light = gizmoLayer._getSharedGizmoLight();
  38236. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes(false));
  38237. return _this;
  38238. }
  38239. /** @hidden */
  38240. AxisDragGizmo._CreateArrow = function (scene, material) {
  38241. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  38242. var cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 0.075, diameterBottom: 0.0375, tessellation: 96 }, scene);
  38243. var line = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0.005, height: 0.275, diameterBottom: 0.005, tessellation: 96 }, scene);
  38244. line.material = material;
  38245. cylinder.parent = arrow;
  38246. line.parent = arrow;
  38247. // Position arrow pointing in its drag axis
  38248. cylinder.material = material;
  38249. cylinder.rotation.x = Math.PI / 2;
  38250. cylinder.position.z += 0.3;
  38251. line.position.z += 0.275 / 2;
  38252. line.rotation.x = Math.PI / 2;
  38253. return arrow;
  38254. };
  38255. /** @hidden */
  38256. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  38257. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  38258. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  38259. var mesh = _a[_i];
  38260. var childInstance = mesh.createInstance(mesh.name);
  38261. childInstance.parent = instance;
  38262. }
  38263. return instance;
  38264. };
  38265. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  38266. if (this.dragBehavior) {
  38267. this.dragBehavior.enabled = value ? true : false;
  38268. }
  38269. };
  38270. /**
  38271. * Disposes of the gizmo
  38272. */
  38273. AxisDragGizmo.prototype.dispose = function () {
  38274. this.onSnapObservable.clear();
  38275. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38276. this.dragBehavior.detach();
  38277. _super.prototype.dispose.call(this);
  38278. };
  38279. return AxisDragGizmo;
  38280. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  38281. /***/ }),
  38282. /***/ "./Gizmos/axisScaleGizmo.ts":
  38283. /*!**********************************!*\
  38284. !*** ./Gizmos/axisScaleGizmo.ts ***!
  38285. \**********************************/
  38286. /*! exports provided: AxisScaleGizmo */
  38287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38288. "use strict";
  38289. __webpack_require__.r(__webpack_exports__);
  38290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  38291. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38292. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38293. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38294. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38295. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  38296. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  38297. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38298. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38299. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38300. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38301. /**
  38302. * Single axis scale gizmo
  38303. */
  38304. var AxisScaleGizmo = /** @class */ (function (_super) {
  38305. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  38306. /**
  38307. * Creates an AxisScaleGizmo
  38308. * @param gizmoLayer The utility layer the gizmo will be added to
  38309. * @param dragAxis The axis which the gizmo will be able to scale on
  38310. * @param color The color of the gizmo
  38311. */
  38312. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  38313. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38314. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38315. var _this = _super.call(this, gizmoLayer) || this;
  38316. _this._pointerObserver = null;
  38317. /**
  38318. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38319. */
  38320. _this.snapDistance = 0;
  38321. /**
  38322. * Event that fires each time the gizmo snaps to a new location.
  38323. * * snapDistance is the the change in distance
  38324. */
  38325. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38326. /**
  38327. * If the scaling operation should be done on all axis (default: false)
  38328. */
  38329. _this.uniformScaling = false;
  38330. // Create Material
  38331. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38332. _this._coloredMaterial.diffuseColor = color;
  38333. _this._coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  38334. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38335. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38336. // Build mesh on root node
  38337. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38338. var arrowMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__["BoxBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  38339. var arrowTail = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0.005, height: 0.275, diameterBottom: 0.005, tessellation: 96 }, gizmoLayer.utilityLayerScene);
  38340. arrowTail.material = _this._coloredMaterial;
  38341. arrow.addChild(arrowMesh);
  38342. arrow.addChild(arrowTail);
  38343. // Position arrow pointing in its drag axis
  38344. arrowMesh.scaling.scaleInPlace(0.1);
  38345. arrowMesh.material = _this._coloredMaterial;
  38346. arrowMesh.rotation.x = Math.PI / 2;
  38347. arrowMesh.position.z += 0.3;
  38348. arrowTail.position.z += 0.275 / 2;
  38349. arrowTail.rotation.x = Math.PI / 2;
  38350. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  38351. _this._rootMesh.addChild(arrow);
  38352. arrow.scaling.scaleInPlace(1 / 3);
  38353. // Add drag behavior to handle events when the gizmo is dragged
  38354. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38355. _this.dragBehavior.moveAttached = false;
  38356. _this._rootMesh.addBehavior(_this.dragBehavior);
  38357. var currentSnapDragDistance = 0;
  38358. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38359. var tmpSnapEvent = { snapDistance: 0 };
  38360. _this.dragBehavior.onDragObservable.add(function (event) {
  38361. if (_this.attachedMesh) {
  38362. // Snapping logic
  38363. var snapped = false;
  38364. var dragSteps = 0;
  38365. if (_this.uniformScaling) {
  38366. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  38367. if (tmpVector.y < 0) {
  38368. tmpVector.scaleInPlace(-1);
  38369. }
  38370. }
  38371. else {
  38372. tmpVector.copyFrom(dragAxis);
  38373. }
  38374. if (_this.snapDistance == 0) {
  38375. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  38376. }
  38377. else {
  38378. currentSnapDragDistance += event.dragDistance;
  38379. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38380. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38381. if (currentSnapDragDistance < 0) {
  38382. dragSteps *= -1;
  38383. }
  38384. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38385. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  38386. snapped = true;
  38387. }
  38388. else {
  38389. tmpVector.scaleInPlace(0);
  38390. }
  38391. }
  38392. _this.attachedMesh.scaling.addInPlace(tmpVector);
  38393. if (snapped) {
  38394. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  38395. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38396. }
  38397. }
  38398. });
  38399. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38400. if (_this._customMeshSet) {
  38401. return;
  38402. }
  38403. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38404. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  38405. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38406. m.material = material;
  38407. if (m.color) {
  38408. m.color = material.diffuseColor;
  38409. }
  38410. });
  38411. });
  38412. var light = gizmoLayer._getSharedGizmoLight();
  38413. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes());
  38414. return _this;
  38415. }
  38416. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  38417. if (this.dragBehavior) {
  38418. this.dragBehavior.enabled = value ? true : false;
  38419. }
  38420. };
  38421. /**
  38422. * Disposes of the gizmo
  38423. */
  38424. AxisScaleGizmo.prototype.dispose = function () {
  38425. this.onSnapObservable.clear();
  38426. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38427. this.dragBehavior.detach();
  38428. _super.prototype.dispose.call(this);
  38429. };
  38430. /**
  38431. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38432. * @param mesh The mesh to replace the default mesh of the gizmo
  38433. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  38434. */
  38435. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  38436. var _this = this;
  38437. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  38438. _super.prototype.setCustomMesh.call(this, mesh);
  38439. if (useGizmoMaterial) {
  38440. this._rootMesh.getChildMeshes().forEach(function (m) {
  38441. m.material = _this._coloredMaterial;
  38442. if (m.color) {
  38443. m.color = _this._coloredMaterial.diffuseColor;
  38444. }
  38445. });
  38446. this._customMeshSet = false;
  38447. }
  38448. };
  38449. return AxisScaleGizmo;
  38450. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  38451. /***/ }),
  38452. /***/ "./Gizmos/boundingBoxGizmo.ts":
  38453. /*!************************************!*\
  38454. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  38455. \************************************/
  38456. /*! exports provided: BoundingBoxGizmo */
  38457. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38458. "use strict";
  38459. __webpack_require__.r(__webpack_exports__);
  38460. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  38461. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38462. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38463. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38464. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38465. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38466. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38467. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  38468. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  38469. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  38470. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38471. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38472. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38473. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38474. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  38475. /**
  38476. * Bounding box gizmo
  38477. */
  38478. var BoundingBoxGizmo = /** @class */ (function (_super) {
  38479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  38480. /**
  38481. * Creates an BoundingBoxGizmo
  38482. * @param gizmoLayer The utility layer the gizmo will be added to
  38483. * @param color The color of the gizmo
  38484. */
  38485. function BoundingBoxGizmo(color, gizmoLayer) {
  38486. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  38487. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  38488. var _this = _super.call(this, gizmoLayer) || this;
  38489. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  38490. _this._renderObserver = null;
  38491. _this._pointerObserver = null;
  38492. _this._scaleDragSpeed = 0.2;
  38493. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38494. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  38495. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  38496. /**
  38497. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  38498. */
  38499. _this.ignoreChildren = false;
  38500. /**
  38501. * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)
  38502. */
  38503. _this.includeChildPredicate = null;
  38504. /**
  38505. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  38506. */
  38507. _this.rotationSphereSize = 0.1;
  38508. /**
  38509. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  38510. */
  38511. _this.scaleBoxSize = 0.1;
  38512. /**
  38513. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  38514. */
  38515. _this.fixedDragMeshScreenSize = false;
  38516. /**
  38517. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  38518. */
  38519. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  38520. /**
  38521. * Fired when a rotation sphere or scale box is dragged
  38522. */
  38523. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38524. /**
  38525. * Fired when a scale box is dragged
  38526. */
  38527. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38528. /**
  38529. * Fired when a scale box drag is ended
  38530. */
  38531. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38532. /**
  38533. * Fired when a rotation sphere is dragged
  38534. */
  38535. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38536. /**
  38537. * Fired when a rotation sphere drag is ended
  38538. */
  38539. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38540. /**
  38541. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  38542. */
  38543. _this.scalePivot = null;
  38544. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  38545. // Dragging
  38546. _this._dragMesh = null;
  38547. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]();
  38548. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  38549. _this._updateScale = false;
  38550. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  38551. // Create Materials
  38552. _this.coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38553. _this.coloredMaterial.disableLighting = true;
  38554. _this.hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38555. _this.hoverColoredMaterial.disableLighting = true;
  38556. // Build bounding box out of lines
  38557. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38558. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38559. var lines = [];
  38560. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, 0)] }, gizmoLayer.utilityLayerScene));
  38561. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  38562. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  38563. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  38564. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  38565. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  38566. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  38567. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  38568. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  38569. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  38570. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  38571. lines.push(_Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  38572. lines.forEach(function (l) {
  38573. l.color = color;
  38574. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  38575. l.isPickable = false;
  38576. _this._lineBoundingBox.addChild(l);
  38577. });
  38578. _this._rootMesh.addChild(_this._lineBoundingBox);
  38579. _this.setColor(color);
  38580. // Create rotation spheres
  38581. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38582. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38583. var _loop_1 = function (i_1) {
  38584. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__["SphereBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  38585. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38586. sphere.material = this_1.coloredMaterial;
  38587. // Drag behavior
  38588. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({});
  38589. _dragBehavior.moveAttached = false;
  38590. _dragBehavior.updateDragPlane = false;
  38591. sphere.addBehavior(_dragBehavior);
  38592. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  38593. var totalTurnAmountOfDrag = 0;
  38594. _dragBehavior.onDragStartObservable.add(function () {
  38595. startingTurnDirection.copyFrom(sphere.forward);
  38596. totalTurnAmountOfDrag = 0;
  38597. });
  38598. _dragBehavior.onDragObservable.add(function (event) {
  38599. _this.onRotationSphereDragObservable.notifyObservers({});
  38600. if (_this.attachedMesh) {
  38601. var originalParent = _this.attachedMesh.parent;
  38602. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38603. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38604. return;
  38605. }
  38606. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38607. var worldDragDirection = startingTurnDirection;
  38608. // Project the world right on to the drag plane
  38609. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  38610. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  38611. // project drag delta on to the resulting drag axis and rotate based on that
  38612. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  38613. // Make rotation relative to size of mesh.
  38614. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38615. // Rotate based on axis
  38616. if (!_this.attachedMesh.rotationQuaternion) {
  38617. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  38618. }
  38619. if (!_this._anchorMesh.rotationQuaternion) {
  38620. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  38621. }
  38622. // Do not allow the object to turn more than a full circle
  38623. totalTurnAmountOfDrag += projectDist;
  38624. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  38625. if (i_1 >= 8) {
  38626. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  38627. }
  38628. else if (i_1 >= 4) {
  38629. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  38630. }
  38631. else {
  38632. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  38633. }
  38634. // Rotate around center of bounding box
  38635. _this._anchorMesh.addChild(_this.attachedMesh);
  38636. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  38637. _this._anchorMesh.removeChild(_this.attachedMesh);
  38638. _this.attachedMesh.setParent(originalParent);
  38639. }
  38640. _this.updateBoundingBox();
  38641. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38642. }
  38643. _this._updateDummy();
  38644. });
  38645. // Selection/deselection
  38646. _dragBehavior.onDragStartObservable.add(function () {
  38647. _this.onDragStartObservable.notifyObservers({});
  38648. _this._selectNode(sphere);
  38649. });
  38650. _dragBehavior.onDragEndObservable.add(function () {
  38651. _this.onRotationSphereDragEndObservable.notifyObservers({});
  38652. _this._selectNode(null);
  38653. _this._updateDummy();
  38654. });
  38655. this_1._rotateSpheresParent.addChild(sphere);
  38656. };
  38657. var this_1 = this, _dragBehavior;
  38658. for (var i_1 = 0; i_1 < 12; i_1++) {
  38659. _loop_1(i_1);
  38660. }
  38661. _this._rootMesh.addChild(_this._rotateSpheresParent);
  38662. // Create scale cubes
  38663. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38664. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38665. for (var i = 0; i < 2; i++) {
  38666. for (var j = 0; j < 2; j++) {
  38667. var _loop_2 = function () {
  38668. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  38669. box.material = this_2.coloredMaterial;
  38670. // Dragging logic
  38671. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  38672. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38673. _dragBehavior.moveAttached = false;
  38674. box.addBehavior(_dragBehavior);
  38675. _dragBehavior.onDragObservable.add(function (event) {
  38676. _this.onScaleBoxDragObservable.notifyObservers({});
  38677. if (_this.attachedMesh) {
  38678. var originalParent = _this.attachedMesh.parent;
  38679. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38680. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38681. return;
  38682. }
  38683. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38684. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38685. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  38686. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  38687. _this.updateBoundingBox();
  38688. if (_this.scalePivot) {
  38689. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  38690. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  38691. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  38692. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38693. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38694. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  38695. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38696. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  38697. }
  38698. else {
  38699. // Scale from the position of the opposite corner
  38700. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  38701. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38702. }
  38703. _this._anchorMesh.addChild(_this.attachedMesh);
  38704. _this._anchorMesh.scaling.addInPlace(deltaScale);
  38705. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  38706. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  38707. }
  38708. _this._anchorMesh.removeChild(_this.attachedMesh);
  38709. _this.attachedMesh.setParent(originalParent);
  38710. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38711. }
  38712. _this._updateDummy();
  38713. });
  38714. // Selection/deselection
  38715. _dragBehavior.onDragStartObservable.add(function () {
  38716. _this.onDragStartObservable.notifyObservers({});
  38717. _this._selectNode(box);
  38718. });
  38719. _dragBehavior.onDragEndObservable.add(function () {
  38720. _this.onScaleBoxDragEndObservable.notifyObservers({});
  38721. _this._selectNode(null);
  38722. _this._updateDummy();
  38723. });
  38724. this_2._scaleBoxesParent.addChild(box);
  38725. };
  38726. var this_2 = this, _dragBehavior;
  38727. for (var k = 0; k < 2; k++) {
  38728. _loop_2();
  38729. }
  38730. }
  38731. }
  38732. _this._rootMesh.addChild(_this._scaleBoxesParent);
  38733. // Hover color change
  38734. var pointerIds = new Array();
  38735. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38736. if (!pointerIds[pointerInfo.event.pointerId]) {
  38737. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  38738. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  38739. pointerIds[pointerInfo.event.pointerId] = mesh;
  38740. mesh.material = _this.hoverColoredMaterial;
  38741. }
  38742. });
  38743. }
  38744. else {
  38745. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  38746. pointerIds[pointerInfo.event.pointerId].material = _this.coloredMaterial;
  38747. delete pointerIds[pointerInfo.event.pointerId];
  38748. }
  38749. }
  38750. });
  38751. // Update bounding box positions
  38752. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  38753. // Only update the bouding box if scaling has changed
  38754. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  38755. _this.updateBoundingBox();
  38756. }
  38757. else if (_this.fixedDragMeshScreenSize) {
  38758. _this._updateRotationSpheres();
  38759. _this._updateScaleBoxes();
  38760. }
  38761. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  38762. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  38763. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  38764. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  38765. }
  38766. });
  38767. _this.updateBoundingBox();
  38768. return _this;
  38769. }
  38770. /**
  38771. * Sets the color of the bounding box gizmo
  38772. * @param color the color to set
  38773. */
  38774. BoundingBoxGizmo.prototype.setColor = function (color) {
  38775. this.coloredMaterial.emissiveColor = color;
  38776. this.hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  38777. this._lineBoundingBox.getChildren().forEach(function (l) {
  38778. if (l.color) {
  38779. l.color = color;
  38780. }
  38781. });
  38782. };
  38783. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  38784. var _this = this;
  38785. if (value) {
  38786. // Reset anchor mesh to match attached mesh's scale
  38787. // This is needed to avoid invalid box/sphere position on first drag
  38788. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(value);
  38789. var originalParent = value.parent;
  38790. this._anchorMesh.addChild(value);
  38791. this._anchorMesh.removeChild(value);
  38792. value.setParent(originalParent);
  38793. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(value);
  38794. this.updateBoundingBox();
  38795. value.getChildMeshes(false).forEach(function (m) {
  38796. m.markAsDirty("scaling");
  38797. });
  38798. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  38799. _this._updateDummy();
  38800. });
  38801. }
  38802. };
  38803. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  38804. this._rotateSpheresParent.getChildMeshes()
  38805. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  38806. m.isVisible = (!selectedMesh || m == selectedMesh);
  38807. });
  38808. };
  38809. /**
  38810. * Updates the bounding box information for the Gizmo
  38811. */
  38812. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  38813. if (this.attachedMesh) {
  38814. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  38815. // Store original parent
  38816. var originalParent = this.attachedMesh.parent;
  38817. this.attachedMesh.setParent(null);
  38818. // Store original skelton override mesh
  38819. var originalSkeletonOverrideMesh = null;
  38820. if (this.attachedMesh.skeleton) {
  38821. originalSkeletonOverrideMesh = this.attachedMesh.skeleton.overrideMesh;
  38822. this.attachedMesh.skeleton.overrideMesh = null;
  38823. }
  38824. this._update();
  38825. // Rotate based on axis
  38826. if (!this.attachedMesh.rotationQuaternion) {
  38827. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  38828. }
  38829. if (!this._anchorMesh.rotationQuaternion) {
  38830. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  38831. }
  38832. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  38833. // Store original position and reset mesh to origin before computing the bounding box
  38834. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  38835. this._tmpVector.copyFrom(this.attachedMesh.position);
  38836. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  38837. this.attachedMesh.position.set(0, 0, 0);
  38838. // Update bounding dimensions/positions
  38839. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  38840. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  38841. // Update gizmo to match bounding box scaling and rotation
  38842. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  38843. this._lineBoundingBox.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  38844. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  38845. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  38846. this._lineBoundingBox.computeWorldMatrix();
  38847. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  38848. // Restore position/rotation values
  38849. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  38850. this.attachedMesh.position.copyFrom(this._tmpVector);
  38851. // Restore original parent
  38852. this.attachedMesh.setParent(originalParent);
  38853. // Restore original skeleton override mesh
  38854. if (this.attachedMesh.skeleton) {
  38855. this.attachedMesh.skeleton.overrideMesh = originalSkeletonOverrideMesh;
  38856. }
  38857. }
  38858. this._updateRotationSpheres();
  38859. this._updateScaleBoxes();
  38860. if (this.attachedMesh) {
  38861. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  38862. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  38863. }
  38864. };
  38865. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  38866. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  38867. for (var i = 0; i < 3; i++) {
  38868. for (var j = 0; j < 2; j++) {
  38869. for (var k = 0; k < 2; k++) {
  38870. var index = ((i * 4) + (j * 2)) + k;
  38871. if (i == 0) {
  38872. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38873. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38874. rotateSpheres[index].lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Cross(rotateSpheres[index].position.normalizeToNew(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Right()).normalizeToNew().add(rotateSpheres[index].position));
  38875. }
  38876. if (i == 1) {
  38877. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  38878. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38879. rotateSpheres[index].lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Cross(rotateSpheres[index].position.normalizeToNew(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up()).normalizeToNew().add(rotateSpheres[index].position));
  38880. }
  38881. if (i == 2) {
  38882. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  38883. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38884. rotateSpheres[index].lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Cross(rotateSpheres[index].position.normalizeToNew(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Forward()).normalizeToNew().add(rotateSpheres[index].position));
  38885. }
  38886. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38887. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38888. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38889. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38890. }
  38891. else {
  38892. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  38893. }
  38894. }
  38895. }
  38896. }
  38897. };
  38898. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  38899. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  38900. for (var i = 0; i < 2; i++) {
  38901. for (var j = 0; j < 2; j++) {
  38902. for (var k = 0; k < 2; k++) {
  38903. var index = ((i * 4) + (j * 2)) + k;
  38904. if (scaleBoxes[index]) {
  38905. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38906. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38907. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38908. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38909. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38910. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38911. }
  38912. else {
  38913. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  38914. }
  38915. }
  38916. }
  38917. }
  38918. }
  38919. };
  38920. /**
  38921. * Enables rotation on the specified axis and disables rotation on the others
  38922. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  38923. */
  38924. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  38925. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  38926. if (i < 4) {
  38927. m.setEnabled(axis.indexOf("x") != -1);
  38928. }
  38929. else if (i < 8) {
  38930. m.setEnabled(axis.indexOf("y") != -1);
  38931. }
  38932. else {
  38933. m.setEnabled(axis.indexOf("z") != -1);
  38934. }
  38935. });
  38936. };
  38937. /**
  38938. * Enables/disables scaling
  38939. * @param enable if scaling should be enabled
  38940. */
  38941. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  38942. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  38943. m.setEnabled(enable);
  38944. });
  38945. };
  38946. BoundingBoxGizmo.prototype._updateDummy = function () {
  38947. if (this._dragMesh) {
  38948. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  38949. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  38950. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  38951. }
  38952. };
  38953. /**
  38954. * Enables a pointer drag behavior on the bounding box of the gizmo
  38955. */
  38956. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  38957. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  38958. this._dragMesh.visibility = 0;
  38959. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38960. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  38961. this._dragMesh.addBehavior(this.pointerDragBehavior);
  38962. };
  38963. /**
  38964. * Disposes of the gizmo
  38965. */
  38966. BoundingBoxGizmo.prototype.dispose = function () {
  38967. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38968. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  38969. this._lineBoundingBox.dispose();
  38970. this._rotateSpheresParent.dispose();
  38971. this._scaleBoxesParent.dispose();
  38972. if (this._dragMesh) {
  38973. this._dragMesh.dispose();
  38974. }
  38975. _super.prototype.dispose.call(this);
  38976. };
  38977. /**
  38978. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  38979. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  38980. * @returns the bounding box mesh with the passed in mesh as a child
  38981. */
  38982. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  38983. var makeNotPickable = function (root) {
  38984. root.isPickable = false;
  38985. root.getChildMeshes().forEach(function (c) {
  38986. makeNotPickable(c);
  38987. });
  38988. };
  38989. makeNotPickable(mesh);
  38990. // Reset position to get boudning box from origin with no rotation
  38991. if (!mesh.rotationQuaternion) {
  38992. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  38993. }
  38994. var oldPos = mesh.position.clone();
  38995. var oldRot = mesh.rotationQuaternion.clone();
  38996. mesh.rotationQuaternion.set(0, 0, 0, 1);
  38997. mesh.position.set(0, 0, 0);
  38998. // Update bounding dimensions/positions
  38999. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  39000. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  39001. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  39002. // Adjust scale to avoid undefined behavior when adding child
  39003. if (box.scaling.y === 0) {
  39004. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  39005. }
  39006. if (box.scaling.x === 0) {
  39007. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  39008. }
  39009. if (box.scaling.z === 0) {
  39010. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  39011. }
  39012. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  39013. // Restore original positions
  39014. mesh.addChild(box);
  39015. mesh.rotationQuaternion.copyFrom(oldRot);
  39016. mesh.position.copyFrom(oldPos);
  39017. // Reverse parenting
  39018. mesh.removeChild(box);
  39019. box.addChild(mesh);
  39020. box.visibility = 0;
  39021. return box;
  39022. };
  39023. /**
  39024. * CustomMeshes are not supported by this gizmo
  39025. * @param mesh The mesh to replace the default mesh of the gizmo
  39026. */
  39027. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  39028. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  39029. };
  39030. return BoundingBoxGizmo;
  39031. }(_gizmo__WEBPACK_IMPORTED_MODULE_10__["Gizmo"]));
  39032. /***/ }),
  39033. /***/ "./Gizmos/gizmo.ts":
  39034. /*!*************************!*\
  39035. !*** ./Gizmos/gizmo.ts ***!
  39036. \*************************/
  39037. /*! exports provided: Gizmo */
  39038. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39039. "use strict";
  39040. __webpack_require__.r(__webpack_exports__);
  39041. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  39042. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39043. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39044. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39045. /**
  39046. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39047. */
  39048. var Gizmo = /** @class */ (function () {
  39049. /**
  39050. * Creates a gizmo
  39051. * @param gizmoLayer The utility layer the gizmo will be added to
  39052. */
  39053. function Gizmo(
  39054. /** The utility layer the gizmo will be added to */
  39055. gizmoLayer) {
  39056. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39057. var _this = this;
  39058. this.gizmoLayer = gizmoLayer;
  39059. /**
  39060. * Ratio for the scale of the gizmo (Default: 1)
  39061. */
  39062. this.scaleRatio = 1;
  39063. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  39064. /**
  39065. * If a custom mesh has been set (Default: false)
  39066. */
  39067. this._customMeshSet = false;
  39068. /**
  39069. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39070. */
  39071. this.updateGizmoRotationToMatchAttachedMesh = true;
  39072. /**
  39073. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39074. */
  39075. this.updateGizmoPositionToMatchAttachedMesh = true;
  39076. /**
  39077. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39078. */
  39079. this._updateScale = true;
  39080. this._interactionsEnabled = true;
  39081. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  39082. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  39083. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  39084. _this._update();
  39085. });
  39086. this.attachedMesh = null;
  39087. }
  39088. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  39089. /**
  39090. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39091. * * When set, interactions will be enabled
  39092. */
  39093. get: function () {
  39094. return this._attachedMesh;
  39095. },
  39096. set: function (value) {
  39097. this._attachedMesh = value;
  39098. this._rootMesh.setEnabled(value ? true : false);
  39099. this._attachedMeshChanged(value);
  39100. },
  39101. enumerable: true,
  39102. configurable: true
  39103. });
  39104. /**
  39105. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39106. * @param mesh The mesh to replace the default mesh of the gizmo
  39107. */
  39108. Gizmo.prototype.setCustomMesh = function (mesh) {
  39109. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  39110. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  39111. }
  39112. this._rootMesh.getChildMeshes().forEach(function (c) {
  39113. c.dispose();
  39114. });
  39115. mesh.parent = this._rootMesh;
  39116. this._customMeshSet = true;
  39117. };
  39118. Gizmo.prototype._attachedMeshChanged = function (value) {
  39119. };
  39120. /**
  39121. * @hidden
  39122. * Updates the gizmo to match the attached mesh's position/rotation
  39123. */
  39124. Gizmo.prototype._update = function () {
  39125. if (this.attachedMesh) {
  39126. var effectiveMesh = this.attachedMesh._effectiveMesh || this.attachedMesh;
  39127. if (this.updateGizmoRotationToMatchAttachedMesh) {
  39128. if (!this._rootMesh.rotationQuaternion) {
  39129. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  39130. }
  39131. effectiveMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  39132. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  39133. }
  39134. else if (this._rootMesh.rotationQuaternion) {
  39135. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  39136. }
  39137. if (this.updateGizmoPositionToMatchAttachedMesh) {
  39138. this._rootMesh.position.copyFrom(effectiveMesh.absolutePosition);
  39139. }
  39140. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  39141. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  39142. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  39143. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  39144. }
  39145. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  39146. var dist = this._tempVector.length() * this.scaleRatio;
  39147. this._rootMesh.scaling.set(dist, dist, dist);
  39148. }
  39149. }
  39150. };
  39151. /**
  39152. * Disposes of the gizmo
  39153. */
  39154. Gizmo.prototype.dispose = function () {
  39155. this._rootMesh.dispose();
  39156. if (this._beforeRenderObserver) {
  39157. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  39158. }
  39159. };
  39160. return Gizmo;
  39161. }());
  39162. /***/ }),
  39163. /***/ "./Gizmos/gizmoManager.ts":
  39164. /*!********************************!*\
  39165. !*** ./Gizmos/gizmoManager.ts ***!
  39166. \********************************/
  39167. /*! exports provided: GizmoManager */
  39168. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39169. "use strict";
  39170. __webpack_require__.r(__webpack_exports__);
  39171. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  39172. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39173. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  39174. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39175. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39176. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39177. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  39178. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  39179. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  39180. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  39181. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  39182. /**
  39183. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  39184. */
  39185. var GizmoManager = /** @class */ (function () {
  39186. /**
  39187. * Instatiates a gizmo manager
  39188. * @param scene the scene to overlay the gizmos on top of
  39189. */
  39190. function GizmoManager(scene) {
  39191. var _this = this;
  39192. this.scene = scene;
  39193. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  39194. this.clearGizmoOnEmptyPointerEvent = false;
  39195. /** Fires an event when the manager is attached to a mesh */
  39196. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  39197. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  39198. this._pointerObserver = null;
  39199. this._attachedMesh = null;
  39200. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  39201. /**
  39202. * When bounding box gizmo is enabled, this can be used to track drag/end events
  39203. */
  39204. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  39205. /**
  39206. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  39207. */
  39208. this.attachableMeshes = null;
  39209. /**
  39210. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  39211. */
  39212. this.usePointerToAttachGizmos = true;
  39213. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  39214. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  39215. this._defaultUtilityLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"].DefaultUtilityLayer;
  39216. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  39217. // Instatiate/dispose gizmos based on pointer actions
  39218. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  39219. if (!_this.usePointerToAttachGizmos) {
  39220. return;
  39221. }
  39222. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  39223. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  39224. var node = pointerInfo.pickInfo.pickedMesh;
  39225. if (_this.attachableMeshes == null) {
  39226. // Attach to the most parent node
  39227. while (node && node.parent != null) {
  39228. node = node.parent;
  39229. }
  39230. }
  39231. else {
  39232. // Attach to the parent node that is an attachableMesh
  39233. var found = false;
  39234. _this.attachableMeshes.forEach(function (mesh) {
  39235. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  39236. node = mesh;
  39237. found = true;
  39238. }
  39239. });
  39240. if (!found) {
  39241. node = null;
  39242. }
  39243. }
  39244. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  39245. if (_this._attachedMesh != node) {
  39246. _this.attachToMesh(node);
  39247. }
  39248. }
  39249. else {
  39250. if (_this.clearGizmoOnEmptyPointerEvent) {
  39251. _this.attachToMesh(null);
  39252. }
  39253. }
  39254. }
  39255. else {
  39256. if (_this.clearGizmoOnEmptyPointerEvent) {
  39257. _this.attachToMesh(null);
  39258. }
  39259. }
  39260. }
  39261. });
  39262. }
  39263. /**
  39264. * Attaches a set of gizmos to the specified mesh
  39265. * @param mesh The mesh the gizmo's should be attached to
  39266. */
  39267. GizmoManager.prototype.attachToMesh = function (mesh) {
  39268. if (this._attachedMesh) {
  39269. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39270. }
  39271. this._attachedMesh = mesh;
  39272. for (var key in this.gizmos) {
  39273. var gizmo = (this.gizmos[key]);
  39274. if (gizmo && this._gizmosEnabled[key]) {
  39275. gizmo.attachedMesh = mesh;
  39276. }
  39277. }
  39278. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  39279. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  39280. }
  39281. this.onAttachedToMeshObservable.notifyObservers(mesh);
  39282. };
  39283. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  39284. get: function () {
  39285. return this._gizmosEnabled.positionGizmo;
  39286. },
  39287. /**
  39288. * If the position gizmo is enabled
  39289. */
  39290. set: function (value) {
  39291. if (value) {
  39292. if (!this.gizmos.positionGizmo) {
  39293. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  39294. }
  39295. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  39296. }
  39297. else if (this.gizmos.positionGizmo) {
  39298. this.gizmos.positionGizmo.attachedMesh = null;
  39299. }
  39300. this._gizmosEnabled.positionGizmo = value;
  39301. },
  39302. enumerable: true,
  39303. configurable: true
  39304. });
  39305. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  39306. get: function () {
  39307. return this._gizmosEnabled.rotationGizmo;
  39308. },
  39309. /**
  39310. * If the rotation gizmo is enabled
  39311. */
  39312. set: function (value) {
  39313. if (value) {
  39314. if (!this.gizmos.rotationGizmo) {
  39315. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  39316. }
  39317. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  39318. }
  39319. else if (this.gizmos.rotationGizmo) {
  39320. this.gizmos.rotationGizmo.attachedMesh = null;
  39321. }
  39322. this._gizmosEnabled.rotationGizmo = value;
  39323. },
  39324. enumerable: true,
  39325. configurable: true
  39326. });
  39327. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  39328. get: function () {
  39329. return this._gizmosEnabled.scaleGizmo;
  39330. },
  39331. /**
  39332. * If the scale gizmo is enabled
  39333. */
  39334. set: function (value) {
  39335. if (value) {
  39336. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  39337. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  39338. }
  39339. else if (this.gizmos.scaleGizmo) {
  39340. this.gizmos.scaleGizmo.attachedMesh = null;
  39341. }
  39342. this._gizmosEnabled.scaleGizmo = value;
  39343. },
  39344. enumerable: true,
  39345. configurable: true
  39346. });
  39347. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  39348. get: function () {
  39349. return this._gizmosEnabled.boundingBoxGizmo;
  39350. },
  39351. /**
  39352. * If the boundingBox gizmo is enabled
  39353. */
  39354. set: function (value) {
  39355. if (value) {
  39356. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  39357. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  39358. if (this._attachedMesh) {
  39359. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39360. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  39361. }
  39362. }
  39363. else if (this.gizmos.boundingBoxGizmo) {
  39364. if (this._attachedMesh) {
  39365. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39366. }
  39367. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  39368. }
  39369. this._gizmosEnabled.boundingBoxGizmo = value;
  39370. },
  39371. enumerable: true,
  39372. configurable: true
  39373. });
  39374. /**
  39375. * Disposes of the gizmo manager
  39376. */
  39377. GizmoManager.prototype.dispose = function () {
  39378. this.scene.onPointerObservable.remove(this._pointerObserver);
  39379. for (var key in this.gizmos) {
  39380. var gizmo = (this.gizmos[key]);
  39381. if (gizmo) {
  39382. gizmo.dispose();
  39383. }
  39384. }
  39385. this._defaultKeepDepthUtilityLayer.dispose();
  39386. this.boundingBoxDragBehavior.detach();
  39387. this.onAttachedToMeshObservable.clear();
  39388. };
  39389. return GizmoManager;
  39390. }());
  39391. /***/ }),
  39392. /***/ "./Gizmos/index.ts":
  39393. /*!*************************!*\
  39394. !*** ./Gizmos/index.ts ***!
  39395. \*************************/
  39396. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo */
  39397. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39398. "use strict";
  39399. __webpack_require__.r(__webpack_exports__);
  39400. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  39401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  39402. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  39403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  39404. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  39405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  39406. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  39408. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  39409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  39410. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  39411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  39412. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  39413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  39414. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  39415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  39416. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  39417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  39418. /* harmony import */ var _lightGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lightGizmo */ "./Gizmos/lightGizmo.ts");
  39419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _lightGizmo__WEBPACK_IMPORTED_MODULE_9__["LightGizmo"]; });
  39420. /***/ }),
  39421. /***/ "./Gizmos/lightGizmo.ts":
  39422. /*!******************************!*\
  39423. !*** ./Gizmos/lightGizmo.ts ***!
  39424. \******************************/
  39425. /*! exports provided: LightGizmo */
  39426. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39427. "use strict";
  39428. __webpack_require__.r(__webpack_exports__);
  39429. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return LightGizmo; });
  39430. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39431. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39432. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39433. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39434. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39435. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39436. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  39437. /* harmony import */ var _Lights_directionalLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/directionalLight */ "./Lights/directionalLight.ts");
  39438. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  39439. /* harmony import */ var _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/hemisphereBuilder */ "./Meshes/Builders/hemisphereBuilder.ts");
  39440. /* harmony import */ var _Lights_spotLight__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Lights/spotLight */ "./Lights/spotLight.ts");
  39441. /**
  39442. * Gizmo that enables viewing a light
  39443. */
  39444. var LightGizmo = /** @class */ (function (_super) {
  39445. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LightGizmo, _super);
  39446. /**
  39447. * Creates a LightGizmo
  39448. * @param gizmoLayer The utility layer the gizmo will be added to
  39449. */
  39450. function LightGizmo(gizmoLayer) {
  39451. var _this = _super.call(this, gizmoLayer) || this;
  39452. _this._light = null;
  39453. _this.attachedMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", _this.gizmoLayer.utilityLayerScene);
  39454. _this._material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("light", _this.gizmoLayer.originalScene);
  39455. _this._material.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.5, 0.5, 0.5);
  39456. _this._material.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.1, 0.1, 0.1);
  39457. return _this;
  39458. }
  39459. Object.defineProperty(LightGizmo.prototype, "light", {
  39460. get: function () {
  39461. return this._light;
  39462. },
  39463. /**
  39464. * The light that the gizmo is attached to
  39465. */
  39466. set: function (light) {
  39467. var _this = this;
  39468. this._light = light;
  39469. if (light) {
  39470. // Create the mesh for the given light type
  39471. if (this._lightMesh) {
  39472. this._lightMesh.dispose();
  39473. }
  39474. if (light instanceof _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_6__["HemisphericLight"]) {
  39475. this._lightMesh = LightGizmo._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene);
  39476. }
  39477. else if (light instanceof _Lights_directionalLight__WEBPACK_IMPORTED_MODULE_7__["DirectionalLight"]) {
  39478. this._lightMesh = LightGizmo._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene);
  39479. }
  39480. else if (light instanceof _Lights_spotLight__WEBPACK_IMPORTED_MODULE_10__["SpotLight"]) {
  39481. this._lightMesh = LightGizmo._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene);
  39482. }
  39483. else {
  39484. this._lightMesh = LightGizmo._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene);
  39485. }
  39486. this._lightMesh.getChildMeshes(false).forEach(function (m) {
  39487. m.material = _this._material;
  39488. });
  39489. this._lightMesh.parent = this._rootMesh;
  39490. // Add lighting to the light gizmo
  39491. var gizmoLight = this.gizmoLayer._getSharedGizmoLight();
  39492. gizmoLight.includedOnlyMeshes = gizmoLight.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(false));
  39493. // Get update position and direction if the light has it
  39494. if (light.position) {
  39495. this.attachedMesh.position.copyFrom(light.position);
  39496. }
  39497. if (light.direction) {
  39498. this._lightMesh.setDirection(light.direction);
  39499. }
  39500. }
  39501. },
  39502. enumerable: true,
  39503. configurable: true
  39504. });
  39505. /**
  39506. * @hidden
  39507. * Updates the gizmo to match the attached mesh's position/rotation
  39508. */
  39509. LightGizmo.prototype._update = function () {
  39510. _super.prototype._update.call(this);
  39511. if (!this._light) {
  39512. return;
  39513. }
  39514. if (this._light.position) {
  39515. this._light.position.copyFrom(this.attachedMesh.position);
  39516. }
  39517. if (this._light.direction) {
  39518. this._light.direction.copyFrom(this._lightMesh.forward);
  39519. }
  39520. if (!this._light.isEnabled()) {
  39521. this._material.diffuseColor.set(0, 0, 0);
  39522. }
  39523. else {
  39524. this._material.diffuseColor.set(this._light.diffuse.r / 3, this._light.diffuse.g / 3, this._light.diffuse.b / 3);
  39525. }
  39526. };
  39527. LightGizmo._CreateHemisphericLightMesh = function (scene) {
  39528. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("hemisphereLight", scene);
  39529. var hemisphere = _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_9__["HemisphereBuilder"].CreateHemisphere(root.name, { segments: 10, diameter: 1 }, scene);
  39530. hemisphere.position.z = -0.15;
  39531. hemisphere.rotation.x = Math.PI / 2;
  39532. hemisphere.parent = root;
  39533. var lines = this._createLightLines(3, scene);
  39534. lines.parent = root;
  39535. lines.position.z - 0.15;
  39536. root.scaling.scaleInPlace(LightGizmo._Scale);
  39537. root.rotation.x = Math.PI / 2;
  39538. return root;
  39539. };
  39540. LightGizmo._CreatePointLightMesh = function (scene) {
  39541. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("pointLight", scene);
  39542. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__["SphereBuilder"].CreateSphere(root.name, { segments: 10, diameter: 1 }, scene);
  39543. sphere.rotation.x = Math.PI / 2;
  39544. sphere.parent = root;
  39545. var lines = this._createLightLines(5, scene);
  39546. lines.parent = root;
  39547. root.scaling.scaleInPlace(LightGizmo._Scale);
  39548. root.rotation.x = Math.PI / 2;
  39549. return root;
  39550. };
  39551. LightGizmo._CreateSpotLightMesh = function (scene) {
  39552. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("spotLight", scene);
  39553. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__["SphereBuilder"].CreateSphere(root.name, { segments: 10, diameter: 1 }, scene);
  39554. sphere.parent = root;
  39555. var hemisphere = _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_9__["HemisphereBuilder"].CreateHemisphere(root.name, { segments: 10, diameter: 2 }, scene);
  39556. hemisphere.parent = root;
  39557. hemisphere.rotation.x = -Math.PI / 2;
  39558. var lines = this._createLightLines(2, scene);
  39559. lines.parent = root;
  39560. root.scaling.scaleInPlace(LightGizmo._Scale);
  39561. root.rotation.x = Math.PI / 2;
  39562. return root;
  39563. };
  39564. LightGizmo._CreateDirectionalLightMesh = function (scene) {
  39565. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("directionalLight", scene);
  39566. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](root.name, scene);
  39567. mesh.parent = root;
  39568. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__["SphereBuilder"].CreateSphere(root.name, { diameter: 1.2, segments: 10 }, scene);
  39569. sphere.parent = mesh;
  39570. var line = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder(root.name, 6, 0.3, 0.3, 6, 1, scene);
  39571. line.parent = mesh;
  39572. var left = line.clone(root.name);
  39573. left.scaling.y = 0.5;
  39574. left.position.x += 1.25;
  39575. var right = line.clone(root.name);
  39576. right.scaling.y = 0.5;
  39577. right.position.x += -1.25;
  39578. var arrowHead = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder(root.name, 1, 0, 0.6, 6, 1, scene);
  39579. arrowHead.position.y += 3;
  39580. arrowHead.parent = mesh;
  39581. var left = arrowHead.clone(root.name);
  39582. left.position.y = 1.5;
  39583. left.position.x += 1.25;
  39584. var right = arrowHead.clone(root.name);
  39585. right.position.y = 1.5;
  39586. right.position.x += -1.25;
  39587. mesh.scaling.scaleInPlace(LightGizmo._Scale);
  39588. mesh.rotation.z = Math.PI / 2;
  39589. mesh.rotation.y = Math.PI / 2;
  39590. return root;
  39591. };
  39592. // Static helper methods
  39593. LightGizmo._Scale = 0.007;
  39594. /**
  39595. * Creates the lines for a light mesh
  39596. */
  39597. LightGizmo._createLightLines = function (levels, scene) {
  39598. var distFromSphere = 1.2;
  39599. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("root", scene);
  39600. root.rotation.x = Math.PI / 2;
  39601. // Create the top line, this will be cloned for all other lines
  39602. var linePivot = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("linePivot", scene);
  39603. linePivot.parent = root;
  39604. var line = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder("line", 2, 0.2, 0.3, 6, 1, scene);
  39605. line.position.y = line.scaling.y / 2 + distFromSphere;
  39606. line.parent = linePivot;
  39607. if (levels < 2) {
  39608. return linePivot;
  39609. }
  39610. for (var i = 0; i < 4; i++) {
  39611. var l = linePivot.clone("lineParentClone");
  39612. l.rotation.z = Math.PI / 4;
  39613. l.rotation.y = (Math.PI / 2) + (Math.PI / 2 * i);
  39614. l.getChildMeshes()[0].scaling.y = 0.5;
  39615. l.getChildMeshes()[0].scaling.x = l.getChildMeshes()[0].scaling.z = 0.8;
  39616. l.getChildMeshes()[0].position.y = l.getChildMeshes()[0].scaling.y / 2 + distFromSphere;
  39617. }
  39618. if (levels < 3) {
  39619. return root;
  39620. }
  39621. for (var i = 0; i < 4; i++) {
  39622. var l = linePivot.clone("linePivotClone");
  39623. l.rotation.z = Math.PI / 2;
  39624. l.rotation.y = (Math.PI / 2 * i);
  39625. }
  39626. if (levels < 4) {
  39627. return root;
  39628. }
  39629. for (var i = 0; i < 4; i++) {
  39630. var l = linePivot.clone("linePivotClone");
  39631. l.rotation.z = Math.PI + (Math.PI / 4);
  39632. l.rotation.y = (Math.PI / 2) + (Math.PI / 2 * i);
  39633. l.getChildMeshes()[0].scaling.y = 0.5;
  39634. l.getChildMeshes()[0].scaling.x = l.getChildMeshes()[0].scaling.z = 0.8;
  39635. l.getChildMeshes()[0].position.y = l.getChildMeshes()[0].scaling.y / 2 + distFromSphere;
  39636. }
  39637. if (levels < 5) {
  39638. return root;
  39639. }
  39640. var l = linePivot.clone("linePivotClone");
  39641. l.rotation.z = Math.PI;
  39642. return root;
  39643. };
  39644. return LightGizmo;
  39645. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39646. /***/ }),
  39647. /***/ "./Gizmos/planeRotationGizmo.ts":
  39648. /*!**************************************!*\
  39649. !*** ./Gizmos/planeRotationGizmo.ts ***!
  39650. \**************************************/
  39651. /*! exports provided: PlaneRotationGizmo */
  39652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39653. "use strict";
  39654. __webpack_require__.r(__webpack_exports__);
  39655. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  39656. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39657. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39658. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39659. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39660. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39661. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  39662. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39663. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39664. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39665. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  39666. /**
  39667. * Single plane rotation gizmo
  39668. */
  39669. var PlaneRotationGizmo = /** @class */ (function (_super) {
  39670. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  39671. /**
  39672. * Creates a PlaneRotationGizmo
  39673. * @param gizmoLayer The utility layer the gizmo will be added to
  39674. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  39675. * @param color The color of the gizmo
  39676. * @param tessellation Amount of tessellation to be used when creating rotation circles
  39677. */
  39678. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  39679. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  39680. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39681. if (tessellation === void 0) { tessellation = 32; }
  39682. var _this = _super.call(this, gizmoLayer) || this;
  39683. _this._pointerObserver = null;
  39684. /**
  39685. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  39686. */
  39687. _this.snapDistance = 0;
  39688. /**
  39689. * Event that fires each time the gizmo snaps to a new location.
  39690. * * snapDistance is the the change in distance
  39691. */
  39692. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39693. // Create Material
  39694. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39695. coloredMaterial.diffuseColor = color;
  39696. coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  39697. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39698. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  39699. // Build mesh on root node
  39700. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  39701. var drag = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateTorus("", 0.6, 0.03, tessellation, gizmoLayer.utilityLayerScene);
  39702. drag.visibility = 0;
  39703. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateTorus("", 0.6, 0.005, tessellation, gizmoLayer.utilityLayerScene);
  39704. rotationMesh.material = coloredMaterial;
  39705. // Position arrow pointing in its drag axis
  39706. rotationMesh.rotation.x = Math.PI / 2;
  39707. drag.rotation.x = Math.PI / 2;
  39708. parentMesh.addChild(rotationMesh);
  39709. parentMesh.addChild(drag);
  39710. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  39711. _this._rootMesh.addChild(parentMesh);
  39712. parentMesh.scaling.scaleInPlace(1 / 3);
  39713. // Add drag behavior to handle events when the gizmo is dragged
  39714. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  39715. _this.dragBehavior.moveAttached = false;
  39716. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  39717. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  39718. _this._rootMesh.addBehavior(_this.dragBehavior);
  39719. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39720. _this.dragBehavior.onDragStartObservable.add(function (e) {
  39721. if (_this.attachedMesh) {
  39722. lastDragPosition.copyFrom(e.dragPlanePoint);
  39723. }
  39724. });
  39725. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39726. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39727. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39728. var tmpSnapEvent = { snapDistance: 0 };
  39729. var currentSnapDragDistance = 0;
  39730. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39731. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39732. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  39733. _this.dragBehavior.onDragObservable.add(function (event) {
  39734. if (_this.attachedMesh) {
  39735. if (!_this.attachedMesh.rotationQuaternion) {
  39736. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  39737. }
  39738. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  39739. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  39740. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  39741. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  39742. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  39743. var angle = Math.atan2(cross.length(), dot);
  39744. planeNormalTowardsCamera.copyFrom(planeNormal);
  39745. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  39746. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39747. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  39748. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  39749. }
  39750. // Flip up vector depending on which side the camera is on
  39751. if (gizmoLayer.utilityLayerScene.activeCamera) {
  39752. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  39753. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  39754. planeNormalTowardsCamera.scaleInPlace(-1);
  39755. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  39756. }
  39757. }
  39758. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  39759. if (halfCircleSide) {
  39760. angle = -angle;
  39761. }
  39762. // Snapping logic
  39763. var snapped = false;
  39764. if (_this.snapDistance != 0) {
  39765. currentSnapDragDistance += angle;
  39766. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  39767. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  39768. if (currentSnapDragDistance < 0) {
  39769. dragSteps *= -1;
  39770. }
  39771. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  39772. angle = _this.snapDistance * dragSteps;
  39773. snapped = true;
  39774. }
  39775. else {
  39776. angle = 0;
  39777. }
  39778. }
  39779. // If the mesh has a parent, convert needed world rotation to local rotation
  39780. tmpMatrix.reset();
  39781. if (_this.attachedMesh.parent) {
  39782. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  39783. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  39784. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  39785. }
  39786. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  39787. var quaternionCoefficient = Math.sin(angle / 2);
  39788. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  39789. // If the meshes local scale is inverted (eg. loaded gltf file parent with z scale of -1) the rotation needs to be inverted on the y axis
  39790. if (tmpMatrix.determinant() > 0) {
  39791. amountToRotate.toEulerAnglesToRef(tmpVector);
  39792. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  39793. }
  39794. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39795. // Rotate selected mesh quaternion over fixed axis
  39796. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  39797. }
  39798. else {
  39799. // Rotate selected mesh quaternion over rotated axis
  39800. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  39801. }
  39802. lastDragPosition.copyFrom(event.dragPlanePoint);
  39803. if (snapped) {
  39804. tmpSnapEvent.snapDistance = angle;
  39805. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  39806. }
  39807. }
  39808. });
  39809. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  39810. if (_this._customMeshSet) {
  39811. return;
  39812. }
  39813. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  39814. var material = isHovered ? hoverMaterial : coloredMaterial;
  39815. _this._rootMesh.getChildMeshes().forEach(function (m) {
  39816. m.material = material;
  39817. if (m.color) {
  39818. m.color = material.diffuseColor;
  39819. }
  39820. });
  39821. });
  39822. var light = gizmoLayer._getSharedGizmoLight();
  39823. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes(false));
  39824. return _this;
  39825. }
  39826. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  39827. if (this.dragBehavior) {
  39828. this.dragBehavior.enabled = value ? true : false;
  39829. }
  39830. };
  39831. /**
  39832. * Disposes of the gizmo
  39833. */
  39834. PlaneRotationGizmo.prototype.dispose = function () {
  39835. this.onSnapObservable.clear();
  39836. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  39837. this.dragBehavior.detach();
  39838. _super.prototype.dispose.call(this);
  39839. };
  39840. return PlaneRotationGizmo;
  39841. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  39842. /***/ }),
  39843. /***/ "./Gizmos/positionGizmo.ts":
  39844. /*!*********************************!*\
  39845. !*** ./Gizmos/positionGizmo.ts ***!
  39846. \*********************************/
  39847. /*! exports provided: PositionGizmo */
  39848. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39849. "use strict";
  39850. __webpack_require__.r(__webpack_exports__);
  39851. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  39852. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39853. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39854. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39855. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39856. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39857. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  39858. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39859. /**
  39860. * Gizmo that enables dragging a mesh along 3 axis
  39861. */
  39862. var PositionGizmo = /** @class */ (function (_super) {
  39863. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  39864. /**
  39865. * Creates a PositionGizmo
  39866. * @param gizmoLayer The utility layer the gizmo will be added to
  39867. */
  39868. function PositionGizmo(gizmoLayer) {
  39869. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39870. var _this = _super.call(this, gizmoLayer) || this;
  39871. /** Fires an event when any of it's sub gizmos are dragged */
  39872. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39873. /** Fires an event when any of it's sub gizmos are released from dragging */
  39874. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39875. _this.xGizmo = new _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__["AxisDragGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red().scale(0.5), gizmoLayer);
  39876. _this.yGizmo = new _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__["AxisDragGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Green().scale(0.5), gizmoLayer);
  39877. _this.zGizmo = new _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__["AxisDragGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Blue().scale(0.5), gizmoLayer);
  39878. // Relay drag events
  39879. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  39880. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39881. _this.onDragStartObservable.notifyObservers({});
  39882. });
  39883. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39884. _this.onDragEndObservable.notifyObservers({});
  39885. });
  39886. });
  39887. _this.attachedMesh = null;
  39888. return _this;
  39889. }
  39890. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  39891. get: function () {
  39892. return this.xGizmo.attachedMesh;
  39893. },
  39894. set: function (mesh) {
  39895. if (this.xGizmo) {
  39896. this.xGizmo.attachedMesh = mesh;
  39897. this.yGizmo.attachedMesh = mesh;
  39898. this.zGizmo.attachedMesh = mesh;
  39899. }
  39900. },
  39901. enumerable: true,
  39902. configurable: true
  39903. });
  39904. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39905. get: function () {
  39906. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39907. },
  39908. set: function (value) {
  39909. if (this.xGizmo) {
  39910. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39911. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39912. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39913. }
  39914. },
  39915. enumerable: true,
  39916. configurable: true
  39917. });
  39918. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  39919. get: function () {
  39920. return this.xGizmo.snapDistance;
  39921. },
  39922. /**
  39923. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39924. */
  39925. set: function (value) {
  39926. if (this.xGizmo) {
  39927. this.xGizmo.snapDistance = value;
  39928. this.yGizmo.snapDistance = value;
  39929. this.zGizmo.snapDistance = value;
  39930. }
  39931. },
  39932. enumerable: true,
  39933. configurable: true
  39934. });
  39935. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  39936. get: function () {
  39937. return this.xGizmo.scaleRatio;
  39938. },
  39939. /**
  39940. * Ratio for the scale of the gizmo (Default: 1)
  39941. */
  39942. set: function (value) {
  39943. if (this.xGizmo) {
  39944. this.xGizmo.scaleRatio = value;
  39945. this.yGizmo.scaleRatio = value;
  39946. this.zGizmo.scaleRatio = value;
  39947. }
  39948. },
  39949. enumerable: true,
  39950. configurable: true
  39951. });
  39952. /**
  39953. * Disposes of the gizmo
  39954. */
  39955. PositionGizmo.prototype.dispose = function () {
  39956. this.xGizmo.dispose();
  39957. this.yGizmo.dispose();
  39958. this.zGizmo.dispose();
  39959. this.onDragStartObservable.clear();
  39960. this.onDragEndObservable.clear();
  39961. };
  39962. /**
  39963. * CustomMeshes are not supported by this gizmo
  39964. * @param mesh The mesh to replace the default mesh of the gizmo
  39965. */
  39966. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  39967. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].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)");
  39968. };
  39969. return PositionGizmo;
  39970. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39971. /***/ }),
  39972. /***/ "./Gizmos/rotationGizmo.ts":
  39973. /*!*********************************!*\
  39974. !*** ./Gizmos/rotationGizmo.ts ***!
  39975. \*********************************/
  39976. /*! exports provided: RotationGizmo */
  39977. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39978. "use strict";
  39979. __webpack_require__.r(__webpack_exports__);
  39980. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  39981. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39982. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39983. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39984. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39985. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39986. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  39987. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39988. /**
  39989. * Gizmo that enables rotating a mesh along 3 axis
  39990. */
  39991. var RotationGizmo = /** @class */ (function (_super) {
  39992. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  39993. /**
  39994. * Creates a RotationGizmo
  39995. * @param gizmoLayer The utility layer the gizmo will be added to
  39996. * @param tessellation Amount of tessellation to be used when creating rotation circles
  39997. */
  39998. function RotationGizmo(gizmoLayer, tessellation) {
  39999. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  40000. if (tessellation === void 0) { tessellation = 32; }
  40001. var _this = _super.call(this, gizmoLayer) || this;
  40002. /** Fires an event when any of it's sub gizmos are dragged */
  40003. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40004. /** Fires an event when any of it's sub gizmos are released from dragging */
  40005. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40006. _this.xGizmo = new _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red().scale(0.5), gizmoLayer, tessellation);
  40007. _this.yGizmo = new _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Green().scale(0.5), gizmoLayer, tessellation);
  40008. _this.zGizmo = new _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Blue().scale(0.5), gizmoLayer, tessellation);
  40009. // Relay drag events
  40010. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  40011. gizmo.dragBehavior.onDragStartObservable.add(function () {
  40012. _this.onDragStartObservable.notifyObservers({});
  40013. });
  40014. gizmo.dragBehavior.onDragEndObservable.add(function () {
  40015. _this.onDragEndObservable.notifyObservers({});
  40016. });
  40017. });
  40018. _this.attachedMesh = null;
  40019. return _this;
  40020. }
  40021. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  40022. get: function () {
  40023. return this.xGizmo.attachedMesh;
  40024. },
  40025. set: function (mesh) {
  40026. if (this.xGizmo) {
  40027. this.xGizmo.attachedMesh = mesh;
  40028. this.yGizmo.attachedMesh = mesh;
  40029. this.zGizmo.attachedMesh = mesh;
  40030. }
  40031. },
  40032. enumerable: true,
  40033. configurable: true
  40034. });
  40035. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  40036. get: function () {
  40037. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  40038. },
  40039. set: function (value) {
  40040. if (this.xGizmo) {
  40041. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40042. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40043. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40044. }
  40045. },
  40046. enumerable: true,
  40047. configurable: true
  40048. });
  40049. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  40050. get: function () {
  40051. return this.xGizmo.snapDistance;
  40052. },
  40053. /**
  40054. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40055. */
  40056. set: function (value) {
  40057. if (this.xGizmo) {
  40058. this.xGizmo.snapDistance = value;
  40059. this.yGizmo.snapDistance = value;
  40060. this.zGizmo.snapDistance = value;
  40061. }
  40062. },
  40063. enumerable: true,
  40064. configurable: true
  40065. });
  40066. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  40067. get: function () {
  40068. return this.xGizmo.scaleRatio;
  40069. },
  40070. /**
  40071. * Ratio for the scale of the gizmo (Default: 1)
  40072. */
  40073. set: function (value) {
  40074. if (this.xGizmo) {
  40075. this.xGizmo.scaleRatio = value;
  40076. this.yGizmo.scaleRatio = value;
  40077. this.zGizmo.scaleRatio = value;
  40078. }
  40079. },
  40080. enumerable: true,
  40081. configurable: true
  40082. });
  40083. /**
  40084. * Disposes of the gizmo
  40085. */
  40086. RotationGizmo.prototype.dispose = function () {
  40087. this.xGizmo.dispose();
  40088. this.yGizmo.dispose();
  40089. this.zGizmo.dispose();
  40090. this.onDragStartObservable.clear();
  40091. this.onDragEndObservable.clear();
  40092. };
  40093. /**
  40094. * CustomMeshes are not supported by this gizmo
  40095. * @param mesh The mesh to replace the default mesh of the gizmo
  40096. */
  40097. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  40098. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].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)");
  40099. };
  40100. return RotationGizmo;
  40101. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  40102. /***/ }),
  40103. /***/ "./Gizmos/scaleGizmo.ts":
  40104. /*!******************************!*\
  40105. !*** ./Gizmos/scaleGizmo.ts ***!
  40106. \******************************/
  40107. /*! exports provided: ScaleGizmo */
  40108. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40109. "use strict";
  40110. __webpack_require__.r(__webpack_exports__);
  40111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  40112. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40113. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40114. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40115. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40116. /* harmony import */ var _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  40117. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  40118. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  40119. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  40120. /**
  40121. * Gizmo that enables scaling a mesh along 3 axis
  40122. */
  40123. var ScaleGizmo = /** @class */ (function (_super) {
  40124. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  40125. /**
  40126. * Creates a ScaleGizmo
  40127. * @param gizmoLayer The utility layer the gizmo will be added to
  40128. */
  40129. function ScaleGizmo(gizmoLayer) {
  40130. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  40131. var _this = _super.call(this, gizmoLayer) || this;
  40132. /** Fires an event when any of it's sub gizmos are dragged */
  40133. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40134. /** Fires an event when any of it's sub gizmos are released from dragging */
  40135. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40136. _this.xGizmo = new _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__["AxisScaleGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red().scale(0.5), gizmoLayer);
  40137. _this.yGizmo = new _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__["AxisScaleGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Green().scale(0.5), gizmoLayer);
  40138. _this.zGizmo = new _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__["AxisScaleGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Blue().scale(0.5), gizmoLayer);
  40139. // Create uniform scale gizmo
  40140. _this.uniformScaleGizmo = new _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__["AxisScaleGizmo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Yellow().scale(0.5), gizmoLayer);
  40141. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  40142. _this.uniformScaleGizmo.uniformScaling = true;
  40143. var uniformScalingMesh = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  40144. uniformScalingMesh.scaling.scaleInPlace(0.02);
  40145. uniformScalingMesh.visibility = 0;
  40146. var octahedron = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  40147. octahedron.scaling.scaleInPlace(0.007);
  40148. uniformScalingMesh.addChild(octahedron);
  40149. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  40150. var light = gizmoLayer._getSharedGizmoLight();
  40151. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(octahedron);
  40152. // Relay drag events
  40153. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  40154. gizmo.dragBehavior.onDragStartObservable.add(function () {
  40155. _this.onDragStartObservable.notifyObservers({});
  40156. });
  40157. gizmo.dragBehavior.onDragEndObservable.add(function () {
  40158. _this.onDragEndObservable.notifyObservers({});
  40159. });
  40160. });
  40161. _this.attachedMesh = null;
  40162. return _this;
  40163. }
  40164. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  40165. get: function () {
  40166. return this.xGizmo.attachedMesh;
  40167. },
  40168. set: function (mesh) {
  40169. if (this.xGizmo) {
  40170. this.xGizmo.attachedMesh = mesh;
  40171. this.yGizmo.attachedMesh = mesh;
  40172. this.zGizmo.attachedMesh = mesh;
  40173. this.uniformScaleGizmo.attachedMesh = mesh;
  40174. }
  40175. },
  40176. enumerable: true,
  40177. configurable: true
  40178. });
  40179. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  40180. get: function () {
  40181. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  40182. },
  40183. set: function (value) {
  40184. if (!value) {
  40185. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  40186. }
  40187. if (this.xGizmo) {
  40188. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40189. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40190. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40191. }
  40192. },
  40193. enumerable: true,
  40194. configurable: true
  40195. });
  40196. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  40197. get: function () {
  40198. return this.xGizmo.snapDistance;
  40199. },
  40200. /**
  40201. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40202. */
  40203. set: function (value) {
  40204. if (this.xGizmo) {
  40205. this.xGizmo.snapDistance = value;
  40206. this.yGizmo.snapDistance = value;
  40207. this.zGizmo.snapDistance = value;
  40208. this.uniformScaleGizmo.snapDistance = value;
  40209. }
  40210. },
  40211. enumerable: true,
  40212. configurable: true
  40213. });
  40214. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  40215. get: function () {
  40216. return this.xGizmo.scaleRatio;
  40217. },
  40218. /**
  40219. * Ratio for the scale of the gizmo (Default: 1)
  40220. */
  40221. set: function (value) {
  40222. if (this.xGizmo) {
  40223. this.xGizmo.scaleRatio = value;
  40224. this.yGizmo.scaleRatio = value;
  40225. this.zGizmo.scaleRatio = value;
  40226. this.uniformScaleGizmo.scaleRatio = value;
  40227. }
  40228. },
  40229. enumerable: true,
  40230. configurable: true
  40231. });
  40232. /**
  40233. * Disposes of the gizmo
  40234. */
  40235. ScaleGizmo.prototype.dispose = function () {
  40236. this.xGizmo.dispose();
  40237. this.yGizmo.dispose();
  40238. this.zGizmo.dispose();
  40239. this.uniformScaleGizmo.dispose();
  40240. this.onDragStartObservable.clear();
  40241. this.onDragEndObservable.clear();
  40242. };
  40243. return ScaleGizmo;
  40244. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  40245. /***/ }),
  40246. /***/ "./Helpers/environmentHelper.ts":
  40247. /*!**************************************!*\
  40248. !*** ./Helpers/environmentHelper.ts ***!
  40249. \**************************************/
  40250. /*! exports provided: EnvironmentHelper */
  40251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40252. "use strict";
  40253. __webpack_require__.r(__webpack_exports__);
  40254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  40255. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40256. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40257. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  40258. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40259. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40260. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  40261. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40262. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  40263. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  40264. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40265. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  40266. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  40267. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  40268. /**
  40269. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  40270. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  40271. * It also helps with the default setup of your imageProcessing configuration.
  40272. */
  40273. var EnvironmentHelper = /** @class */ (function () {
  40274. /**
  40275. * constructor
  40276. * @param options Defines the options we want to customize the helper
  40277. * @param scene The scene to add the material to
  40278. */
  40279. function EnvironmentHelper(options, scene) {
  40280. var _this = this;
  40281. this._errorHandler = function (message, exception) {
  40282. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  40283. };
  40284. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  40285. this._scene = scene;
  40286. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40287. this._setupBackground();
  40288. this._setupImageProcessing();
  40289. }
  40290. /**
  40291. * Creates the default options for the helper.
  40292. */
  40293. EnvironmentHelper._getDefaultOptions = function () {
  40294. return {
  40295. createGround: true,
  40296. groundSize: 15,
  40297. groundTexture: this._groundTextureCDNUrl,
  40298. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  40299. groundOpacity: 0.9,
  40300. enableGroundShadow: true,
  40301. groundShadowLevel: 0.5,
  40302. enableGroundMirror: false,
  40303. groundMirrorSizeRatio: 0.3,
  40304. groundMirrorBlurKernel: 64,
  40305. groundMirrorAmount: 1,
  40306. groundMirrorFresnelWeight: 1,
  40307. groundMirrorFallOffDistance: 0,
  40308. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  40309. groundYBias: 0.00001,
  40310. createSkybox: true,
  40311. skyboxSize: 20,
  40312. skyboxTexture: this._skyboxTextureCDNUrl,
  40313. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  40314. backgroundYRotation: 0,
  40315. sizeAuto: true,
  40316. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  40317. setupImageProcessing: true,
  40318. environmentTexture: this._environmentTextureCDNUrl,
  40319. cameraExposure: 0.8,
  40320. cameraContrast: 1.2,
  40321. toneMappingEnabled: true,
  40322. };
  40323. };
  40324. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  40325. /**
  40326. * Gets the root mesh created by the helper.
  40327. */
  40328. get: function () {
  40329. return this._rootMesh;
  40330. },
  40331. enumerable: true,
  40332. configurable: true
  40333. });
  40334. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  40335. /**
  40336. * Gets the skybox created by the helper.
  40337. */
  40338. get: function () {
  40339. return this._skybox;
  40340. },
  40341. enumerable: true,
  40342. configurable: true
  40343. });
  40344. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  40345. /**
  40346. * Gets the skybox texture created by the helper.
  40347. */
  40348. get: function () {
  40349. return this._skyboxTexture;
  40350. },
  40351. enumerable: true,
  40352. configurable: true
  40353. });
  40354. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  40355. /**
  40356. * Gets the skybox material created by the helper.
  40357. */
  40358. get: function () {
  40359. return this._skyboxMaterial;
  40360. },
  40361. enumerable: true,
  40362. configurable: true
  40363. });
  40364. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  40365. /**
  40366. * Gets the ground mesh created by the helper.
  40367. */
  40368. get: function () {
  40369. return this._ground;
  40370. },
  40371. enumerable: true,
  40372. configurable: true
  40373. });
  40374. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  40375. /**
  40376. * Gets the ground texture created by the helper.
  40377. */
  40378. get: function () {
  40379. return this._groundTexture;
  40380. },
  40381. enumerable: true,
  40382. configurable: true
  40383. });
  40384. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  40385. /**
  40386. * Gets the ground mirror created by the helper.
  40387. */
  40388. get: function () {
  40389. return this._groundMirror;
  40390. },
  40391. enumerable: true,
  40392. configurable: true
  40393. });
  40394. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  40395. /**
  40396. * Gets the ground mirror render list to helps pushing the meshes
  40397. * you wish in the ground reflection.
  40398. */
  40399. get: function () {
  40400. if (this._groundMirror) {
  40401. return this._groundMirror.renderList;
  40402. }
  40403. return null;
  40404. },
  40405. enumerable: true,
  40406. configurable: true
  40407. });
  40408. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  40409. /**
  40410. * Gets the ground material created by the helper.
  40411. */
  40412. get: function () {
  40413. return this._groundMaterial;
  40414. },
  40415. enumerable: true,
  40416. configurable: true
  40417. });
  40418. /**
  40419. * Updates the background according to the new options
  40420. * @param options
  40421. */
  40422. EnvironmentHelper.prototype.updateOptions = function (options) {
  40423. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  40424. if (this._ground && !newOptions.createGround) {
  40425. this._ground.dispose();
  40426. this._ground = null;
  40427. }
  40428. if (this._groundMaterial && !newOptions.createGround) {
  40429. this._groundMaterial.dispose();
  40430. this._groundMaterial = null;
  40431. }
  40432. if (this._groundTexture) {
  40433. if (this._options.groundTexture != newOptions.groundTexture) {
  40434. this._groundTexture.dispose();
  40435. this._groundTexture = null;
  40436. }
  40437. }
  40438. if (this._skybox && !newOptions.createSkybox) {
  40439. this._skybox.dispose();
  40440. this._skybox = null;
  40441. }
  40442. if (this._skyboxMaterial && !newOptions.createSkybox) {
  40443. this._skyboxMaterial.dispose();
  40444. this._skyboxMaterial = null;
  40445. }
  40446. if (this._skyboxTexture) {
  40447. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  40448. this._skyboxTexture.dispose();
  40449. this._skyboxTexture = null;
  40450. }
  40451. }
  40452. if (this._groundMirror && !newOptions.enableGroundMirror) {
  40453. this._groundMirror.dispose();
  40454. this._groundMirror = null;
  40455. }
  40456. if (this._scene.environmentTexture) {
  40457. if (this._options.environmentTexture != newOptions.environmentTexture) {
  40458. this._scene.environmentTexture.dispose();
  40459. }
  40460. }
  40461. this._options = newOptions;
  40462. this._setupBackground();
  40463. this._setupImageProcessing();
  40464. };
  40465. /**
  40466. * Sets the primary color of all the available elements.
  40467. * @param color the main color to affect to the ground and the background
  40468. */
  40469. EnvironmentHelper.prototype.setMainColor = function (color) {
  40470. if (this.groundMaterial) {
  40471. this.groundMaterial.primaryColor = color;
  40472. }
  40473. if (this.skyboxMaterial) {
  40474. this.skyboxMaterial.primaryColor = color;
  40475. }
  40476. if (this.groundMirror) {
  40477. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  40478. }
  40479. };
  40480. /**
  40481. * Setup the image processing according to the specified options.
  40482. */
  40483. EnvironmentHelper.prototype._setupImageProcessing = function () {
  40484. if (this._options.setupImageProcessing) {
  40485. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  40486. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  40487. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  40488. this._setupEnvironmentTexture();
  40489. }
  40490. };
  40491. /**
  40492. * Setup the environment texture according to the specified options.
  40493. */
  40494. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  40495. if (this._scene.environmentTexture) {
  40496. return;
  40497. }
  40498. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40499. this._scene.environmentTexture = this._options.environmentTexture;
  40500. return;
  40501. }
  40502. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  40503. this._scene.environmentTexture = environmentTexture;
  40504. };
  40505. /**
  40506. * Setup the background according to the specified options.
  40507. */
  40508. EnvironmentHelper.prototype._setupBackground = function () {
  40509. if (!this._rootMesh) {
  40510. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  40511. }
  40512. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  40513. var sceneSize = this._getSceneSize();
  40514. if (this._options.createGround) {
  40515. this._setupGround(sceneSize);
  40516. this._setupGroundMaterial();
  40517. this._setupGroundDiffuseTexture();
  40518. if (this._options.enableGroundMirror) {
  40519. this._setupGroundMirrorTexture(sceneSize);
  40520. }
  40521. this._setupMirrorInGroundMaterial();
  40522. }
  40523. if (this._options.createSkybox) {
  40524. this._setupSkybox(sceneSize);
  40525. this._setupSkyboxMaterial();
  40526. this._setupSkyboxReflectionTexture();
  40527. }
  40528. this._rootMesh.position.x = sceneSize.rootPosition.x;
  40529. this._rootMesh.position.z = sceneSize.rootPosition.z;
  40530. this._rootMesh.position.y = sceneSize.rootPosition.y;
  40531. };
  40532. /**
  40533. * Get the scene sizes according to the setup.
  40534. */
  40535. EnvironmentHelper.prototype._getSceneSize = function () {
  40536. var _this = this;
  40537. var groundSize = this._options.groundSize;
  40538. var skyboxSize = this._options.skyboxSize;
  40539. var rootPosition = this._options.rootPosition;
  40540. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  40541. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40542. }
  40543. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  40544. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  40545. });
  40546. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  40547. if (this._options.sizeAuto) {
  40548. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  40549. this._scene.activeCamera.upperRadiusLimit) {
  40550. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  40551. skyboxSize = groundSize;
  40552. }
  40553. var sceneDiagonalLenght = sceneDiagonal.length();
  40554. if (sceneDiagonalLenght > groundSize) {
  40555. groundSize = sceneDiagonalLenght * 2;
  40556. skyboxSize = groundSize;
  40557. }
  40558. // 10 % bigger.
  40559. groundSize *= 1.1;
  40560. skyboxSize *= 1.5;
  40561. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  40562. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  40563. }
  40564. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40565. };
  40566. /**
  40567. * Setup the ground according to the specified options.
  40568. */
  40569. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  40570. var _this = this;
  40571. if (!this._ground || this._ground.isDisposed()) {
  40572. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  40573. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  40574. this._ground.parent = this._rootMesh;
  40575. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  40576. }
  40577. this._ground.receiveShadows = this._options.enableGroundShadow;
  40578. };
  40579. /**
  40580. * Setup the ground material according to the specified options.
  40581. */
  40582. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  40583. if (!this._groundMaterial) {
  40584. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  40585. }
  40586. this._groundMaterial.alpha = this._options.groundOpacity;
  40587. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  40588. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  40589. this._groundMaterial.primaryColor = this._options.groundColor;
  40590. this._groundMaterial.useRGBColor = false;
  40591. this._groundMaterial.enableNoise = true;
  40592. if (this._ground) {
  40593. this._ground.material = this._groundMaterial;
  40594. }
  40595. };
  40596. /**
  40597. * Setup the ground diffuse texture according to the specified options.
  40598. */
  40599. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  40600. if (!this._groundMaterial) {
  40601. return;
  40602. }
  40603. if (this._groundTexture) {
  40604. return;
  40605. }
  40606. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40607. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  40608. return;
  40609. }
  40610. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40611. diffuseTexture.gammaSpace = false;
  40612. diffuseTexture.hasAlpha = true;
  40613. this._groundMaterial.diffuseTexture = diffuseTexture;
  40614. };
  40615. /**
  40616. * Setup the ground mirror texture according to the specified options.
  40617. */
  40618. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  40619. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  40620. if (!this._groundMirror) {
  40621. this._groundMirror = new _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__["MirrorTexture"]("BackgroundPlaneMirrorTexture", { ratio: this._options.groundMirrorSizeRatio }, this._scene, false, this._options.groundMirrorTextureType, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, true);
  40622. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  40623. this._groundMirror.anisotropicFilteringLevel = 1;
  40624. this._groundMirror.wrapU = wrapping;
  40625. this._groundMirror.wrapV = wrapping;
  40626. this._groundMirror.gammaSpace = false;
  40627. if (this._groundMirror.renderList) {
  40628. for (var i = 0; i < this._scene.meshes.length; i++) {
  40629. var mesh = this._scene.meshes[i];
  40630. if (mesh !== this._ground &&
  40631. mesh !== this._skybox &&
  40632. mesh !== this._rootMesh) {
  40633. this._groundMirror.renderList.push(mesh);
  40634. }
  40635. }
  40636. }
  40637. }
  40638. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  40639. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  40640. };
  40641. /**
  40642. * Setup the ground to receive the mirror texture.
  40643. */
  40644. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  40645. if (this._groundMaterial) {
  40646. this._groundMaterial.reflectionTexture = this._groundMirror;
  40647. this._groundMaterial.reflectionFresnel = true;
  40648. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  40649. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  40650. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  40651. }
  40652. };
  40653. /**
  40654. * Setup the skybox according to the specified options.
  40655. */
  40656. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  40657. var _this = this;
  40658. if (!this._skybox || this._skybox.isDisposed()) {
  40659. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  40660. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  40661. }
  40662. this._skybox.parent = this._rootMesh;
  40663. };
  40664. /**
  40665. * Setup the skybox material according to the specified options.
  40666. */
  40667. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  40668. if (!this._skybox) {
  40669. return;
  40670. }
  40671. if (!this._skyboxMaterial) {
  40672. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  40673. }
  40674. this._skyboxMaterial.useRGBColor = false;
  40675. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  40676. this._skyboxMaterial.enableNoise = true;
  40677. this._skybox.material = this._skyboxMaterial;
  40678. };
  40679. /**
  40680. * Setup the skybox reflection texture according to the specified options.
  40681. */
  40682. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  40683. if (!this._skyboxMaterial) {
  40684. return;
  40685. }
  40686. if (this._skyboxTexture) {
  40687. return;
  40688. }
  40689. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40690. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  40691. return;
  40692. }
  40693. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40694. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  40695. this._skyboxTexture.gammaSpace = false;
  40696. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  40697. };
  40698. /**
  40699. * Dispose all the elements created by the Helper.
  40700. */
  40701. EnvironmentHelper.prototype.dispose = function () {
  40702. if (this._groundMaterial) {
  40703. this._groundMaterial.dispose(true, true);
  40704. }
  40705. if (this._skyboxMaterial) {
  40706. this._skyboxMaterial.dispose(true, true);
  40707. }
  40708. this._rootMesh.dispose(false);
  40709. };
  40710. /**
  40711. * Default ground texture URL.
  40712. */
  40713. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  40714. /**
  40715. * Default skybox texture URL.
  40716. */
  40717. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  40718. /**
  40719. * Default environment texture URL.
  40720. */
  40721. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  40722. return EnvironmentHelper;
  40723. }());
  40724. /***/ }),
  40725. /***/ "./Helpers/index.ts":
  40726. /*!**************************!*\
  40727. !*** ./Helpers/index.ts ***!
  40728. \**************************/
  40729. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  40730. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40731. "use strict";
  40732. __webpack_require__.r(__webpack_exports__);
  40733. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  40735. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  40736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  40737. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  40738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  40739. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  40740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  40741. /***/ }),
  40742. /***/ "./Helpers/photoDome.ts":
  40743. /*!******************************!*\
  40744. !*** ./Helpers/photoDome.ts ***!
  40745. \******************************/
  40746. /*! exports provided: PhotoDome */
  40747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40748. "use strict";
  40749. __webpack_require__.r(__webpack_exports__);
  40750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  40751. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40752. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40753. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  40754. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40755. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40756. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40757. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  40758. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40759. /**
  40760. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  40761. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  40762. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  40763. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  40764. */
  40765. var PhotoDome = /** @class */ (function (_super) {
  40766. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  40767. /**
  40768. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  40769. * @param name Element's name, child elements will append suffixes for their own names.
  40770. * @param urlsOfPhoto defines the url of the photo to display
  40771. * @param options defines an object containing optional or exposed sub element properties
  40772. * @param onError defines a callback called when an error occured while loading the texture
  40773. */
  40774. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  40775. if (onError === void 0) { onError = null; }
  40776. var _this = _super.call(this, name, scene) || this;
  40777. _this._useDirectMapping = false;
  40778. /**
  40779. * Observable raised when an error occured while loading the 360 image
  40780. */
  40781. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40782. // set defaults and manage values
  40783. name = name || "photoDome";
  40784. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  40785. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  40786. if (options.useDirectMapping === undefined) {
  40787. _this._useDirectMapping = true;
  40788. }
  40789. else {
  40790. _this._useDirectMapping = options.useDirectMapping;
  40791. }
  40792. if (options.faceForward === undefined) {
  40793. options.faceForward = true;
  40794. }
  40795. _this._setReady(false);
  40796. // create
  40797. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  40798. _this._mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateSphere(name + "_mesh", options.resolution, options.size, scene, false, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].BACKSIDE);
  40799. // configure material
  40800. material.opacityFresnel = false;
  40801. material.useEquirectangularFOV = true;
  40802. material.fovMultiplier = 1.0;
  40803. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  40804. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  40805. if (onError) {
  40806. onError(message, exception);
  40807. }
  40808. });
  40809. _this.photoTexture.onLoadObservable.addOnce(function () {
  40810. _this._setReady(true);
  40811. });
  40812. // configure mesh
  40813. _this._mesh.material = material;
  40814. _this._mesh.parent = _this;
  40815. // Initial rotation
  40816. if (options.faceForward && scene.activeCamera) {
  40817. var camera = scene.activeCamera;
  40818. var forward = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Forward();
  40819. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].TransformNormal(forward, camera.getViewMatrix());
  40820. direction.normalize();
  40821. _this.rotation.y = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Dot(forward, direction));
  40822. }
  40823. return _this;
  40824. }
  40825. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  40826. /**
  40827. * Gets or sets the texture being displayed on the sphere
  40828. */
  40829. get: function () {
  40830. return this._photoTexture;
  40831. },
  40832. set: function (value) {
  40833. if (this._photoTexture === value) {
  40834. return;
  40835. }
  40836. this._photoTexture = value;
  40837. if (this._useDirectMapping) {
  40838. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40839. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40840. this._material.diffuseTexture = this._photoTexture;
  40841. }
  40842. else {
  40843. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  40844. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40845. this._material.reflectionTexture = this._photoTexture;
  40846. }
  40847. },
  40848. enumerable: true,
  40849. configurable: true
  40850. });
  40851. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  40852. /**
  40853. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40854. * Also see the options.resolution property.
  40855. */
  40856. get: function () {
  40857. return this._material.fovMultiplier;
  40858. },
  40859. set: function (value) {
  40860. this._material.fovMultiplier = value;
  40861. },
  40862. enumerable: true,
  40863. configurable: true
  40864. });
  40865. /**
  40866. * Releases resources associated with this node.
  40867. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40868. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40869. */
  40870. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  40871. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  40872. this._photoTexture.dispose();
  40873. this._mesh.dispose();
  40874. this._material.dispose();
  40875. this.onLoadErrorObservable.clear();
  40876. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  40877. };
  40878. return PhotoDome;
  40879. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  40880. /***/ }),
  40881. /***/ "./Helpers/sceneHelpers.ts":
  40882. /*!*********************************!*\
  40883. !*** ./Helpers/sceneHelpers.ts ***!
  40884. \*********************************/
  40885. /*! exports provided: _forceSceneHelpersToBundle */
  40886. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40887. "use strict";
  40888. __webpack_require__.r(__webpack_exports__);
  40889. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  40890. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40891. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  40892. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40893. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40894. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40895. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  40896. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  40897. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  40898. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40899. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  40900. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  40901. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  40902. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  40903. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  40904. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  40905. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  40906. /* harmony import */ var _Materials_Textures_Loaders_ddsTextureLoader__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  40907. /* harmony import */ var _Materials_Textures_Loaders_envTextureLoader__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/Loaders/envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  40908. /* harmony import */ var _Materials_Textures_Loaders_ktxTextureLoader__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  40909. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  40910. /** @hidden */
  40911. var _forceSceneHelpersToBundle = true;
  40912. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  40913. if (replace === void 0) { replace = false; }
  40914. // Dispose existing light in replace mode.
  40915. if (replace) {
  40916. if (this.lights) {
  40917. for (var i = 0; i < this.lights.length; i++) {
  40918. this.lights[i].dispose();
  40919. }
  40920. }
  40921. }
  40922. // Light
  40923. if (this.lights.length === 0) {
  40924. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  40925. }
  40926. };
  40927. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  40928. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  40929. if (replace === void 0) { replace = false; }
  40930. if (attachCameraControls === void 0) { attachCameraControls = false; }
  40931. // Dispose existing camera in replace mode.
  40932. if (replace) {
  40933. if (this.activeCamera) {
  40934. this.activeCamera.dispose();
  40935. this.activeCamera = null;
  40936. }
  40937. }
  40938. // Camera
  40939. if (!this.activeCamera) {
  40940. var worldExtends = this.getWorldExtends();
  40941. var worldSize = worldExtends.max.subtract(worldExtends.min);
  40942. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  40943. var camera;
  40944. var radius = worldSize.length() * 1.5;
  40945. // empty scene scenario!
  40946. if (!isFinite(radius)) {
  40947. radius = 1;
  40948. worldCenter.copyFromFloats(0, 0, 0);
  40949. }
  40950. if (createArcRotateCamera) {
  40951. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  40952. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  40953. arcRotateCamera.wheelPrecision = 100 / radius;
  40954. camera = arcRotateCamera;
  40955. }
  40956. else {
  40957. var freeCamera = new _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__["FreeCamera"]("default camera", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](worldCenter.x, worldCenter.y, -radius), this);
  40958. freeCamera.setTarget(worldCenter);
  40959. camera = freeCamera;
  40960. }
  40961. camera.minZ = radius * 0.01;
  40962. camera.maxZ = radius * 1000;
  40963. camera.speed = radius * 0.2;
  40964. this.activeCamera = camera;
  40965. var canvas = this.getEngine().getRenderingCanvas();
  40966. if (attachCameraControls && canvas) {
  40967. camera.attachControl(canvas);
  40968. }
  40969. }
  40970. };
  40971. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  40972. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  40973. if (replace === void 0) { replace = false; }
  40974. if (attachCameraControls === void 0) { attachCameraControls = false; }
  40975. this.createDefaultLight(replace);
  40976. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  40977. };
  40978. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  40979. if (pbr === void 0) { pbr = false; }
  40980. if (scale === void 0) { scale = 1000; }
  40981. if (blur === void 0) { blur = 0; }
  40982. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  40983. if (!environmentTexture) {
  40984. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  40985. return null;
  40986. }
  40987. if (setGlobalEnvTexture) {
  40988. if (environmentTexture) {
  40989. this.environmentTexture = environmentTexture;
  40990. }
  40991. }
  40992. // Skybox
  40993. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  40994. if (pbr) {
  40995. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  40996. hdrSkyboxMaterial.backFaceCulling = false;
  40997. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  40998. if (hdrSkyboxMaterial.reflectionTexture) {
  40999. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  41000. }
  41001. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  41002. hdrSkyboxMaterial.disableLighting = true;
  41003. hdrSkyboxMaterial.twoSidedLighting = true;
  41004. hdrSkybox.infiniteDistance = true;
  41005. hdrSkybox.material = hdrSkyboxMaterial;
  41006. }
  41007. else {
  41008. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  41009. skyboxMaterial.backFaceCulling = false;
  41010. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  41011. if (skyboxMaterial.reflectionTexture) {
  41012. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  41013. }
  41014. skyboxMaterial.disableLighting = true;
  41015. hdrSkybox.infiniteDistance = true;
  41016. hdrSkybox.material = skyboxMaterial;
  41017. }
  41018. hdrSkybox.isPickable = false;
  41019. return hdrSkybox;
  41020. };
  41021. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  41022. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  41023. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  41024. }
  41025. return null;
  41026. };
  41027. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  41028. if (webVROptions === void 0) { webVROptions = {}; }
  41029. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  41030. };
  41031. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  41032. var _this = this;
  41033. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  41034. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  41035. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  41036. .then(function (ui) {
  41037. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  41038. return helper;
  41039. });
  41040. });
  41041. };
  41042. /***/ }),
  41043. /***/ "./Helpers/videoDome.ts":
  41044. /*!******************************!*\
  41045. !*** ./Helpers/videoDome.ts ***!
  41046. \******************************/
  41047. /*! exports provided: VideoDome */
  41048. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41049. "use strict";
  41050. __webpack_require__.r(__webpack_exports__);
  41051. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  41052. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41053. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  41054. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  41055. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41056. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  41057. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  41058. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  41059. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41060. /**
  41061. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  41062. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  41063. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  41064. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  41065. */
  41066. var VideoDome = /** @class */ (function (_super) {
  41067. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  41068. /**
  41069. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  41070. * @param name Element's name, child elements will append suffixes for their own names.
  41071. * @param urlsOrVideo defines the url(s) or the video element to use
  41072. * @param options An object containing optional or exposed sub element properties
  41073. */
  41074. function VideoDome(name, urlsOrVideo, options, scene) {
  41075. var _this = _super.call(this, name, scene) || this;
  41076. _this._useDirectMapping = false;
  41077. _this._videoMode = VideoDome.MODE_MONOSCOPIC;
  41078. /**
  41079. * Oberserver used in Stereoscopic VR Mode.
  41080. */
  41081. _this._onBeforeCameraRenderObserver = null;
  41082. scene = _this.getScene();
  41083. // set defaults and manage values
  41084. name = name || "videoDome";
  41085. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  41086. options.clickToPlay = Boolean(options.clickToPlay);
  41087. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  41088. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  41089. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  41090. if (options.useDirectMapping === undefined) {
  41091. _this._useDirectMapping = true;
  41092. }
  41093. else {
  41094. _this._useDirectMapping = options.useDirectMapping;
  41095. }
  41096. if (options.faceForward === undefined) {
  41097. options.faceForward = true;
  41098. }
  41099. _this._setReady(false);
  41100. // create
  41101. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  41102. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  41103. var texture = _this._videoTexture = new _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__["VideoTexture"](name + "_texture", urlsOrVideo, scene, false, _this._useDirectMapping, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].TRILINEAR_SAMPLINGMODE, tempOptions);
  41104. _this._mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].CreateSphere(name + "_mesh", options.resolution, options.size, scene, false, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].BACKSIDE);
  41105. texture.onLoadObservable.addOnce(function () {
  41106. _this._setReady(true);
  41107. });
  41108. // configure material
  41109. material.useEquirectangularFOV = true;
  41110. material.fovMultiplier = 1.0;
  41111. material.opacityFresnel = false;
  41112. if (_this._useDirectMapping) {
  41113. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  41114. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  41115. material.diffuseTexture = texture;
  41116. }
  41117. else {
  41118. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  41119. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  41120. material.reflectionTexture = texture;
  41121. }
  41122. // configure mesh
  41123. _this._mesh.material = material;
  41124. _this._mesh.parent = _this;
  41125. // optional configuration
  41126. if (options.clickToPlay) {
  41127. scene.onPointerUp = function () {
  41128. _this._videoTexture.video.play();
  41129. };
  41130. }
  41131. // Initial rotation
  41132. if (options.faceForward && scene.activeCamera) {
  41133. var camera = scene.activeCamera;
  41134. var forward = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Forward();
  41135. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].TransformNormal(forward, camera.getViewMatrix());
  41136. direction.normalize();
  41137. _this.rotation.y = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Dot(forward, direction));
  41138. }
  41139. return _this;
  41140. }
  41141. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  41142. /**
  41143. * Gets the video texture being displayed on the sphere
  41144. */
  41145. get: function () {
  41146. return this._videoTexture;
  41147. },
  41148. enumerable: true,
  41149. configurable: true
  41150. });
  41151. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  41152. /**
  41153. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  41154. * Also see the options.resolution property.
  41155. */
  41156. get: function () {
  41157. return this._material.fovMultiplier;
  41158. },
  41159. set: function (value) {
  41160. this._material.fovMultiplier = value;
  41161. },
  41162. enumerable: true,
  41163. configurable: true
  41164. });
  41165. Object.defineProperty(VideoDome.prototype, "videoMode", {
  41166. /**
  41167. * Gets or set the current video mode for the video. It can be:
  41168. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  41169. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  41170. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  41171. */
  41172. get: function () {
  41173. return this._videoMode;
  41174. },
  41175. set: function (value) {
  41176. if (this._videoMode === value) {
  41177. return;
  41178. }
  41179. this._changeVideoMode(value);
  41180. },
  41181. enumerable: true,
  41182. configurable: true
  41183. });
  41184. VideoDome.prototype._changeVideoMode = function (value) {
  41185. var _this = this;
  41186. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41187. this._videoMode = value;
  41188. // Default Setup and Reset.
  41189. this._videoTexture.uScale = 1;
  41190. this._videoTexture.vScale = 1;
  41191. this._videoTexture.uOffset = 0;
  41192. this._videoTexture.vOffset = 0;
  41193. switch (value) {
  41194. case VideoDome.MODE_SIDEBYSIDE:
  41195. this._videoTexture.uScale = 0.5;
  41196. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  41197. _this._videoTexture.uOffset = camera.isRightCamera ? 0.5 : 0.0;
  41198. });
  41199. break;
  41200. case VideoDome.MODE_TOPBOTTOM:
  41201. this._videoTexture.vScale = 0.5;
  41202. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  41203. _this._videoTexture.vOffset = camera.isRightCamera ? 0.5 : 0.0;
  41204. });
  41205. break;
  41206. }
  41207. };
  41208. /**
  41209. * Releases resources associated with this node.
  41210. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  41211. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  41212. */
  41213. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  41214. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  41215. this._videoTexture.dispose();
  41216. this._mesh.dispose();
  41217. this._material.dispose();
  41218. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41219. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  41220. };
  41221. /**
  41222. * Define the video source as a Monoscopic panoramic 360 video.
  41223. */
  41224. VideoDome.MODE_MONOSCOPIC = 0;
  41225. /**
  41226. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  41227. */
  41228. VideoDome.MODE_TOPBOTTOM = 1;
  41229. /**
  41230. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  41231. */
  41232. VideoDome.MODE_SIDEBYSIDE = 2;
  41233. return VideoDome;
  41234. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  41235. /***/ }),
  41236. /***/ "./Instrumentation/engineInstrumentation.ts":
  41237. /*!**************************************************!*\
  41238. !*** ./Instrumentation/engineInstrumentation.ts ***!
  41239. \**************************************************/
  41240. /*! exports provided: EngineInstrumentation */
  41241. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41242. "use strict";
  41243. __webpack_require__.r(__webpack_exports__);
  41244. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  41245. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41246. /**
  41247. * This class can be used to get instrumentation data from a Babylon engine
  41248. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41249. */
  41250. var EngineInstrumentation = /** @class */ (function () {
  41251. /**
  41252. * Instantiates a new engine instrumentation.
  41253. * This class can be used to get instrumentation data from a Babylon engine
  41254. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41255. * @param engine Defines the engine to instrument
  41256. */
  41257. function EngineInstrumentation(
  41258. /**
  41259. * Define the instrumented engine.
  41260. */
  41261. engine) {
  41262. this.engine = engine;
  41263. this._captureGPUFrameTime = false;
  41264. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41265. this._captureShaderCompilationTime = false;
  41266. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41267. // Observers
  41268. this._onBeginFrameObserver = null;
  41269. this._onEndFrameObserver = null;
  41270. this._onBeforeShaderCompilationObserver = null;
  41271. this._onAfterShaderCompilationObserver = null;
  41272. }
  41273. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  41274. // Properties
  41275. /**
  41276. * Gets the perf counter used for GPU frame time
  41277. */
  41278. get: function () {
  41279. return this._gpuFrameTime;
  41280. },
  41281. enumerable: true,
  41282. configurable: true
  41283. });
  41284. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  41285. /**
  41286. * Gets the GPU frame time capture status
  41287. */
  41288. get: function () {
  41289. return this._captureGPUFrameTime;
  41290. },
  41291. /**
  41292. * Enable or disable the GPU frame time capture
  41293. */
  41294. set: function (value) {
  41295. var _this = this;
  41296. if (value === this._captureGPUFrameTime) {
  41297. return;
  41298. }
  41299. this._captureGPUFrameTime = value;
  41300. if (value) {
  41301. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  41302. if (!_this._gpuFrameTimeToken) {
  41303. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  41304. }
  41305. });
  41306. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  41307. if (!_this._gpuFrameTimeToken) {
  41308. return;
  41309. }
  41310. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  41311. if (time > -1) {
  41312. _this._gpuFrameTimeToken = null;
  41313. _this._gpuFrameTime.fetchNewFrame();
  41314. _this._gpuFrameTime.addCount(time, true);
  41315. }
  41316. });
  41317. }
  41318. else {
  41319. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  41320. this._onBeginFrameObserver = null;
  41321. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  41322. this._onEndFrameObserver = null;
  41323. }
  41324. },
  41325. enumerable: true,
  41326. configurable: true
  41327. });
  41328. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  41329. /**
  41330. * Gets the perf counter used for shader compilation time
  41331. */
  41332. get: function () {
  41333. return this._shaderCompilationTime;
  41334. },
  41335. enumerable: true,
  41336. configurable: true
  41337. });
  41338. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  41339. /**
  41340. * Gets the shader compilation time capture status
  41341. */
  41342. get: function () {
  41343. return this._captureShaderCompilationTime;
  41344. },
  41345. /**
  41346. * Enable or disable the shader compilation time capture
  41347. */
  41348. set: function (value) {
  41349. var _this = this;
  41350. if (value === this._captureShaderCompilationTime) {
  41351. return;
  41352. }
  41353. this._captureShaderCompilationTime = value;
  41354. if (value) {
  41355. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  41356. _this._shaderCompilationTime.fetchNewFrame();
  41357. _this._shaderCompilationTime.beginMonitoring();
  41358. });
  41359. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  41360. _this._shaderCompilationTime.endMonitoring();
  41361. });
  41362. }
  41363. else {
  41364. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  41365. this._onBeforeShaderCompilationObserver = null;
  41366. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  41367. this._onAfterShaderCompilationObserver = null;
  41368. }
  41369. },
  41370. enumerable: true,
  41371. configurable: true
  41372. });
  41373. /**
  41374. * Dispose and release associated resources.
  41375. */
  41376. EngineInstrumentation.prototype.dispose = function () {
  41377. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  41378. this._onBeginFrameObserver = null;
  41379. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  41380. this._onEndFrameObserver = null;
  41381. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  41382. this._onBeforeShaderCompilationObserver = null;
  41383. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  41384. this._onAfterShaderCompilationObserver = null;
  41385. this.engine = null;
  41386. };
  41387. return EngineInstrumentation;
  41388. }());
  41389. /***/ }),
  41390. /***/ "./Instrumentation/index.ts":
  41391. /*!**********************************!*\
  41392. !*** ./Instrumentation/index.ts ***!
  41393. \**********************************/
  41394. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  41395. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41396. "use strict";
  41397. __webpack_require__.r(__webpack_exports__);
  41398. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  41399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  41400. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  41401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  41402. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  41403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  41404. /***/ }),
  41405. /***/ "./Instrumentation/sceneInstrumentation.ts":
  41406. /*!*************************************************!*\
  41407. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  41408. \*************************************************/
  41409. /*! exports provided: SceneInstrumentation */
  41410. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41411. "use strict";
  41412. __webpack_require__.r(__webpack_exports__);
  41413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  41414. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41415. /**
  41416. * This class can be used to get instrumentation data from a Babylon engine
  41417. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  41418. */
  41419. var SceneInstrumentation = /** @class */ (function () {
  41420. /**
  41421. * Instantiates a new scene instrumentation.
  41422. * This class can be used to get instrumentation data from a Babylon engine
  41423. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  41424. * @param scene Defines the scene to instrument
  41425. */
  41426. function SceneInstrumentation(
  41427. /**
  41428. * Defines the scene to instrument
  41429. */
  41430. scene) {
  41431. var _this = this;
  41432. this.scene = scene;
  41433. this._captureActiveMeshesEvaluationTime = false;
  41434. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41435. this._captureRenderTargetsRenderTime = false;
  41436. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41437. this._captureFrameTime = false;
  41438. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41439. this._captureRenderTime = false;
  41440. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41441. this._captureInterFrameTime = false;
  41442. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41443. this._captureParticlesRenderTime = false;
  41444. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41445. this._captureSpritesRenderTime = false;
  41446. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41447. this._capturePhysicsTime = false;
  41448. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41449. this._captureAnimationsTime = false;
  41450. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41451. this._captureCameraRenderTime = false;
  41452. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41453. // Observers
  41454. this._onBeforeActiveMeshesEvaluationObserver = null;
  41455. this._onAfterActiveMeshesEvaluationObserver = null;
  41456. this._onBeforeRenderTargetsRenderObserver = null;
  41457. this._onAfterRenderTargetsRenderObserver = null;
  41458. this._onAfterRenderObserver = null;
  41459. this._onBeforeDrawPhaseObserver = null;
  41460. this._onAfterDrawPhaseObserver = null;
  41461. this._onBeforeAnimationsObserver = null;
  41462. this._onBeforeParticlesRenderingObserver = null;
  41463. this._onAfterParticlesRenderingObserver = null;
  41464. this._onBeforeSpritesRenderingObserver = null;
  41465. this._onAfterSpritesRenderingObserver = null;
  41466. this._onBeforePhysicsObserver = null;
  41467. this._onAfterPhysicsObserver = null;
  41468. this._onAfterAnimationsObserver = null;
  41469. this._onBeforeCameraRenderObserver = null;
  41470. this._onAfterCameraRenderObserver = null;
  41471. // Before render
  41472. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  41473. if (_this._captureActiveMeshesEvaluationTime) {
  41474. _this._activeMeshesEvaluationTime.fetchNewFrame();
  41475. }
  41476. if (_this._captureRenderTargetsRenderTime) {
  41477. _this._renderTargetsRenderTime.fetchNewFrame();
  41478. }
  41479. if (_this._captureFrameTime) {
  41480. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  41481. _this._frameTime.beginMonitoring();
  41482. }
  41483. if (_this._captureInterFrameTime) {
  41484. _this._interFrameTime.endMonitoring();
  41485. }
  41486. if (_this._captureParticlesRenderTime) {
  41487. _this._particlesRenderTime.fetchNewFrame();
  41488. }
  41489. if (_this._captureSpritesRenderTime) {
  41490. _this._spritesRenderTime.fetchNewFrame();
  41491. }
  41492. if (_this._captureAnimationsTime) {
  41493. _this._animationsTime.beginMonitoring();
  41494. }
  41495. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  41496. });
  41497. // After render
  41498. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  41499. if (_this._captureFrameTime) {
  41500. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  41501. _this._frameTime.endMonitoring();
  41502. }
  41503. if (_this._captureRenderTime) {
  41504. _this._renderTime.endMonitoring(false);
  41505. }
  41506. if (_this._captureInterFrameTime) {
  41507. _this._interFrameTime.beginMonitoring();
  41508. }
  41509. });
  41510. }
  41511. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  41512. // Properties
  41513. /**
  41514. * Gets the perf counter used for active meshes evaluation time
  41515. */
  41516. get: function () {
  41517. return this._activeMeshesEvaluationTime;
  41518. },
  41519. enumerable: true,
  41520. configurable: true
  41521. });
  41522. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  41523. /**
  41524. * Gets the active meshes evaluation time capture status
  41525. */
  41526. get: function () {
  41527. return this._captureActiveMeshesEvaluationTime;
  41528. },
  41529. /**
  41530. * Enable or disable the active meshes evaluation time capture
  41531. */
  41532. set: function (value) {
  41533. var _this = this;
  41534. if (value === this._captureActiveMeshesEvaluationTime) {
  41535. return;
  41536. }
  41537. this._captureActiveMeshesEvaluationTime = value;
  41538. if (value) {
  41539. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  41540. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  41541. _this._activeMeshesEvaluationTime.beginMonitoring();
  41542. });
  41543. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  41544. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  41545. _this._activeMeshesEvaluationTime.endMonitoring();
  41546. });
  41547. }
  41548. else {
  41549. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  41550. this._onBeforeActiveMeshesEvaluationObserver = null;
  41551. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  41552. this._onAfterActiveMeshesEvaluationObserver = null;
  41553. }
  41554. },
  41555. enumerable: true,
  41556. configurable: true
  41557. });
  41558. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  41559. /**
  41560. * Gets the perf counter used for render targets render time
  41561. */
  41562. get: function () {
  41563. return this._renderTargetsRenderTime;
  41564. },
  41565. enumerable: true,
  41566. configurable: true
  41567. });
  41568. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  41569. /**
  41570. * Gets the render targets render time capture status
  41571. */
  41572. get: function () {
  41573. return this._captureRenderTargetsRenderTime;
  41574. },
  41575. /**
  41576. * Enable or disable the render targets render time capture
  41577. */
  41578. set: function (value) {
  41579. var _this = this;
  41580. if (value === this._captureRenderTargetsRenderTime) {
  41581. return;
  41582. }
  41583. this._captureRenderTargetsRenderTime = value;
  41584. if (value) {
  41585. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  41586. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  41587. _this._renderTargetsRenderTime.beginMonitoring();
  41588. });
  41589. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  41590. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  41591. _this._renderTargetsRenderTime.endMonitoring(false);
  41592. });
  41593. }
  41594. else {
  41595. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  41596. this._onBeforeRenderTargetsRenderObserver = null;
  41597. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  41598. this._onAfterRenderTargetsRenderObserver = null;
  41599. }
  41600. },
  41601. enumerable: true,
  41602. configurable: true
  41603. });
  41604. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  41605. /**
  41606. * Gets the perf counter used for particles render time
  41607. */
  41608. get: function () {
  41609. return this._particlesRenderTime;
  41610. },
  41611. enumerable: true,
  41612. configurable: true
  41613. });
  41614. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  41615. /**
  41616. * Gets the particles render time capture status
  41617. */
  41618. get: function () {
  41619. return this._captureParticlesRenderTime;
  41620. },
  41621. /**
  41622. * Enable or disable the particles render time capture
  41623. */
  41624. set: function (value) {
  41625. var _this = this;
  41626. if (value === this._captureParticlesRenderTime) {
  41627. return;
  41628. }
  41629. this._captureParticlesRenderTime = value;
  41630. if (value) {
  41631. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  41632. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  41633. _this._particlesRenderTime.beginMonitoring();
  41634. });
  41635. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  41636. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  41637. _this._particlesRenderTime.endMonitoring(false);
  41638. });
  41639. }
  41640. else {
  41641. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  41642. this._onBeforeParticlesRenderingObserver = null;
  41643. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  41644. this._onAfterParticlesRenderingObserver = null;
  41645. }
  41646. },
  41647. enumerable: true,
  41648. configurable: true
  41649. });
  41650. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  41651. /**
  41652. * Gets the perf counter used for sprites render time
  41653. */
  41654. get: function () {
  41655. return this._spritesRenderTime;
  41656. },
  41657. enumerable: true,
  41658. configurable: true
  41659. });
  41660. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  41661. /**
  41662. * Gets the sprites render time capture status
  41663. */
  41664. get: function () {
  41665. return this._captureSpritesRenderTime;
  41666. },
  41667. /**
  41668. * Enable or disable the sprites render time capture
  41669. */
  41670. set: function (value) {
  41671. var _this = this;
  41672. if (value === this._captureSpritesRenderTime) {
  41673. return;
  41674. }
  41675. this._captureSpritesRenderTime = value;
  41676. if (!this.scene.spriteManagers) {
  41677. return;
  41678. }
  41679. if (value) {
  41680. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  41681. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  41682. _this._spritesRenderTime.beginMonitoring();
  41683. });
  41684. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  41685. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  41686. _this._spritesRenderTime.endMonitoring(false);
  41687. });
  41688. }
  41689. else {
  41690. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  41691. this._onBeforeSpritesRenderingObserver = null;
  41692. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  41693. this._onAfterSpritesRenderingObserver = null;
  41694. }
  41695. },
  41696. enumerable: true,
  41697. configurable: true
  41698. });
  41699. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  41700. /**
  41701. * Gets the perf counter used for physics time
  41702. */
  41703. get: function () {
  41704. return this._physicsTime;
  41705. },
  41706. enumerable: true,
  41707. configurable: true
  41708. });
  41709. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  41710. /**
  41711. * Gets the physics time capture status
  41712. */
  41713. get: function () {
  41714. return this._capturePhysicsTime;
  41715. },
  41716. /**
  41717. * Enable or disable the physics time capture
  41718. */
  41719. set: function (value) {
  41720. var _this = this;
  41721. if (value === this._capturePhysicsTime) {
  41722. return;
  41723. }
  41724. if (!this.scene.onBeforePhysicsObservable) {
  41725. return;
  41726. }
  41727. this._capturePhysicsTime = value;
  41728. if (value) {
  41729. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  41730. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  41731. _this._physicsTime.beginMonitoring();
  41732. });
  41733. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  41734. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  41735. _this._physicsTime.endMonitoring();
  41736. });
  41737. }
  41738. else {
  41739. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  41740. this._onBeforePhysicsObserver = null;
  41741. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  41742. this._onAfterPhysicsObserver = null;
  41743. }
  41744. },
  41745. enumerable: true,
  41746. configurable: true
  41747. });
  41748. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  41749. /**
  41750. * Gets the perf counter used for animations time
  41751. */
  41752. get: function () {
  41753. return this._animationsTime;
  41754. },
  41755. enumerable: true,
  41756. configurable: true
  41757. });
  41758. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  41759. /**
  41760. * Gets the animations time capture status
  41761. */
  41762. get: function () {
  41763. return this._captureAnimationsTime;
  41764. },
  41765. /**
  41766. * Enable or disable the animations time capture
  41767. */
  41768. set: function (value) {
  41769. var _this = this;
  41770. if (value === this._captureAnimationsTime) {
  41771. return;
  41772. }
  41773. this._captureAnimationsTime = value;
  41774. if (value) {
  41775. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  41776. _this._animationsTime.endMonitoring();
  41777. });
  41778. }
  41779. else {
  41780. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  41781. this._onAfterAnimationsObserver = null;
  41782. }
  41783. },
  41784. enumerable: true,
  41785. configurable: true
  41786. });
  41787. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  41788. /**
  41789. * Gets the perf counter used for frame time capture
  41790. */
  41791. get: function () {
  41792. return this._frameTime;
  41793. },
  41794. enumerable: true,
  41795. configurable: true
  41796. });
  41797. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  41798. /**
  41799. * Gets the frame time capture status
  41800. */
  41801. get: function () {
  41802. return this._captureFrameTime;
  41803. },
  41804. /**
  41805. * Enable or disable the frame time capture
  41806. */
  41807. set: function (value) {
  41808. this._captureFrameTime = value;
  41809. },
  41810. enumerable: true,
  41811. configurable: true
  41812. });
  41813. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  41814. /**
  41815. * Gets the perf counter used for inter-frames time capture
  41816. */
  41817. get: function () {
  41818. return this._interFrameTime;
  41819. },
  41820. enumerable: true,
  41821. configurable: true
  41822. });
  41823. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  41824. /**
  41825. * Gets the inter-frames time capture status
  41826. */
  41827. get: function () {
  41828. return this._captureInterFrameTime;
  41829. },
  41830. /**
  41831. * Enable or disable the inter-frames time capture
  41832. */
  41833. set: function (value) {
  41834. this._captureInterFrameTime = value;
  41835. },
  41836. enumerable: true,
  41837. configurable: true
  41838. });
  41839. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  41840. /**
  41841. * Gets the perf counter used for render time capture
  41842. */
  41843. get: function () {
  41844. return this._renderTime;
  41845. },
  41846. enumerable: true,
  41847. configurable: true
  41848. });
  41849. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  41850. /**
  41851. * Gets the render time capture status
  41852. */
  41853. get: function () {
  41854. return this._captureRenderTime;
  41855. },
  41856. /**
  41857. * Enable or disable the render time capture
  41858. */
  41859. set: function (value) {
  41860. var _this = this;
  41861. if (value === this._captureRenderTime) {
  41862. return;
  41863. }
  41864. this._captureRenderTime = value;
  41865. if (value) {
  41866. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  41867. _this._renderTime.beginMonitoring();
  41868. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  41869. });
  41870. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  41871. _this._renderTime.endMonitoring(false);
  41872. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  41873. });
  41874. }
  41875. else {
  41876. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  41877. this._onBeforeDrawPhaseObserver = null;
  41878. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  41879. this._onAfterDrawPhaseObserver = null;
  41880. }
  41881. },
  41882. enumerable: true,
  41883. configurable: true
  41884. });
  41885. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  41886. /**
  41887. * Gets the perf counter used for camera render time capture
  41888. */
  41889. get: function () {
  41890. return this._cameraRenderTime;
  41891. },
  41892. enumerable: true,
  41893. configurable: true
  41894. });
  41895. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  41896. /**
  41897. * Gets the camera render time capture status
  41898. */
  41899. get: function () {
  41900. return this._captureCameraRenderTime;
  41901. },
  41902. /**
  41903. * Enable or disable the camera render time capture
  41904. */
  41905. set: function (value) {
  41906. var _this = this;
  41907. if (value === this._captureCameraRenderTime) {
  41908. return;
  41909. }
  41910. this._captureCameraRenderTime = value;
  41911. if (value) {
  41912. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  41913. _this._cameraRenderTime.beginMonitoring();
  41914. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  41915. });
  41916. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  41917. _this._cameraRenderTime.endMonitoring(false);
  41918. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  41919. });
  41920. }
  41921. else {
  41922. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41923. this._onBeforeCameraRenderObserver = null;
  41924. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  41925. this._onAfterCameraRenderObserver = null;
  41926. }
  41927. },
  41928. enumerable: true,
  41929. configurable: true
  41930. });
  41931. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  41932. /**
  41933. * Gets the perf counter used for draw calls
  41934. */
  41935. get: function () {
  41936. return this.scene.getEngine()._drawCalls;
  41937. },
  41938. enumerable: true,
  41939. configurable: true
  41940. });
  41941. /**
  41942. * Dispose and release associated resources.
  41943. */
  41944. SceneInstrumentation.prototype.dispose = function () {
  41945. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  41946. this._onAfterRenderObserver = null;
  41947. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  41948. this._onBeforeActiveMeshesEvaluationObserver = null;
  41949. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  41950. this._onAfterActiveMeshesEvaluationObserver = null;
  41951. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  41952. this._onBeforeRenderTargetsRenderObserver = null;
  41953. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  41954. this._onAfterRenderTargetsRenderObserver = null;
  41955. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  41956. this._onBeforeAnimationsObserver = null;
  41957. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  41958. this._onBeforeParticlesRenderingObserver = null;
  41959. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  41960. this._onAfterParticlesRenderingObserver = null;
  41961. if (this._onBeforeSpritesRenderingObserver) {
  41962. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  41963. this._onBeforeSpritesRenderingObserver = null;
  41964. }
  41965. if (this._onAfterSpritesRenderingObserver) {
  41966. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  41967. this._onAfterSpritesRenderingObserver = null;
  41968. }
  41969. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  41970. this._onBeforeDrawPhaseObserver = null;
  41971. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  41972. this._onAfterDrawPhaseObserver = null;
  41973. if (this._onBeforePhysicsObserver) {
  41974. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  41975. this._onBeforePhysicsObserver = null;
  41976. }
  41977. if (this._onAfterPhysicsObserver) {
  41978. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  41979. this._onAfterPhysicsObserver = null;
  41980. }
  41981. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  41982. this._onAfterAnimationsObserver = null;
  41983. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41984. this._onBeforeCameraRenderObserver = null;
  41985. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  41986. this._onAfterCameraRenderObserver = null;
  41987. this.scene = null;
  41988. };
  41989. return SceneInstrumentation;
  41990. }());
  41991. /***/ }),
  41992. /***/ "./Instrumentation/timeToken.ts":
  41993. /*!**************************************!*\
  41994. !*** ./Instrumentation/timeToken.ts ***!
  41995. \**************************************/
  41996. /*! exports provided: _TimeToken */
  41997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41998. "use strict";
  41999. __webpack_require__.r(__webpack_exports__);
  42000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  42001. /**
  42002. * @hidden
  42003. **/
  42004. var _TimeToken = /** @class */ (function () {
  42005. function _TimeToken() {
  42006. this._timeElapsedQueryEnded = false;
  42007. }
  42008. return _TimeToken;
  42009. }());
  42010. /***/ }),
  42011. /***/ "./Layers/effectLayer.ts":
  42012. /*!*******************************!*\
  42013. !*** ./Layers/effectLayer.ts ***!
  42014. \*******************************/
  42015. /*! exports provided: EffectLayer */
  42016. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42017. "use strict";
  42018. __webpack_require__.r(__webpack_exports__);
  42019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  42020. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42021. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42022. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42023. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42024. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42025. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  42026. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42027. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42028. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42029. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42030. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  42031. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42032. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  42033. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  42034. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  42035. /**
  42036. * The effect layer Helps adding post process effect blended with the main pass.
  42037. *
  42038. * This can be for instance use to generate glow or higlight effects on the scene.
  42039. *
  42040. * The effect layer class can not be used directly and is intented to inherited from to be
  42041. * customized per effects.
  42042. */
  42043. var EffectLayer = /** @class */ (function () {
  42044. /**
  42045. * Instantiates a new effect Layer and references it in the scene.
  42046. * @param name The name of the layer
  42047. * @param scene The scene to use the layer in
  42048. */
  42049. function EffectLayer(
  42050. /** The Friendly of the effect in the scene */
  42051. name, scene) {
  42052. this._vertexBuffers = {};
  42053. this._maxSize = 0;
  42054. this._mainTextureDesiredSize = { width: 0, height: 0 };
  42055. this._shouldRender = true;
  42056. this._postProcesses = [];
  42057. this._textures = [];
  42058. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  42059. /**
  42060. * The clear color of the texture used to generate the glow map.
  42061. */
  42062. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  42063. /**
  42064. * Specifies wether the highlight layer is enabled or not.
  42065. */
  42066. this.isEnabled = true;
  42067. /**
  42068. * An event triggered when the effect layer has been disposed.
  42069. */
  42070. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42071. /**
  42072. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  42073. */
  42074. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42075. /**
  42076. * An event triggered when the generated texture is being merged in the scene.
  42077. */
  42078. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42079. /**
  42080. * An event triggered when the generated texture has been merged in the scene.
  42081. */
  42082. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42083. /**
  42084. * An event triggered when the efffect layer changes its size.
  42085. */
  42086. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42087. this.name = name;
  42088. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  42089. EffectLayer._SceneComponentInitialization(this._scene);
  42090. this._engine = this._scene.getEngine();
  42091. this._maxSize = this._engine.getCaps().maxTextureSize;
  42092. this._scene.effectLayers.push(this);
  42093. // Generate Buffers
  42094. this._generateIndexBuffer();
  42095. this._genrateVertexBuffer();
  42096. }
  42097. Object.defineProperty(EffectLayer.prototype, "camera", {
  42098. /**
  42099. * Gets the camera attached to the layer.
  42100. */
  42101. get: function () {
  42102. return this._effectLayerOptions.camera;
  42103. },
  42104. enumerable: true,
  42105. configurable: true
  42106. });
  42107. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  42108. /**
  42109. * Gets the rendering group id the layer should render in.
  42110. */
  42111. get: function () {
  42112. return this._effectLayerOptions.renderingGroupId;
  42113. },
  42114. enumerable: true,
  42115. configurable: true
  42116. });
  42117. /**
  42118. * Initializes the effect layer with the required options.
  42119. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  42120. */
  42121. EffectLayer.prototype._init = function (options) {
  42122. // Adapt options
  42123. this._effectLayerOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: 0.5, alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_COMBINE, camera: null, renderingGroupId: -1 }, options);
  42124. this._setMainTextureSize();
  42125. this._createMainTexture();
  42126. this._createTextureAndPostProcesses();
  42127. this._mergeEffect = this._createMergeEffect();
  42128. };
  42129. /**
  42130. * Generates the index buffer of the full screen quad blending to the main canvas.
  42131. */
  42132. EffectLayer.prototype._generateIndexBuffer = function () {
  42133. // Indices
  42134. var indices = [];
  42135. indices.push(0);
  42136. indices.push(1);
  42137. indices.push(2);
  42138. indices.push(0);
  42139. indices.push(2);
  42140. indices.push(3);
  42141. this._indexBuffer = this._engine.createIndexBuffer(indices);
  42142. };
  42143. /**
  42144. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  42145. */
  42146. EffectLayer.prototype._genrateVertexBuffer = function () {
  42147. // VBO
  42148. var vertices = [];
  42149. vertices.push(1, 1);
  42150. vertices.push(-1, 1);
  42151. vertices.push(-1, -1);
  42152. vertices.push(1, -1);
  42153. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  42154. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  42155. };
  42156. /**
  42157. * Sets the main texture desired size which is the closest power of two
  42158. * of the engine canvas size.
  42159. */
  42160. EffectLayer.prototype._setMainTextureSize = function () {
  42161. if (this._effectLayerOptions.mainTextureFixedSize) {
  42162. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  42163. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  42164. }
  42165. else {
  42166. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  42167. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  42168. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  42169. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  42170. }
  42171. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  42172. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  42173. };
  42174. /**
  42175. * Creates the main texture for the effect layer.
  42176. */
  42177. EffectLayer.prototype._createMainTexture = function () {
  42178. var _this = this;
  42179. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  42180. width: this._mainTextureDesiredSize.width,
  42181. height: this._mainTextureDesiredSize.height
  42182. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  42183. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  42184. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42185. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42186. this._mainTexture.anisotropicFilteringLevel = 1;
  42187. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  42188. this._mainTexture.renderParticles = false;
  42189. this._mainTexture.renderList = null;
  42190. this._mainTexture.ignoreCameraViewport = true;
  42191. // Custom render function
  42192. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  42193. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  42194. var index;
  42195. var engine = _this._scene.getEngine();
  42196. if (depthOnlySubMeshes.length) {
  42197. engine.setColorWrite(false);
  42198. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  42199. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  42200. }
  42201. engine.setColorWrite(true);
  42202. }
  42203. for (index = 0; index < opaqueSubMeshes.length; index++) {
  42204. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  42205. }
  42206. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  42207. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  42208. }
  42209. for (index = 0; index < transparentSubMeshes.length; index++) {
  42210. _this._renderSubMesh(transparentSubMeshes.data[index]);
  42211. }
  42212. };
  42213. this._mainTexture.onClearObservable.add(function (engine) {
  42214. engine.clear(_this.neutralColor, true, true, true);
  42215. });
  42216. };
  42217. /**
  42218. * Adds specific effects defines.
  42219. * @param defines The defines to add specifics to.
  42220. */
  42221. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  42222. // Nothing to add by default.
  42223. };
  42224. /**
  42225. * Checks for the readiness of the element composing the layer.
  42226. * @param subMesh the mesh to check for
  42227. * @param useInstances specify wether or not to use instances to render the mesh
  42228. * @param emissiveTexture the associated emissive texture used to generate the glow
  42229. * @return true if ready otherwise, false
  42230. */
  42231. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  42232. var material = subMesh.getMaterial();
  42233. if (!material) {
  42234. return false;
  42235. }
  42236. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  42237. return false;
  42238. }
  42239. var defines = [];
  42240. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  42241. var mesh = subMesh.getMesh();
  42242. var uv1 = false;
  42243. var uv2 = false;
  42244. // Diffuse
  42245. if (material) {
  42246. var needAlphaTest = material.needAlphaTesting();
  42247. var diffuseTexture = material.getAlphaTestTexture();
  42248. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  42249. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  42250. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  42251. defines.push("#define DIFFUSE");
  42252. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  42253. diffuseTexture.coordinatesIndex === 1) {
  42254. defines.push("#define DIFFUSEUV2");
  42255. uv2 = true;
  42256. }
  42257. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  42258. defines.push("#define DIFFUSEUV1");
  42259. uv1 = true;
  42260. }
  42261. if (needAlphaTest) {
  42262. defines.push("#define ALPHATEST");
  42263. defines.push("#define ALPHATESTVALUE 0.4");
  42264. }
  42265. }
  42266. var opacityTexture = material.opacityTexture;
  42267. if (opacityTexture) {
  42268. defines.push("#define OPACITY");
  42269. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  42270. opacityTexture.coordinatesIndex === 1) {
  42271. defines.push("#define OPACITYUV2");
  42272. uv2 = true;
  42273. }
  42274. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  42275. defines.push("#define OPACITYUV1");
  42276. uv1 = true;
  42277. }
  42278. }
  42279. }
  42280. // Emissive
  42281. if (emissiveTexture) {
  42282. defines.push("#define EMISSIVE");
  42283. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  42284. emissiveTexture.coordinatesIndex === 1) {
  42285. defines.push("#define EMISSIVEUV2");
  42286. uv2 = true;
  42287. }
  42288. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  42289. defines.push("#define EMISSIVEUV1");
  42290. uv1 = true;
  42291. }
  42292. }
  42293. // Vertex
  42294. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  42295. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  42296. defines.push("#define VERTEXALPHA");
  42297. }
  42298. if (uv1) {
  42299. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  42300. defines.push("#define UV1");
  42301. }
  42302. if (uv2) {
  42303. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  42304. defines.push("#define UV2");
  42305. }
  42306. // Bones
  42307. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  42308. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  42309. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  42310. if (mesh.numBoneInfluencers > 4) {
  42311. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  42312. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  42313. }
  42314. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  42315. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  42316. }
  42317. else {
  42318. defines.push("#define NUM_BONE_INFLUENCERS 0");
  42319. }
  42320. // Morph targets
  42321. var manager = mesh.morphTargetManager;
  42322. var morphInfluencers = 0;
  42323. if (manager) {
  42324. if (manager.numInfluencers > 0) {
  42325. defines.push("#define MORPHTARGETS");
  42326. morphInfluencers = manager.numInfluencers;
  42327. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  42328. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  42329. }
  42330. }
  42331. // Instances
  42332. if (useInstances) {
  42333. defines.push("#define INSTANCES");
  42334. attribs.push("world0");
  42335. attribs.push("world1");
  42336. attribs.push("world2");
  42337. attribs.push("world3");
  42338. }
  42339. this._addCustomEffectDefines(defines);
  42340. // Get correct effect
  42341. var join = defines.join("\n");
  42342. if (this._cachedDefines !== join) {
  42343. this._cachedDefines = join;
  42344. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  42345. "color", "morphTargetInfluences",
  42346. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  42347. }
  42348. return this._effectLayerMapGenerationEffect.isReady();
  42349. };
  42350. /**
  42351. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  42352. */
  42353. EffectLayer.prototype.render = function () {
  42354. var currentEffect = this._mergeEffect;
  42355. // Check
  42356. if (!currentEffect.isReady()) {
  42357. return;
  42358. }
  42359. for (var i = 0; i < this._postProcesses.length; i++) {
  42360. if (!this._postProcesses[i].isReady()) {
  42361. return;
  42362. }
  42363. }
  42364. var engine = this._scene.getEngine();
  42365. this.onBeforeComposeObservable.notifyObservers(this);
  42366. // Render
  42367. engine.enableEffect(currentEffect);
  42368. engine.setState(false);
  42369. // VBOs
  42370. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  42371. // Cache
  42372. var previousAlphaMode = engine.getAlphaMode();
  42373. // Go Blend.
  42374. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  42375. // Blends the map on the main canvas.
  42376. this._internalRender(currentEffect);
  42377. // Restore Alpha
  42378. engine.setAlphaMode(previousAlphaMode);
  42379. this.onAfterComposeObservable.notifyObservers(this);
  42380. // Handle size changes.
  42381. var size = this._mainTexture.getSize();
  42382. this._setMainTextureSize();
  42383. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  42384. // Recreate RTT and post processes on size change.
  42385. this.onSizeChangedObservable.notifyObservers(this);
  42386. this._disposeTextureAndPostProcesses();
  42387. this._createMainTexture();
  42388. this._createTextureAndPostProcesses();
  42389. }
  42390. };
  42391. /**
  42392. * Determine if a given mesh will be used in the current effect.
  42393. * @param mesh mesh to test
  42394. * @returns true if the mesh will be used
  42395. */
  42396. EffectLayer.prototype.hasMesh = function (mesh) {
  42397. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  42398. return true;
  42399. }
  42400. return false;
  42401. };
  42402. /**
  42403. * Returns true if the layer contains information to display, otherwise false.
  42404. * @returns true if the glow layer should be rendered
  42405. */
  42406. EffectLayer.prototype.shouldRender = function () {
  42407. return this.isEnabled && this._shouldRender;
  42408. };
  42409. /**
  42410. * Returns true if the mesh should render, otherwise false.
  42411. * @param mesh The mesh to render
  42412. * @returns true if it should render otherwise false
  42413. */
  42414. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  42415. return true;
  42416. };
  42417. /**
  42418. * Returns true if the mesh can be rendered, otherwise false.
  42419. * @param mesh The mesh to render
  42420. * @param material The material used on the mesh
  42421. * @returns true if it can be rendered otherwise false
  42422. */
  42423. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  42424. return !material.needAlphaBlendingForMesh(mesh);
  42425. };
  42426. /**
  42427. * Returns true if the mesh should render, otherwise false.
  42428. * @param mesh The mesh to render
  42429. * @returns true if it should render otherwise false
  42430. */
  42431. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  42432. return true;
  42433. };
  42434. /**
  42435. * Renders the submesh passed in parameter to the generation map.
  42436. */
  42437. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  42438. var _this = this;
  42439. if (!this.shouldRender()) {
  42440. return;
  42441. }
  42442. var material = subMesh.getMaterial();
  42443. var mesh = subMesh.getRenderingMesh();
  42444. var scene = this._scene;
  42445. var engine = scene.getEngine();
  42446. if (!material) {
  42447. return;
  42448. }
  42449. // Do not block in blend mode.
  42450. if (!this._canRenderMesh(mesh, material)) {
  42451. return;
  42452. }
  42453. // Culling
  42454. engine.setState(material.backFaceCulling);
  42455. // Managing instances
  42456. var batch = mesh._getInstancesRenderList(subMesh._id);
  42457. if (batch.mustReturn) {
  42458. return;
  42459. }
  42460. // Early Exit per mesh
  42461. if (!this._shouldRenderMesh(mesh)) {
  42462. return;
  42463. }
  42464. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  42465. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  42466. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  42467. engine.enableEffect(this._effectLayerMapGenerationEffect);
  42468. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  42469. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  42470. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  42471. var needAlphaTest = material.needAlphaTesting();
  42472. var diffuseTexture = material.getAlphaTestTexture();
  42473. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  42474. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  42475. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  42476. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  42477. var textureMatrix = diffuseTexture.getTextureMatrix();
  42478. if (textureMatrix) {
  42479. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  42480. }
  42481. }
  42482. var opacityTexture = material.opacityTexture;
  42483. if (opacityTexture) {
  42484. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  42485. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  42486. var textureMatrix = opacityTexture.getTextureMatrix();
  42487. if (textureMatrix) {
  42488. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  42489. }
  42490. }
  42491. // Glow emissive only
  42492. if (this._emissiveTextureAndColor.texture) {
  42493. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  42494. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  42495. }
  42496. // Bones
  42497. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  42498. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  42499. }
  42500. // Morph targets
  42501. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  42502. // Draw
  42503. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  42504. }
  42505. else {
  42506. // Need to reset refresh rate of the main map
  42507. this._mainTexture.resetRefreshCounter();
  42508. }
  42509. };
  42510. /**
  42511. * Rebuild the required buffers.
  42512. * @hidden Internal use only.
  42513. */
  42514. EffectLayer.prototype._rebuild = function () {
  42515. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  42516. if (vb) {
  42517. vb._rebuild();
  42518. }
  42519. this._generateIndexBuffer();
  42520. };
  42521. /**
  42522. * Dispose only the render target textures and post process.
  42523. */
  42524. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  42525. this._mainTexture.dispose();
  42526. for (var i = 0; i < this._postProcesses.length; i++) {
  42527. if (this._postProcesses[i]) {
  42528. this._postProcesses[i].dispose();
  42529. }
  42530. }
  42531. this._postProcesses = [];
  42532. for (var i = 0; i < this._textures.length; i++) {
  42533. if (this._textures[i]) {
  42534. this._textures[i].dispose();
  42535. }
  42536. }
  42537. this._textures = [];
  42538. };
  42539. /**
  42540. * Dispose the highlight layer and free resources.
  42541. */
  42542. EffectLayer.prototype.dispose = function () {
  42543. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  42544. if (vertexBuffer) {
  42545. vertexBuffer.dispose();
  42546. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  42547. }
  42548. if (this._indexBuffer) {
  42549. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  42550. this._indexBuffer = null;
  42551. }
  42552. // Clean textures and post processes
  42553. this._disposeTextureAndPostProcesses();
  42554. // Remove from scene
  42555. var index = this._scene.effectLayers.indexOf(this, 0);
  42556. if (index > -1) {
  42557. this._scene.effectLayers.splice(index, 1);
  42558. }
  42559. // Callback
  42560. this.onDisposeObservable.notifyObservers(this);
  42561. this.onDisposeObservable.clear();
  42562. this.onBeforeRenderMainTextureObservable.clear();
  42563. this.onBeforeComposeObservable.clear();
  42564. this.onAfterComposeObservable.clear();
  42565. this.onSizeChangedObservable.clear();
  42566. };
  42567. /**
  42568. * Gets the class name of the effect layer
  42569. * @returns the string with the class name of the effect layer
  42570. */
  42571. EffectLayer.prototype.getClassName = function () {
  42572. return "EffectLayer";
  42573. };
  42574. /**
  42575. * Creates an effect layer from parsed effect layer data
  42576. * @param parsedEffectLayer defines effect layer data
  42577. * @param scene defines the current scene
  42578. * @param rootUrl defines the root URL containing the effect layer information
  42579. * @returns a parsed effect Layer
  42580. */
  42581. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  42582. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  42583. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  42584. };
  42585. /** @hidden */
  42586. EffectLayer._SceneComponentInitialization = function (_) {
  42587. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__["_DevTools"].WarnImport("EffectLayerSceneComponent");
  42588. };
  42589. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42590. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42591. ], EffectLayer.prototype, "name", void 0);
  42592. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42593. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  42594. ], EffectLayer.prototype, "neutralColor", void 0);
  42595. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42596. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42597. ], EffectLayer.prototype, "isEnabled", void 0);
  42598. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42599. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  42600. ], EffectLayer.prototype, "camera", null);
  42601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42602. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42603. ], EffectLayer.prototype, "renderingGroupId", null);
  42604. return EffectLayer;
  42605. }());
  42606. /***/ }),
  42607. /***/ "./Layers/effectLayerSceneComponent.ts":
  42608. /*!*********************************************!*\
  42609. !*** ./Layers/effectLayerSceneComponent.ts ***!
  42610. \*********************************************/
  42611. /*! exports provided: EffectLayerSceneComponent */
  42612. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42613. "use strict";
  42614. __webpack_require__.r(__webpack_exports__);
  42615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  42616. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  42617. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42618. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42619. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42620. // Adds the parser to the scene parsers.
  42621. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  42622. if (parsedData.effectLayers) {
  42623. if (!container.effectLayers) {
  42624. container.effectLayers = new Array();
  42625. }
  42626. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  42627. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  42628. container.effectLayers.push(effectLayer);
  42629. }
  42630. }
  42631. });
  42632. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  42633. var index = this.effectLayers.indexOf(toRemove);
  42634. if (index !== -1) {
  42635. this.effectLayers.splice(index, 1);
  42636. }
  42637. return index;
  42638. };
  42639. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  42640. this.effectLayers.push(newEffectLayer);
  42641. };
  42642. /**
  42643. * Defines the layer scene component responsible to manage any effect layers
  42644. * in a given scene.
  42645. */
  42646. var EffectLayerSceneComponent = /** @class */ (function () {
  42647. /**
  42648. * Creates a new instance of the component for the given scene
  42649. * @param scene Defines the scene to register the component in
  42650. */
  42651. function EffectLayerSceneComponent(scene) {
  42652. /**
  42653. * The component name helpfull to identify the component in the list of scene components.
  42654. */
  42655. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  42656. this._renderEffects = false;
  42657. this._needStencil = false;
  42658. this._previousStencilState = false;
  42659. this.scene = scene;
  42660. this._engine = scene.getEngine();
  42661. scene.effectLayers = new Array();
  42662. }
  42663. /**
  42664. * Registers the component in a given scene
  42665. */
  42666. EffectLayerSceneComponent.prototype.register = function () {
  42667. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  42668. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  42669. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  42670. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  42671. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  42672. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  42673. };
  42674. /**
  42675. * Rebuilds the elements related to this component in case of
  42676. * context lost for instance.
  42677. */
  42678. EffectLayerSceneComponent.prototype.rebuild = function () {
  42679. var layers = this.scene.effectLayers;
  42680. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  42681. var effectLayer = layers_1[_i];
  42682. effectLayer._rebuild();
  42683. }
  42684. };
  42685. /**
  42686. * Serializes the component data to the specified json object
  42687. * @param serializationObject The object to serialize to
  42688. */
  42689. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  42690. // Effect layers
  42691. serializationObject.effectLayers = [];
  42692. var layers = this.scene.effectLayers;
  42693. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  42694. var effectLayer = layers_2[_i];
  42695. if (effectLayer.serialize) {
  42696. serializationObject.effectLayers.push(effectLayer.serialize());
  42697. }
  42698. }
  42699. };
  42700. /**
  42701. * Adds all the element from the container to the scene
  42702. * @param container the container holding the elements
  42703. */
  42704. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  42705. var _this = this;
  42706. if (!container.effectLayers) {
  42707. return;
  42708. }
  42709. container.effectLayers.forEach(function (o) {
  42710. _this.scene.addEffectLayer(o);
  42711. });
  42712. };
  42713. /**
  42714. * Removes all the elements in the container from the scene
  42715. * @param container contains the elements to remove
  42716. * @param dispose if the removed element should be disposed (default: false)
  42717. */
  42718. EffectLayerSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  42719. var _this = this;
  42720. if (!container.effectLayers) {
  42721. return;
  42722. }
  42723. container.effectLayers.forEach(function (o) {
  42724. _this.scene.removeEffectLayer(o);
  42725. if (dispose) {
  42726. o.dispose();
  42727. }
  42728. });
  42729. };
  42730. /**
  42731. * Disposes the component and the associated ressources.
  42732. */
  42733. EffectLayerSceneComponent.prototype.dispose = function () {
  42734. var layers = this.scene.effectLayers;
  42735. while (layers.length) {
  42736. layers[0].dispose();
  42737. }
  42738. };
  42739. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  42740. var layers = this.scene.effectLayers;
  42741. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  42742. var layer = layers_3[_i];
  42743. if (!layer.hasMesh(mesh)) {
  42744. continue;
  42745. }
  42746. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  42747. var subMesh = _b[_a];
  42748. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  42749. return false;
  42750. }
  42751. }
  42752. }
  42753. return true;
  42754. };
  42755. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  42756. this._renderEffects = false;
  42757. this._needStencil = false;
  42758. var needRebind = false;
  42759. var layers = this.scene.effectLayers;
  42760. if (layers && layers.length > 0) {
  42761. this._previousStencilState = this._engine.getStencilBuffer();
  42762. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  42763. var effectLayer = layers_4[_i];
  42764. if (effectLayer.shouldRender() &&
  42765. (!effectLayer.camera ||
  42766. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  42767. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  42768. this._renderEffects = true;
  42769. this._needStencil = this._needStencil || effectLayer.needStencil();
  42770. var renderTarget = effectLayer._mainTexture;
  42771. if (renderTarget._shouldRender()) {
  42772. this.scene.incrementRenderId();
  42773. renderTarget.render(false, false);
  42774. needRebind = true;
  42775. }
  42776. }
  42777. }
  42778. this.scene.incrementRenderId();
  42779. }
  42780. return needRebind;
  42781. };
  42782. EffectLayerSceneComponent.prototype._setStencil = function () {
  42783. // Activate effect Layer stencil
  42784. if (this._needStencil) {
  42785. this._engine.setStencilBuffer(true);
  42786. }
  42787. };
  42788. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  42789. // Restore effect Layer stencil
  42790. if (this._needStencil) {
  42791. this._engine.setStencilBuffer(this._previousStencilState);
  42792. }
  42793. };
  42794. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  42795. if (this._renderEffects) {
  42796. this._engine.setDepthBuffer(false);
  42797. var layers = this.scene.effectLayers;
  42798. for (var i = 0; i < layers.length; i++) {
  42799. var effectLayer = layers[i];
  42800. if (effectLayer.renderingGroupId === renderingGroupId) {
  42801. if (effectLayer.shouldRender()) {
  42802. effectLayer.render();
  42803. }
  42804. }
  42805. }
  42806. this._engine.setDepthBuffer(true);
  42807. }
  42808. };
  42809. EffectLayerSceneComponent.prototype._drawCamera = function () {
  42810. if (this._renderEffects) {
  42811. this._draw(-1);
  42812. }
  42813. };
  42814. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  42815. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  42816. this._draw(index);
  42817. }
  42818. };
  42819. return EffectLayerSceneComponent;
  42820. }());
  42821. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  42822. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  42823. if (!component) {
  42824. component = new EffectLayerSceneComponent(scene);
  42825. scene._addComponent(component);
  42826. }
  42827. };
  42828. /***/ }),
  42829. /***/ "./Layers/glowLayer.ts":
  42830. /*!*****************************!*\
  42831. !*** ./Layers/glowLayer.ts ***!
  42832. \*****************************/
  42833. /*! exports provided: GlowLayer */
  42834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42835. "use strict";
  42836. __webpack_require__.r(__webpack_exports__);
  42837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  42838. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42839. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42840. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42841. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42842. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42843. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42844. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42845. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42846. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42847. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42848. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42849. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42850. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42851. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42852. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42853. /* harmony import */ var _Layers_effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Layers/effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  42854. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  42855. for (var index = 0; index < this.effectLayers.length; index++) {
  42856. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  42857. return this.effectLayers[index];
  42858. }
  42859. }
  42860. return null;
  42861. };
  42862. /**
  42863. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  42864. *
  42865. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  42866. * glowy meshes to your scene.
  42867. *
  42868. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  42869. */
  42870. var GlowLayer = /** @class */ (function (_super) {
  42871. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  42872. /**
  42873. * Instantiates a new glow Layer and references it to the scene.
  42874. * @param name The name of the layer
  42875. * @param scene The scene to use the layer in
  42876. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  42877. */
  42878. function GlowLayer(name, scene, options) {
  42879. var _this = _super.call(this, name, scene) || this;
  42880. _this._intensity = 1.0;
  42881. _this._includedOnlyMeshes = [];
  42882. _this._excludedMeshes = [];
  42883. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  42884. // Adapt options
  42885. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  42886. // Initialize the layer
  42887. _this._init({
  42888. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  42889. camera: _this._options.camera,
  42890. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  42891. mainTextureRatio: _this._options.mainTextureRatio,
  42892. renderingGroupId: _this._options.renderingGroupId
  42893. });
  42894. return _this;
  42895. }
  42896. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  42897. /**
  42898. * Gets the kernel size of the blur.
  42899. */
  42900. get: function () {
  42901. return this._horizontalBlurPostprocess1.kernel;
  42902. },
  42903. /**
  42904. * Sets the kernel size of the blur.
  42905. */
  42906. set: function (value) {
  42907. this._horizontalBlurPostprocess1.kernel = value;
  42908. this._verticalBlurPostprocess1.kernel = value;
  42909. this._horizontalBlurPostprocess2.kernel = value;
  42910. this._verticalBlurPostprocess2.kernel = value;
  42911. },
  42912. enumerable: true,
  42913. configurable: true
  42914. });
  42915. Object.defineProperty(GlowLayer.prototype, "intensity", {
  42916. /**
  42917. * Gets the glow intensity.
  42918. */
  42919. get: function () {
  42920. return this._intensity;
  42921. },
  42922. /**
  42923. * Sets the glow intensity.
  42924. */
  42925. set: function (value) {
  42926. this._intensity = value;
  42927. },
  42928. enumerable: true,
  42929. configurable: true
  42930. });
  42931. /**
  42932. * Get the effect name of the layer.
  42933. * @return The effect name
  42934. */
  42935. GlowLayer.prototype.getEffectName = function () {
  42936. return GlowLayer.EffectName;
  42937. };
  42938. /**
  42939. * Create the merge effect. This is the shader use to blit the information back
  42940. * to the main canvas at the end of the scene rendering.
  42941. */
  42942. GlowLayer.prototype._createMergeEffect = function () {
  42943. // Effect
  42944. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  42945. };
  42946. /**
  42947. * Creates the render target textures and post processes used in the glow layer.
  42948. */
  42949. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  42950. var _this = this;
  42951. var blurTextureWidth = this._mainTextureDesiredSize.width;
  42952. var blurTextureHeight = this._mainTextureDesiredSize.height;
  42953. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42954. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42955. var textureType = 0;
  42956. if (this._engine.getCaps().textureHalfFloatRender) {
  42957. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42958. }
  42959. else {
  42960. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42961. }
  42962. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  42963. width: blurTextureWidth,
  42964. height: blurTextureHeight
  42965. }, this._scene, false, true, textureType);
  42966. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42967. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42968. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  42969. this._blurTexture1.renderParticles = false;
  42970. this._blurTexture1.ignoreCameraViewport = true;
  42971. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  42972. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  42973. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  42974. width: blurTextureWidth2,
  42975. height: blurTextureHeight2
  42976. }, this._scene, false, true, textureType);
  42977. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42978. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42979. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  42980. this._blurTexture2.renderParticles = false;
  42981. this._blurTexture2.ignoreCameraViewport = true;
  42982. this._textures = [this._blurTexture1, this._blurTexture2];
  42983. this._horizontalBlurPostprocess1 = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__["BlurPostProcess"]("GlowLayerHBP1", new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1.0, 0), this._options.blurKernelSize / 2, {
  42984. width: blurTextureWidth,
  42985. height: blurTextureHeight
  42986. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42987. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  42988. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  42989. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  42990. effect.setTexture("textureSampler", _this._mainTexture);
  42991. });
  42992. this._verticalBlurPostprocess1 = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__["BlurPostProcess"]("GlowLayerVBP1", new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 1.0), this._options.blurKernelSize / 2, {
  42993. width: blurTextureWidth,
  42994. height: blurTextureHeight
  42995. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42996. this._horizontalBlurPostprocess2 = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__["BlurPostProcess"]("GlowLayerHBP2", new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1.0, 0), this._options.blurKernelSize / 2, {
  42997. width: blurTextureWidth2,
  42998. height: blurTextureHeight2
  42999. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43000. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  43001. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  43002. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  43003. effect.setTexture("textureSampler", _this._blurTexture1);
  43004. });
  43005. this._verticalBlurPostprocess2 = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__["BlurPostProcess"]("GlowLayerVBP2", new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 1.0), this._options.blurKernelSize / 2, {
  43006. width: blurTextureWidth2,
  43007. height: blurTextureHeight2
  43008. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43009. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  43010. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  43011. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  43012. this._mainTexture.samples = this._options.mainTextureSamples;
  43013. this._mainTexture.onAfterUnbindObservable.add(function () {
  43014. var internalTexture = _this._blurTexture1.getInternalTexture();
  43015. if (internalTexture) {
  43016. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  43017. internalTexture = _this._blurTexture2.getInternalTexture();
  43018. if (internalTexture) {
  43019. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  43020. }
  43021. }
  43022. });
  43023. // Prevent autoClear.
  43024. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  43025. };
  43026. /**
  43027. * Checks for the readiness of the element composing the layer.
  43028. * @param subMesh the mesh to check for
  43029. * @param useInstances specify wether or not to use instances to render the mesh
  43030. * @param emissiveTexture the associated emissive texture used to generate the glow
  43031. * @return true if ready otherwise, false
  43032. */
  43033. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  43034. var material = subMesh.getMaterial();
  43035. var mesh = subMesh.getRenderingMesh();
  43036. if (!material || !mesh) {
  43037. return false;
  43038. }
  43039. var emissiveTexture = material.emissiveTexture;
  43040. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  43041. };
  43042. /**
  43043. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43044. */
  43045. GlowLayer.prototype.needStencil = function () {
  43046. return false;
  43047. };
  43048. /**
  43049. * Returns true if the mesh can be rendered, otherwise false.
  43050. * @param mesh The mesh to render
  43051. * @param material The material used on the mesh
  43052. * @returns true if it can be rendered otherwise false
  43053. */
  43054. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  43055. return true;
  43056. };
  43057. /**
  43058. * Implementation specific of rendering the generating effect on the main canvas.
  43059. * @param effect The effect used to render through
  43060. */
  43061. GlowLayer.prototype._internalRender = function (effect) {
  43062. // Texture
  43063. effect.setTexture("textureSampler", this._blurTexture1);
  43064. effect.setTexture("textureSampler2", this._blurTexture2);
  43065. effect.setFloat("offset", this._intensity);
  43066. // Cache
  43067. var engine = this._engine;
  43068. var previousStencilBuffer = engine.getStencilBuffer();
  43069. // Draw order
  43070. engine.setStencilBuffer(false);
  43071. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  43072. // Draw order
  43073. engine.setStencilBuffer(previousStencilBuffer);
  43074. };
  43075. /**
  43076. * Sets the required values for both the emissive texture and and the main color.
  43077. */
  43078. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  43079. var textureLevel = 1.0;
  43080. if (this.customEmissiveTextureSelector) {
  43081. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  43082. }
  43083. else {
  43084. if (material) {
  43085. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  43086. if (this._emissiveTextureAndColor.texture) {
  43087. textureLevel = this._emissiveTextureAndColor.texture.level;
  43088. }
  43089. }
  43090. else {
  43091. this._emissiveTextureAndColor.texture = null;
  43092. }
  43093. }
  43094. if (this.customEmissiveColorSelector) {
  43095. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  43096. }
  43097. else {
  43098. if (material.emissiveColor) {
  43099. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  43100. }
  43101. else {
  43102. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  43103. }
  43104. }
  43105. };
  43106. /**
  43107. * Returns true if the mesh should render, otherwise false.
  43108. * @param mesh The mesh to render
  43109. * @returns true if it should render otherwise false
  43110. */
  43111. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  43112. return this.hasMesh(mesh);
  43113. };
  43114. /**
  43115. * Adds specific effects defines.
  43116. * @param defines The defines to add specifics to.
  43117. */
  43118. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  43119. defines.push("#define GLOW");
  43120. };
  43121. /**
  43122. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  43123. * @param mesh The mesh to exclude from the glow layer
  43124. */
  43125. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  43126. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  43127. this._excludedMeshes.push(mesh.uniqueId);
  43128. }
  43129. };
  43130. /**
  43131. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  43132. * @param mesh The mesh to remove
  43133. */
  43134. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  43135. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  43136. if (index !== -1) {
  43137. this._excludedMeshes.splice(index, 1);
  43138. }
  43139. };
  43140. /**
  43141. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  43142. * @param mesh The mesh to include in the glow layer
  43143. */
  43144. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  43145. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  43146. this._includedOnlyMeshes.push(mesh.uniqueId);
  43147. }
  43148. };
  43149. /**
  43150. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  43151. * @param mesh The mesh to remove
  43152. */
  43153. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  43154. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  43155. if (index !== -1) {
  43156. this._includedOnlyMeshes.splice(index, 1);
  43157. }
  43158. };
  43159. /**
  43160. * Determine if a given mesh will be used in the glow layer
  43161. * @param mesh The mesh to test
  43162. * @returns true if the mesh will be highlighted by the current glow layer
  43163. */
  43164. GlowLayer.prototype.hasMesh = function (mesh) {
  43165. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43166. return false;
  43167. }
  43168. // Included Mesh
  43169. if (this._includedOnlyMeshes.length) {
  43170. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  43171. }
  43172. // Excluded Mesh
  43173. if (this._excludedMeshes.length) {
  43174. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  43175. }
  43176. return true;
  43177. };
  43178. /**
  43179. * Free any resources and references associated to a mesh.
  43180. * Internal use
  43181. * @param mesh The mesh to free.
  43182. * @hidden
  43183. */
  43184. GlowLayer.prototype._disposeMesh = function (mesh) {
  43185. this.removeIncludedOnlyMesh(mesh);
  43186. this.removeExcludedMesh(mesh);
  43187. };
  43188. /**
  43189. * Gets the class name of the effect layer
  43190. * @returns the string with the class name of the effect layer
  43191. */
  43192. GlowLayer.prototype.getClassName = function () {
  43193. return "GlowLayer";
  43194. };
  43195. /**
  43196. * Serializes this glow layer
  43197. * @returns a serialized glow layer object
  43198. */
  43199. GlowLayer.prototype.serialize = function () {
  43200. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  43201. serializationObject.customType = "BABYLON.GlowLayer";
  43202. var index;
  43203. // Included meshes
  43204. serializationObject.includedMeshes = [];
  43205. if (this._includedOnlyMeshes.length) {
  43206. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  43207. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  43208. if (mesh) {
  43209. serializationObject.includedMeshes.push(mesh.id);
  43210. }
  43211. }
  43212. }
  43213. // Excluded meshes
  43214. serializationObject.excludedMeshes = [];
  43215. if (this._excludedMeshes.length) {
  43216. for (index = 0; index < this._excludedMeshes.length; index++) {
  43217. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  43218. if (mesh) {
  43219. serializationObject.excludedMeshes.push(mesh.id);
  43220. }
  43221. }
  43222. }
  43223. return serializationObject;
  43224. };
  43225. /**
  43226. * Creates a Glow Layer from parsed glow layer data
  43227. * @param parsedGlowLayer defines glow layer data
  43228. * @param scene defines the current scene
  43229. * @param rootUrl defines the root URL containing the glow layer information
  43230. * @returns a parsed Glow Layer
  43231. */
  43232. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  43233. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  43234. var index;
  43235. // Excluded meshes
  43236. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  43237. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  43238. if (mesh) {
  43239. gl.addExcludedMesh(mesh);
  43240. }
  43241. }
  43242. // Included meshes
  43243. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  43244. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  43245. if (mesh) {
  43246. gl.addIncludedOnlyMesh(mesh);
  43247. }
  43248. }
  43249. return gl;
  43250. };
  43251. /**
  43252. * Effect Name of the layer.
  43253. */
  43254. GlowLayer.EffectName = "GlowLayer";
  43255. /**
  43256. * The default blur kernel size used for the glow.
  43257. */
  43258. GlowLayer.DefaultBlurKernelSize = 32;
  43259. /**
  43260. * The default texture size ratio used for the glow.
  43261. */
  43262. GlowLayer.DefaultTextureRatio = 0.5;
  43263. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43264. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43265. ], GlowLayer.prototype, "blurKernelSize", null);
  43266. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43267. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43268. ], GlowLayer.prototype, "intensity", null);
  43269. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  43271. ], GlowLayer.prototype, "_options", void 0);
  43272. return GlowLayer;
  43273. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  43274. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  43275. /***/ }),
  43276. /***/ "./Layers/highlightLayer.ts":
  43277. /*!**********************************!*\
  43278. !*** ./Layers/highlightLayer.ts ***!
  43279. \**********************************/
  43280. /*! exports provided: HighlightLayer */
  43281. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43282. "use strict";
  43283. __webpack_require__.r(__webpack_exports__);
  43284. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  43285. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  43286. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  43287. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  43288. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43289. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43290. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43291. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43292. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43293. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  43294. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  43295. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  43296. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  43297. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  43298. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  43299. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43300. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  43301. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  43302. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  43303. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  43304. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  43305. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  43306. for (var index = 0; index < this.effectLayers.length; index++) {
  43307. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  43308. return this.effectLayers[index];
  43309. }
  43310. }
  43311. return null;
  43312. };
  43313. /**
  43314. * Special Glow Blur post process only blurring the alpha channel
  43315. * It enforces keeping the most luminous color in the color channel.
  43316. */
  43317. var GlowBlurPostProcess = /** @class */ (function (_super) {
  43318. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  43319. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  43320. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  43321. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  43322. _this.direction = direction;
  43323. _this.kernel = kernel;
  43324. _this.onApplyObservable.add(function (effect) {
  43325. effect.setFloat2("screenSize", _this.width, _this.height);
  43326. effect.setVector2("direction", _this.direction);
  43327. effect.setFloat("blurWidth", _this.kernel);
  43328. });
  43329. return _this;
  43330. }
  43331. return GlowBlurPostProcess;
  43332. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  43333. /**
  43334. * The highlight layer Helps adding a glow effect around a mesh.
  43335. *
  43336. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  43337. * glowy meshes to your scene.
  43338. *
  43339. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  43340. */
  43341. var HighlightLayer = /** @class */ (function (_super) {
  43342. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  43343. /**
  43344. * Instantiates a new highlight Layer and references it to the scene..
  43345. * @param name The name of the layer
  43346. * @param scene The scene to use the layer in
  43347. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  43348. */
  43349. function HighlightLayer(name, scene, options) {
  43350. var _this = _super.call(this, name, scene) || this;
  43351. _this.name = name;
  43352. /**
  43353. * Specifies whether or not the inner glow is ACTIVE in the layer.
  43354. */
  43355. _this.innerGlow = true;
  43356. /**
  43357. * Specifies whether or not the outer glow is ACTIVE in the layer.
  43358. */
  43359. _this.outerGlow = true;
  43360. /**
  43361. * An event triggered when the highlight layer is being blurred.
  43362. */
  43363. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  43364. /**
  43365. * An event triggered when the highlight layer has been blurred.
  43366. */
  43367. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  43368. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  43369. _this._meshes = {};
  43370. _this._excludedMeshes = {};
  43371. _this.neutralColor = HighlightLayer.NeutralColor;
  43372. // Warn on stencil
  43373. if (!_this._engine.isStencilEnable) {
  43374. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new Engine(canvas, antialias, { stencil: true }");
  43375. }
  43376. // Adapt options
  43377. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: 0.5, blurTextureSizeRatio: 0.5, blurHorizontalSize: 1.0, blurVerticalSize: 1.0, alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE, camera: null, renderingGroupId: -1 }, options);
  43378. // Initialize the layer
  43379. _this._init({
  43380. alphaBlendingMode: _this._options.alphaBlendingMode,
  43381. camera: _this._options.camera,
  43382. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  43383. mainTextureRatio: _this._options.mainTextureRatio,
  43384. renderingGroupId: _this._options.renderingGroupId
  43385. });
  43386. // Do not render as long as no meshes have been added
  43387. _this._shouldRender = false;
  43388. return _this;
  43389. }
  43390. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  43391. /**
  43392. * Gets the horizontal size of the blur.
  43393. */
  43394. get: function () {
  43395. return this._horizontalBlurPostprocess.kernel;
  43396. },
  43397. /**
  43398. * Specifies the horizontal size of the blur.
  43399. */
  43400. set: function (value) {
  43401. this._horizontalBlurPostprocess.kernel = value;
  43402. },
  43403. enumerable: true,
  43404. configurable: true
  43405. });
  43406. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  43407. /**
  43408. * Gets the vertical size of the blur.
  43409. */
  43410. get: function () {
  43411. return this._verticalBlurPostprocess.kernel;
  43412. },
  43413. /**
  43414. * Specifies the vertical size of the blur.
  43415. */
  43416. set: function (value) {
  43417. this._verticalBlurPostprocess.kernel = value;
  43418. },
  43419. enumerable: true,
  43420. configurable: true
  43421. });
  43422. /**
  43423. * Get the effect name of the layer.
  43424. * @return The effect name
  43425. */
  43426. HighlightLayer.prototype.getEffectName = function () {
  43427. return HighlightLayer.EffectName;
  43428. };
  43429. /**
  43430. * Create the merge effect. This is the shader use to blit the information back
  43431. * to the main canvas at the end of the scene rendering.
  43432. */
  43433. HighlightLayer.prototype._createMergeEffect = function () {
  43434. // Effect
  43435. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  43436. };
  43437. /**
  43438. * Creates the render target textures and post processes used in the highlight layer.
  43439. */
  43440. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  43441. var _this = this;
  43442. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  43443. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  43444. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  43445. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  43446. var textureType = 0;
  43447. if (this._engine.getCaps().textureHalfFloatRender) {
  43448. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  43449. }
  43450. else {
  43451. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  43452. }
  43453. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  43454. width: blurTextureWidth,
  43455. height: blurTextureHeight
  43456. }, this._scene, false, true, textureType);
  43457. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  43458. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  43459. this._blurTexture.anisotropicFilteringLevel = 16;
  43460. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  43461. this._blurTexture.renderParticles = false;
  43462. this._blurTexture.ignoreCameraViewport = true;
  43463. this._textures = [this._blurTexture];
  43464. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  43465. this._downSamplePostprocess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__["PassPostProcess"]("HighlightLayerPPP", this._options.blurTextureSizeRatio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine());
  43466. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  43467. effect.setTexture("textureSampler", _this._mainTexture);
  43468. });
  43469. this._horizontalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerHBP", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](1.0, 0), this._options.blurHorizontalSize, 1, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine());
  43470. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  43471. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  43472. });
  43473. this._verticalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerVBP", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](0, 1.0), this._options.blurVerticalSize, 1, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine());
  43474. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  43475. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  43476. });
  43477. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  43478. }
  43479. else {
  43480. this._horizontalBlurPostprocess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__["BlurPostProcess"]("HighlightLayerHBP", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](1.0, 0), this._options.blurHorizontalSize / 2, {
  43481. width: blurTextureWidth,
  43482. height: blurTextureHeight
  43483. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43484. this._horizontalBlurPostprocess.width = blurTextureWidth;
  43485. this._horizontalBlurPostprocess.height = blurTextureHeight;
  43486. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  43487. effect.setTexture("textureSampler", _this._mainTexture);
  43488. });
  43489. this._verticalBlurPostprocess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__["BlurPostProcess"]("HighlightLayerVBP", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](0, 1.0), this._options.blurVerticalSize / 2, {
  43490. width: blurTextureWidth,
  43491. height: blurTextureHeight
  43492. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43493. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  43494. }
  43495. this._mainTexture.onAfterUnbindObservable.add(function () {
  43496. _this.onBeforeBlurObservable.notifyObservers(_this);
  43497. var internalTexture = _this._blurTexture.getInternalTexture();
  43498. if (internalTexture) {
  43499. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  43500. }
  43501. _this.onAfterBlurObservable.notifyObservers(_this);
  43502. });
  43503. // Prevent autoClear.
  43504. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  43505. };
  43506. /**
  43507. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43508. */
  43509. HighlightLayer.prototype.needStencil = function () {
  43510. return true;
  43511. };
  43512. /**
  43513. * Checks for the readiness of the element composing the layer.
  43514. * @param subMesh the mesh to check for
  43515. * @param useInstances specify wether or not to use instances to render the mesh
  43516. * @param emissiveTexture the associated emissive texture used to generate the glow
  43517. * @return true if ready otherwise, false
  43518. */
  43519. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  43520. var material = subMesh.getMaterial();
  43521. var mesh = subMesh.getRenderingMesh();
  43522. if (!material || !mesh || !this._meshes) {
  43523. return false;
  43524. }
  43525. var emissiveTexture = null;
  43526. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  43527. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  43528. emissiveTexture = material.emissiveTexture;
  43529. }
  43530. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  43531. };
  43532. /**
  43533. * Implementation specific of rendering the generating effect on the main canvas.
  43534. * @param effect The effect used to render through
  43535. */
  43536. HighlightLayer.prototype._internalRender = function (effect) {
  43537. // Texture
  43538. effect.setTexture("textureSampler", this._blurTexture);
  43539. // Cache
  43540. var engine = this._engine;
  43541. engine.cacheStencilState();
  43542. // Stencil operations
  43543. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  43544. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  43545. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  43546. // Draw order
  43547. engine.setStencilMask(0x00);
  43548. engine.setStencilBuffer(true);
  43549. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  43550. // 2 passes inner outer
  43551. if (this.outerGlow) {
  43552. effect.setFloat("offset", 0);
  43553. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  43554. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43555. }
  43556. if (this.innerGlow) {
  43557. effect.setFloat("offset", 1);
  43558. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  43559. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43560. }
  43561. // Restore Cache
  43562. engine.restoreStencilState();
  43563. };
  43564. /**
  43565. * Returns true if the layer contains information to display, otherwise false.
  43566. */
  43567. HighlightLayer.prototype.shouldRender = function () {
  43568. if (_super.prototype.shouldRender.call(this)) {
  43569. return this._meshes ? true : false;
  43570. }
  43571. return false;
  43572. };
  43573. /**
  43574. * Returns true if the mesh should render, otherwise false.
  43575. * @param mesh The mesh to render
  43576. * @returns true if it should render otherwise false
  43577. */
  43578. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  43579. // Excluded Mesh
  43580. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  43581. return false;
  43582. }
  43583. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43584. return false;
  43585. }
  43586. return true;
  43587. };
  43588. /**
  43589. * Sets the required values for both the emissive texture and and the main color.
  43590. */
  43591. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  43592. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  43593. if (highlightLayerMesh) {
  43594. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  43595. }
  43596. else {
  43597. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  43598. }
  43599. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  43600. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  43601. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  43602. }
  43603. else {
  43604. this._emissiveTextureAndColor.texture = null;
  43605. }
  43606. };
  43607. /**
  43608. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  43609. * @param mesh The mesh to exclude from the highlight layer
  43610. */
  43611. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  43612. if (!this._excludedMeshes) {
  43613. return;
  43614. }
  43615. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  43616. if (!meshExcluded) {
  43617. this._excludedMeshes[mesh.uniqueId] = {
  43618. mesh: mesh,
  43619. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  43620. mesh.getEngine().setStencilBuffer(false);
  43621. }),
  43622. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  43623. mesh.getEngine().setStencilBuffer(true);
  43624. }),
  43625. };
  43626. }
  43627. };
  43628. /**
  43629. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  43630. * @param mesh The mesh to highlight
  43631. */
  43632. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  43633. if (!this._excludedMeshes) {
  43634. return;
  43635. }
  43636. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  43637. if (meshExcluded) {
  43638. if (meshExcluded.beforeBind) {
  43639. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  43640. }
  43641. if (meshExcluded.afterRender) {
  43642. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  43643. }
  43644. }
  43645. this._excludedMeshes[mesh.uniqueId] = null;
  43646. };
  43647. /**
  43648. * Determine if a given mesh will be highlighted by the current HighlightLayer
  43649. * @param mesh mesh to test
  43650. * @returns true if the mesh will be highlighted by the current HighlightLayer
  43651. */
  43652. HighlightLayer.prototype.hasMesh = function (mesh) {
  43653. if (!this._meshes) {
  43654. return false;
  43655. }
  43656. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43657. return false;
  43658. }
  43659. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  43660. };
  43661. /**
  43662. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  43663. * @param mesh The mesh to highlight
  43664. * @param color The color of the highlight
  43665. * @param glowEmissiveOnly Extract the glow from the emissive texture
  43666. */
  43667. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  43668. var _this = this;
  43669. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  43670. if (!this._meshes) {
  43671. return;
  43672. }
  43673. var meshHighlight = this._meshes[mesh.uniqueId];
  43674. if (meshHighlight) {
  43675. meshHighlight.color = color;
  43676. }
  43677. else {
  43678. this._meshes[mesh.uniqueId] = {
  43679. mesh: mesh,
  43680. color: color,
  43681. // Lambda required for capture due to Observable this context
  43682. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  43683. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  43684. _this._defaultStencilReference(mesh);
  43685. }
  43686. else {
  43687. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  43688. }
  43689. }),
  43690. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  43691. glowEmissiveOnly: glowEmissiveOnly
  43692. };
  43693. mesh.onDisposeObservable.add(function () {
  43694. _this._disposeMesh(mesh);
  43695. });
  43696. }
  43697. this._shouldRender = true;
  43698. };
  43699. /**
  43700. * Remove a mesh from the highlight layer in order to make it stop glowing.
  43701. * @param mesh The mesh to highlight
  43702. */
  43703. HighlightLayer.prototype.removeMesh = function (mesh) {
  43704. if (!this._meshes) {
  43705. return;
  43706. }
  43707. var meshHighlight = this._meshes[mesh.uniqueId];
  43708. if (meshHighlight) {
  43709. if (meshHighlight.observerHighlight) {
  43710. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  43711. }
  43712. if (meshHighlight.observerDefault) {
  43713. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  43714. }
  43715. delete this._meshes[mesh.uniqueId];
  43716. }
  43717. this._shouldRender = false;
  43718. for (var meshHighlightToCheck in this._meshes) {
  43719. if (this._meshes[meshHighlightToCheck]) {
  43720. this._shouldRender = true;
  43721. break;
  43722. }
  43723. }
  43724. };
  43725. /**
  43726. * Force the stencil to the normal expected value for none glowing parts
  43727. */
  43728. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  43729. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  43730. };
  43731. /**
  43732. * Free any resources and references associated to a mesh.
  43733. * Internal use
  43734. * @param mesh The mesh to free.
  43735. * @hidden
  43736. */
  43737. HighlightLayer.prototype._disposeMesh = function (mesh) {
  43738. this.removeMesh(mesh);
  43739. this.removeExcludedMesh(mesh);
  43740. };
  43741. /**
  43742. * Dispose the highlight layer and free resources.
  43743. */
  43744. HighlightLayer.prototype.dispose = function () {
  43745. if (this._meshes) {
  43746. // Clean mesh references
  43747. for (var id in this._meshes) {
  43748. var meshHighlight = this._meshes[id];
  43749. if (meshHighlight && meshHighlight.mesh) {
  43750. if (meshHighlight.observerHighlight) {
  43751. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  43752. }
  43753. if (meshHighlight.observerDefault) {
  43754. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  43755. }
  43756. }
  43757. }
  43758. this._meshes = null;
  43759. }
  43760. if (this._excludedMeshes) {
  43761. for (var id in this._excludedMeshes) {
  43762. var meshHighlight = this._excludedMeshes[id];
  43763. if (meshHighlight) {
  43764. if (meshHighlight.beforeBind) {
  43765. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  43766. }
  43767. if (meshHighlight.afterRender) {
  43768. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  43769. }
  43770. }
  43771. }
  43772. this._excludedMeshes = null;
  43773. }
  43774. _super.prototype.dispose.call(this);
  43775. };
  43776. /**
  43777. * Gets the class name of the effect layer
  43778. * @returns the string with the class name of the effect layer
  43779. */
  43780. HighlightLayer.prototype.getClassName = function () {
  43781. return "HighlightLayer";
  43782. };
  43783. /**
  43784. * Serializes this Highlight layer
  43785. * @returns a serialized Highlight layer object
  43786. */
  43787. HighlightLayer.prototype.serialize = function () {
  43788. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  43789. serializationObject.customType = "BABYLON.HighlightLayer";
  43790. // Highlighted meshes
  43791. serializationObject.meshes = [];
  43792. if (this._meshes) {
  43793. for (var m in this._meshes) {
  43794. var mesh = this._meshes[m];
  43795. if (mesh) {
  43796. serializationObject.meshes.push({
  43797. glowEmissiveOnly: mesh.glowEmissiveOnly,
  43798. color: mesh.color.asArray(),
  43799. meshId: mesh.mesh.id
  43800. });
  43801. }
  43802. }
  43803. }
  43804. // Excluded meshes
  43805. serializationObject.excludedMeshes = [];
  43806. if (this._excludedMeshes) {
  43807. for (var e in this._excludedMeshes) {
  43808. var excludedMesh = this._excludedMeshes[e];
  43809. if (excludedMesh) {
  43810. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  43811. }
  43812. }
  43813. }
  43814. return serializationObject;
  43815. };
  43816. /**
  43817. * Creates a Highlight layer from parsed Highlight layer data
  43818. * @param parsedHightlightLayer defines the Highlight layer data
  43819. * @param scene defines the current scene
  43820. * @param rootUrl defines the root URL containing the Highlight layer information
  43821. * @returns a parsed Highlight layer
  43822. */
  43823. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  43824. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  43825. var index;
  43826. // Excluded meshes
  43827. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  43828. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  43829. if (mesh) {
  43830. hl.addExcludedMesh(mesh);
  43831. }
  43832. }
  43833. // Included meshes
  43834. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  43835. var highlightedMesh = parsedHightlightLayer.meshes[index];
  43836. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  43837. if (mesh) {
  43838. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  43839. }
  43840. }
  43841. return hl;
  43842. };
  43843. /**
  43844. * Effect Name of the highlight layer.
  43845. */
  43846. HighlightLayer.EffectName = "HighlightLayer";
  43847. /**
  43848. * The neutral color used during the preparation of the glow effect.
  43849. * This is black by default as the blend operation is a blend operation.
  43850. */
  43851. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  43852. /**
  43853. * Stencil value used for glowing meshes.
  43854. */
  43855. HighlightLayer.GlowingMeshStencilReference = 0x02;
  43856. /**
  43857. * Stencil value used for the other meshes in the scene.
  43858. */
  43859. HighlightLayer.NormalMeshStencilReference = 0x01;
  43860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43862. ], HighlightLayer.prototype, "innerGlow", void 0);
  43863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43865. ], HighlightLayer.prototype, "outerGlow", void 0);
  43866. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43867. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43868. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  43869. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43870. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43871. ], HighlightLayer.prototype, "blurVerticalSize", null);
  43872. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  43874. ], HighlightLayer.prototype, "_options", void 0);
  43875. return HighlightLayer;
  43876. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  43877. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  43878. /***/ }),
  43879. /***/ "./Layers/index.ts":
  43880. /*!*************************!*\
  43881. !*** ./Layers/index.ts ***!
  43882. \*************************/
  43883. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  43884. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43885. "use strict";
  43886. __webpack_require__.r(__webpack_exports__);
  43887. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  43888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  43889. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  43890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  43891. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  43892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  43893. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  43894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  43895. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  43896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  43897. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  43898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  43899. /***/ }),
  43900. /***/ "./Layers/layer.ts":
  43901. /*!*************************!*\
  43902. !*** ./Layers/layer.ts ***!
  43903. \*************************/
  43904. /*! exports provided: Layer */
  43905. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43906. "use strict";
  43907. __webpack_require__.r(__webpack_exports__);
  43908. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  43909. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  43910. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43911. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  43912. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43913. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43914. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43915. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43916. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  43917. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43918. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  43919. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  43920. /**
  43921. * This represents a full screen 2d layer.
  43922. * This can be useful to display a picture in the background of your scene for instance.
  43923. * @see https://www.babylonjs-playground.com/#08A2BS#1
  43924. */
  43925. var Layer = /** @class */ (function () {
  43926. /**
  43927. * Instantiates a new layer.
  43928. * This represents a full screen 2d layer.
  43929. * This can be useful to display a picture in the background of your scene for instance.
  43930. * @see https://www.babylonjs-playground.com/#08A2BS#1
  43931. * @param name Define the name of the layer in the scene
  43932. * @param imgUrl Define the url of the texture to display in the layer
  43933. * @param scene Define the scene the layer belongs to
  43934. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  43935. * @param color Defines a color for the layer
  43936. */
  43937. function Layer(
  43938. /**
  43939. * Define the name of the layer.
  43940. */
  43941. name, imgUrl, scene, isBackground, color) {
  43942. this.name = name;
  43943. /**
  43944. * Define the scale of the layer in order to zoom in out of the texture.
  43945. */
  43946. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  43947. /**
  43948. * Define an offset for the layer in order to shift the texture.
  43949. */
  43950. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  43951. /**
  43952. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  43953. */
  43954. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  43955. /**
  43956. * Define a mask to restrict the layer to only some of the scene cameras.
  43957. */
  43958. this.layerMask = 0x0FFFFFFF;
  43959. /**
  43960. * Define the list of render target the layer is visible into.
  43961. */
  43962. this.renderTargetTextures = [];
  43963. /**
  43964. * Define if the layer is only used in renderTarget or if it also
  43965. * renders in the main frame buffer of the canvas.
  43966. */
  43967. this.renderOnlyInRenderTargetTextures = false;
  43968. this._vertexBuffers = {};
  43969. /**
  43970. * An event triggered when the layer is disposed.
  43971. */
  43972. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43973. /**
  43974. * An event triggered before rendering the scene
  43975. */
  43976. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43977. /**
  43978. * An event triggered after rendering the scene
  43979. */
  43980. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43981. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  43982. this.isBackground = isBackground === undefined ? true : isBackground;
  43983. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  43984. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  43985. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  43986. if (!layerComponent) {
  43987. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  43988. this._scene._addComponent(layerComponent);
  43989. }
  43990. this._scene.layers.push(this);
  43991. var engine = this._scene.getEngine();
  43992. // VBO
  43993. var vertices = [];
  43994. vertices.push(1, 1);
  43995. vertices.push(-1, 1);
  43996. vertices.push(-1, -1);
  43997. vertices.push(1, -1);
  43998. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  43999. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  44000. this._createIndexBuffer();
  44001. // Effects
  44002. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  44003. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  44004. }
  44005. Object.defineProperty(Layer.prototype, "onDispose", {
  44006. /**
  44007. * Back compatibility with callback before the onDisposeObservable existed.
  44008. * The set callback will be triggered when the layer has been disposed.
  44009. */
  44010. set: function (callback) {
  44011. if (this._onDisposeObserver) {
  44012. this.onDisposeObservable.remove(this._onDisposeObserver);
  44013. }
  44014. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  44015. },
  44016. enumerable: true,
  44017. configurable: true
  44018. });
  44019. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  44020. /**
  44021. * Back compatibility with callback before the onBeforeRenderObservable existed.
  44022. * The set callback will be triggered just before rendering the layer.
  44023. */
  44024. set: function (callback) {
  44025. if (this._onBeforeRenderObserver) {
  44026. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  44027. }
  44028. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  44029. },
  44030. enumerable: true,
  44031. configurable: true
  44032. });
  44033. Object.defineProperty(Layer.prototype, "onAfterRender", {
  44034. /**
  44035. * Back compatibility with callback before the onAfterRenderObservable existed.
  44036. * The set callback will be triggered just after rendering the layer.
  44037. */
  44038. set: function (callback) {
  44039. if (this._onAfterRenderObserver) {
  44040. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  44041. }
  44042. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  44043. },
  44044. enumerable: true,
  44045. configurable: true
  44046. });
  44047. Layer.prototype._createIndexBuffer = function () {
  44048. var engine = this._scene.getEngine();
  44049. // Indices
  44050. var indices = [];
  44051. indices.push(0);
  44052. indices.push(1);
  44053. indices.push(2);
  44054. indices.push(0);
  44055. indices.push(2);
  44056. indices.push(3);
  44057. this._indexBuffer = engine.createIndexBuffer(indices);
  44058. };
  44059. /** @hidden */
  44060. Layer.prototype._rebuild = function () {
  44061. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  44062. if (vb) {
  44063. vb._rebuild();
  44064. }
  44065. this._createIndexBuffer();
  44066. };
  44067. /**
  44068. * Renders the layer in the scene.
  44069. */
  44070. Layer.prototype.render = function () {
  44071. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  44072. // Check
  44073. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  44074. return;
  44075. }
  44076. var engine = this._scene.getEngine();
  44077. this.onBeforeRenderObservable.notifyObservers(this);
  44078. // Render
  44079. engine.enableEffect(currentEffect);
  44080. engine.setState(false);
  44081. // Texture
  44082. currentEffect.setTexture("textureSampler", this.texture);
  44083. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  44084. // Color
  44085. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  44086. // Scale / offset
  44087. currentEffect.setVector2("offset", this.offset);
  44088. currentEffect.setVector2("scale", this.scale);
  44089. // VBOs
  44090. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  44091. // Draw order
  44092. if (!this.alphaTest) {
  44093. engine.setAlphaMode(this.alphaBlendingMode);
  44094. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  44095. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  44096. }
  44097. else {
  44098. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  44099. }
  44100. this.onAfterRenderObservable.notifyObservers(this);
  44101. };
  44102. /**
  44103. * Disposes and releases the associated ressources.
  44104. */
  44105. Layer.prototype.dispose = function () {
  44106. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  44107. if (vertexBuffer) {
  44108. vertexBuffer.dispose();
  44109. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  44110. }
  44111. if (this._indexBuffer) {
  44112. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  44113. this._indexBuffer = null;
  44114. }
  44115. if (this.texture) {
  44116. this.texture.dispose();
  44117. this.texture = null;
  44118. }
  44119. // Clean RTT list
  44120. this.renderTargetTextures = [];
  44121. // Remove from scene
  44122. var index = this._scene.layers.indexOf(this);
  44123. this._scene.layers.splice(index, 1);
  44124. // Callback
  44125. this.onDisposeObservable.notifyObservers(this);
  44126. this.onDisposeObservable.clear();
  44127. this.onAfterRenderObservable.clear();
  44128. this.onBeforeRenderObservable.clear();
  44129. };
  44130. return Layer;
  44131. }());
  44132. /***/ }),
  44133. /***/ "./Layers/layerSceneComponent.ts":
  44134. /*!***************************************!*\
  44135. !*** ./Layers/layerSceneComponent.ts ***!
  44136. \***************************************/
  44137. /*! exports provided: LayerSceneComponent */
  44138. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44139. "use strict";
  44140. __webpack_require__.r(__webpack_exports__);
  44141. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  44142. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  44143. /**
  44144. * Defines the layer scene component responsible to manage any layers
  44145. * in a given scene.
  44146. */
  44147. var LayerSceneComponent = /** @class */ (function () {
  44148. /**
  44149. * Creates a new instance of the component for the given scene
  44150. * @param scene Defines the scene to register the component in
  44151. */
  44152. function LayerSceneComponent(scene) {
  44153. /**
  44154. * The component name helpfull to identify the component in the list of scene components.
  44155. */
  44156. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  44157. this.scene = scene;
  44158. this._engine = scene.getEngine();
  44159. scene.layers = new Array();
  44160. }
  44161. /**
  44162. * Registers the component in a given scene
  44163. */
  44164. LayerSceneComponent.prototype.register = function () {
  44165. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  44166. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  44167. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  44168. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  44169. };
  44170. /**
  44171. * Rebuilds the elements related to this component in case of
  44172. * context lost for instance.
  44173. */
  44174. LayerSceneComponent.prototype.rebuild = function () {
  44175. var layers = this.scene.layers;
  44176. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  44177. var layer = layers_1[_i];
  44178. layer._rebuild();
  44179. }
  44180. };
  44181. /**
  44182. * Disposes the component and the associated ressources.
  44183. */
  44184. LayerSceneComponent.prototype.dispose = function () {
  44185. var layers = this.scene.layers;
  44186. while (layers.length) {
  44187. layers[0].dispose();
  44188. }
  44189. };
  44190. LayerSceneComponent.prototype._draw = function (predicate) {
  44191. var layers = this.scene.layers;
  44192. if (layers.length) {
  44193. this._engine.setDepthBuffer(false);
  44194. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  44195. var layer = layers_2[_i];
  44196. if (predicate(layer)) {
  44197. layer.render();
  44198. }
  44199. }
  44200. this._engine.setDepthBuffer(true);
  44201. }
  44202. };
  44203. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  44204. return !layer.renderOnlyInRenderTargetTextures &&
  44205. layer.isBackground === isBackground &&
  44206. ((layer.layerMask & cameraLayerMask) !== 0);
  44207. };
  44208. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  44209. var _this = this;
  44210. this._draw(function (layer) {
  44211. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  44212. });
  44213. };
  44214. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  44215. var _this = this;
  44216. this._draw(function (layer) {
  44217. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  44218. });
  44219. };
  44220. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  44221. return (layer.renderTargetTextures.length > 0) &&
  44222. layer.isBackground === isBackground &&
  44223. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  44224. ((layer.layerMask & cameraLayerMask) !== 0);
  44225. };
  44226. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  44227. var _this = this;
  44228. this._draw(function (layer) {
  44229. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  44230. });
  44231. };
  44232. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  44233. var _this = this;
  44234. this._draw(function (layer) {
  44235. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  44236. });
  44237. };
  44238. return LayerSceneComponent;
  44239. }());
  44240. /***/ }),
  44241. /***/ "./Legacy/legacy.ts":
  44242. /*!**************************!*\
  44243. !*** ./Legacy/legacy.ts ***!
  44244. \**************************/
  44245. /*! exports provided: Debug, AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, _IAnimationState, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, VRMultiviewToSingleviewPostProcess, ReflectionProbe, BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer, Sprite, SpriteManager, SpriteSceneComponent, _AlphaState, _DepthCullingState, _StencilState, AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, EquiRectangularCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, MeshExploder, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  44246. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44247. "use strict";
  44248. __webpack_require__.r(__webpack_exports__);
  44249. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Debug", function() { return Debug; });
  44250. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  44251. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  44252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  44253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  44254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  44255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  44256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  44257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  44258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  44259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  44260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  44261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  44262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  44263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  44264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  44265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  44266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  44267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  44268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  44269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  44270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  44271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  44272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  44273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  44274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  44275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  44276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  44277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  44278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  44279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  44280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IAnimationState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IAnimationState"]; });
  44281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  44282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  44283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  44284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  44285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  44286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  44287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  44288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  44289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  44290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  44291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  44292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  44293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  44294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  44295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  44296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  44297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  44298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  44299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  44300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  44301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  44302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  44303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  44304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  44305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  44306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  44307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  44308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  44309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  44310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  44311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  44312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  44313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  44314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  44315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  44316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  44317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  44318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  44319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  44320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  44321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  44322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  44323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  44324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  44325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  44326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  44327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  44328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  44329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  44330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultCollisionCoordinator"]; });
  44331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  44332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  44333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  44334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  44335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  44336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  44337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  44338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  44339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  44340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  44341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  44342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  44343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  44344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  44345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  44346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  44347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  44348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  44349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  44350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  44351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  44352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  44353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  44354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  44355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  44356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  44357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  44358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  44359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  44360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  44361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  44362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  44363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  44364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  44365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  44366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  44367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  44368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  44369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  44370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  44371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  44372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  44373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  44374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  44375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  44376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  44377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  44378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  44379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  44380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  44381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  44382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  44383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  44384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  44385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  44386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  44387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LightGizmo"]; });
  44388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  44389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  44390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  44391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  44392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  44393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  44394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  44395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  44396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  44397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  44398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  44399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  44400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  44401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  44402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  44403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  44404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  44405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  44406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  44407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  44408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  44409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  44410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  44411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  44412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  44413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  44414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  44415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  44416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  44417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  44418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  44419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  44420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  44421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  44422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  44423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  44424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  44425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  44426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  44427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  44428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  44429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  44430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  44431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EquiRectangularCubeTexture"]; });
  44432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  44433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  44434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  44435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  44436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  44437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  44438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  44439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  44440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  44441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  44442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  44443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  44444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  44445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  44446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  44447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  44448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  44449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  44450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  44451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  44452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  44453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  44454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  44455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  44456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  44457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  44458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  44459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  44460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  44461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  44462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  44463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  44464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  44465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  44466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  44467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  44468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  44469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  44470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  44471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  44472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  44473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  44474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  44475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  44476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TrailMesh"]; });
  44477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  44478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  44479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  44480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  44481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  44482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  44483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  44484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  44485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  44486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  44487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  44488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  44489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  44490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  44491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  44492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  44493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  44494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  44495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  44496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereBuilder"]; });
  44497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderBuilder"]; });
  44498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesBuilder"]; });
  44499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneBuilder"]; });
  44500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  44501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  44502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  44503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  44504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  44505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  44506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  44507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  44508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  44509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  44510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  44511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  44512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  44513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  44514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  44515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  44516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  44517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  44518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  44519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEventOptions"]; });
  44520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEventOptions"]; });
  44521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEventOptions"]; });
  44522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  44523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  44524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  44525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  44526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  44527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  44528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  44529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  44530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  44531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  44532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  44533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  44534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  44535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  44536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  44537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  44538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  44539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  44540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  44541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  44542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  44543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  44544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  44545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  44546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  44547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  44548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  44549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  44550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  44551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  44552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  44553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  44554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  44555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  44556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  44557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  44558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  44559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  44560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  44561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  44562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  44563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRMultiviewToSingleviewPostProcess"]; });
  44564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  44565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  44566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  44567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  44568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  44569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  44570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  44571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  44572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  44573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  44574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  44575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  44576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  44577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  44578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  44579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  44580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  44581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  44582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  44583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  44584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  44585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  44586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  44587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  44588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  44589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  44590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  44591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  44592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  44593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  44594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EquiRectangularCubeTextureAssetTask"]; });
  44595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  44596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  44597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  44598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  44599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  44600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  44601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  44602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  44603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  44604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  44605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  44606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  44607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  44608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  44609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMatrix"]; });
  44610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  44611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  44612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  44613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  44614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshExploder"]; });
  44615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  44616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  44617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  44618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  44619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  44620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  44621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  44622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  44623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  44624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  44625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  44626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  44627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  44628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  44629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  44630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  44631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  44632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  44633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  44634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  44635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  44636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  44637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  44638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  44639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  44640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  44641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  44642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  44643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  44644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  44645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  44646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  44647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  44648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  44649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  44650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  44651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  44652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  44653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  44654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  44655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  44656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  44657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  44658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  44659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  44660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  44661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  44662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  44663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebRequest"]; });
  44664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InspectableType"]; });
  44665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  44666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  44667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  44668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  44669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  44670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  44671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  44672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  44673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  44674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  44675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  44676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  44677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  44678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  44679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  44680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  44681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  44682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  44683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  44684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  44685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  44686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  44687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  44688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  44689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  44690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  44691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  44692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  44693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  44694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  44695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  44696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  44697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  44698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  44699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  44700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  44701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OnAfterEnteringVRObservableEvent"]; });
  44702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  44703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  44704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  44705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  44706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  44707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  44708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  44709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  44710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  44711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  44712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  44713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  44714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  44715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  44716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  44717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  44718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  44719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  44720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  44721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  44722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  44723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterialDefines"]; });
  44724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  44725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  44726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  44727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  44728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  44729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  44730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  44731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  44732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  44733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  44734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  44735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  44736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  44737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscBuilder"]; });
  44738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"]; });
  44739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphereBuilder"]; });
  44740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusBuilder"]; });
  44741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotBuilder"]; });
  44742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonBuilder"]; });
  44743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShapeBuilder"]; });
  44744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LatheBuilder"]; });
  44745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundBuilder"]; });
  44746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TubeBuilder"]; });
  44747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolyhedronBuilder"]; });
  44748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IcoSphereBuilder"]; });
  44749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DecalBuilder"]; });
  44750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  44751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  44752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  44753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  44754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  44755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  44756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  44757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  44758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  44759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  44760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  44761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  44762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  44763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  44764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  44765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  44766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  44767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  44768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  44769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  44770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  44771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  44772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  44773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  44774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  44775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  44776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  44777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  44778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  44779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  44780. /**
  44781. * Legacy support, defining window.BABYLON (global variable).
  44782. *
  44783. * This is the entry point for the UMD module.
  44784. * The entry point for a future ESM package should be index.ts
  44785. */
  44786. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  44787. if (typeof globalObject !== "undefined") {
  44788. globalObject.BABYLON = BABYLON;
  44789. globalObject.BABYLON = globalObject.BABYLON || {};
  44790. var BABYLON = globalObject.BABYLON;
  44791. BABYLON.Debug = BABYLON.Debug || {};
  44792. var keys = [];
  44793. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  44794. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  44795. keys.push(key);
  44796. }
  44797. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  44798. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  44799. }
  44800. }
  44801. var Debug = {
  44802. AxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"],
  44803. BoneAxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"],
  44804. PhysicsViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["PhysicsViewer"],
  44805. SkeletonViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["SkeletonViewer"],
  44806. };
  44807. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  44808. /***/ }),
  44809. /***/ "./LensFlares/index.ts":
  44810. /*!*****************************!*\
  44811. !*** ./LensFlares/index.ts ***!
  44812. \*****************************/
  44813. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  44814. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44815. "use strict";
  44816. __webpack_require__.r(__webpack_exports__);
  44817. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  44818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  44819. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  44820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  44821. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  44822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  44823. /***/ }),
  44824. /***/ "./LensFlares/lensFlare.ts":
  44825. /*!*********************************!*\
  44826. !*** ./LensFlares/lensFlare.ts ***!
  44827. \*********************************/
  44828. /*! exports provided: LensFlare */
  44829. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44830. "use strict";
  44831. __webpack_require__.r(__webpack_exports__);
  44832. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  44833. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44834. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44835. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44836. /**
  44837. * This represents one of the lens effect in a `lensFlareSystem`.
  44838. * It controls one of the indiviual texture used in the effect.
  44839. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44840. */
  44841. var LensFlare = /** @class */ (function () {
  44842. /**
  44843. * Instantiates a new Lens Flare.
  44844. * This represents one of the lens effect in a `lensFlareSystem`.
  44845. * It controls one of the indiviual texture used in the effect.
  44846. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44847. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  44848. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  44849. * @param color Define the lens color
  44850. * @param imgUrl Define the lens texture url
  44851. * @param system Define the `lensFlareSystem` this flare is part of
  44852. */
  44853. function LensFlare(
  44854. /**
  44855. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  44856. */
  44857. size,
  44858. /**
  44859. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  44860. */
  44861. position, color, imgUrl, system) {
  44862. this.size = size;
  44863. this.position = position;
  44864. /**
  44865. * Define the alpha mode to render this particular lens.
  44866. */
  44867. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  44868. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  44869. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  44870. this._system = system;
  44871. system.lensFlares.push(this);
  44872. }
  44873. /**
  44874. * Creates a new Lens Flare.
  44875. * This represents one of the lens effect in a `lensFlareSystem`.
  44876. * It controls one of the indiviual texture used in the effect.
  44877. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44878. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  44879. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  44880. * @param color Define the lens color
  44881. * @param imgUrl Define the lens texture url
  44882. * @param system Define the `lensFlareSystem` this flare is part of
  44883. * @returns The newly created Lens Flare
  44884. */
  44885. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  44886. return new LensFlare(size, position, color, imgUrl, system);
  44887. };
  44888. /**
  44889. * Dispose and release the lens flare with its associated resources.
  44890. */
  44891. LensFlare.prototype.dispose = function () {
  44892. if (this.texture) {
  44893. this.texture.dispose();
  44894. }
  44895. // Remove from scene
  44896. var index = this._system.lensFlares.indexOf(this);
  44897. this._system.lensFlares.splice(index, 1);
  44898. };
  44899. return LensFlare;
  44900. }());
  44901. /***/ }),
  44902. /***/ "./LensFlares/lensFlareSystem.ts":
  44903. /*!***************************************!*\
  44904. !*** ./LensFlares/lensFlareSystem.ts ***!
  44905. \***************************************/
  44906. /*! exports provided: LensFlareSystem */
  44907. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44908. "use strict";
  44909. __webpack_require__.r(__webpack_exports__);
  44910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  44911. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44912. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44913. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  44914. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  44915. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  44916. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  44917. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  44918. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  44919. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44920. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  44921. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  44922. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  44923. /**
  44924. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44925. * It is usually composed of several `lensFlare`.
  44926. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44927. */
  44928. var LensFlareSystem = /** @class */ (function () {
  44929. /**
  44930. * Instantiates a lens flare system.
  44931. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44932. * It is usually composed of several `lensFlare`.
  44933. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44934. * @param name Define the name of the lens flare system in the scene
  44935. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  44936. * @param scene Define the scene the lens flare system belongs to
  44937. */
  44938. function LensFlareSystem(
  44939. /**
  44940. * Define the name of the lens flare system
  44941. */
  44942. name, emitter, scene) {
  44943. this.name = name;
  44944. /**
  44945. * List of lens flares used in this system.
  44946. */
  44947. this.lensFlares = new Array();
  44948. /**
  44949. * Define a limit from the border the lens flare can be visible.
  44950. */
  44951. this.borderLimit = 300;
  44952. /**
  44953. * Define a viewport border we do not want to see the lens flare in.
  44954. */
  44955. this.viewportBorder = 0;
  44956. /**
  44957. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  44958. */
  44959. this.layerMask = 0x0FFFFFFF;
  44960. this._vertexBuffers = {};
  44961. this._isEnabled = true;
  44962. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  44963. LensFlareSystem._SceneComponentInitialization(this._scene);
  44964. this._emitter = emitter;
  44965. this.id = name;
  44966. scene.lensFlareSystems.push(this);
  44967. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  44968. var engine = scene.getEngine();
  44969. // VBO
  44970. var vertices = [];
  44971. vertices.push(1, 1);
  44972. vertices.push(-1, 1);
  44973. vertices.push(-1, -1);
  44974. vertices.push(1, -1);
  44975. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, false, false, 2);
  44976. // Indices
  44977. var indices = [];
  44978. indices.push(0);
  44979. indices.push(1);
  44980. indices.push(2);
  44981. indices.push(0);
  44982. indices.push(2);
  44983. indices.push(3);
  44984. this._indexBuffer = engine.createIndexBuffer(indices);
  44985. // Effects
  44986. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  44987. }
  44988. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  44989. /**
  44990. * Define if the lens flare system is enabled.
  44991. */
  44992. get: function () {
  44993. return this._isEnabled;
  44994. },
  44995. set: function (value) {
  44996. this._isEnabled = value;
  44997. },
  44998. enumerable: true,
  44999. configurable: true
  45000. });
  45001. /**
  45002. * Get the scene the effects belongs to.
  45003. * @returns the scene holding the lens flare system
  45004. */
  45005. LensFlareSystem.prototype.getScene = function () {
  45006. return this._scene;
  45007. };
  45008. /**
  45009. * Get the emitter of the lens flare system.
  45010. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  45011. * @returns the emitter of the lens flare system
  45012. */
  45013. LensFlareSystem.prototype.getEmitter = function () {
  45014. return this._emitter;
  45015. };
  45016. /**
  45017. * Set the emitter of the lens flare system.
  45018. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  45019. * @param newEmitter Define the new emitter of the system
  45020. */
  45021. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  45022. this._emitter = newEmitter;
  45023. };
  45024. /**
  45025. * Get the lens flare system emitter position.
  45026. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  45027. * @returns the position
  45028. */
  45029. LensFlareSystem.prototype.getEmitterPosition = function () {
  45030. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  45031. };
  45032. /**
  45033. * @hidden
  45034. */
  45035. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  45036. var position = this.getEmitterPosition();
  45037. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  45038. this._positionX = position.x;
  45039. this._positionY = position.y;
  45040. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  45041. if (this.viewportBorder > 0) {
  45042. globalViewport.x -= this.viewportBorder;
  45043. globalViewport.y -= this.viewportBorder;
  45044. globalViewport.width += this.viewportBorder * 2;
  45045. globalViewport.height += this.viewportBorder * 2;
  45046. position.x += this.viewportBorder;
  45047. position.y += this.viewportBorder;
  45048. this._positionX += this.viewportBorder;
  45049. this._positionY += this.viewportBorder;
  45050. }
  45051. if (position.z > 0) {
  45052. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  45053. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  45054. return true;
  45055. }
  45056. }
  45057. return true;
  45058. }
  45059. return false;
  45060. };
  45061. /** @hidden */
  45062. LensFlareSystem.prototype._isVisible = function () {
  45063. if (!this._isEnabled || !this._scene.activeCamera) {
  45064. return false;
  45065. }
  45066. var emitterPosition = this.getEmitterPosition();
  45067. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  45068. var distance = direction.length();
  45069. direction.normalize();
  45070. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  45071. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  45072. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  45073. };
  45074. /**
  45075. * @hidden
  45076. */
  45077. LensFlareSystem.prototype.render = function () {
  45078. if (!this._effect.isReady() || !this._scene.activeCamera) {
  45079. return false;
  45080. }
  45081. var engine = this._scene.getEngine();
  45082. var viewport = this._scene.activeCamera.viewport;
  45083. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  45084. // Position
  45085. if (!this.computeEffectivePosition(globalViewport)) {
  45086. return false;
  45087. }
  45088. // Visibility
  45089. if (!this._isVisible()) {
  45090. return false;
  45091. }
  45092. // Intensity
  45093. var awayX;
  45094. var awayY;
  45095. if (this._positionX < this.borderLimit + globalViewport.x) {
  45096. awayX = this.borderLimit + globalViewport.x - this._positionX;
  45097. }
  45098. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  45099. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  45100. }
  45101. else {
  45102. awayX = 0;
  45103. }
  45104. if (this._positionY < this.borderLimit + globalViewport.y) {
  45105. awayY = this.borderLimit + globalViewport.y - this._positionY;
  45106. }
  45107. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  45108. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  45109. }
  45110. else {
  45111. awayY = 0;
  45112. }
  45113. var away = (awayX > awayY) ? awayX : awayY;
  45114. away -= this.viewportBorder;
  45115. if (away > this.borderLimit) {
  45116. away = this.borderLimit;
  45117. }
  45118. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  45119. if (intensity < 0) {
  45120. return false;
  45121. }
  45122. if (intensity > 1.0) {
  45123. intensity = 1.0;
  45124. }
  45125. if (this.viewportBorder > 0) {
  45126. globalViewport.x += this.viewportBorder;
  45127. globalViewport.y += this.viewportBorder;
  45128. globalViewport.width -= this.viewportBorder * 2;
  45129. globalViewport.height -= this.viewportBorder * 2;
  45130. this._positionX -= this.viewportBorder;
  45131. this._positionY -= this.viewportBorder;
  45132. }
  45133. // Position
  45134. var centerX = globalViewport.x + globalViewport.width / 2;
  45135. var centerY = globalViewport.y + globalViewport.height / 2;
  45136. var distX = centerX - this._positionX;
  45137. var distY = centerY - this._positionY;
  45138. // Effects
  45139. engine.enableEffect(this._effect);
  45140. engine.setState(false);
  45141. engine.setDepthBuffer(false);
  45142. // VBOs
  45143. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  45144. // Flares
  45145. for (var index = 0; index < this.lensFlares.length; index++) {
  45146. var flare = this.lensFlares[index];
  45147. engine.setAlphaMode(flare.alphaMode);
  45148. var x = centerX - (distX * flare.position);
  45149. var y = centerY - (distY * flare.position);
  45150. var cw = flare.size;
  45151. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  45152. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  45153. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  45154. var viewportMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromValues(cw / 2, 0, 0, 0, 0, ch / 2, 0, 0, 0, 0, 1, 0, cx, cy, 0, 1);
  45155. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  45156. // Texture
  45157. this._effect.setTexture("textureSampler", flare.texture);
  45158. // Color
  45159. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  45160. // Draw order
  45161. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  45162. }
  45163. engine.setDepthBuffer(true);
  45164. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  45165. return true;
  45166. };
  45167. /**
  45168. * Dispose and release the lens flare with its associated resources.
  45169. */
  45170. LensFlareSystem.prototype.dispose = function () {
  45171. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  45172. if (vertexBuffer) {
  45173. vertexBuffer.dispose();
  45174. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  45175. }
  45176. if (this._indexBuffer) {
  45177. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  45178. this._indexBuffer = null;
  45179. }
  45180. while (this.lensFlares.length) {
  45181. this.lensFlares[0].dispose();
  45182. }
  45183. // Remove from scene
  45184. var index = this._scene.lensFlareSystems.indexOf(this);
  45185. this._scene.lensFlareSystems.splice(index, 1);
  45186. };
  45187. /**
  45188. * Parse a lens flare system from a JSON repressentation
  45189. * @param parsedLensFlareSystem Define the JSON to parse
  45190. * @param scene Define the scene the parsed system should be instantiated in
  45191. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  45192. * @returns the parsed system
  45193. */
  45194. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  45195. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  45196. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  45197. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  45198. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  45199. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  45200. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  45201. var parsedFlare = parsedLensFlareSystem.flares[index];
  45202. _lensFlare__WEBPACK_IMPORTED_MODULE_7__["LensFlare"].AddFlare(parsedFlare.size, parsedFlare.position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFlare.color), parsedFlare.textureName ? rootUrl + parsedFlare.textureName : "", lensFlareSystem);
  45203. }
  45204. return lensFlareSystem;
  45205. };
  45206. /**
  45207. * Serialize the current Lens Flare System into a JSON representation.
  45208. * @returns the serialized JSON
  45209. */
  45210. LensFlareSystem.prototype.serialize = function () {
  45211. var serializationObject = {};
  45212. serializationObject.id = this.id;
  45213. serializationObject.name = this.name;
  45214. serializationObject.emitterId = this.getEmitter().id;
  45215. serializationObject.borderLimit = this.borderLimit;
  45216. serializationObject.flares = [];
  45217. for (var index = 0; index < this.lensFlares.length; index++) {
  45218. var flare = this.lensFlares[index];
  45219. serializationObject.flares.push({
  45220. size: flare.size,
  45221. position: flare.position,
  45222. color: flare.color.asArray(),
  45223. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  45224. });
  45225. }
  45226. return serializationObject;
  45227. };
  45228. /** @hidden */
  45229. LensFlareSystem._SceneComponentInitialization = function (_) {
  45230. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("LensFlareSystemSceneComponent");
  45231. };
  45232. return LensFlareSystem;
  45233. }());
  45234. /***/ }),
  45235. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  45236. /*!*****************************************************!*\
  45237. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  45238. \*****************************************************/
  45239. /*! exports provided: LensFlareSystemSceneComponent */
  45240. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45241. "use strict";
  45242. __webpack_require__.r(__webpack_exports__);
  45243. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  45244. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  45245. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  45246. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  45247. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  45248. // Adds the parser to the scene parsers.
  45249. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  45250. // Lens flares
  45251. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  45252. if (!container.lensFlareSystems) {
  45253. container.lensFlareSystems = new Array();
  45254. }
  45255. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  45256. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  45257. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  45258. container.lensFlareSystems.push(lf);
  45259. }
  45260. }
  45261. });
  45262. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  45263. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  45264. if (this.lensFlareSystems[index].name === name) {
  45265. return this.lensFlareSystems[index];
  45266. }
  45267. }
  45268. return null;
  45269. };
  45270. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  45271. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  45272. if (this.lensFlareSystems[index].id === id) {
  45273. return this.lensFlareSystems[index];
  45274. }
  45275. }
  45276. return null;
  45277. };
  45278. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  45279. var index = this.lensFlareSystems.indexOf(toRemove);
  45280. if (index !== -1) {
  45281. this.lensFlareSystems.splice(index, 1);
  45282. }
  45283. return index;
  45284. };
  45285. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  45286. this.lensFlareSystems.push(newLensFlareSystem);
  45287. };
  45288. /**
  45289. * Defines the lens flare scene component responsible to manage any lens flares
  45290. * in a given scene.
  45291. */
  45292. var LensFlareSystemSceneComponent = /** @class */ (function () {
  45293. /**
  45294. * Creates a new instance of the component for the given scene
  45295. * @param scene Defines the scene to register the component in
  45296. */
  45297. function LensFlareSystemSceneComponent(scene) {
  45298. /**
  45299. * The component name helpfull to identify the component in the list of scene components.
  45300. */
  45301. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  45302. this.scene = scene;
  45303. scene.lensFlareSystems = new Array();
  45304. }
  45305. /**
  45306. * Registers the component in a given scene
  45307. */
  45308. LensFlareSystemSceneComponent.prototype.register = function () {
  45309. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  45310. };
  45311. /**
  45312. * Rebuilds the elements related to this component in case of
  45313. * context lost for instance.
  45314. */
  45315. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  45316. // Nothing to do for lens flare
  45317. };
  45318. /**
  45319. * Adds all the element from the container to the scene
  45320. * @param container the container holding the elements
  45321. */
  45322. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  45323. var _this = this;
  45324. if (!container.lensFlareSystems) {
  45325. return;
  45326. }
  45327. container.lensFlareSystems.forEach(function (o) {
  45328. _this.scene.addLensFlareSystem(o);
  45329. });
  45330. };
  45331. /**
  45332. * Removes all the elements in the container from the scene
  45333. * @param container contains the elements to remove
  45334. * @param dispose if the removed element should be disposed (default: false)
  45335. */
  45336. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  45337. var _this = this;
  45338. if (!container.lensFlareSystems) {
  45339. return;
  45340. }
  45341. container.lensFlareSystems.forEach(function (o) {
  45342. _this.scene.removeLensFlareSystem(o);
  45343. if (dispose) {
  45344. o.dispose();
  45345. }
  45346. });
  45347. };
  45348. /**
  45349. * Serializes the component data to the specified json object
  45350. * @param serializationObject The object to serialize to
  45351. */
  45352. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  45353. // Lens flares
  45354. serializationObject.lensFlareSystems = [];
  45355. var lensFlareSystems = this.scene.lensFlareSystems;
  45356. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  45357. var lensFlareSystem = lensFlareSystems_1[_i];
  45358. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  45359. }
  45360. };
  45361. /**
  45362. * Disposes the component and the associated ressources.
  45363. */
  45364. LensFlareSystemSceneComponent.prototype.dispose = function () {
  45365. var lensFlareSystems = this.scene.lensFlareSystems;
  45366. while (lensFlareSystems.length) {
  45367. lensFlareSystems[0].dispose();
  45368. }
  45369. };
  45370. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  45371. // Lens flares
  45372. if (this.scene.lensFlaresEnabled) {
  45373. var lensFlareSystems = this.scene.lensFlareSystems;
  45374. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  45375. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  45376. var lensFlareSystem = lensFlareSystems_2[_i];
  45377. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  45378. lensFlareSystem.render();
  45379. }
  45380. }
  45381. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  45382. }
  45383. };
  45384. return LensFlareSystemSceneComponent;
  45385. }());
  45386. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  45387. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  45388. if (!component) {
  45389. component = new LensFlareSystemSceneComponent(scene);
  45390. scene._addComponent(component);
  45391. }
  45392. };
  45393. /***/ }),
  45394. /***/ "./Lights/Shadows/index.ts":
  45395. /*!*********************************!*\
  45396. !*** ./Lights/Shadows/index.ts ***!
  45397. \*********************************/
  45398. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  45399. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45400. "use strict";
  45401. __webpack_require__.r(__webpack_exports__);
  45402. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  45403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  45404. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  45405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  45406. /***/ }),
  45407. /***/ "./Lights/Shadows/shadowGenerator.ts":
  45408. /*!*******************************************!*\
  45409. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  45410. \*******************************************/
  45411. /*! exports provided: ShadowGenerator */
  45412. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45413. "use strict";
  45414. __webpack_require__.r(__webpack_exports__);
  45415. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  45416. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45417. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  45418. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  45419. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  45420. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  45421. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  45422. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  45423. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  45424. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  45425. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  45426. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  45427. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  45428. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  45429. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  45430. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  45431. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  45432. /**
  45433. * Default implementation IShadowGenerator.
  45434. * This is the main object responsible of generating shadows in the framework.
  45435. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  45436. */
  45437. var ShadowGenerator = /** @class */ (function () {
  45438. /**
  45439. * Creates a ShadowGenerator object.
  45440. * A ShadowGenerator is the required tool to use the shadows.
  45441. * Each light casting shadows needs to use its own ShadowGenerator.
  45442. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  45443. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  45444. * @param light The light object generating the shadows.
  45445. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  45446. */
  45447. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  45448. /**
  45449. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  45450. */
  45451. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  45452. /**
  45453. * Observable triggered before a mesh is rendered in the shadow map.
  45454. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  45455. */
  45456. this.onBeforeShadowMapRenderMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  45457. this._bias = 0.00005;
  45458. this._normalBias = 0;
  45459. this._blurBoxOffset = 1;
  45460. this._blurScale = 2;
  45461. this._blurKernel = 1;
  45462. this._useKernelBlur = false;
  45463. this._filter = ShadowGenerator.FILTER_NONE;
  45464. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  45465. this._contactHardeningLightSizeUVRatio = 0.1;
  45466. this._darkness = 0;
  45467. this._transparencyShadow = false;
  45468. /**
  45469. * Controls the extent to which the shadows fade out at the edge of the frustum
  45470. * Used only by directionals and spots
  45471. */
  45472. this.frustumEdgeFalloff = 0;
  45473. /**
  45474. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  45475. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  45476. * It might on the other hand introduce peter panning.
  45477. */
  45478. this.forceBackFacesOnly = false;
  45479. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  45480. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45481. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45482. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45483. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  45484. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  45485. this._currentFaceIndex = 0;
  45486. this._currentFaceIndexCache = 0;
  45487. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  45488. this._mapSize = mapSize;
  45489. this._light = light;
  45490. this._scene = light.getScene();
  45491. light._shadowGenerator = this;
  45492. ShadowGenerator._SceneComponentInitialization(this._scene);
  45493. // Texture type fallback from float to int if not supported.
  45494. var caps = this._scene.getEngine().getCaps();
  45495. if (!usefulFloatFirst) {
  45496. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  45497. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  45498. }
  45499. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  45500. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  45501. }
  45502. else {
  45503. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  45504. }
  45505. }
  45506. else {
  45507. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  45508. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  45509. }
  45510. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  45511. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  45512. }
  45513. else {
  45514. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  45515. }
  45516. }
  45517. this._initializeGenerator();
  45518. this._applyFilterValues();
  45519. }
  45520. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  45521. /**
  45522. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  45523. */
  45524. get: function () {
  45525. return this._bias;
  45526. },
  45527. /**
  45528. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  45529. */
  45530. set: function (bias) {
  45531. this._bias = bias;
  45532. },
  45533. enumerable: true,
  45534. configurable: true
  45535. });
  45536. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  45537. /**
  45538. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  45539. */
  45540. get: function () {
  45541. return this._normalBias;
  45542. },
  45543. /**
  45544. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  45545. */
  45546. set: function (normalBias) {
  45547. this._normalBias = normalBias;
  45548. },
  45549. enumerable: true,
  45550. configurable: true
  45551. });
  45552. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  45553. /**
  45554. * Gets the blur box offset: offset applied during the blur pass.
  45555. * Only useful if useKernelBlur = false
  45556. */
  45557. get: function () {
  45558. return this._blurBoxOffset;
  45559. },
  45560. /**
  45561. * Sets the blur box offset: offset applied during the blur pass.
  45562. * Only useful if useKernelBlur = false
  45563. */
  45564. set: function (value) {
  45565. if (this._blurBoxOffset === value) {
  45566. return;
  45567. }
  45568. this._blurBoxOffset = value;
  45569. this._disposeBlurPostProcesses();
  45570. },
  45571. enumerable: true,
  45572. configurable: true
  45573. });
  45574. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  45575. /**
  45576. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  45577. * 2 means half of the size.
  45578. */
  45579. get: function () {
  45580. return this._blurScale;
  45581. },
  45582. /**
  45583. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  45584. * 2 means half of the size.
  45585. */
  45586. set: function (value) {
  45587. if (this._blurScale === value) {
  45588. return;
  45589. }
  45590. this._blurScale = value;
  45591. this._disposeBlurPostProcesses();
  45592. },
  45593. enumerable: true,
  45594. configurable: true
  45595. });
  45596. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  45597. /**
  45598. * Gets the blur kernel: kernel size of the blur pass.
  45599. * Only useful if useKernelBlur = true
  45600. */
  45601. get: function () {
  45602. return this._blurKernel;
  45603. },
  45604. /**
  45605. * Sets the blur kernel: kernel size of the blur pass.
  45606. * Only useful if useKernelBlur = true
  45607. */
  45608. set: function (value) {
  45609. if (this._blurKernel === value) {
  45610. return;
  45611. }
  45612. this._blurKernel = value;
  45613. this._disposeBlurPostProcesses();
  45614. },
  45615. enumerable: true,
  45616. configurable: true
  45617. });
  45618. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  45619. /**
  45620. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  45621. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  45622. */
  45623. get: function () {
  45624. return this._useKernelBlur;
  45625. },
  45626. /**
  45627. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  45628. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  45629. */
  45630. set: function (value) {
  45631. if (this._useKernelBlur === value) {
  45632. return;
  45633. }
  45634. this._useKernelBlur = value;
  45635. this._disposeBlurPostProcesses();
  45636. },
  45637. enumerable: true,
  45638. configurable: true
  45639. });
  45640. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  45641. /**
  45642. * Gets the depth scale used in ESM mode.
  45643. */
  45644. get: function () {
  45645. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  45646. },
  45647. /**
  45648. * Sets the depth scale used in ESM mode.
  45649. * This can override the scale stored on the light.
  45650. */
  45651. set: function (value) {
  45652. this._depthScale = value;
  45653. },
  45654. enumerable: true,
  45655. configurable: true
  45656. });
  45657. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  45658. /**
  45659. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  45660. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  45661. */
  45662. get: function () {
  45663. return this._filter;
  45664. },
  45665. /**
  45666. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  45667. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  45668. */
  45669. set: function (value) {
  45670. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  45671. if (this._light.needCube()) {
  45672. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  45673. this.useExponentialShadowMap = true;
  45674. return;
  45675. }
  45676. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  45677. this.useCloseExponentialShadowMap = true;
  45678. return;
  45679. }
  45680. // PCF on cubemap would also be expensive
  45681. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  45682. this.usePoissonSampling = true;
  45683. return;
  45684. }
  45685. }
  45686. // Weblg1 fallback for PCF.
  45687. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  45688. if (this._scene.getEngine().webGLVersion === 1) {
  45689. this.usePoissonSampling = true;
  45690. return;
  45691. }
  45692. }
  45693. if (this._filter === value) {
  45694. return;
  45695. }
  45696. this._filter = value;
  45697. this._disposeBlurPostProcesses();
  45698. this._applyFilterValues();
  45699. this._light._markMeshesAsLightDirty();
  45700. },
  45701. enumerable: true,
  45702. configurable: true
  45703. });
  45704. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  45705. /**
  45706. * Gets if the current filter is set to Poisson Sampling.
  45707. */
  45708. get: function () {
  45709. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  45710. },
  45711. /**
  45712. * Sets the current filter to Poisson Sampling.
  45713. */
  45714. set: function (value) {
  45715. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  45716. return;
  45717. }
  45718. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  45719. },
  45720. enumerable: true,
  45721. configurable: true
  45722. });
  45723. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  45724. /**
  45725. * Gets if the current filter is set to ESM.
  45726. */
  45727. get: function () {
  45728. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  45729. },
  45730. /**
  45731. * Sets the current filter is to ESM.
  45732. */
  45733. set: function (value) {
  45734. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  45735. return;
  45736. }
  45737. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45738. },
  45739. enumerable: true,
  45740. configurable: true
  45741. });
  45742. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  45743. /**
  45744. * Gets if the current filter is set to filtered ESM.
  45745. */
  45746. get: function () {
  45747. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  45748. },
  45749. /**
  45750. * Gets if the current filter is set to filtered ESM.
  45751. */
  45752. set: function (value) {
  45753. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  45754. return;
  45755. }
  45756. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45757. },
  45758. enumerable: true,
  45759. configurable: true
  45760. });
  45761. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  45762. /**
  45763. * Gets if the current filter is set to "close ESM" (using the inverse of the
  45764. * exponential to prevent steep falloff artifacts).
  45765. */
  45766. get: function () {
  45767. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  45768. },
  45769. /**
  45770. * Sets the current filter to "close ESM" (using the inverse of the
  45771. * exponential to prevent steep falloff artifacts).
  45772. */
  45773. set: function (value) {
  45774. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  45775. return;
  45776. }
  45777. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45778. },
  45779. enumerable: true,
  45780. configurable: true
  45781. });
  45782. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  45783. /**
  45784. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  45785. * exponential to prevent steep falloff artifacts).
  45786. */
  45787. get: function () {
  45788. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  45789. },
  45790. /**
  45791. * Sets the current filter to filtered "close ESM" (using the inverse of the
  45792. * exponential to prevent steep falloff artifacts).
  45793. */
  45794. set: function (value) {
  45795. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  45796. return;
  45797. }
  45798. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45799. },
  45800. enumerable: true,
  45801. configurable: true
  45802. });
  45803. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  45804. /**
  45805. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  45806. */
  45807. get: function () {
  45808. return this.filter === ShadowGenerator.FILTER_PCF;
  45809. },
  45810. /**
  45811. * Sets the current filter to "PCF" (percentage closer filtering).
  45812. */
  45813. set: function (value) {
  45814. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  45815. return;
  45816. }
  45817. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  45818. },
  45819. enumerable: true,
  45820. configurable: true
  45821. });
  45822. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  45823. /**
  45824. * Gets the PCF or PCSS Quality.
  45825. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  45826. */
  45827. get: function () {
  45828. return this._filteringQuality;
  45829. },
  45830. /**
  45831. * Sets the PCF or PCSS Quality.
  45832. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  45833. */
  45834. set: function (filteringQuality) {
  45835. this._filteringQuality = filteringQuality;
  45836. },
  45837. enumerable: true,
  45838. configurable: true
  45839. });
  45840. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  45841. /**
  45842. * Gets if the current filter is set to "PCSS" (contact hardening).
  45843. */
  45844. get: function () {
  45845. return this.filter === ShadowGenerator.FILTER_PCSS;
  45846. },
  45847. /**
  45848. * Sets the current filter to "PCSS" (contact hardening).
  45849. */
  45850. set: function (value) {
  45851. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  45852. return;
  45853. }
  45854. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  45855. },
  45856. enumerable: true,
  45857. configurable: true
  45858. });
  45859. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  45860. /**
  45861. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  45862. * Using a ratio helps keeping shape stability independently of the map size.
  45863. *
  45864. * It does not account for the light projection as it was having too much
  45865. * instability during the light setup or during light position changes.
  45866. *
  45867. * Only valid if useContactHardeningShadow is true.
  45868. */
  45869. get: function () {
  45870. return this._contactHardeningLightSizeUVRatio;
  45871. },
  45872. /**
  45873. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  45874. * Using a ratio helps keeping shape stability independently of the map size.
  45875. *
  45876. * It does not account for the light projection as it was having too much
  45877. * instability during the light setup or during light position changes.
  45878. *
  45879. * Only valid if useContactHardeningShadow is true.
  45880. */
  45881. set: function (contactHardeningLightSizeUVRatio) {
  45882. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  45883. },
  45884. enumerable: true,
  45885. configurable: true
  45886. });
  45887. /**
  45888. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  45889. * 0 means strongest and 1 would means no shadow.
  45890. * @returns the darkness.
  45891. */
  45892. ShadowGenerator.prototype.getDarkness = function () {
  45893. return this._darkness;
  45894. };
  45895. /**
  45896. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  45897. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  45898. * @returns the shadow generator allowing fluent coding.
  45899. */
  45900. ShadowGenerator.prototype.setDarkness = function (darkness) {
  45901. if (darkness >= 1.0) {
  45902. this._darkness = 1.0;
  45903. }
  45904. else if (darkness <= 0.0) {
  45905. this._darkness = 0.0;
  45906. }
  45907. else {
  45908. this._darkness = darkness;
  45909. }
  45910. return this;
  45911. };
  45912. /**
  45913. * Sets the ability to have transparent shadow (boolean).
  45914. * @param transparent True if transparent else False
  45915. * @returns the shadow generator allowing fluent coding
  45916. */
  45917. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  45918. this._transparencyShadow = transparent;
  45919. return this;
  45920. };
  45921. /**
  45922. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  45923. * @returns The render target texture if present otherwise, null
  45924. */
  45925. ShadowGenerator.prototype.getShadowMap = function () {
  45926. return this._shadowMap;
  45927. };
  45928. /**
  45929. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  45930. * @returns The render target texture if the shadow map is present otherwise, null
  45931. */
  45932. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  45933. if (this._shadowMap2) {
  45934. return this._shadowMap2;
  45935. }
  45936. return this._shadowMap;
  45937. };
  45938. /**
  45939. * Helper function to add a mesh and its descendants to the list of shadow casters.
  45940. * @param mesh Mesh to add
  45941. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  45942. * @returns the Shadow Generator itself
  45943. */
  45944. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  45945. if (includeDescendants === void 0) { includeDescendants = true; }
  45946. var _a;
  45947. if (!this._shadowMap) {
  45948. return this;
  45949. }
  45950. if (!this._shadowMap.renderList) {
  45951. this._shadowMap.renderList = [];
  45952. }
  45953. this._shadowMap.renderList.push(mesh);
  45954. if (includeDescendants) {
  45955. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  45956. }
  45957. return this;
  45958. };
  45959. /**
  45960. * Helper function to remove a mesh and its descendants from the list of shadow casters
  45961. * @param mesh Mesh to remove
  45962. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  45963. * @returns the Shadow Generator itself
  45964. */
  45965. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  45966. if (includeDescendants === void 0) { includeDescendants = true; }
  45967. if (!this._shadowMap || !this._shadowMap.renderList) {
  45968. return this;
  45969. }
  45970. var index = this._shadowMap.renderList.indexOf(mesh);
  45971. if (index !== -1) {
  45972. this._shadowMap.renderList.splice(index, 1);
  45973. }
  45974. if (includeDescendants) {
  45975. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  45976. var child = _a[_i];
  45977. this.removeShadowCaster(child);
  45978. }
  45979. }
  45980. return this;
  45981. };
  45982. /**
  45983. * Returns the associated light object.
  45984. * @returns the light generating the shadow
  45985. */
  45986. ShadowGenerator.prototype.getLight = function () {
  45987. return this._light;
  45988. };
  45989. ShadowGenerator.prototype._initializeGenerator = function () {
  45990. this._light._markMeshesAsLightDirty();
  45991. this._initializeShadowMap();
  45992. };
  45993. ShadowGenerator.prototype._initializeShadowMap = function () {
  45994. var _this = this;
  45995. // Render target
  45996. var engine = this._scene.getEngine();
  45997. if (engine.webGLVersion > 1) {
  45998. this._shadowMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap", this._mapSize, this._scene, false, true, this._textureType, this._light.needCube(), undefined, false, false);
  45999. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  46000. }
  46001. else {
  46002. this._shadowMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap", this._mapSize, this._scene, false, true, this._textureType, this._light.needCube());
  46003. }
  46004. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  46005. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  46006. this._shadowMap.anisotropicFilteringLevel = 1;
  46007. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  46008. this._shadowMap.renderParticles = false;
  46009. this._shadowMap.ignoreCameraViewport = true;
  46010. // Record Face Index before render.
  46011. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  46012. _this._currentFaceIndex = faceIndex;
  46013. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  46014. engine.setColorWrite(false);
  46015. }
  46016. });
  46017. // Custom render function.
  46018. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  46019. // Blur if required afer render.
  46020. this._shadowMap.onAfterUnbindObservable.add(function () {
  46021. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  46022. engine.setColorWrite(true);
  46023. }
  46024. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  46025. return;
  46026. }
  46027. var shadowMap = _this.getShadowMapForRendering();
  46028. if (shadowMap) {
  46029. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  46030. }
  46031. });
  46032. // Clear according to the chosen filter.
  46033. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  46034. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  46035. this._shadowMap.onClearObservable.add(function (engine) {
  46036. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  46037. engine.clear(clearOne, false, true, false);
  46038. }
  46039. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  46040. engine.clear(clearZero, true, true, false);
  46041. }
  46042. else {
  46043. engine.clear(clearOne, true, true, false);
  46044. }
  46045. });
  46046. };
  46047. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  46048. var _this = this;
  46049. var engine = this._scene.getEngine();
  46050. var targetSize = this._mapSize / this.blurScale;
  46051. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  46052. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  46053. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  46054. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  46055. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  46056. }
  46057. if (this.useKernelBlur) {
  46058. this._kernelBlurXPostprocess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__["BlurPostProcess"](this._light.name + "KernelBlurX", new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 0), this.blurKernel, 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, this._textureType);
  46059. this._kernelBlurXPostprocess.width = targetSize;
  46060. this._kernelBlurXPostprocess.height = targetSize;
  46061. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  46062. effect.setTexture("textureSampler", _this._shadowMap);
  46063. });
  46064. this._kernelBlurYPostprocess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__["BlurPostProcess"](this._light.name + "KernelBlurY", new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 1), this.blurKernel, 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, this._textureType);
  46065. this._kernelBlurXPostprocess.autoClear = false;
  46066. this._kernelBlurYPostprocess.autoClear = false;
  46067. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  46068. this._kernelBlurXPostprocess.packedFloat = true;
  46069. this._kernelBlurYPostprocess.packedFloat = true;
  46070. }
  46071. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  46072. }
  46073. else {
  46074. this._boxBlurPostprocess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__["PostProcess"](this._light.name + "DepthBoxBlur", "depthBoxBlur", ["screenSize", "boxOffset"], [], 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, "#define OFFSET " + this._blurBoxOffset, this._textureType);
  46075. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  46076. effect.setFloat2("screenSize", targetSize, targetSize);
  46077. effect.setTexture("textureSampler", _this._shadowMap);
  46078. });
  46079. this._boxBlurPostprocess.autoClear = false;
  46080. this._blurPostProcesses = [this._boxBlurPostprocess];
  46081. }
  46082. };
  46083. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  46084. var index;
  46085. var engine = this._scene.getEngine();
  46086. if (depthOnlySubMeshes.length) {
  46087. engine.setColorWrite(false);
  46088. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  46089. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  46090. }
  46091. engine.setColorWrite(true);
  46092. }
  46093. for (index = 0; index < opaqueSubMeshes.length; index++) {
  46094. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  46095. }
  46096. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  46097. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  46098. }
  46099. if (this._transparencyShadow) {
  46100. for (index = 0; index < transparentSubMeshes.length; index++) {
  46101. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  46102. }
  46103. }
  46104. };
  46105. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  46106. var _this = this;
  46107. var mesh = subMesh.getRenderingMesh();
  46108. var scene = this._scene;
  46109. var engine = scene.getEngine();
  46110. var material = subMesh.getMaterial();
  46111. if (!material || subMesh.verticesCount === 0) {
  46112. return;
  46113. }
  46114. // Culling
  46115. engine.setState(material.backFaceCulling);
  46116. // Managing instances
  46117. var batch = mesh._getInstancesRenderList(subMesh._id);
  46118. if (batch.mustReturn) {
  46119. return;
  46120. }
  46121. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  46122. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  46123. engine.enableEffect(this._effect);
  46124. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  46125. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  46126. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  46127. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  46128. this._effect.setVector3("lightData", this._cachedDirection);
  46129. }
  46130. else {
  46131. this._effect.setVector3("lightData", this._cachedPosition);
  46132. }
  46133. if (scene.activeCamera) {
  46134. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  46135. }
  46136. // Alpha test
  46137. if (material && material.needAlphaTesting()) {
  46138. var alphaTexture = material.getAlphaTestTexture();
  46139. if (alphaTexture) {
  46140. this._effect.setTexture("diffuseSampler", alphaTexture);
  46141. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  46142. }
  46143. }
  46144. // Bones
  46145. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  46146. var skeleton = mesh.skeleton;
  46147. if (skeleton.isUsingTextureForMatrices) {
  46148. var boneTexture = skeleton.getTransformMatrixTexture();
  46149. if (!boneTexture) {
  46150. return;
  46151. }
  46152. this._effect.setTexture("boneSampler", boneTexture);
  46153. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  46154. }
  46155. else {
  46156. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  46157. }
  46158. }
  46159. // Morph targets
  46160. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  46161. if (this.forceBackFacesOnly) {
  46162. engine.setState(true, 0, false, true);
  46163. }
  46164. // Observables
  46165. this.onBeforeShadowMapRenderMeshObservable.notifyObservers(mesh);
  46166. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  46167. // Draw
  46168. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  46169. if (this.forceBackFacesOnly) {
  46170. engine.setState(true, 0, false, false);
  46171. }
  46172. }
  46173. else {
  46174. // Need to reset refresh rate of the shadowMap
  46175. if (this._shadowMap) {
  46176. this._shadowMap.resetRefreshCounter();
  46177. }
  46178. }
  46179. };
  46180. ShadowGenerator.prototype._applyFilterValues = function () {
  46181. if (!this._shadowMap) {
  46182. return;
  46183. }
  46184. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  46185. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  46186. }
  46187. else {
  46188. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  46189. }
  46190. };
  46191. /**
  46192. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  46193. * @param onCompiled Callback triggered at the and of the effects compilation
  46194. * @param options Sets of optional options forcing the compilation with different modes
  46195. */
  46196. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  46197. var _this = this;
  46198. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  46199. var shadowMap = this.getShadowMap();
  46200. if (!shadowMap) {
  46201. if (onCompiled) {
  46202. onCompiled(this);
  46203. }
  46204. return;
  46205. }
  46206. var renderList = shadowMap.renderList;
  46207. if (!renderList) {
  46208. if (onCompiled) {
  46209. onCompiled(this);
  46210. }
  46211. return;
  46212. }
  46213. var subMeshes = new Array();
  46214. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  46215. var mesh = renderList_1[_i];
  46216. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  46217. }
  46218. if (subMeshes.length === 0) {
  46219. if (onCompiled) {
  46220. onCompiled(this);
  46221. }
  46222. return;
  46223. }
  46224. var currentIndex = 0;
  46225. var checkReady = function () {
  46226. if (!_this._scene || !_this._scene.getEngine()) {
  46227. return;
  46228. }
  46229. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  46230. currentIndex++;
  46231. if (currentIndex >= subMeshes.length) {
  46232. if (onCompiled) {
  46233. onCompiled(_this);
  46234. }
  46235. return;
  46236. }
  46237. }
  46238. setTimeout(checkReady, 16);
  46239. };
  46240. checkReady();
  46241. };
  46242. /**
  46243. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  46244. * @param options Sets of optional options forcing the compilation with different modes
  46245. * @returns A promise that resolves when the compilation completes
  46246. */
  46247. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  46248. var _this = this;
  46249. return new Promise(function (resolve) {
  46250. _this.forceCompilation(function () {
  46251. resolve();
  46252. }, options);
  46253. });
  46254. };
  46255. /**
  46256. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  46257. * @param subMesh The submesh we want to render in the shadow map
  46258. * @param useInstances Defines wether will draw in the map using instances
  46259. * @returns true if ready otherwise, false
  46260. */
  46261. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  46262. var defines = [];
  46263. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  46264. defines.push("#define FLOAT");
  46265. }
  46266. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  46267. defines.push("#define ESM");
  46268. }
  46269. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  46270. defines.push("#define DEPTHTEXTURE");
  46271. }
  46272. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  46273. var mesh = subMesh.getMesh();
  46274. var material = subMesh.getMaterial();
  46275. // Normal bias.
  46276. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  46277. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  46278. defines.push("#define NORMAL");
  46279. if (mesh.nonUniformScaling) {
  46280. defines.push("#define NONUNIFORMSCALING");
  46281. }
  46282. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  46283. defines.push("#define DIRECTIONINLIGHTDATA");
  46284. }
  46285. }
  46286. // Alpha test
  46287. if (material && material.needAlphaTesting()) {
  46288. var alphaTexture = material.getAlphaTestTexture();
  46289. if (alphaTexture) {
  46290. defines.push("#define ALPHATEST");
  46291. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  46292. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  46293. defines.push("#define UV1");
  46294. }
  46295. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  46296. if (alphaTexture.coordinatesIndex === 1) {
  46297. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  46298. defines.push("#define UV2");
  46299. }
  46300. }
  46301. }
  46302. }
  46303. // Bones
  46304. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  46305. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  46306. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  46307. if (mesh.numBoneInfluencers > 4) {
  46308. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  46309. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  46310. }
  46311. var skeleton = mesh.skeleton;
  46312. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  46313. if (skeleton.isUsingTextureForMatrices) {
  46314. defines.push("#define BONETEXTURE");
  46315. }
  46316. else {
  46317. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  46318. }
  46319. }
  46320. else {
  46321. defines.push("#define NUM_BONE_INFLUENCERS 0");
  46322. }
  46323. // Morph targets
  46324. var manager = mesh.morphTargetManager;
  46325. var morphInfluencers = 0;
  46326. if (manager) {
  46327. if (manager.numInfluencers > 0) {
  46328. defines.push("#define MORPHTARGETS");
  46329. morphInfluencers = manager.numInfluencers;
  46330. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  46331. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  46332. }
  46333. }
  46334. // Instances
  46335. if (useInstances) {
  46336. defines.push("#define INSTANCES");
  46337. attribs.push("world0");
  46338. attribs.push("world1");
  46339. attribs.push("world2");
  46340. attribs.push("world3");
  46341. }
  46342. if (this.customShaderOptions) {
  46343. if (this.customShaderOptions.defines) {
  46344. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  46345. var define = _a[_i];
  46346. if (defines.indexOf(define) === -1) {
  46347. defines.push(define);
  46348. }
  46349. }
  46350. }
  46351. }
  46352. // Get correct effect
  46353. var join = defines.join("\n");
  46354. if (this._cachedDefines !== join) {
  46355. this._cachedDefines = join;
  46356. var shaderName = "shadowMap";
  46357. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  46358. var samplers = ["diffuseSampler", "boneSampler"];
  46359. // Custom shader?
  46360. if (this.customShaderOptions) {
  46361. shaderName = this.customShaderOptions.shaderName;
  46362. if (this.customShaderOptions.attributes) {
  46363. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  46364. var attrib = _c[_b];
  46365. if (attribs.indexOf(attrib) === -1) {
  46366. attribs.push(attrib);
  46367. }
  46368. }
  46369. }
  46370. if (this.customShaderOptions.uniforms) {
  46371. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  46372. var uniform = _e[_d];
  46373. if (uniforms.indexOf(uniform) === -1) {
  46374. uniforms.push(uniform);
  46375. }
  46376. }
  46377. }
  46378. if (this.customShaderOptions.samplers) {
  46379. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  46380. var sampler = _g[_f];
  46381. if (samplers.indexOf(sampler) === -1) {
  46382. samplers.push(sampler);
  46383. }
  46384. }
  46385. }
  46386. }
  46387. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  46388. }
  46389. if (!this._effect.isReady()) {
  46390. return false;
  46391. }
  46392. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  46393. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  46394. this._initializeBlurRTTAndPostProcesses();
  46395. }
  46396. }
  46397. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  46398. return false;
  46399. }
  46400. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  46401. return false;
  46402. }
  46403. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  46404. return false;
  46405. }
  46406. return true;
  46407. };
  46408. /**
  46409. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  46410. * @param defines Defines of the material we want to update
  46411. * @param lightIndex Index of the light in the enabled light list of the material
  46412. */
  46413. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  46414. var scene = this._scene;
  46415. var light = this._light;
  46416. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  46417. return;
  46418. }
  46419. defines["SHADOW" + lightIndex] = true;
  46420. if (this.useContactHardeningShadow) {
  46421. defines["SHADOWPCSS" + lightIndex] = true;
  46422. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  46423. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  46424. }
  46425. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  46426. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  46427. }
  46428. // else default to high.
  46429. }
  46430. if (this.usePercentageCloserFiltering) {
  46431. defines["SHADOWPCF" + lightIndex] = true;
  46432. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  46433. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  46434. }
  46435. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  46436. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  46437. }
  46438. // else default to high.
  46439. }
  46440. else if (this.usePoissonSampling) {
  46441. defines["SHADOWPOISSON" + lightIndex] = true;
  46442. }
  46443. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  46444. defines["SHADOWESM" + lightIndex] = true;
  46445. }
  46446. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  46447. defines["SHADOWCLOSEESM" + lightIndex] = true;
  46448. }
  46449. if (light.needCube()) {
  46450. defines["SHADOWCUBE" + lightIndex] = true;
  46451. }
  46452. };
  46453. /**
  46454. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  46455. * defined in the generator but impacting the effect).
  46456. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  46457. * @param effect The effect we are binfing the information for
  46458. */
  46459. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  46460. var light = this._light;
  46461. var scene = this._scene;
  46462. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  46463. return;
  46464. }
  46465. var camera = scene.activeCamera;
  46466. if (!camera) {
  46467. return;
  46468. }
  46469. var shadowMap = this.getShadowMap();
  46470. if (!shadowMap) {
  46471. return;
  46472. }
  46473. if (!light.needCube()) {
  46474. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  46475. }
  46476. // Only PCF uses depth stencil texture.
  46477. if (this._filter === ShadowGenerator.FILTER_PCF) {
  46478. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46479. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  46480. }
  46481. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  46482. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46483. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  46484. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  46485. }
  46486. else {
  46487. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46488. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  46489. }
  46490. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  46491. };
  46492. /**
  46493. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  46494. * (eq to shadow prjection matrix * light transform matrix)
  46495. * @returns The transform matrix used to create the shadow map
  46496. */
  46497. ShadowGenerator.prototype.getTransformMatrix = function () {
  46498. var scene = this._scene;
  46499. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  46500. return this._transformMatrix;
  46501. }
  46502. this._currentRenderID = scene.getRenderId();
  46503. this._currentFaceIndexCache = this._currentFaceIndex;
  46504. var lightPosition = this._light.position;
  46505. if (this._light.computeTransformedInformation()) {
  46506. lightPosition = this._light.transformedPosition;
  46507. }
  46508. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  46509. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  46510. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  46511. }
  46512. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  46513. this._cachedPosition.copyFrom(lightPosition);
  46514. this._cachedDirection.copyFrom(this._lightDirection);
  46515. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  46516. var shadowMap = this.getShadowMap();
  46517. if (shadowMap) {
  46518. var renderList = shadowMap.renderList;
  46519. if (renderList) {
  46520. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  46521. }
  46522. }
  46523. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  46524. }
  46525. return this._transformMatrix;
  46526. };
  46527. /**
  46528. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  46529. * Cube and 2D textures for instance.
  46530. */
  46531. ShadowGenerator.prototype.recreateShadowMap = function () {
  46532. var shadowMap = this._shadowMap;
  46533. if (!shadowMap) {
  46534. return;
  46535. }
  46536. // Track render list.
  46537. var renderList = shadowMap.renderList;
  46538. // Clean up existing data.
  46539. this._disposeRTTandPostProcesses();
  46540. // Reinitializes.
  46541. this._initializeGenerator();
  46542. // Reaffect the filter to ensure a correct fallback if necessary.
  46543. this.filter = this.filter;
  46544. // Reaffect the filter.
  46545. this._applyFilterValues();
  46546. // Reaffect Render List.
  46547. this._shadowMap.renderList = renderList;
  46548. };
  46549. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  46550. if (this._shadowMap2) {
  46551. this._shadowMap2.dispose();
  46552. this._shadowMap2 = null;
  46553. }
  46554. if (this._boxBlurPostprocess) {
  46555. this._boxBlurPostprocess.dispose();
  46556. this._boxBlurPostprocess = null;
  46557. }
  46558. if (this._kernelBlurXPostprocess) {
  46559. this._kernelBlurXPostprocess.dispose();
  46560. this._kernelBlurXPostprocess = null;
  46561. }
  46562. if (this._kernelBlurYPostprocess) {
  46563. this._kernelBlurYPostprocess.dispose();
  46564. this._kernelBlurYPostprocess = null;
  46565. }
  46566. this._blurPostProcesses = [];
  46567. };
  46568. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  46569. if (this._shadowMap) {
  46570. this._shadowMap.dispose();
  46571. this._shadowMap = null;
  46572. }
  46573. this._disposeBlurPostProcesses();
  46574. };
  46575. /**
  46576. * Disposes the ShadowGenerator.
  46577. * Returns nothing.
  46578. */
  46579. ShadowGenerator.prototype.dispose = function () {
  46580. this._disposeRTTandPostProcesses();
  46581. if (this._light) {
  46582. this._light._shadowGenerator = null;
  46583. this._light._markMeshesAsLightDirty();
  46584. }
  46585. };
  46586. /**
  46587. * Serializes the shadow generator setup to a json object.
  46588. * @returns The serialized JSON object
  46589. */
  46590. ShadowGenerator.prototype.serialize = function () {
  46591. var serializationObject = {};
  46592. var shadowMap = this.getShadowMap();
  46593. if (!shadowMap) {
  46594. return serializationObject;
  46595. }
  46596. serializationObject.lightId = this._light.id;
  46597. serializationObject.mapSize = shadowMap.getRenderSize();
  46598. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  46599. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  46600. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  46601. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  46602. serializationObject.usePoissonSampling = this.usePoissonSampling;
  46603. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  46604. serializationObject.depthScale = this.depthScale;
  46605. serializationObject.darkness = this.getDarkness();
  46606. serializationObject.blurBoxOffset = this.blurBoxOffset;
  46607. serializationObject.blurKernel = this.blurKernel;
  46608. serializationObject.blurScale = this.blurScale;
  46609. serializationObject.useKernelBlur = this.useKernelBlur;
  46610. serializationObject.transparencyShadow = this._transparencyShadow;
  46611. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  46612. serializationObject.bias = this.bias;
  46613. serializationObject.normalBias = this.normalBias;
  46614. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  46615. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  46616. serializationObject.filteringQuality = this.filteringQuality;
  46617. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  46618. serializationObject.renderList = [];
  46619. if (shadowMap.renderList) {
  46620. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  46621. var mesh = shadowMap.renderList[meshIndex];
  46622. serializationObject.renderList.push(mesh.id);
  46623. }
  46624. }
  46625. return serializationObject;
  46626. };
  46627. /**
  46628. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  46629. * @param parsedShadowGenerator The JSON object to parse
  46630. * @param scene The scene to create the shadow map for
  46631. * @returns The parsed shadow generator
  46632. */
  46633. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  46634. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  46635. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  46636. var shadowMap = shadowGenerator.getShadowMap();
  46637. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  46638. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  46639. meshes.forEach(function (mesh) {
  46640. if (!shadowMap) {
  46641. return;
  46642. }
  46643. if (!shadowMap.renderList) {
  46644. shadowMap.renderList = [];
  46645. }
  46646. shadowMap.renderList.push(mesh);
  46647. });
  46648. }
  46649. if (parsedShadowGenerator.usePoissonSampling) {
  46650. shadowGenerator.usePoissonSampling = true;
  46651. }
  46652. else if (parsedShadowGenerator.useExponentialShadowMap) {
  46653. shadowGenerator.useExponentialShadowMap = true;
  46654. }
  46655. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  46656. shadowGenerator.useBlurExponentialShadowMap = true;
  46657. }
  46658. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  46659. shadowGenerator.useCloseExponentialShadowMap = true;
  46660. }
  46661. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  46662. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  46663. }
  46664. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  46665. shadowGenerator.usePercentageCloserFiltering = true;
  46666. }
  46667. else if (parsedShadowGenerator.useContactHardeningShadow) {
  46668. shadowGenerator.useContactHardeningShadow = true;
  46669. }
  46670. if (parsedShadowGenerator.filteringQuality) {
  46671. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  46672. }
  46673. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  46674. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  46675. }
  46676. // Backward compat
  46677. else if (parsedShadowGenerator.useVarianceShadowMap) {
  46678. shadowGenerator.useExponentialShadowMap = true;
  46679. }
  46680. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  46681. shadowGenerator.useBlurExponentialShadowMap = true;
  46682. }
  46683. if (parsedShadowGenerator.depthScale) {
  46684. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  46685. }
  46686. if (parsedShadowGenerator.blurScale) {
  46687. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  46688. }
  46689. if (parsedShadowGenerator.blurBoxOffset) {
  46690. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  46691. }
  46692. if (parsedShadowGenerator.useKernelBlur) {
  46693. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  46694. }
  46695. if (parsedShadowGenerator.blurKernel) {
  46696. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  46697. }
  46698. if (parsedShadowGenerator.bias !== undefined) {
  46699. shadowGenerator.bias = parsedShadowGenerator.bias;
  46700. }
  46701. if (parsedShadowGenerator.normalBias !== undefined) {
  46702. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  46703. }
  46704. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  46705. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  46706. }
  46707. if (parsedShadowGenerator.darkness) {
  46708. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  46709. }
  46710. if (parsedShadowGenerator.transparencyShadow) {
  46711. shadowGenerator.setTransparencyShadow(true);
  46712. }
  46713. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  46714. return shadowGenerator;
  46715. };
  46716. /**
  46717. * Shadow generator mode None: no filtering applied.
  46718. */
  46719. ShadowGenerator.FILTER_NONE = 0;
  46720. /**
  46721. * Shadow generator mode ESM: Exponential Shadow Mapping.
  46722. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46723. */
  46724. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  46725. /**
  46726. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  46727. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  46728. */
  46729. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  46730. /**
  46731. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  46732. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46733. */
  46734. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  46735. /**
  46736. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  46737. * edge artifacts on steep falloff.
  46738. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46739. */
  46740. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  46741. /**
  46742. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  46743. * edge artifacts on steep falloff.
  46744. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46745. */
  46746. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  46747. /**
  46748. * Shadow generator mode PCF: Percentage Closer Filtering
  46749. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  46750. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  46751. */
  46752. ShadowGenerator.FILTER_PCF = 6;
  46753. /**
  46754. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  46755. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  46756. * Contact Hardening
  46757. */
  46758. ShadowGenerator.FILTER_PCSS = 7;
  46759. /**
  46760. * Reserved for PCF and PCSS
  46761. * Highest Quality.
  46762. *
  46763. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  46764. *
  46765. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  46766. */
  46767. ShadowGenerator.QUALITY_HIGH = 0;
  46768. /**
  46769. * Reserved for PCF and PCSS
  46770. * Good tradeoff for quality/perf cross devices
  46771. *
  46772. * Execute PCF on a 3*3 kernel.
  46773. *
  46774. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  46775. */
  46776. ShadowGenerator.QUALITY_MEDIUM = 1;
  46777. /**
  46778. * Reserved for PCF and PCSS
  46779. * The lowest quality but the fastest.
  46780. *
  46781. * Execute PCF on a 1*1 kernel.
  46782. *
  46783. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  46784. */
  46785. ShadowGenerator.QUALITY_LOW = 2;
  46786. /** @hidden */
  46787. ShadowGenerator._SceneComponentInitialization = function (_) {
  46788. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__["_DevTools"].WarnImport("ShadowGeneratorSceneComponent");
  46789. };
  46790. return ShadowGenerator;
  46791. }());
  46792. /***/ }),
  46793. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  46794. /*!*********************************************************!*\
  46795. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  46796. \*********************************************************/
  46797. /*! exports provided: ShadowGeneratorSceneComponent */
  46798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46799. "use strict";
  46800. __webpack_require__.r(__webpack_exports__);
  46801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  46802. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  46803. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  46804. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  46805. // Adds the parser to the scene parsers.
  46806. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  46807. // Shadows
  46808. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  46809. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  46810. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  46811. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  46812. // SG would be available on their associated lights
  46813. }
  46814. }
  46815. });
  46816. /**
  46817. * Defines the shadow generator component responsible to manage any shadow generators
  46818. * in a given scene.
  46819. */
  46820. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  46821. /**
  46822. * Creates a new instance of the component for the given scene
  46823. * @param scene Defines the scene to register the component in
  46824. */
  46825. function ShadowGeneratorSceneComponent(scene) {
  46826. /**
  46827. * The component name helpfull to identify the component in the list of scene components.
  46828. */
  46829. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  46830. this.scene = scene;
  46831. }
  46832. /**
  46833. * Registers the component in a given scene
  46834. */
  46835. ShadowGeneratorSceneComponent.prototype.register = function () {
  46836. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  46837. };
  46838. /**
  46839. * Rebuilds the elements related to this component in case of
  46840. * context lost for instance.
  46841. */
  46842. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  46843. // Nothing To Do Here.
  46844. };
  46845. /**
  46846. * Serializes the component data to the specified json object
  46847. * @param serializationObject The object to serialize to
  46848. */
  46849. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  46850. // Shadows
  46851. serializationObject.shadowGenerators = [];
  46852. var lights = this.scene.lights;
  46853. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  46854. var light = lights_1[_i];
  46855. var shadowGenerator = light.getShadowGenerator();
  46856. if (shadowGenerator) {
  46857. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  46858. }
  46859. }
  46860. };
  46861. /**
  46862. * Adds all the element from the container to the scene
  46863. * @param container the container holding the elements
  46864. */
  46865. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  46866. // Nothing To Do Here. (directly attached to a light)
  46867. };
  46868. /**
  46869. * Removes all the elements in the container from the scene
  46870. * @param container contains the elements to remove
  46871. * @param dispose if the removed element should be disposed (default: false)
  46872. */
  46873. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  46874. // Nothing To Do Here. (directly attached to a light)
  46875. };
  46876. /**
  46877. * Rebuilds the elements related to this component in case of
  46878. * context lost for instance.
  46879. */
  46880. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  46881. // Nothing To Do Here.
  46882. };
  46883. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  46884. // Shadows
  46885. var scene = this.scene;
  46886. if (this.scene.shadowsEnabled) {
  46887. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  46888. var light = scene.lights[lightIndex];
  46889. var shadowGenerator = light.getShadowGenerator();
  46890. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  46891. var shadowMap = (shadowGenerator.getShadowMap());
  46892. if (scene.textures.indexOf(shadowMap) !== -1) {
  46893. renderTargets.push(shadowMap);
  46894. }
  46895. }
  46896. }
  46897. }
  46898. };
  46899. return ShadowGeneratorSceneComponent;
  46900. }());
  46901. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  46902. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  46903. if (!component) {
  46904. component = new ShadowGeneratorSceneComponent(scene);
  46905. scene._addComponent(component);
  46906. }
  46907. };
  46908. /***/ }),
  46909. /***/ "./Lights/directionalLight.ts":
  46910. /*!************************************!*\
  46911. !*** ./Lights/directionalLight.ts ***!
  46912. \************************************/
  46913. /*! exports provided: DirectionalLight */
  46914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46915. "use strict";
  46916. __webpack_require__.r(__webpack_exports__);
  46917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  46918. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46919. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46920. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46921. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46922. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46923. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46924. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  46925. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46926. });
  46927. /**
  46928. * A directional light is defined by a direction (what a surprise!).
  46929. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46930. * An example of a directional light is when a distance planet is lit by the apparently parallel lines of light from its sun. Light in a downward direction will light the top of an object.
  46931. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46932. */
  46933. var DirectionalLight = /** @class */ (function (_super) {
  46934. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  46935. /**
  46936. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46937. * The directional light is emitted from everywhere in the given direction.
  46938. * It can cast shadows.
  46939. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46940. * @param name The friendly name of the light
  46941. * @param direction The direction of the light
  46942. * @param scene The scene the light belongs to
  46943. */
  46944. function DirectionalLight(name, direction, scene) {
  46945. var _this = _super.call(this, name, scene) || this;
  46946. _this._shadowFrustumSize = 0;
  46947. _this._shadowOrthoScale = 0.1;
  46948. /**
  46949. * Automatically compute the projection matrix to best fit (including all the casters)
  46950. * on each frame.
  46951. */
  46952. _this.autoUpdateExtends = true;
  46953. // Cache
  46954. _this._orthoLeft = Number.MAX_VALUE;
  46955. _this._orthoRight = Number.MIN_VALUE;
  46956. _this._orthoTop = Number.MIN_VALUE;
  46957. _this._orthoBottom = Number.MAX_VALUE;
  46958. _this.position = direction.scale(-1.0);
  46959. _this.direction = direction;
  46960. return _this;
  46961. }
  46962. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  46963. /**
  46964. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46965. */
  46966. get: function () {
  46967. return this._shadowFrustumSize;
  46968. },
  46969. /**
  46970. * Specifies a fix frustum size for the shadow generation.
  46971. */
  46972. set: function (value) {
  46973. this._shadowFrustumSize = value;
  46974. this.forceProjectionMatrixCompute();
  46975. },
  46976. enumerable: true,
  46977. configurable: true
  46978. });
  46979. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  46980. /**
  46981. * Gets the shadow projection scale against the optimal computed one.
  46982. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46983. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46984. */
  46985. get: function () {
  46986. return this._shadowOrthoScale;
  46987. },
  46988. /**
  46989. * Sets the shadow projection scale against the optimal computed one.
  46990. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46991. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46992. */
  46993. set: function (value) {
  46994. this._shadowOrthoScale = value;
  46995. this.forceProjectionMatrixCompute();
  46996. },
  46997. enumerable: true,
  46998. configurable: true
  46999. });
  47000. /**
  47001. * Returns the string "DirectionalLight".
  47002. * @return The class name
  47003. */
  47004. DirectionalLight.prototype.getClassName = function () {
  47005. return "DirectionalLight";
  47006. };
  47007. /**
  47008. * Returns the integer 1.
  47009. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47010. */
  47011. DirectionalLight.prototype.getTypeID = function () {
  47012. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  47013. };
  47014. /**
  47015. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47016. * Returns the DirectionalLight Shadow projection matrix.
  47017. */
  47018. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47019. if (this.shadowFrustumSize > 0) {
  47020. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  47021. }
  47022. else {
  47023. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  47024. }
  47025. };
  47026. /**
  47027. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47028. * Returns the DirectionalLight Shadow projection matrix.
  47029. */
  47030. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  47031. var activeCamera = this.getScene().activeCamera;
  47032. if (!activeCamera) {
  47033. return;
  47034. }
  47035. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].OrthoLHToRef(this.shadowFrustumSize, this.shadowFrustumSize, this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ, this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ, matrix);
  47036. };
  47037. /**
  47038. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47039. * Returns the DirectionalLight Shadow projection matrix.
  47040. */
  47041. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47042. var activeCamera = this.getScene().activeCamera;
  47043. if (!activeCamera) {
  47044. return;
  47045. }
  47046. // Check extends
  47047. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  47048. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47049. this._orthoLeft = Number.MAX_VALUE;
  47050. this._orthoRight = Number.MIN_VALUE;
  47051. this._orthoTop = Number.MIN_VALUE;
  47052. this._orthoBottom = Number.MAX_VALUE;
  47053. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  47054. var mesh = renderList[meshIndex];
  47055. if (!mesh) {
  47056. continue;
  47057. }
  47058. var boundingInfo = mesh.getBoundingInfo();
  47059. var boundingBox = boundingInfo.boundingBox;
  47060. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  47061. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  47062. if (tempVector3.x < this._orthoLeft) {
  47063. this._orthoLeft = tempVector3.x;
  47064. }
  47065. if (tempVector3.y < this._orthoBottom) {
  47066. this._orthoBottom = tempVector3.y;
  47067. }
  47068. if (tempVector3.x > this._orthoRight) {
  47069. this._orthoRight = tempVector3.x;
  47070. }
  47071. if (tempVector3.y > this._orthoTop) {
  47072. this._orthoTop = tempVector3.y;
  47073. }
  47074. }
  47075. }
  47076. }
  47077. var xOffset = this._orthoRight - this._orthoLeft;
  47078. var yOffset = this._orthoTop - this._orthoBottom;
  47079. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].OrthoOffCenterLHToRef(this._orthoLeft - xOffset * this.shadowOrthoScale, this._orthoRight + xOffset * this.shadowOrthoScale, this._orthoBottom - yOffset * this.shadowOrthoScale, this._orthoTop + yOffset * this.shadowOrthoScale, this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ, this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ, matrix);
  47080. };
  47081. DirectionalLight.prototype._buildUniformLayout = function () {
  47082. this._uniformBuffer.addUniform("vLightData", 4);
  47083. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47084. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47085. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47086. this._uniformBuffer.addUniform("depthValues", 2);
  47087. this._uniformBuffer.create();
  47088. };
  47089. /**
  47090. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47091. * @param effect The effect to update
  47092. * @param lightIndex The index of the light in the effect to update
  47093. * @returns The directional light
  47094. */
  47095. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  47096. if (this.computeTransformedInformation()) {
  47097. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  47098. return this;
  47099. }
  47100. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  47101. return this;
  47102. };
  47103. /**
  47104. * Gets the minZ used for shadow according to both the scene and the light.
  47105. *
  47106. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47107. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47108. * @param activeCamera The camera we are returning the min for
  47109. * @returns the depth min z
  47110. */
  47111. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  47112. return 1;
  47113. };
  47114. /**
  47115. * Gets the maxZ used for shadow according to both the scene and the light.
  47116. *
  47117. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47118. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47119. * @param activeCamera The camera we are returning the max for
  47120. * @returns the depth max z
  47121. */
  47122. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  47123. return 1;
  47124. };
  47125. /**
  47126. * Prepares the list of defines specific to the light type.
  47127. * @param defines the list of defines
  47128. * @param lightIndex defines the index of the light for the effect
  47129. */
  47130. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47131. defines["DIRLIGHT" + lightIndex] = true;
  47132. };
  47133. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47134. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47135. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  47136. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47137. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47138. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  47139. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47140. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47141. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  47142. return DirectionalLight;
  47143. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47144. /***/ }),
  47145. /***/ "./Lights/hemisphericLight.ts":
  47146. /*!************************************!*\
  47147. !*** ./Lights/hemisphericLight.ts ***!
  47148. \************************************/
  47149. /*! exports provided: HemisphericLight */
  47150. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47151. "use strict";
  47152. __webpack_require__.r(__webpack_exports__);
  47153. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  47154. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47155. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47156. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47157. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47158. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47159. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  47160. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  47161. });
  47162. /**
  47163. * The HemisphericLight simulates the ambient environment light,
  47164. * so the passed direction is the light reflection direction, not the incoming direction.
  47165. */
  47166. var HemisphericLight = /** @class */ (function (_super) {
  47167. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  47168. /**
  47169. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  47170. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  47171. * The HemisphericLight can't cast shadows.
  47172. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47173. * @param name The friendly name of the light
  47174. * @param direction The direction of the light reflection
  47175. * @param scene The scene the light belongs to
  47176. */
  47177. function HemisphericLight(name, direction, scene) {
  47178. var _this = _super.call(this, name, scene) || this;
  47179. /**
  47180. * The groundColor is the light in the opposite direction to the one specified during creation.
  47181. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  47182. */
  47183. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  47184. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  47185. return _this;
  47186. }
  47187. HemisphericLight.prototype._buildUniformLayout = function () {
  47188. this._uniformBuffer.addUniform("vLightData", 4);
  47189. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47190. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47191. this._uniformBuffer.addUniform("vLightGround", 3);
  47192. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47193. this._uniformBuffer.addUniform("depthValues", 2);
  47194. this._uniformBuffer.create();
  47195. };
  47196. /**
  47197. * Returns the string "HemisphericLight".
  47198. * @return The class name
  47199. */
  47200. HemisphericLight.prototype.getClassName = function () {
  47201. return "HemisphericLight";
  47202. };
  47203. /**
  47204. * Sets the HemisphericLight direction towards the passed target (Vector3).
  47205. * Returns the updated direction.
  47206. * @param target The target the direction should point to
  47207. * @return The computed direction
  47208. */
  47209. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  47210. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  47211. return this.direction;
  47212. };
  47213. /**
  47214. * Returns the shadow generator associated to the light.
  47215. * @returns Always null for hemispheric lights because it does not support shadows.
  47216. */
  47217. HemisphericLight.prototype.getShadowGenerator = function () {
  47218. return null;
  47219. };
  47220. /**
  47221. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  47222. * @param effect The effect to update
  47223. * @param lightIndex The index of the light in the effect to update
  47224. * @returns The hemispheric light
  47225. */
  47226. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  47227. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  47228. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  47229. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  47230. return this;
  47231. };
  47232. /**
  47233. * Computes the world matrix of the node
  47234. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  47235. * @param useWasUpdatedFlag defines a reserved property
  47236. * @returns the world matrix
  47237. */
  47238. HemisphericLight.prototype.computeWorldMatrix = function () {
  47239. if (!this._worldMatrix) {
  47240. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  47241. }
  47242. return this._worldMatrix;
  47243. };
  47244. /**
  47245. * Returns the integer 3.
  47246. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47247. */
  47248. HemisphericLight.prototype.getTypeID = function () {
  47249. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  47250. };
  47251. /**
  47252. * Prepares the list of defines specific to the light type.
  47253. * @param defines the list of defines
  47254. * @param lightIndex defines the index of the light for the effect
  47255. */
  47256. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47257. defines["HEMILIGHT" + lightIndex] = true;
  47258. };
  47259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47261. ], HemisphericLight.prototype, "groundColor", void 0);
  47262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47264. ], HemisphericLight.prototype, "direction", void 0);
  47265. return HemisphericLight;
  47266. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  47267. /***/ }),
  47268. /***/ "./Lights/index.ts":
  47269. /*!*************************!*\
  47270. !*** ./Lights/index.ts ***!
  47271. \*************************/
  47272. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  47273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47274. "use strict";
  47275. __webpack_require__.r(__webpack_exports__);
  47276. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  47278. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  47280. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  47281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  47282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  47283. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  47284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  47285. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  47286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  47287. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  47288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  47289. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  47290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  47291. /***/ }),
  47292. /***/ "./Lights/light.ts":
  47293. /*!*************************!*\
  47294. !*** ./Lights/light.ts ***!
  47295. \*************************/
  47296. /*! exports provided: Light */
  47297. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47298. "use strict";
  47299. __webpack_require__.r(__webpack_exports__);
  47300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  47301. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47302. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47303. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47304. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47305. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  47306. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  47307. /**
  47308. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  47309. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  47310. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  47311. */
  47312. var Light = /** @class */ (function (_super) {
  47313. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  47314. /**
  47315. * Creates a Light object in the scene.
  47316. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47317. * @param name The firendly name of the light
  47318. * @param scene The scene the light belongs too
  47319. */
  47320. function Light(name, scene) {
  47321. var _this = _super.call(this, name, scene) || this;
  47322. /**
  47323. * Diffuse gives the basic color to an object.
  47324. */
  47325. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  47326. /**
  47327. * Specular produces a highlight color on an object.
  47328. * Note: This is note affecting PBR materials.
  47329. */
  47330. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  47331. /**
  47332. * Defines the falloff type for this light. This lets overrriding how punctual light are
  47333. * falling off base on range or angle.
  47334. * This can be set to any values in Light.FALLOFF_x.
  47335. *
  47336. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  47337. * other types of materials.
  47338. */
  47339. _this.falloffType = Light.FALLOFF_DEFAULT;
  47340. /**
  47341. * Strength of the light.
  47342. * Note: By default it is define in the framework own unit.
  47343. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  47344. */
  47345. _this.intensity = 1.0;
  47346. _this._range = Number.MAX_VALUE;
  47347. _this._inverseSquaredRange = 0;
  47348. /**
  47349. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  47350. * of light.
  47351. */
  47352. _this._photometricScale = 1.0;
  47353. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  47354. _this._radius = 0.00001;
  47355. /**
  47356. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  47357. * exceeding the number allowed of the materials.
  47358. */
  47359. _this.renderPriority = 0;
  47360. _this._shadowEnabled = true;
  47361. _this._excludeWithLayerMask = 0;
  47362. _this._includeOnlyWithLayerMask = 0;
  47363. _this._lightmapMode = 0;
  47364. /**
  47365. * @hidden Internal use only.
  47366. */
  47367. _this._excludedMeshesIds = new Array();
  47368. /**
  47369. * @hidden Internal use only.
  47370. */
  47371. _this._includedOnlyMeshesIds = new Array();
  47372. /** @hidden */
  47373. _this._isLight = true;
  47374. _this.getScene().addLight(_this);
  47375. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  47376. _this._buildUniformLayout();
  47377. _this.includedOnlyMeshes = new Array();
  47378. _this.excludedMeshes = new Array();
  47379. _this._resyncMeshes();
  47380. return _this;
  47381. }
  47382. Object.defineProperty(Light.prototype, "range", {
  47383. /**
  47384. * Defines how far from the source the light is impacting in scene units.
  47385. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  47386. */
  47387. get: function () {
  47388. return this._range;
  47389. },
  47390. /**
  47391. * Defines how far from the source the light is impacting in scene units.
  47392. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  47393. */
  47394. set: function (value) {
  47395. this._range = value;
  47396. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  47397. },
  47398. enumerable: true,
  47399. configurable: true
  47400. });
  47401. Object.defineProperty(Light.prototype, "intensityMode", {
  47402. /**
  47403. * Gets the photometric scale used to interpret the intensity.
  47404. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  47405. */
  47406. get: function () {
  47407. return this._intensityMode;
  47408. },
  47409. /**
  47410. * Sets the photometric scale used to interpret the intensity.
  47411. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  47412. */
  47413. set: function (value) {
  47414. this._intensityMode = value;
  47415. this._computePhotometricScale();
  47416. },
  47417. enumerable: true,
  47418. configurable: true
  47419. });
  47420. Object.defineProperty(Light.prototype, "radius", {
  47421. /**
  47422. * Gets the light radius used by PBR Materials to simulate soft area lights.
  47423. */
  47424. get: function () {
  47425. return this._radius;
  47426. },
  47427. /**
  47428. * sets the light radius used by PBR Materials to simulate soft area lights.
  47429. */
  47430. set: function (value) {
  47431. this._radius = value;
  47432. this._computePhotometricScale();
  47433. },
  47434. enumerable: true,
  47435. configurable: true
  47436. });
  47437. Object.defineProperty(Light.prototype, "shadowEnabled", {
  47438. /**
  47439. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  47440. * the current shadow generator.
  47441. */
  47442. get: function () {
  47443. return this._shadowEnabled;
  47444. },
  47445. /**
  47446. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  47447. * the current shadow generator.
  47448. */
  47449. set: function (value) {
  47450. if (this._shadowEnabled === value) {
  47451. return;
  47452. }
  47453. this._shadowEnabled = value;
  47454. this._markMeshesAsLightDirty();
  47455. },
  47456. enumerable: true,
  47457. configurable: true
  47458. });
  47459. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  47460. /**
  47461. * Gets the only meshes impacted by this light.
  47462. */
  47463. get: function () {
  47464. return this._includedOnlyMeshes;
  47465. },
  47466. /**
  47467. * Sets the only meshes impacted by this light.
  47468. */
  47469. set: function (value) {
  47470. this._includedOnlyMeshes = value;
  47471. this._hookArrayForIncludedOnly(value);
  47472. },
  47473. enumerable: true,
  47474. configurable: true
  47475. });
  47476. Object.defineProperty(Light.prototype, "excludedMeshes", {
  47477. /**
  47478. * Gets the meshes not impacted by this light.
  47479. */
  47480. get: function () {
  47481. return this._excludedMeshes;
  47482. },
  47483. /**
  47484. * Sets the meshes not impacted by this light.
  47485. */
  47486. set: function (value) {
  47487. this._excludedMeshes = value;
  47488. this._hookArrayForExcluded(value);
  47489. },
  47490. enumerable: true,
  47491. configurable: true
  47492. });
  47493. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  47494. /**
  47495. * Gets the layer id use to find what meshes are not impacted by the light.
  47496. * Inactive if 0
  47497. */
  47498. get: function () {
  47499. return this._excludeWithLayerMask;
  47500. },
  47501. /**
  47502. * Sets the layer id use to find what meshes are not impacted by the light.
  47503. * Inactive if 0
  47504. */
  47505. set: function (value) {
  47506. this._excludeWithLayerMask = value;
  47507. this._resyncMeshes();
  47508. },
  47509. enumerable: true,
  47510. configurable: true
  47511. });
  47512. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  47513. /**
  47514. * Gets the layer id use to find what meshes are impacted by the light.
  47515. * Inactive if 0
  47516. */
  47517. get: function () {
  47518. return this._includeOnlyWithLayerMask;
  47519. },
  47520. /**
  47521. * Sets the layer id use to find what meshes are impacted by the light.
  47522. * Inactive if 0
  47523. */
  47524. set: function (value) {
  47525. this._includeOnlyWithLayerMask = value;
  47526. this._resyncMeshes();
  47527. },
  47528. enumerable: true,
  47529. configurable: true
  47530. });
  47531. Object.defineProperty(Light.prototype, "lightmapMode", {
  47532. /**
  47533. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  47534. */
  47535. get: function () {
  47536. return this._lightmapMode;
  47537. },
  47538. /**
  47539. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  47540. */
  47541. set: function (value) {
  47542. if (this._lightmapMode === value) {
  47543. return;
  47544. }
  47545. this._lightmapMode = value;
  47546. this._markMeshesAsLightDirty();
  47547. },
  47548. enumerable: true,
  47549. configurable: true
  47550. });
  47551. /**
  47552. * Returns the string "Light".
  47553. * @returns the class name
  47554. */
  47555. Light.prototype.getClassName = function () {
  47556. return "Light";
  47557. };
  47558. /**
  47559. * Converts the light information to a readable string for debug purpose.
  47560. * @param fullDetails Supports for multiple levels of logging within scene loading
  47561. * @returns the human readable light info
  47562. */
  47563. Light.prototype.toString = function (fullDetails) {
  47564. var ret = "Name: " + this.name;
  47565. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  47566. if (this.animations) {
  47567. for (var i = 0; i < this.animations.length; i++) {
  47568. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  47569. }
  47570. }
  47571. if (fullDetails) {
  47572. }
  47573. return ret;
  47574. };
  47575. /** @hidden */
  47576. Light.prototype._syncParentEnabledState = function () {
  47577. _super.prototype._syncParentEnabledState.call(this);
  47578. this._resyncMeshes();
  47579. };
  47580. /**
  47581. * Set the enabled state of this node.
  47582. * @param value - the new enabled state
  47583. */
  47584. Light.prototype.setEnabled = function (value) {
  47585. _super.prototype.setEnabled.call(this, value);
  47586. this._resyncMeshes();
  47587. };
  47588. /**
  47589. * Returns the Light associated shadow generator if any.
  47590. * @return the associated shadow generator.
  47591. */
  47592. Light.prototype.getShadowGenerator = function () {
  47593. return this._shadowGenerator;
  47594. };
  47595. /**
  47596. * Returns a Vector3, the absolute light position in the World.
  47597. * @returns the world space position of the light
  47598. */
  47599. Light.prototype.getAbsolutePosition = function () {
  47600. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47601. };
  47602. /**
  47603. * Specifies if the light will affect the passed mesh.
  47604. * @param mesh The mesh to test against the light
  47605. * @return true the mesh is affected otherwise, false.
  47606. */
  47607. Light.prototype.canAffectMesh = function (mesh) {
  47608. if (!mesh) {
  47609. return true;
  47610. }
  47611. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  47612. return false;
  47613. }
  47614. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  47615. return false;
  47616. }
  47617. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  47618. return false;
  47619. }
  47620. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  47621. return false;
  47622. }
  47623. return true;
  47624. };
  47625. /**
  47626. * Sort function to order lights for rendering.
  47627. * @param a First Light object to compare to second.
  47628. * @param b Second Light object to compare first.
  47629. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  47630. */
  47631. Light.CompareLightsPriority = function (a, b) {
  47632. //shadow-casting lights have priority over non-shadow-casting lights
  47633. //the renderPrioirty is a secondary sort criterion
  47634. if (a.shadowEnabled !== b.shadowEnabled) {
  47635. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  47636. }
  47637. return b.renderPriority - a.renderPriority;
  47638. };
  47639. /**
  47640. * Releases resources associated with this node.
  47641. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47642. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47643. */
  47644. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  47645. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  47646. if (this._shadowGenerator) {
  47647. this._shadowGenerator.dispose();
  47648. this._shadowGenerator = null;
  47649. }
  47650. // Animations
  47651. this.getScene().stopAnimation(this);
  47652. // Remove from meshes
  47653. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47654. var mesh = _a[_i];
  47655. mesh._removeLightSource(this);
  47656. }
  47657. this._uniformBuffer.dispose();
  47658. // Remove from scene
  47659. this.getScene().removeLight(this);
  47660. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  47661. };
  47662. /**
  47663. * Returns the light type ID (integer).
  47664. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47665. */
  47666. Light.prototype.getTypeID = function () {
  47667. return 0;
  47668. };
  47669. /**
  47670. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  47671. * @returns the scaled intensity in intensity mode unit
  47672. */
  47673. Light.prototype.getScaledIntensity = function () {
  47674. return this._photometricScale * this.intensity;
  47675. };
  47676. /**
  47677. * Returns a new Light object, named "name", from the current one.
  47678. * @param name The name of the cloned light
  47679. * @returns the new created light
  47680. */
  47681. Light.prototype.clone = function (name) {
  47682. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  47683. if (!constructor) {
  47684. return null;
  47685. }
  47686. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  47687. };
  47688. /**
  47689. * Serializes the current light into a Serialization object.
  47690. * @returns the serialized object.
  47691. */
  47692. Light.prototype.serialize = function () {
  47693. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  47694. // Type
  47695. serializationObject.type = this.getTypeID();
  47696. // Parent
  47697. if (this.parent) {
  47698. serializationObject.parentId = this.parent.id;
  47699. }
  47700. // Inclusion / exclusions
  47701. if (this.excludedMeshes.length > 0) {
  47702. serializationObject.excludedMeshesIds = [];
  47703. this.excludedMeshes.forEach(function (mesh) {
  47704. serializationObject.excludedMeshesIds.push(mesh.id);
  47705. });
  47706. }
  47707. if (this.includedOnlyMeshes.length > 0) {
  47708. serializationObject.includedOnlyMeshesIds = [];
  47709. this.includedOnlyMeshes.forEach(function (mesh) {
  47710. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  47711. });
  47712. }
  47713. // Animations
  47714. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  47715. serializationObject.ranges = this.serializeAnimationRanges();
  47716. return serializationObject;
  47717. };
  47718. /**
  47719. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  47720. * This new light is named "name" and added to the passed scene.
  47721. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  47722. * @param name The friendly name of the light
  47723. * @param scene The scene the new light will belong to
  47724. * @returns the constructor function
  47725. */
  47726. Light.GetConstructorFromName = function (type, name, scene) {
  47727. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  47728. if (constructorFunc) {
  47729. return constructorFunc;
  47730. }
  47731. // Default to no light for none present once.
  47732. return null;
  47733. };
  47734. /**
  47735. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  47736. * @param parsedLight The JSON representation of the light
  47737. * @param scene The scene to create the parsed light in
  47738. * @returns the created light after parsing
  47739. */
  47740. Light.Parse = function (parsedLight, scene) {
  47741. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  47742. if (!constructor) {
  47743. return null;
  47744. }
  47745. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  47746. // Inclusion / exclusions
  47747. if (parsedLight.excludedMeshesIds) {
  47748. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  47749. }
  47750. if (parsedLight.includedOnlyMeshesIds) {
  47751. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  47752. }
  47753. // Parent
  47754. if (parsedLight.parentId) {
  47755. light._waitingParentId = parsedLight.parentId;
  47756. }
  47757. // Animations
  47758. if (parsedLight.animations) {
  47759. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  47760. var parsedAnimation = parsedLight.animations[animationIndex];
  47761. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  47762. if (internalClass) {
  47763. light.animations.push(internalClass.Parse(parsedAnimation));
  47764. }
  47765. }
  47766. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  47767. }
  47768. if (parsedLight.autoAnimate) {
  47769. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  47770. }
  47771. return light;
  47772. };
  47773. Light.prototype._hookArrayForExcluded = function (array) {
  47774. var _this = this;
  47775. var oldPush = array.push;
  47776. array.push = function () {
  47777. var items = [];
  47778. for (var _i = 0; _i < arguments.length; _i++) {
  47779. items[_i] = arguments[_i];
  47780. }
  47781. var result = oldPush.apply(array, items);
  47782. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  47783. var item = items_1[_a];
  47784. item._resyncLighSource(_this);
  47785. }
  47786. return result;
  47787. };
  47788. var oldSplice = array.splice;
  47789. array.splice = function (index, deleteCount) {
  47790. var deleted = oldSplice.apply(array, [index, deleteCount]);
  47791. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  47792. var item = deleted_1[_i];
  47793. item._resyncLighSource(_this);
  47794. }
  47795. return deleted;
  47796. };
  47797. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  47798. var item = array_1[_i];
  47799. item._resyncLighSource(this);
  47800. }
  47801. };
  47802. Light.prototype._hookArrayForIncludedOnly = function (array) {
  47803. var _this = this;
  47804. var oldPush = array.push;
  47805. array.push = function () {
  47806. var items = [];
  47807. for (var _i = 0; _i < arguments.length; _i++) {
  47808. items[_i] = arguments[_i];
  47809. }
  47810. var result = oldPush.apply(array, items);
  47811. _this._resyncMeshes();
  47812. return result;
  47813. };
  47814. var oldSplice = array.splice;
  47815. array.splice = function (index, deleteCount) {
  47816. var deleted = oldSplice.apply(array, [index, deleteCount]);
  47817. _this._resyncMeshes();
  47818. return deleted;
  47819. };
  47820. this._resyncMeshes();
  47821. };
  47822. Light.prototype._resyncMeshes = function () {
  47823. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47824. var mesh = _a[_i];
  47825. mesh._resyncLighSource(this);
  47826. }
  47827. };
  47828. /**
  47829. * Forces the meshes to update their light related information in their rendering used effects
  47830. * @hidden Internal Use Only
  47831. */
  47832. Light.prototype._markMeshesAsLightDirty = function () {
  47833. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47834. var mesh = _a[_i];
  47835. if (mesh._lightSources.indexOf(this) !== -1) {
  47836. mesh._markSubMeshesAsLightDirty();
  47837. }
  47838. }
  47839. };
  47840. /**
  47841. * Recomputes the cached photometric scale if needed.
  47842. */
  47843. Light.prototype._computePhotometricScale = function () {
  47844. this._photometricScale = this._getPhotometricScale();
  47845. this.getScene().resetCachedMaterial();
  47846. };
  47847. /**
  47848. * Returns the Photometric Scale according to the light type and intensity mode.
  47849. */
  47850. Light.prototype._getPhotometricScale = function () {
  47851. var photometricScale = 0.0;
  47852. var lightTypeID = this.getTypeID();
  47853. //get photometric mode
  47854. var photometricMode = this.intensityMode;
  47855. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  47856. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  47857. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  47858. }
  47859. else {
  47860. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  47861. }
  47862. }
  47863. //compute photometric scale
  47864. switch (lightTypeID) {
  47865. case Light.LIGHTTYPEID_POINTLIGHT:
  47866. case Light.LIGHTTYPEID_SPOTLIGHT:
  47867. switch (photometricMode) {
  47868. case Light.INTENSITYMODE_LUMINOUSPOWER:
  47869. photometricScale = 1.0 / (4.0 * Math.PI);
  47870. break;
  47871. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  47872. photometricScale = 1.0;
  47873. break;
  47874. case Light.INTENSITYMODE_LUMINANCE:
  47875. photometricScale = this.radius * this.radius;
  47876. break;
  47877. }
  47878. break;
  47879. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  47880. switch (photometricMode) {
  47881. case Light.INTENSITYMODE_ILLUMINANCE:
  47882. photometricScale = 1.0;
  47883. break;
  47884. case Light.INTENSITYMODE_LUMINANCE:
  47885. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  47886. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  47887. var apexAngleRadians = this.radius;
  47888. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  47889. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  47890. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  47891. photometricScale = solidAngle;
  47892. break;
  47893. }
  47894. break;
  47895. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  47896. // No fall off in hemisperic light.
  47897. photometricScale = 1.0;
  47898. break;
  47899. }
  47900. return photometricScale;
  47901. };
  47902. /**
  47903. * Reorder the light in the scene according to their defined priority.
  47904. * @hidden Internal Use Only
  47905. */
  47906. Light.prototype._reorderLightsInScene = function () {
  47907. var scene = this.getScene();
  47908. if (this._renderPriority != 0) {
  47909. scene.requireLightSorting = true;
  47910. }
  47911. this.getScene().sortLightsByPriority();
  47912. };
  47913. /**
  47914. * Falloff Default: light is falling off following the material specification:
  47915. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  47916. */
  47917. Light.FALLOFF_DEFAULT = 0;
  47918. /**
  47919. * Falloff Physical: light is falling off following the inverse squared distance law.
  47920. */
  47921. Light.FALLOFF_PHYSICAL = 1;
  47922. /**
  47923. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  47924. * to enhance interoperability with other engines.
  47925. */
  47926. Light.FALLOFF_GLTF = 2;
  47927. /**
  47928. * Falloff Standard: light is falling off like in the standard material
  47929. * to enhance interoperability with other materials.
  47930. */
  47931. Light.FALLOFF_STANDARD = 3;
  47932. //lightmapMode Consts
  47933. /**
  47934. * If every light affecting the material is in this lightmapMode,
  47935. * material.lightmapTexture adds or multiplies
  47936. * (depends on material.useLightmapAsShadowmap)
  47937. * after every other light calculations.
  47938. */
  47939. Light.LIGHTMAP_DEFAULT = 0;
  47940. /**
  47941. * material.lightmapTexture as only diffuse lighting from this light
  47942. * adds only specular lighting from this light
  47943. * adds dynamic shadows
  47944. */
  47945. Light.LIGHTMAP_SPECULAR = 1;
  47946. /**
  47947. * material.lightmapTexture as only lighting
  47948. * no light calculation from this light
  47949. * only adds dynamic shadows from this light
  47950. */
  47951. Light.LIGHTMAP_SHADOWSONLY = 2;
  47952. // Intensity Mode Consts
  47953. /**
  47954. * Each light type uses the default quantity according to its type:
  47955. * point/spot lights use luminous intensity
  47956. * directional lights use illuminance
  47957. */
  47958. Light.INTENSITYMODE_AUTOMATIC = 0;
  47959. /**
  47960. * lumen (lm)
  47961. */
  47962. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  47963. /**
  47964. * candela (lm/sr)
  47965. */
  47966. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  47967. /**
  47968. * lux (lm/m^2)
  47969. */
  47970. Light.INTENSITYMODE_ILLUMINANCE = 3;
  47971. /**
  47972. * nit (cd/m^2)
  47973. */
  47974. Light.INTENSITYMODE_LUMINANCE = 4;
  47975. // Light types ids const.
  47976. /**
  47977. * Light type const id of the point light.
  47978. */
  47979. Light.LIGHTTYPEID_POINTLIGHT = 0;
  47980. /**
  47981. * Light type const id of the directional light.
  47982. */
  47983. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  47984. /**
  47985. * Light type const id of the spot light.
  47986. */
  47987. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  47988. /**
  47989. * Light type const id of the hemispheric light.
  47990. */
  47991. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  47992. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47993. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47994. ], Light.prototype, "diffuse", void 0);
  47995. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47996. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47997. ], Light.prototype, "specular", void 0);
  47998. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47999. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48000. ], Light.prototype, "falloffType", void 0);
  48001. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48002. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48003. ], Light.prototype, "intensity", void 0);
  48004. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48005. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48006. ], Light.prototype, "range", null);
  48007. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48008. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48009. ], Light.prototype, "intensityMode", null);
  48010. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48012. ], Light.prototype, "radius", null);
  48013. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48014. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48015. ], Light.prototype, "_renderPriority", void 0);
  48016. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48017. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  48018. ], Light.prototype, "renderPriority", void 0);
  48019. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48020. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  48021. ], Light.prototype, "_shadowEnabled", void 0);
  48022. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48023. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  48024. ], Light.prototype, "_excludeWithLayerMask", void 0);
  48025. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48026. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  48027. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  48028. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48029. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  48030. ], Light.prototype, "_lightmapMode", void 0);
  48031. return Light;
  48032. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  48033. /***/ }),
  48034. /***/ "./Lights/pointLight.ts":
  48035. /*!******************************!*\
  48036. !*** ./Lights/pointLight.ts ***!
  48037. \******************************/
  48038. /*! exports provided: PointLight */
  48039. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48040. "use strict";
  48041. __webpack_require__.r(__webpack_exports__);
  48042. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  48043. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48044. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  48045. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  48046. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  48047. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  48048. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  48049. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  48050. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  48051. });
  48052. /**
  48053. * A point light is a light defined by an unique point in world space.
  48054. * The light is emitted in every direction from this point.
  48055. * A good example of a point light is a standard light bulb.
  48056. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48057. */
  48058. var PointLight = /** @class */ (function (_super) {
  48059. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  48060. /**
  48061. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48062. * A PointLight emits the light in every direction.
  48063. * It can cast shadows.
  48064. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48065. * ```javascript
  48066. * var pointLight = new PointLight("pl", camera.position, scene);
  48067. * ```
  48068. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48069. * @param name The light friendly name
  48070. * @param position The position of the point light in the scene
  48071. * @param scene The scene the lights belongs to
  48072. */
  48073. function PointLight(name, position, scene) {
  48074. var _this = _super.call(this, name, scene) || this;
  48075. _this._shadowAngle = Math.PI / 2;
  48076. _this.position = position;
  48077. return _this;
  48078. }
  48079. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  48080. /**
  48081. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48082. * This specifies what angle the shadow will use to be created.
  48083. *
  48084. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48085. */
  48086. get: function () {
  48087. return this._shadowAngle;
  48088. },
  48089. /**
  48090. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48091. * This specifies what angle the shadow will use to be created.
  48092. *
  48093. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48094. */
  48095. set: function (value) {
  48096. this._shadowAngle = value;
  48097. this.forceProjectionMatrixCompute();
  48098. },
  48099. enumerable: true,
  48100. configurable: true
  48101. });
  48102. Object.defineProperty(PointLight.prototype, "direction", {
  48103. /**
  48104. * Gets the direction if it has been set.
  48105. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48106. */
  48107. get: function () {
  48108. return this._direction;
  48109. },
  48110. /**
  48111. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48112. */
  48113. set: function (value) {
  48114. var previousNeedCube = this.needCube();
  48115. this._direction = value;
  48116. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  48117. this._shadowGenerator.recreateShadowMap();
  48118. }
  48119. },
  48120. enumerable: true,
  48121. configurable: true
  48122. });
  48123. /**
  48124. * Returns the string "PointLight"
  48125. * @returns the class name
  48126. */
  48127. PointLight.prototype.getClassName = function () {
  48128. return "PointLight";
  48129. };
  48130. /**
  48131. * Returns the integer 0.
  48132. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48133. */
  48134. PointLight.prototype.getTypeID = function () {
  48135. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  48136. };
  48137. /**
  48138. * Specifies wether or not the shadowmap should be a cube texture.
  48139. * @returns true if the shadowmap needs to be a cube texture.
  48140. */
  48141. PointLight.prototype.needCube = function () {
  48142. return !this.direction;
  48143. };
  48144. /**
  48145. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48146. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48147. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48148. */
  48149. PointLight.prototype.getShadowDirection = function (faceIndex) {
  48150. if (this.direction) {
  48151. return _super.prototype.getShadowDirection.call(this, faceIndex);
  48152. }
  48153. else {
  48154. switch (faceIndex) {
  48155. case 0:
  48156. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  48157. case 1:
  48158. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  48159. case 2:
  48160. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  48161. case 3:
  48162. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  48163. case 4:
  48164. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  48165. case 5:
  48166. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  48167. }
  48168. }
  48169. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48170. };
  48171. /**
  48172. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48173. * - fov = PI / 2
  48174. * - aspect ratio : 1.0
  48175. * - z-near and far equal to the active camera minZ and maxZ.
  48176. * Returns the PointLight.
  48177. */
  48178. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48179. var activeCamera = this.getScene().activeCamera;
  48180. if (!activeCamera) {
  48181. return;
  48182. }
  48183. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  48184. };
  48185. PointLight.prototype._buildUniformLayout = function () {
  48186. this._uniformBuffer.addUniform("vLightData", 4);
  48187. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  48188. this._uniformBuffer.addUniform("vLightSpecular", 3);
  48189. this._uniformBuffer.addUniform("vLightFalloff", 4);
  48190. this._uniformBuffer.addUniform("shadowsInfo", 3);
  48191. this._uniformBuffer.addUniform("depthValues", 2);
  48192. this._uniformBuffer.create();
  48193. };
  48194. /**
  48195. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48196. * @param effect The effect to update
  48197. * @param lightIndex The index of the light in the effect to update
  48198. * @returns The point light
  48199. */
  48200. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  48201. if (this.computeTransformedInformation()) {
  48202. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  48203. }
  48204. else {
  48205. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  48206. }
  48207. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  48208. return this;
  48209. };
  48210. /**
  48211. * Prepares the list of defines specific to the light type.
  48212. * @param defines the list of defines
  48213. * @param lightIndex defines the index of the light for the effect
  48214. */
  48215. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  48216. defines["POINTLIGHT" + lightIndex] = true;
  48217. };
  48218. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48219. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48220. ], PointLight.prototype, "shadowAngle", null);
  48221. return PointLight;
  48222. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  48223. /***/ }),
  48224. /***/ "./Lights/shadowLight.ts":
  48225. /*!*******************************!*\
  48226. !*** ./Lights/shadowLight.ts ***!
  48227. \*******************************/
  48228. /*! exports provided: ShadowLight */
  48229. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48230. "use strict";
  48231. __webpack_require__.r(__webpack_exports__);
  48232. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  48233. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48234. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  48235. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  48236. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  48237. /**
  48238. * Base implementation IShadowLight
  48239. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  48240. */
  48241. var ShadowLight = /** @class */ (function (_super) {
  48242. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  48243. function ShadowLight() {
  48244. var _this = _super !== null && _super.apply(this, arguments) || this;
  48245. _this._needProjectionMatrixCompute = true;
  48246. return _this;
  48247. }
  48248. ShadowLight.prototype._setPosition = function (value) {
  48249. this._position = value;
  48250. };
  48251. Object.defineProperty(ShadowLight.prototype, "position", {
  48252. /**
  48253. * Sets the position the shadow will be casted from. Also use as the light position for both
  48254. * point and spot lights.
  48255. */
  48256. get: function () {
  48257. return this._position;
  48258. },
  48259. /**
  48260. * Sets the position the shadow will be casted from. Also use as the light position for both
  48261. * point and spot lights.
  48262. */
  48263. set: function (value) {
  48264. this._setPosition(value);
  48265. },
  48266. enumerable: true,
  48267. configurable: true
  48268. });
  48269. ShadowLight.prototype._setDirection = function (value) {
  48270. this._direction = value;
  48271. };
  48272. Object.defineProperty(ShadowLight.prototype, "direction", {
  48273. /**
  48274. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  48275. * Also use as the light direction on spot and directional lights.
  48276. */
  48277. get: function () {
  48278. return this._direction;
  48279. },
  48280. /**
  48281. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  48282. * Also use as the light direction on spot and directional lights.
  48283. */
  48284. set: function (value) {
  48285. this._setDirection(value);
  48286. },
  48287. enumerable: true,
  48288. configurable: true
  48289. });
  48290. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  48291. /**
  48292. * Gets the shadow projection clipping minimum z value.
  48293. */
  48294. get: function () {
  48295. return this._shadowMinZ;
  48296. },
  48297. /**
  48298. * Sets the shadow projection clipping minimum z value.
  48299. */
  48300. set: function (value) {
  48301. this._shadowMinZ = value;
  48302. this.forceProjectionMatrixCompute();
  48303. },
  48304. enumerable: true,
  48305. configurable: true
  48306. });
  48307. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  48308. /**
  48309. * Sets the shadow projection clipping maximum z value.
  48310. */
  48311. get: function () {
  48312. return this._shadowMaxZ;
  48313. },
  48314. /**
  48315. * Gets the shadow projection clipping maximum z value.
  48316. */
  48317. set: function (value) {
  48318. this._shadowMaxZ = value;
  48319. this.forceProjectionMatrixCompute();
  48320. },
  48321. enumerable: true,
  48322. configurable: true
  48323. });
  48324. /**
  48325. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  48326. * @returns true if the information has been computed, false if it does not need to (no parenting)
  48327. */
  48328. ShadowLight.prototype.computeTransformedInformation = function () {
  48329. if (this.parent && this.parent.getWorldMatrix) {
  48330. if (!this.transformedPosition) {
  48331. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48332. }
  48333. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  48334. // In case the direction is present.
  48335. if (this.direction) {
  48336. if (!this.transformedDirection) {
  48337. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48338. }
  48339. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  48340. }
  48341. return true;
  48342. }
  48343. return false;
  48344. };
  48345. /**
  48346. * Return the depth scale used for the shadow map.
  48347. * @returns the depth scale.
  48348. */
  48349. ShadowLight.prototype.getDepthScale = function () {
  48350. return 50.0;
  48351. };
  48352. /**
  48353. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  48354. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48355. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48356. */
  48357. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  48358. return this.transformedDirection ? this.transformedDirection : this.direction;
  48359. };
  48360. /**
  48361. * Returns the ShadowLight absolute position in the World.
  48362. * @returns the position vector in world space
  48363. */
  48364. ShadowLight.prototype.getAbsolutePosition = function () {
  48365. return this.transformedPosition ? this.transformedPosition : this.position;
  48366. };
  48367. /**
  48368. * Sets the ShadowLight direction toward the passed target.
  48369. * @param target The point to target in local space
  48370. * @returns the updated ShadowLight direction
  48371. */
  48372. ShadowLight.prototype.setDirectionToTarget = function (target) {
  48373. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  48374. return this.direction;
  48375. };
  48376. /**
  48377. * Returns the light rotation in euler definition.
  48378. * @returns the x y z rotation in local space.
  48379. */
  48380. ShadowLight.prototype.getRotation = function () {
  48381. this.direction.normalize();
  48382. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  48383. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  48384. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  48385. };
  48386. /**
  48387. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  48388. * @returns true if a cube texture needs to be use
  48389. */
  48390. ShadowLight.prototype.needCube = function () {
  48391. return false;
  48392. };
  48393. /**
  48394. * Detects if the projection matrix requires to be recomputed this frame.
  48395. * @returns true if it requires to be recomputed otherwise, false.
  48396. */
  48397. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  48398. return this._needProjectionMatrixCompute;
  48399. };
  48400. /**
  48401. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  48402. */
  48403. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  48404. this._needProjectionMatrixCompute = true;
  48405. };
  48406. /** @hidden */
  48407. ShadowLight.prototype._initCache = function () {
  48408. _super.prototype._initCache.call(this);
  48409. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48410. };
  48411. /** @hidden */
  48412. ShadowLight.prototype._isSynchronized = function () {
  48413. if (!this._cache.position.equals(this.position)) {
  48414. return false;
  48415. }
  48416. return true;
  48417. };
  48418. /**
  48419. * Computes the world matrix of the node
  48420. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  48421. * @returns the world matrix
  48422. */
  48423. ShadowLight.prototype.computeWorldMatrix = function (force) {
  48424. if (!force && this.isSynchronized()) {
  48425. this._currentRenderId = this.getScene().getRenderId();
  48426. return this._worldMatrix;
  48427. }
  48428. this._updateCache();
  48429. this._cache.position.copyFrom(this.position);
  48430. if (!this._worldMatrix) {
  48431. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  48432. }
  48433. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  48434. if (this.parent && this.parent.getWorldMatrix) {
  48435. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  48436. this._markSyncedWithParent();
  48437. }
  48438. // Cache the determinant
  48439. this._worldMatrixDeterminantIsDirty = true;
  48440. return this._worldMatrix;
  48441. };
  48442. /**
  48443. * Gets the minZ used for shadow according to both the scene and the light.
  48444. * @param activeCamera The camera we are returning the min for
  48445. * @returns the depth min z
  48446. */
  48447. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  48448. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  48449. };
  48450. /**
  48451. * Gets the maxZ used for shadow according to both the scene and the light.
  48452. * @param activeCamera The camera we are returning the max for
  48453. * @returns the depth max z
  48454. */
  48455. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  48456. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  48457. };
  48458. /**
  48459. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  48460. * @param matrix The materix to updated with the projection information
  48461. * @param viewMatrix The transform matrix of the light
  48462. * @param renderList The list of mesh to render in the map
  48463. * @returns The current light
  48464. */
  48465. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48466. if (this.customProjectionMatrixBuilder) {
  48467. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  48468. }
  48469. else {
  48470. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  48471. }
  48472. return this;
  48473. };
  48474. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48475. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  48476. ], ShadowLight.prototype, "position", null);
  48477. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48478. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  48479. ], ShadowLight.prototype, "direction", null);
  48480. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48481. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48482. ], ShadowLight.prototype, "shadowMinZ", null);
  48483. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48484. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48485. ], ShadowLight.prototype, "shadowMaxZ", null);
  48486. return ShadowLight;
  48487. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  48488. /***/ }),
  48489. /***/ "./Lights/spotLight.ts":
  48490. /*!*****************************!*\
  48491. !*** ./Lights/spotLight.ts ***!
  48492. \*****************************/
  48493. /*! exports provided: SpotLight */
  48494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48495. "use strict";
  48496. __webpack_require__.r(__webpack_exports__);
  48497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  48498. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48499. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  48500. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  48501. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  48502. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  48503. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  48504. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  48505. return function () { return new SpotLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), 0, 0, scene); };
  48506. });
  48507. /**
  48508. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48509. * These values define a cone of light starting from the position, emitting toward the direction.
  48510. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48511. * and the exponent defines the speed of the decay of the light with distance (reach).
  48512. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48513. */
  48514. var SpotLight = /** @class */ (function (_super) {
  48515. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  48516. /**
  48517. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48518. * It can cast shadows.
  48519. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48520. * @param name The light friendly name
  48521. * @param position The position of the spot light in the scene
  48522. * @param direction The direction of the light in the scene
  48523. * @param angle The cone angle of the light in Radians
  48524. * @param exponent The light decay speed with the distance from the emission spot
  48525. * @param scene The scene the lights belongs to
  48526. */
  48527. function SpotLight(name, position, direction, angle, exponent, scene) {
  48528. var _this = _super.call(this, name, scene) || this;
  48529. _this._innerAngle = 0;
  48530. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48531. _this._projectionTextureLightNear = 1e-6;
  48532. _this._projectionTextureLightFar = 1000.0;
  48533. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  48534. _this._projectionTextureViewLightDirty = true;
  48535. _this._projectionTextureProjectionLightDirty = true;
  48536. _this._projectionTextureDirty = true;
  48537. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48538. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48539. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48540. _this._projectionTextureScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromValues(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0);
  48541. _this.position = position;
  48542. _this.direction = direction;
  48543. _this.angle = angle;
  48544. _this.exponent = exponent;
  48545. return _this;
  48546. }
  48547. Object.defineProperty(SpotLight.prototype, "angle", {
  48548. /**
  48549. * Gets the cone angle of the spot light in Radians.
  48550. */
  48551. get: function () {
  48552. return this._angle;
  48553. },
  48554. /**
  48555. * Sets the cone angle of the spot light in Radians.
  48556. */
  48557. set: function (value) {
  48558. this._angle = value;
  48559. this._cosHalfAngle = Math.cos(value * 0.5);
  48560. this._projectionTextureProjectionLightDirty = true;
  48561. this.forceProjectionMatrixCompute();
  48562. this._computeAngleValues();
  48563. },
  48564. enumerable: true,
  48565. configurable: true
  48566. });
  48567. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  48568. /**
  48569. * Only used in gltf falloff mode, this defines the angle where
  48570. * the directional falloff will start before cutting at angle which could be seen
  48571. * as outer angle.
  48572. */
  48573. get: function () {
  48574. return this._innerAngle;
  48575. },
  48576. /**
  48577. * Only used in gltf falloff mode, this defines the angle where
  48578. * the directional falloff will start before cutting at angle which could be seen
  48579. * as outer angle.
  48580. */
  48581. set: function (value) {
  48582. this._innerAngle = value;
  48583. this._computeAngleValues();
  48584. },
  48585. enumerable: true,
  48586. configurable: true
  48587. });
  48588. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  48589. /**
  48590. * Allows scaling the angle of the light for shadow generation only.
  48591. */
  48592. get: function () {
  48593. return this._shadowAngleScale;
  48594. },
  48595. /**
  48596. * Allows scaling the angle of the light for shadow generation only.
  48597. */
  48598. set: function (value) {
  48599. this._shadowAngleScale = value;
  48600. this.forceProjectionMatrixCompute();
  48601. },
  48602. enumerable: true,
  48603. configurable: true
  48604. });
  48605. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  48606. /**
  48607. * Allows reading the projecton texture
  48608. */
  48609. get: function () {
  48610. return this._projectionTextureMatrix;
  48611. },
  48612. enumerable: true,
  48613. configurable: true
  48614. });
  48615. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  48616. /**
  48617. * Gets the near clip of the Spotlight for texture projection.
  48618. */
  48619. get: function () {
  48620. return this._projectionTextureLightNear;
  48621. },
  48622. /**
  48623. * Sets the near clip of the Spotlight for texture projection.
  48624. */
  48625. set: function (value) {
  48626. this._projectionTextureLightNear = value;
  48627. this._projectionTextureProjectionLightDirty = true;
  48628. },
  48629. enumerable: true,
  48630. configurable: true
  48631. });
  48632. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  48633. /**
  48634. * Gets the far clip of the Spotlight for texture projection.
  48635. */
  48636. get: function () {
  48637. return this._projectionTextureLightFar;
  48638. },
  48639. /**
  48640. * Sets the far clip of the Spotlight for texture projection.
  48641. */
  48642. set: function (value) {
  48643. this._projectionTextureLightFar = value;
  48644. this._projectionTextureProjectionLightDirty = true;
  48645. },
  48646. enumerable: true,
  48647. configurable: true
  48648. });
  48649. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  48650. /**
  48651. * Gets the Up vector of the Spotlight for texture projection.
  48652. */
  48653. get: function () {
  48654. return this._projectionTextureUpDirection;
  48655. },
  48656. /**
  48657. * Sets the Up vector of the Spotlight for texture projection.
  48658. */
  48659. set: function (value) {
  48660. this._projectionTextureUpDirection = value;
  48661. this._projectionTextureProjectionLightDirty = true;
  48662. },
  48663. enumerable: true,
  48664. configurable: true
  48665. });
  48666. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  48667. /**
  48668. * Gets the projection texture of the light.
  48669. */
  48670. get: function () {
  48671. return this._projectionTexture;
  48672. },
  48673. /**
  48674. * Sets the projection texture of the light.
  48675. */
  48676. set: function (value) {
  48677. this._projectionTexture = value;
  48678. this._projectionTextureDirty = true;
  48679. },
  48680. enumerable: true,
  48681. configurable: true
  48682. });
  48683. /**
  48684. * Returns the string "SpotLight".
  48685. * @returns the class name
  48686. */
  48687. SpotLight.prototype.getClassName = function () {
  48688. return "SpotLight";
  48689. };
  48690. /**
  48691. * Returns the integer 2.
  48692. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48693. */
  48694. SpotLight.prototype.getTypeID = function () {
  48695. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  48696. };
  48697. /**
  48698. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48699. */
  48700. SpotLight.prototype._setDirection = function (value) {
  48701. _super.prototype._setDirection.call(this, value);
  48702. this._projectionTextureViewLightDirty = true;
  48703. };
  48704. /**
  48705. * Overrides the position setter to recompute the projection texture view light Matrix.
  48706. */
  48707. SpotLight.prototype._setPosition = function (value) {
  48708. _super.prototype._setPosition.call(this, value);
  48709. this._projectionTextureViewLightDirty = true;
  48710. };
  48711. /**
  48712. * Sets the passed matrix "matrix" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.
  48713. * Returns the SpotLight.
  48714. */
  48715. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48716. var activeCamera = this.getScene().activeCamera;
  48717. if (!activeCamera) {
  48718. return;
  48719. }
  48720. this._shadowAngleScale = this._shadowAngleScale || 1;
  48721. var angle = this._shadowAngleScale * this._angle;
  48722. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  48723. };
  48724. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  48725. this._projectionTextureViewLightDirty = false;
  48726. this._projectionTextureDirty = true;
  48727. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  48728. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  48729. };
  48730. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  48731. this._projectionTextureProjectionLightDirty = false;
  48732. this._projectionTextureDirty = true;
  48733. var light_far = this.projectionTextureLightFar;
  48734. var light_near = this.projectionTextureLightNear;
  48735. var P = light_far / (light_far - light_near);
  48736. var Q = -P * light_near;
  48737. var S = 1.0 / Math.tan(this._angle / 2.0);
  48738. var A = 1.0;
  48739. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromValuesToRef(S / A, 0.0, 0.0, 0.0, 0.0, S, 0.0, 0.0, 0.0, 0.0, P, 1.0, 0.0, 0.0, Q, 0.0, this._projectionTextureProjectionLightMatrix);
  48740. };
  48741. /**
  48742. * Main function for light texture projection matrix computing.
  48743. */
  48744. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  48745. this._projectionTextureDirty = false;
  48746. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  48747. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  48748. };
  48749. SpotLight.prototype._buildUniformLayout = function () {
  48750. this._uniformBuffer.addUniform("vLightData", 4);
  48751. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  48752. this._uniformBuffer.addUniform("vLightSpecular", 3);
  48753. this._uniformBuffer.addUniform("vLightDirection", 3);
  48754. this._uniformBuffer.addUniform("vLightFalloff", 4);
  48755. this._uniformBuffer.addUniform("shadowsInfo", 3);
  48756. this._uniformBuffer.addUniform("depthValues", 2);
  48757. this._uniformBuffer.create();
  48758. };
  48759. SpotLight.prototype._computeAngleValues = function () {
  48760. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  48761. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  48762. };
  48763. /**
  48764. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48765. * @param effect The effect to update
  48766. * @param lightIndex The index of the light in the effect to update
  48767. * @returns The spot light
  48768. */
  48769. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  48770. var normalizeDirection;
  48771. if (this.computeTransformedInformation()) {
  48772. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  48773. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  48774. }
  48775. else {
  48776. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  48777. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  48778. }
  48779. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  48780. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  48781. if (this.projectionTexture && this.projectionTexture.isReady()) {
  48782. if (this._projectionTextureViewLightDirty) {
  48783. this._computeProjectionTextureViewLightMatrix();
  48784. }
  48785. if (this._projectionTextureProjectionLightDirty) {
  48786. this._computeProjectionTextureProjectionLightMatrix();
  48787. }
  48788. if (this._projectionTextureDirty) {
  48789. this._computeProjectionTextureMatrix();
  48790. }
  48791. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  48792. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  48793. }
  48794. return this;
  48795. };
  48796. /**
  48797. * Disposes the light and the associated resources.
  48798. */
  48799. SpotLight.prototype.dispose = function () {
  48800. _super.prototype.dispose.call(this);
  48801. if (this._projectionTexture) {
  48802. this._projectionTexture.dispose();
  48803. }
  48804. };
  48805. /**
  48806. * Prepares the list of defines specific to the light type.
  48807. * @param defines the list of defines
  48808. * @param lightIndex defines the index of the light for the effect
  48809. */
  48810. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  48811. defines["SPOTLIGHT" + lightIndex] = true;
  48812. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  48813. };
  48814. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48815. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48816. ], SpotLight.prototype, "angle", null);
  48817. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48819. ], SpotLight.prototype, "innerAngle", null);
  48820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48822. ], SpotLight.prototype, "shadowAngleScale", null);
  48823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48825. ], SpotLight.prototype, "exponent", void 0);
  48826. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48827. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48828. ], SpotLight.prototype, "projectionTextureLightNear", null);
  48829. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48831. ], SpotLight.prototype, "projectionTextureLightFar", null);
  48832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48834. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  48835. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48836. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  48837. ], SpotLight.prototype, "_projectionTexture", void 0);
  48838. return SpotLight;
  48839. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  48840. /***/ }),
  48841. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  48842. /*!**********************************************!*\
  48843. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  48844. \**********************************************/
  48845. /*! exports provided: _BabylonLoaderRegistered */
  48846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48847. "use strict";
  48848. __webpack_require__.r(__webpack_exports__);
  48849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  48850. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  48851. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  48852. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  48853. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  48854. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  48855. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  48856. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  48857. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  48858. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  48859. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  48860. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  48861. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  48862. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  48863. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  48864. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  48865. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  48866. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  48867. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  48868. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  48869. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  48870. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  48871. /* harmony import */ var _Physics_Plugins_ammoJSPlugin__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Physics/Plugins/ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  48872. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  48873. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  48874. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  48875. /** @hidden */
  48876. var _BabylonLoaderRegistered = true;
  48877. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  48878. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  48879. var parsedMaterial = parsedData.materials[index];
  48880. if (parsedMaterial.id === id) {
  48881. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  48882. }
  48883. }
  48884. return null;
  48885. };
  48886. var isDescendantOf = function (mesh, names, hierarchyIds) {
  48887. for (var i in names) {
  48888. if (mesh.name === names[i]) {
  48889. hierarchyIds.push(mesh.id);
  48890. return true;
  48891. }
  48892. }
  48893. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  48894. hierarchyIds.push(mesh.id);
  48895. return true;
  48896. }
  48897. return false;
  48898. };
  48899. var logOperation = function (operation, producer) {
  48900. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  48901. };
  48902. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  48903. if (addToScene === void 0) { addToScene = false; }
  48904. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_15__["AssetContainer"](scene);
  48905. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48906. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48907. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48908. // and avoid problems with multiple concurrent .babylon loads.
  48909. var log = "importScene has failed JSON parse";
  48910. try {
  48911. var parsedData = JSON.parse(data);
  48912. log = "";
  48913. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  48914. var index;
  48915. var cache;
  48916. // Environment texture
  48917. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  48918. // PBR needed for both HDR texture (gamma space) & a sky box
  48919. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  48920. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  48921. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  48922. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"]((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  48923. if (parsedData.environmentTextureRotationY) {
  48924. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  48925. }
  48926. scene.environmentTexture = hdrTexture;
  48927. }
  48928. else {
  48929. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_24__["Tools"].EndsWith(parsedData.environmentTexture, ".env")) {
  48930. var compressedTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"]((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene);
  48931. if (parsedData.environmentTextureRotationY) {
  48932. compressedTexture.rotationY = parsedData.environmentTextureRotationY;
  48933. }
  48934. scene.environmentTexture = compressedTexture;
  48935. }
  48936. else {
  48937. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene);
  48938. if (parsedData.environmentTextureRotationY) {
  48939. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  48940. }
  48941. scene.environmentTexture = cubeTexture;
  48942. }
  48943. }
  48944. if (parsedData.createDefaultSkybox === true) {
  48945. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  48946. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  48947. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  48948. }
  48949. container.environmentTexture = scene.environmentTexture;
  48950. }
  48951. // Lights
  48952. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  48953. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  48954. var parsedLight = parsedData.lights[index];
  48955. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_11__["Light"].Parse(parsedLight, scene);
  48956. if (light) {
  48957. container.lights.push(light);
  48958. log += (index === 0 ? "\n\tLights:" : "");
  48959. log += "\n\t\t" + light.toString(fullDetails);
  48960. }
  48961. }
  48962. }
  48963. // Reflection probes
  48964. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  48965. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  48966. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  48967. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_22__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  48968. if (reflectionProbe) {
  48969. container.reflectionProbes.push(reflectionProbe);
  48970. log += (index === 0 ? "\n\tReflection Probes:" : "");
  48971. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  48972. }
  48973. }
  48974. }
  48975. // Animations
  48976. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  48977. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  48978. var parsedAnimation = parsedData.animations[index];
  48979. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_23__["_TypeStore"].GetClass("BABYLON.Animation");
  48980. if (internalClass) {
  48981. var animation = internalClass.Parse(parsedAnimation);
  48982. scene.animations.push(animation);
  48983. container.animations.push(animation);
  48984. log += (index === 0 ? "\n\tAnimations:" : "");
  48985. log += "\n\t\t" + animation.toString(fullDetails);
  48986. }
  48987. }
  48988. }
  48989. // Materials
  48990. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  48991. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  48992. var parsedMaterial = parsedData.materials[index];
  48993. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  48994. if (mat) {
  48995. container.materials.push(mat);
  48996. log += (index === 0 ? "\n\tMaterials:" : "");
  48997. log += "\n\t\t" + mat.toString(fullDetails);
  48998. // Textures
  48999. var textures = mat.getActiveTextures();
  49000. textures.forEach(function (t) {
  49001. if (container.textures.indexOf(t) == -1) {
  49002. container.textures.push(t);
  49003. }
  49004. });
  49005. }
  49006. }
  49007. }
  49008. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  49009. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  49010. var parsedMultiMaterial = parsedData.multiMaterials[index];
  49011. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  49012. container.multiMaterials.push(mmat);
  49013. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  49014. log += "\n\t\t" + mmat.toString(fullDetails);
  49015. // Textures
  49016. var textures = mmat.getActiveTextures();
  49017. textures.forEach(function (t) {
  49018. if (container.textures.indexOf(t) == -1) {
  49019. container.textures.push(t);
  49020. }
  49021. });
  49022. }
  49023. }
  49024. // Morph targets
  49025. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  49026. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  49027. var managerData = _a[_i];
  49028. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene));
  49029. }
  49030. }
  49031. // Skeletons
  49032. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  49033. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  49034. var parsedSkeleton = parsedData.skeletons[index];
  49035. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  49036. container.skeletons.push(skeleton);
  49037. log += (index === 0 ? "\n\tSkeletons:" : "");
  49038. log += "\n\t\t" + skeleton.toString(fullDetails);
  49039. }
  49040. }
  49041. // Geometries
  49042. var geometries = parsedData.geometries;
  49043. if (geometries !== undefined && geometries !== null) {
  49044. var addedGeometry = new Array();
  49045. // VertexData
  49046. var vertexData = geometries.vertexData;
  49047. if (vertexData !== undefined && vertexData !== null) {
  49048. for (index = 0, cache = vertexData.length; index < cache; index++) {
  49049. var parsedVertexData = vertexData[index];
  49050. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  49051. }
  49052. }
  49053. addedGeometry.forEach(function (g) {
  49054. if (g) {
  49055. container.geometries.push(g);
  49056. }
  49057. });
  49058. }
  49059. // Transform nodes
  49060. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  49061. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  49062. var parsedTransformNode = parsedData.transformNodes[index];
  49063. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  49064. container.transformNodes.push(node);
  49065. }
  49066. }
  49067. // Meshes
  49068. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  49069. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  49070. var parsedMesh = parsedData.meshes[index];
  49071. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  49072. container.meshes.push(mesh);
  49073. log += (index === 0 ? "\n\tMeshes:" : "");
  49074. log += "\n\t\t" + mesh.toString(fullDetails);
  49075. }
  49076. }
  49077. // Cameras
  49078. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  49079. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  49080. var parsedCamera = parsedData.cameras[index];
  49081. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  49082. container.cameras.push(camera);
  49083. log += (index === 0 ? "\n\tCameras:" : "");
  49084. log += "\n\t\t" + camera.toString(fullDetails);
  49085. }
  49086. }
  49087. // Animation Groups
  49088. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  49089. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  49090. var parsedAnimationGroup = parsedData.animationGroups[index];
  49091. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  49092. container.animationGroups.push(animationGroup);
  49093. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  49094. log += "\n\t\t" + animationGroup.toString(fullDetails);
  49095. }
  49096. }
  49097. // Browsing all the graph to connect the dots
  49098. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  49099. var camera = scene.cameras[index];
  49100. if (camera._waitingParentId) {
  49101. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  49102. camera._waitingParentId = null;
  49103. }
  49104. }
  49105. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  49106. var light_1 = scene.lights[index];
  49107. if (light_1 && light_1._waitingParentId) {
  49108. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  49109. light_1._waitingParentId = null;
  49110. }
  49111. }
  49112. // Connect parents & children and parse actions
  49113. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  49114. var transformNode = scene.transformNodes[index];
  49115. if (transformNode._waitingParentId) {
  49116. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  49117. transformNode._waitingParentId = null;
  49118. }
  49119. }
  49120. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49121. var mesh = scene.meshes[index];
  49122. if (mesh._waitingParentId) {
  49123. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  49124. mesh._waitingParentId = null;
  49125. }
  49126. }
  49127. // freeze world matrix application
  49128. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49129. var currentMesh = scene.meshes[index];
  49130. if (currentMesh._waitingFreezeWorldMatrix) {
  49131. currentMesh.freezeWorldMatrix();
  49132. currentMesh._waitingFreezeWorldMatrix = null;
  49133. }
  49134. else {
  49135. currentMesh.computeWorldMatrix(true);
  49136. }
  49137. }
  49138. // Lights exclusions / inclusions
  49139. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  49140. var light_2 = scene.lights[index];
  49141. // Excluded check
  49142. if (light_2._excludedMeshesIds.length > 0) {
  49143. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  49144. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  49145. if (excludedMesh) {
  49146. light_2.excludedMeshes.push(excludedMesh);
  49147. }
  49148. }
  49149. light_2._excludedMeshesIds = [];
  49150. }
  49151. // Included check
  49152. if (light_2._includedOnlyMeshesIds.length > 0) {
  49153. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  49154. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  49155. if (includedOnlyMesh) {
  49156. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  49157. }
  49158. }
  49159. light_2._includedOnlyMeshesIds = [];
  49160. }
  49161. }
  49162. _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  49163. // Actions (scene) Done last as it can access other objects.
  49164. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49165. var mesh = scene.meshes[index];
  49166. if (mesh._waitingActions) {
  49167. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  49168. mesh._waitingActions = null;
  49169. }
  49170. }
  49171. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  49172. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(parsedData.actions, null, scene);
  49173. }
  49174. if (!addToScene) {
  49175. container.removeAllFromScene();
  49176. }
  49177. }
  49178. catch (err) {
  49179. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  49180. if (onError) {
  49181. onError(msg, err);
  49182. }
  49183. else {
  49184. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  49185. throw err;
  49186. }
  49187. }
  49188. finally {
  49189. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  49190. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  49191. }
  49192. }
  49193. return container;
  49194. };
  49195. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].RegisterPlugin({
  49196. name: "babylon.js",
  49197. extensions: ".babylon",
  49198. canDirectLoad: function (data) {
  49199. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  49200. return true;
  49201. }
  49202. return false;
  49203. },
  49204. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  49205. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  49206. // when SceneLoader.debugLogging = true (default), or exception encountered.
  49207. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  49208. // and avoid problems with multiple concurrent .babylon loads.
  49209. var log = "importMesh has failed JSON parse";
  49210. try {
  49211. var parsedData = JSON.parse(data);
  49212. log = "";
  49213. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  49214. if (!meshesNames) {
  49215. meshesNames = null;
  49216. }
  49217. else if (!Array.isArray(meshesNames)) {
  49218. meshesNames = [meshesNames];
  49219. }
  49220. var hierarchyIds = new Array();
  49221. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  49222. var loadedSkeletonsIds = [];
  49223. var loadedMaterialsIds = [];
  49224. var index;
  49225. var cache;
  49226. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  49227. var parsedMesh = parsedData.meshes[index];
  49228. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  49229. if (meshesNames !== null) {
  49230. // Remove found mesh name from list.
  49231. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  49232. }
  49233. //Geometry?
  49234. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  49235. //does the file contain geometries?
  49236. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  49237. //find the correct geometry and add it to the scene
  49238. var found = false;
  49239. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  49240. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  49241. return;
  49242. }
  49243. else {
  49244. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  49245. if (parsedGeometryData.id === parsedMesh.geometryId) {
  49246. switch (geometryType) {
  49247. case "vertexData":
  49248. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  49249. break;
  49250. }
  49251. found = true;
  49252. }
  49253. });
  49254. }
  49255. });
  49256. if (found === false) {
  49257. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  49258. }
  49259. }
  49260. }
  49261. // Material ?
  49262. if (parsedMesh.materialId) {
  49263. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  49264. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  49265. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  49266. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  49267. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  49268. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  49269. var subMatId = parsedMultiMaterial.materials[matIndex];
  49270. loadedMaterialsIds.push(subMatId);
  49271. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  49272. if (mat) {
  49273. log += "\n\tMaterial " + mat.toString(fullDetails);
  49274. }
  49275. }
  49276. loadedMaterialsIds.push(parsedMultiMaterial.id);
  49277. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  49278. if (mmat) {
  49279. materialFound = true;
  49280. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  49281. }
  49282. break;
  49283. }
  49284. }
  49285. }
  49286. if (materialFound === false) {
  49287. loadedMaterialsIds.push(parsedMesh.materialId);
  49288. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  49289. if (!mat) {
  49290. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  49291. }
  49292. else {
  49293. log += "\n\tMaterial " + mat.toString(fullDetails);
  49294. }
  49295. }
  49296. }
  49297. // Skeleton ?
  49298. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  49299. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  49300. if (skeletonAlreadyLoaded === false) {
  49301. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  49302. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  49303. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  49304. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  49305. skeletons.push(skeleton);
  49306. loadedSkeletonsIds.push(parsedSkeleton.id);
  49307. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  49308. }
  49309. }
  49310. }
  49311. }
  49312. // Morph targets ?
  49313. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  49314. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  49315. var managerData = _a[_i];
  49316. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene);
  49317. }
  49318. }
  49319. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  49320. meshes.push(mesh);
  49321. log += "\n\tMesh " + mesh.toString(fullDetails);
  49322. }
  49323. }
  49324. // Connecting parents
  49325. var currentMesh;
  49326. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49327. currentMesh = scene.meshes[index];
  49328. if (currentMesh._waitingParentId) {
  49329. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  49330. currentMesh._waitingParentId = null;
  49331. }
  49332. }
  49333. // freeze and compute world matrix application
  49334. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49335. currentMesh = scene.meshes[index];
  49336. if (currentMesh._waitingFreezeWorldMatrix) {
  49337. currentMesh.freezeWorldMatrix();
  49338. currentMesh._waitingFreezeWorldMatrix = null;
  49339. }
  49340. else {
  49341. currentMesh.computeWorldMatrix(true);
  49342. }
  49343. }
  49344. }
  49345. // Particles
  49346. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  49347. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_12__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  49348. if (parser) {
  49349. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  49350. var parsedParticleSystem = parsedData.particleSystems[index];
  49351. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  49352. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  49353. }
  49354. }
  49355. }
  49356. }
  49357. return true;
  49358. }
  49359. catch (err) {
  49360. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  49361. if (onError) {
  49362. onError(msg, err);
  49363. }
  49364. else {
  49365. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  49366. throw err;
  49367. }
  49368. }
  49369. finally {
  49370. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  49371. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  49372. }
  49373. }
  49374. return false;
  49375. },
  49376. load: function (scene, data, rootUrl, onError) {
  49377. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  49378. // when SceneLoader.debugLogging = true (default), or exception encountered.
  49379. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  49380. // and avoid problems with multiple concurrent .babylon loads.
  49381. var log = "importScene has failed JSON parse";
  49382. try {
  49383. var parsedData = JSON.parse(data);
  49384. log = "";
  49385. // Scene
  49386. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  49387. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  49388. }
  49389. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  49390. scene.autoClear = parsedData.autoClear;
  49391. }
  49392. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  49393. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  49394. }
  49395. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  49396. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  49397. }
  49398. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  49399. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  49400. }
  49401. // Fog
  49402. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  49403. scene.fogMode = parsedData.fogMode;
  49404. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  49405. scene.fogStart = parsedData.fogStart;
  49406. scene.fogEnd = parsedData.fogEnd;
  49407. scene.fogDensity = parsedData.fogDensity;
  49408. log += "\tFog mode for scene: ";
  49409. switch (scene.fogMode) {
  49410. // getters not compiling, so using hardcoded
  49411. case 1:
  49412. log += "exp\n";
  49413. break;
  49414. case 2:
  49415. log += "exp2\n";
  49416. break;
  49417. case 3:
  49418. log += "linear\n";
  49419. break;
  49420. }
  49421. }
  49422. //Physics
  49423. if (parsedData.physicsEnabled) {
  49424. var physicsPlugin;
  49425. if (parsedData.physicsEngine === "cannon") {
  49426. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__["CannonJSPlugin"]();
  49427. }
  49428. else if (parsedData.physicsEngine === "oimo") {
  49429. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__["OimoJSPlugin"]();
  49430. }
  49431. else if (parsedData.physicsEngine === "ammo") {
  49432. physicsPlugin = new _Physics_Plugins_ammoJSPlugin__WEBPACK_IMPORTED_MODULE_21__["AmmoJSPlugin"]();
  49433. }
  49434. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  49435. //else - default engine, which is currently oimo
  49436. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  49437. scene.enablePhysics(physicsGravity, physicsPlugin);
  49438. }
  49439. // Metadata
  49440. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  49441. scene.metadata = parsedData.metadata;
  49442. }
  49443. //collisions, if defined. otherwise, default is true
  49444. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  49445. scene.collisionsEnabled = parsedData.collisionsEnabled;
  49446. }
  49447. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  49448. if (!container) {
  49449. return false;
  49450. }
  49451. if (parsedData.autoAnimate) {
  49452. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  49453. }
  49454. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  49455. scene.setActiveCameraByID(parsedData.activeCameraID);
  49456. }
  49457. // Environment texture
  49458. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  49459. // PBR needed for both HDR texture (gamma space) & a sky box
  49460. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  49461. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  49462. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  49463. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  49464. if (parsedData.environmentTextureRotationY) {
  49465. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  49466. }
  49467. scene.environmentTexture = hdrTexture;
  49468. }
  49469. else {
  49470. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_24__["Tools"].EndsWith(parsedData.environmentTexture, ".env")) {
  49471. var compressedTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](rootUrl + parsedData.environmentTexture, scene);
  49472. if (parsedData.environmentTextureRotationY) {
  49473. compressedTexture.rotationY = parsedData.environmentTextureRotationY;
  49474. }
  49475. scene.environmentTexture = compressedTexture;
  49476. }
  49477. else {
  49478. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  49479. if (parsedData.environmentTextureRotationY) {
  49480. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  49481. }
  49482. scene.environmentTexture = cubeTexture;
  49483. }
  49484. }
  49485. if (parsedData.createDefaultSkybox === true) {
  49486. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  49487. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  49488. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  49489. }
  49490. }
  49491. // Finish
  49492. return true;
  49493. }
  49494. catch (err) {
  49495. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  49496. if (onError) {
  49497. onError(msg, err);
  49498. }
  49499. else {
  49500. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  49501. throw err;
  49502. }
  49503. }
  49504. finally {
  49505. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  49506. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  49507. }
  49508. }
  49509. return false;
  49510. },
  49511. loadAssetContainer: function (scene, data, rootUrl, onError) {
  49512. var container = loadAssetContainer(scene, data, rootUrl, onError);
  49513. return container;
  49514. }
  49515. });
  49516. /***/ }),
  49517. /***/ "./Loading/Plugins/index.ts":
  49518. /*!**********************************!*\
  49519. !*** ./Loading/Plugins/index.ts ***!
  49520. \**********************************/
  49521. /*! exports provided: _BabylonLoaderRegistered */
  49522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49523. "use strict";
  49524. __webpack_require__.r(__webpack_exports__);
  49525. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  49526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  49527. /***/ }),
  49528. /***/ "./Loading/index.ts":
  49529. /*!**************************!*\
  49530. !*** ./Loading/index.ts ***!
  49531. \**************************/
  49532. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  49533. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49534. "use strict";
  49535. __webpack_require__.r(__webpack_exports__);
  49536. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  49537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  49538. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  49539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  49540. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  49541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  49542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  49543. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  49544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  49545. /***/ }),
  49546. /***/ "./Loading/loadingScreen.ts":
  49547. /*!**********************************!*\
  49548. !*** ./Loading/loadingScreen.ts ***!
  49549. \**********************************/
  49550. /*! exports provided: DefaultLoadingScreen */
  49551. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49552. "use strict";
  49553. __webpack_require__.r(__webpack_exports__);
  49554. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  49555. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  49556. /**
  49557. * Class used for the default loading screen
  49558. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  49559. */
  49560. var DefaultLoadingScreen = /** @class */ (function () {
  49561. /**
  49562. * Creates a new default loading screen
  49563. * @param _renderingCanvas defines the canvas used to render the scene
  49564. * @param _loadingText defines the default text to display
  49565. * @param _loadingDivBackgroundColor defines the default background color
  49566. */
  49567. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  49568. if (_loadingText === void 0) { _loadingText = ""; }
  49569. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  49570. var _this = this;
  49571. this._renderingCanvas = _renderingCanvas;
  49572. this._loadingText = _loadingText;
  49573. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  49574. // Resize
  49575. this._resizeLoadingUI = function () {
  49576. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  49577. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  49578. if (!_this._loadingDiv) {
  49579. return;
  49580. }
  49581. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  49582. _this._loadingDiv.style.left = canvasRect.left + "px";
  49583. _this._loadingDiv.style.top = canvasRect.top + "px";
  49584. _this._loadingDiv.style.width = canvasRect.width + "px";
  49585. _this._loadingDiv.style.height = canvasRect.height + "px";
  49586. };
  49587. }
  49588. /**
  49589. * Function called to display the loading screen
  49590. */
  49591. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  49592. if (this._loadingDiv) {
  49593. // Do not add a loading screen if there is already one
  49594. return;
  49595. }
  49596. this._loadingDiv = document.createElement("div");
  49597. this._loadingDiv.id = "babylonjsLoadingDiv";
  49598. this._loadingDiv.style.opacity = "0";
  49599. this._loadingDiv.style.transition = "opacity 1.5s ease";
  49600. this._loadingDiv.style.pointerEvents = "none";
  49601. // Loading text
  49602. this._loadingTextDiv = document.createElement("div");
  49603. this._loadingTextDiv.style.position = "absolute";
  49604. this._loadingTextDiv.style.left = "0";
  49605. this._loadingTextDiv.style.top = "50%";
  49606. this._loadingTextDiv.style.marginTop = "80px";
  49607. this._loadingTextDiv.style.width = "100%";
  49608. this._loadingTextDiv.style.height = "20px";
  49609. this._loadingTextDiv.style.fontFamily = "Arial";
  49610. this._loadingTextDiv.style.fontSize = "14px";
  49611. this._loadingTextDiv.style.color = "white";
  49612. this._loadingTextDiv.style.textAlign = "center";
  49613. this._loadingTextDiv.innerHTML = "Loading";
  49614. this._loadingDiv.appendChild(this._loadingTextDiv);
  49615. //set the predefined text
  49616. this._loadingTextDiv.innerHTML = this._loadingText;
  49617. // Generating keyframes
  49618. var style = document.createElement('style');
  49619. style.type = 'text/css';
  49620. var keyFrames = "@-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 }";
  49621. style.innerHTML = keyFrames;
  49622. document.getElementsByTagName('head')[0].appendChild(style);
  49623. // Loading img
  49624. var imgBack = new Image();
  49625. imgBack.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTZEaa/1AAAYq0lEQVR4Xu2dCZRcVZnHScAJUZSwjSOIbAJmEAZwQCCMoAInYRGIg8AwegQx7AFzUBBmzAFlE4EAwxz2GRk2w7AnAURZBiEOZgyEQDAQAjmEJqTpNd3V1V3Vmd+/6utKV7/1vnpVXd2p/zn3vOV+27vfu/fd/W3QQAPrBZqbm7fJZrN79vf3T+/r67uf4wO9vb37WXQDIwWtra0Tenp6voQTv5XP56/BkfcR3iLk1g6B7hEeI+zP5V+ZiAbqBZ2dnZ8lV+6Gg87CobfhpOc4byf0FjwYE9DneBkWcXrM2tmzNzTxDdQKJPyETCazI46YgiMuI9zJuXJltuChFIHsP/PSfIfTjU19A2mira1tcxy3ey6XO5vEnkV4kes11XBmENDVj97XOT2O03FmWgMuoNLzGRJva8IUnPkzjjcT/kLoKCZzfQB7XiX8M2G8md7AUJgzJ+Z6e88gZ1xGuj3HsY17PcVkrG9gp7CUF/F8PUvxqdZDrFq1ahNVfKjwTCYxZuDE2wjKlc2WViMePM+HPNsFPOdf22OPblD5OZQHvphnV65cjTMzxaQY3eA5V9OO/hmnm1lSjE7woFsQbiXki4++foHnXkW4mLC1JUl947333tsMY3emqfB9jtPJlXN5U0+bOXPmWCPxgOccSy4+AfqPio+9/oFnbyatbqVE28GSZfjQ1NT0KQzaHMcdyPfyaNoE12HcvdxT29K3Fkv8A2vWrPmcifAFZNtD91yRY+SBZ+9UsMtEgD+jTpeenp6JXI6xpKkuUDqRcA6Kr0Wpens+InQTnIpV6Fdi+BQT64ulS5eOIzefD62na7CeoGcnLCM8ykt5OWlzcPv772/BS/w3nP+K+xU11+DvQe5dcrQlTfWAwbNMb8XA8AyGX80xtLlA6TAJuteMbVhhia1v5VMcr+LWMeoZ4xiYw7q6urbhHbgG+paCkIRQehHu4pO3O5fVydEomF5Ulx548JfVD2wqfKE2I3R3ob/f2GoC1DWhdz7HG3i5j2pvb9+Z24m6HvVZQtYsZFWcowlzePEP4jJdR/OQhxTVpAs9NMXxmZxuZKo8IG4s+v8R2tUFphSBTBWzH+OAFwn/gS3TuN55xYoVqfc6dXd3fwHZ1xFaTX0iyGbwjJqXXAammxP00EXx6UMGEx7ram7+vKnzBZ/87Xiwp40tEdDTgYwlHG/CmadSjO7L+XiialOZAej7POFG2VK0Khngl6Pn8/LL0YEtlFh4n8oDAqvaAYH8tzH2iNDm1IIFn8Ax50G7xtgCAU07CfAG4RHOz+vLZL7e0dGxlYlKHaj8BHo25xgrsfV5wrYH4KmouxV+ZZDnCUdwmXxMGgFvFUVWD+jQuOot6rI0tb4gcfaG9v+MrcAn+wj38gL8C7cObmlp2ZRjOkWYD6ypuAf6zjFHLSJ0c/6YQ813DM/yZXgehreiVgP8cvSfsOeExYsXuzs6n8v9j8mqBRZQmdjXVPuira1NHSpn8UDf4Xu0vd2uCtDzacJOlDDf5ng94X8JTWarB8R1EK7ju7udiYgEz/v3pLFKm4oHUHhh3iZdfshpaEYpA4pvKLLXBujLYKRq71XLhUHg27z12rW9B6L/QhLrWWxRH7nzeDK8awi/5HRTEx0K6MZQ694LHk0DqrgfADkreIYz1q5c+UlTEQzesIuMryrggYQWjNL3RGO7p2tuFMeqjaOidgzyCz1yJMTJ6L6d66WEVCcHIO/dQkI75Chs2g97Hoc3jRz9Lge1ED5l4r0gckqRPB0gTw34t1B+h3IqxZkmrn2SULUa7ezZszdE5xfR9130Xsm5ilrnHrmkQOcKvrkncxqrIiY6wlewbw7BOUfDo/b84zzvj9C7J7eCS0NrUiRKCPjUE7ScMBdlF/B2HqBi0ERXBcuXL99YnQz9fX2ah3Up4UnsWGEmDRuUhoTn+Z5PfvbZZ2N/fuCZRJgnfhNVBu73EZoIKt7l0L2UBsYeDZg016nb5EUCWuXQewinUtTuyq2aTStF14a8SD+VDQVj6hDYxjuXf4Hjl83sSMCmTp8j4FtoMuRQ5dAZcii3kk/0s2bBhxIcBxjxUlib1hWInEDO/6qKV+y4geO5HAMntEE/pq+nZyo0ywsG1SmwL4Orf+0yqGCfmvR73LAn9lAeBjQTEhkA+1h49a08iRflcq4H5iuXFU9cz4lqihC/LXS/NZa6Bc+pz5gql5ub6VXD2tZWTSPeyS7XgeLhXrMnEhj6MSHSwaIhFGZH8oA/JzzFeexvJbRN2HW03moT6cEChx6w4QY2rurn85JWrxsiCy0FwjcIqos8w7GZNPulkawDEbFHlaBtjzODEDrVztuKXMmADPWA3RaljyJeNdKq98ilAez8iJdyGqfO31V4NoV/EvyaCqR54V2EshE5Lqcb+TrkstkTLD4WKB4PNNZQ8P05HAelMXNSPWChC8JsYvwthJo0jSoF6fIqjjqe08Aat+LIkd+AVjn09zxbZFqK3tjXAUbXUaWDjTUSyN4J45YZX2Igo4cEOVfFson2ALIxSjR0jog5YNgpfNHM90BxIjDyWIB8Z2NfB01HISJ20wPaw4w1FlavXq1v8aPGXhFw9JNRFTDItifU/RwwpfmKxYsDK180kU4x0lhAXvOSJUs+bezlIDL2N4xi4GpjK4MGCuzUA+SPxzn3m4iKgKyV2DCV08DeMWg0B+zHHOt2DpjS3Mz1BfFOM25C5ZH4LxldJBB0g7GVARkaXgv8VsKqZtIMPpN9RUnJgRzU5Wfp22vifcG3+2vQvmdsdQXsX2pm+oKX+GYjjQXkPWqsXshpRhcJ0RpbGShSHiSuheP37ZYHsGusVHOrU1lMxkO9od4eE+8LlSzQqfetpnPAooBN/2Um+gISp89MkF8K4G3RrMJYoOhbYGxlQEGhSOGogfoLwipExGtUZVVBYIVAluaAaUpuWA+YujlPF22Ra/iBLYEOsV6tV4w0FiitfmLsXiBMU0NiAVrfsp77Zd8MHPgbDoHtva6uLs1jiv1piAKy5tCG+4KJ9wVO/p6RDzvy+b5rzSwP9Okh/WKPERiCWzfk4K8bUSTiOljAyCdx5DZG4gE8W5Dov+NYUfsV/j50fUC4dmXIQDh0qQ6PVgJsOcLM8oA410Ggvo6Ojr81di+g2TKuQOiyJOKWxlpCJpM5zUjKAL3awTsamQfEbYhjtDGKa5tPsyn/wAuiURftlBO56h6aunEwCMxxvV1d+2Fr7Jce2vAu5LUtLeoGi/19gtbToCaR97BoD6BvUs+WkXqgbw6OuhC6wH5l4rRGaCFOvYnjYbyxnpcsCvDVhYOxo6+zszNwSNHVTtJEmSiwzlMAQmNPwIPW42Dds2hfEK/5WJo0Fth+5VNxFHSlkoTzFRh/N3wnq0OGWxXtdoO8enFwaI4jsyidYgNZTxhrMEjEJ4w+En65ESWRXZ7Q4K/COqDAPlhka87WedB8KawmngTIHREOJs5pMiRp+p/GGgxL1FiA9hxjK6G1tVVdhJGAV15+cPXq1f7dahVC20Wg4miCp0uTe3Xh4Hwu93rY1B7SR/t7xQbP5R1FGgpy8IlKe+MJhZ9Aa7u5jPm+pGLX2BMDOZ+hDXgQiXIJ5xoXHZg96anEEFcvOTi0SMUXS4w0FijSTzTWYEA3hkTSEtDI2qw6RoytDLA6jctCvzKqJ8oPFOO7kAhnYe9cZGiWiZ/N9ezguWaSL4h3TUfvKJIfoN0I4sjigYSdZyxlcDVMgEczEY41ER6oZFBOh2Yqegf2zYoziFC3DuZZrjSTPLDtMlxaNPmPP/54W2OPxksrVozP5fLPGr8vEOpbxJCr3jQSJyDvGRNRhv7iHh8vE5LMpKznHBz4zSTOaXwe+mXGGh9tbWvVQf+iyfCAON/ZlTj4v43ECfB94Le4CuMrWVpTtw7O9fZOM5M8oD7xVSOLBdLuNWN1g7bgJUF8+4qpBjf7Te9M6hD4tBDc0289Wh2MHbuaSR7gsHOMLBaQ9W/G6o5MJrNDPu9dcYdQ33Yc95I6OFV5hnp2cGCliDingX5KU+9MShd0dmqta/k8J4zwnV2JsuuNxAnI83VwNpO52kiSoC4djA255cuXBzYPycGzjTQWkPdNY00OfRcQVLafRnd39ySLLsG1i20AyPZ3cDb7AyNJgnp1cOhUHUhcFiL045v9jTUa8Gjlm29fsQQhb3DzJLUEhC+oiK7EISPOwapoEh+7JQJti5YfGXs0YNC62ouC1h9lsrlToClsjc/RM7uSe0kd3EmlzTO/Kqk8Q106mM/Yw2aOB9jnOg6sWTHxJ9FraSJMy6nGz7RbZUDYmN7e3BnQ5Gisez7u3J9c0JwA6Pb0aCFvNObgwKk6NoU59uJwaJ8y1viAT4vCtEFXYO8SFQGtCZpllyXQtNqL+4lmZ/BN/5qJKQFZozEHe9JtAGSaw4wsFnie4JmUQcjleh8yZq0Fnmq3y0D02IzPMgnonYqYIfA4pC+TcXrgIahLB+PEb5s5HrjaR0b7kbHGB0pK7TDO1/T39x1lUZGAPlUH0xTbz+KSoC4dDDx2DQCHzTCaWOB5zjbW+KCSpW0IS0BIJmy6zWCk7WDuxZ4r5oO6dHB7e/sBZo4H2OfUsYOv9jHW+ECJdkAtA/c6MpmMd+XaEKj7km9M4F5TEfBzSKovDLKG1cHobw+b6EDa3WOksYBPAhevBUJMxl8GJTRhFyMLBKSJFn5ls9nvmogS0DfaHOzb3h8AcUuNNBLQNiWa0gRv4MwMMyBwCqxAfCIH82JdYSJKQN+ocjA5NHD2I/e1aj/23iPyhbG6A+bAgXsZoUEII/UAkkQORu71JqIE7o22HBw4VaelpWU74mPPDc/39d1trO5Qb4vJ8QXxbwat06WofcTInMCzeToAtN4VXUn/l1AXDkan9tDSfmL6C81BZooHxDkN9CMveLFZFFAWWZtDwVta3G0sJcAbe3bmYEiniShBXabcL+wflQDD5mD0yKlvk0b/Tk33AG5F7idG+/ibRe54oEl1nLG6A+ZYe1jyAIuG/u2LB3MazxwAfL5vJFGJinxQUwcju6c/n3+FNPm5JhJyy2k/sQTp5nm+2HBJCGi1X1WpwzuBoQXAN+IcjDz8mdePKi/WhH1uxd7GcCjIVBcWpUYDfZ0VbclEJSr2akMBhVrdX6j+Jx3DpSh7vKB8CIiqKwcrcXGqdr05k3RKbU9ryTQVkUB3aHMrEshw7kGCXiv8xxG0h6Uzent6Fpn6MhA17A6GT/3yTxNO1coJbgWur3JFf1fXNuTes5AZe18xXobFHJKv04JZc3O7CtIcgGL9KW03u3QCfL4D4b292dhrpoYgsYOhEz4kaOuHqXKqiagYiN9QnUlyKgX84JUYsQFP9GKzMFRSe8XJb9upE9Dn62CK/KQT75wdTLz+NXgPNdrDuYzeUd0ByN4Wp07n+EdCRZuTY1/ymZQDwIjQye9pA32xdw6IiUgHc639mN8kzCLRjkxzQRzitUpkZ8LZBP1CILUd55EVvdgsCrzJl5i8mgCja+Zgjst4Pq3DUnMmtSWqyNIuQruRU3+CbO08n+pvBAZAjf1IU5kcGJc0YRMBfVV3MPd2RN4+YbvYukI/3sSpe+LUmbw0ryG/6ts1oSLeYrMw6C0xeaFAGc+Wq3hbfeRk582b55lrzf3UHJwWkD0Wp+6BQ3+BfXEXw6UCdHX4TVB0BoJi9Y1Cp59XbUWN8HW7lRjLli3zbINE+1hNiCRI1cGakIhT99ani/A6z1z1nDoUqNQfbO40kyqDfrCBwMg3E5rsCy+8sFlHR8dEnFzRTq/I8hQ9NFFOtGhXVOxgFeUqfknUK7Ctpjl1ANKJ/vmUkvrdwRZmWjpA4J9MTyja2toKY8TQa/ufxP/Whdd5c5cQJHIwfBsTvkKiaqd6/fRyOHKqavdL0H+V2sxmWvrQCAeKItfmQlNyDG/8SVwnetMHyxmA7lm0K2I7GFrlVBW/V6FPP9GqeU4V0Kt2+O2yhctUN6AJBEWD9ngMnessJxh5AfCoQe+8q+xQOYLuWbQrQh2MXP1XYh8S9DKC2sI1z6kCatW3/RCZ6Vj9fNPMqx2wQVNJQlcNEl/mGG5pv48bi7HxMVSOoHsW7QqPg5GlvnJtk6/B9+HMqYUfaXE6rampqWy4dVhgi8FfLprnBXEex+i/wCSkNiSNDSpUxxt7Ccj2nQQYAwUHc9yE3HEotuifDklnfFYMdGNC/lWCxotDf4PvB/jHZTs71c+f2n+ryqCPPcb5/pKdGrTvbH2MUjH4ByOLBDpON9YSFi5cuI1FOwFbbyTox5T6y+iwFL8CqvWvwVtolWgSv/N4sXbl5ZP3r8hRLT50d56KgYJDCYXVhYOhtqqReKDdZuGJtSQSOk8f67x581SspvH3lpoBe9Vefbg/lzveaXmnAf6tEDMNGRp3LnV3ch29o10lQIf+bOKZc+XnmMGARF2EK4vUwQiSw33n7ZlqDWwcaK9Ob29vd26vwj+OT8m3kKFxdd9tlILSJ1Wo8Y8RZT/YiKOY4le5P3SGZJAc7telg7FroL16Jc/n/a1cBBCxsSblwT8LOfofcCh4AQ4x1uoCXZtgVKnYDXLMUECnPSQD29VBcrhfVw7GHrVXb6WylGg0SvUZcrr+YPYuwWVfaE9ltmpA2Q6EQq2UY+yigzf2oqCH4v4MIysD94fdwdig9uqDnB4T5/d+gwHPGNVFcOopyJiPLOfmGTwa0Ek8qS8RKDKORLFWH95utwbDd94SRqqN/Cv4PDXbTFfXfUZWBvRUPJCRBJiIqfnnccy0Dz74wHkWoypY2D4ZGU8gK+kKjQKQ8RcTW1uQI2fmc7nH7LIMFEW+sw6xdyN4CgvNByNIDjp+ZyRVhzlV7dVLaZc7t1cRoW0w9of/No6ptbuRdZupqC3QPZY33HchMkbJiRPssgyaHkN82XaJXPtOJuN+JRuixQI6Cu1VXiZtJehcFGpeNPyXI6cqPWTIvsxU1R7o912akevre4OHfTHot3fEfRbD3y8+Qu0djO5Ce5UXNGl7dTt4z0RGqnOuhgLZgmcPk2FHrrd3jgwkAVQ58e1ioxjcHeMLPWQcq+5gZKm9+hJHjXo5z4xQBQsxxyDjEfir+nNq5GfQo/nYh6f9e4NUgGEFx3DEzvw1nPrOhSJ+kh6GUBUHw6//Kmls96dJ2qv6FxNF9z8g405kVLVXDfkaiFAd4JIkttYUGFpyDOf91Ch/YVEe8DA/gORpuywDfLNMjBOQt4qEupbTPTX4YeJig+/qrnoxkfMeIdH2UHGBfP0H6kFepElc1rY5lBQYXZbzuO7BWYH7b3V3d/+TX1FEG/JSExEJdOi7qsnrx3DuNM8Zdg2NqnN/BjK0EXlVhxORr56wP6Lv/DT+X1FzYLynaOWe2s1TjCQW4An9t6Jk4hBVdH6YpB9YNXoS+SRk/JaQZHd5J2CnesLuyGaze3KZ2hTemoNcpO+uB3pAQuzvC7SeJSfc0258Wo97aX9PT+TmMEMB73jsO0wJzXnVx4llL7pe5kWaFtSqGHHgu6rpPr5jsdx+hyI59G+hA4C25GDO1V69mbf/77h0+lZpzZX44B+Ye1X1cWKz92pKrYlcjtzc6gfN+ufhApd/ErcwTvuTRNI0m4c4Tg77u6gfbCHdTuQcrRFaRKiFU7Xl1O/RqX9RObevRxR43gmEBYUn9wEJIMeF/jk0yVKTta2tE0jg43kx1OatWifEYKDrHYKGDnfkMrU1xHUPaoh7k8i+030EvoV3c6i4aTCoc/9+9NVkFgh6BmZFaig08he3oxYkwBEkQGCzg7gfG6kzaDvuSyLfgIyqt1cF6SAspoS4iJf3c9xaf3JrGEgUzZcOGgvO4agzjTQUkI9V5z4851MuLhBvUUp1gR7tjXEHL+shXFZnduNIBomi6T73FVLLByQePu4N3CxMbVxyzfeQUTYZrdpA3yvoPVf/1jdTGggC6aXx0ieLSecFcWoj72vkhU4IcswU7gVORksb6FHnufbouJ4Xbv+gf1g0EADav9uSeO9YenpA3IfURFVZ0gqEms1rRg0qCzM4TuYy1T061jt0dXXpX0xJ96FMDXIqQXtJ3tSfze6OaY0KU1ogfTUgUJMK0lBIL06dS/F/LJeRe0k2kAAk7BgSWN2GVW/aCOjRuPCbBHVGBG6J3ECKIN3VlfjroguqA+RrMsFvCNqisf5mRox2qPlB4s8vuiMdIE/fVjVvLlRnhKlqYLig7QIpOiva40PAqR2E22neJFrN10AVgWMOIDgPuMOjmRFa+HVaR0fHliaugXoEOe80nBWrZg2dZkZoYffuaW5u1kCVkadmbT70AGdqJodWOhxHqP2eFg1UDvsLatnSFq41M+KKnp6eXbhsdB2OdGiCeX8+/2ecqgnmk/VXNYtqYLSAnNposzpjgw3+H/belpVa8J7TAAAAAElFTkSuQmCC";
  49626. imgBack.style.position = "absolute";
  49627. imgBack.style.left = "50%";
  49628. imgBack.style.top = "50%";
  49629. imgBack.style.marginLeft = "-60px";
  49630. imgBack.style.marginTop = "-60px";
  49631. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  49632. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  49633. imgBack.style.transformOrigin = "50% 50%";
  49634. imgBack.style.webkitTransformOrigin = "50% 50%";
  49635. this._loadingDiv.appendChild(imgBack);
  49636. this._resizeLoadingUI();
  49637. window.addEventListener("resize", this._resizeLoadingUI);
  49638. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  49639. document.body.appendChild(this._loadingDiv);
  49640. this._loadingDiv.style.opacity = "1";
  49641. };
  49642. /**
  49643. * Function called to hide the loading screen
  49644. */
  49645. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  49646. var _this = this;
  49647. if (!this._loadingDiv) {
  49648. return;
  49649. }
  49650. var onTransitionEnd = function () {
  49651. if (!_this._loadingDiv) {
  49652. return;
  49653. }
  49654. if (_this._loadingDiv.parentElement) {
  49655. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  49656. }
  49657. window.removeEventListener("resize", _this._resizeLoadingUI);
  49658. _this._loadingDiv = null;
  49659. };
  49660. this._loadingDiv.style.opacity = "0";
  49661. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  49662. };
  49663. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  49664. get: function () {
  49665. return this._loadingText;
  49666. },
  49667. /**
  49668. * Gets or sets the text to display while loading
  49669. */
  49670. set: function (text) {
  49671. this._loadingText = text;
  49672. if (this._loadingTextDiv) {
  49673. this._loadingTextDiv.innerHTML = this._loadingText;
  49674. }
  49675. },
  49676. enumerable: true,
  49677. configurable: true
  49678. });
  49679. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  49680. /**
  49681. * Gets or sets the color to use for the background
  49682. */
  49683. get: function () {
  49684. return this._loadingDivBackgroundColor;
  49685. },
  49686. set: function (color) {
  49687. this._loadingDivBackgroundColor = color;
  49688. if (!this._loadingDiv) {
  49689. return;
  49690. }
  49691. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  49692. },
  49693. enumerable: true,
  49694. configurable: true
  49695. });
  49696. return DefaultLoadingScreen;
  49697. }());
  49698. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  49699. /***/ }),
  49700. /***/ "./Loading/sceneLoader.ts":
  49701. /*!********************************!*\
  49702. !*** ./Loading/sceneLoader.ts ***!
  49703. \********************************/
  49704. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  49705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49706. "use strict";
  49707. __webpack_require__.r(__webpack_exports__);
  49708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  49709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  49710. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  49711. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  49712. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  49713. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  49714. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  49715. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  49716. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  49717. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  49718. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  49719. /**
  49720. * Class used to represent data loading progression
  49721. */
  49722. var SceneLoaderProgressEvent = /** @class */ (function () {
  49723. /**
  49724. * Create a new progress event
  49725. * @param lengthComputable defines if data length to load can be evaluated
  49726. * @param loaded defines the loaded data length
  49727. * @param total defines the data length to load
  49728. */
  49729. function SceneLoaderProgressEvent(
  49730. /** defines if data length to load can be evaluated */
  49731. lengthComputable,
  49732. /** defines the loaded data length */
  49733. loaded,
  49734. /** defines the data length to load */
  49735. total) {
  49736. this.lengthComputable = lengthComputable;
  49737. this.loaded = loaded;
  49738. this.total = total;
  49739. }
  49740. /**
  49741. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  49742. * @param event defines the source event
  49743. * @returns a new SceneLoaderProgressEvent
  49744. */
  49745. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  49746. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  49747. };
  49748. return SceneLoaderProgressEvent;
  49749. }());
  49750. /**
  49751. * Class used to load scene from various file formats using registered plugins
  49752. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  49753. */
  49754. var SceneLoader = /** @class */ (function () {
  49755. function SceneLoader() {
  49756. }
  49757. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  49758. /**
  49759. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49760. */
  49761. get: function () {
  49762. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  49763. },
  49764. set: function (value) {
  49765. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  49766. },
  49767. enumerable: true,
  49768. configurable: true
  49769. });
  49770. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  49771. /**
  49772. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49773. */
  49774. get: function () {
  49775. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  49776. },
  49777. set: function (value) {
  49778. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  49779. },
  49780. enumerable: true,
  49781. configurable: true
  49782. });
  49783. Object.defineProperty(SceneLoader, "loggingLevel", {
  49784. /**
  49785. * Defines the current logging level (while loading the scene)
  49786. * @ignorenaming
  49787. */
  49788. get: function () {
  49789. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  49790. },
  49791. set: function (value) {
  49792. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  49793. },
  49794. enumerable: true,
  49795. configurable: true
  49796. });
  49797. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  49798. /**
  49799. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49800. */
  49801. get: function () {
  49802. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  49803. },
  49804. set: function (value) {
  49805. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  49806. },
  49807. enumerable: true,
  49808. configurable: true
  49809. });
  49810. SceneLoader._getDefaultPlugin = function () {
  49811. return SceneLoader._registeredPlugins[".babylon"];
  49812. };
  49813. SceneLoader._getPluginForExtension = function (extension) {
  49814. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  49815. if (registeredPlugin) {
  49816. return registeredPlugin;
  49817. }
  49818. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("Unable to find a plugin to load " + extension + " files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: http://doc.babylonjs.com/how_to/load_from_any_file_type");
  49819. return SceneLoader._getDefaultPlugin();
  49820. };
  49821. SceneLoader._getPluginForDirectLoad = function (data) {
  49822. for (var extension in SceneLoader._registeredPlugins) {
  49823. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  49824. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  49825. return SceneLoader._registeredPlugins[extension];
  49826. }
  49827. }
  49828. return SceneLoader._getDefaultPlugin();
  49829. };
  49830. SceneLoader._getPluginForFilename = function (sceneFilename) {
  49831. var queryStringPosition = sceneFilename.indexOf("?");
  49832. if (queryStringPosition !== -1) {
  49833. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  49834. }
  49835. var dotPosition = sceneFilename.lastIndexOf(".");
  49836. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  49837. return SceneLoader._getPluginForExtension(extension);
  49838. };
  49839. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  49840. SceneLoader._getDirectLoad = function (sceneFilename) {
  49841. if (sceneFilename.substr(0, 5) === "data:") {
  49842. return sceneFilename.substr(5);
  49843. }
  49844. return null;
  49845. };
  49846. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  49847. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  49848. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  49849. var plugin;
  49850. if (registeredPlugin.plugin.createPlugin) {
  49851. plugin = registeredPlugin.plugin.createPlugin();
  49852. }
  49853. else {
  49854. plugin = registeredPlugin.plugin;
  49855. }
  49856. if (!plugin) {
  49857. 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.";
  49858. }
  49859. var useArrayBuffer = registeredPlugin.isBinary;
  49860. var offlineProvider;
  49861. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  49862. var dataCallback = function (data, responseURL) {
  49863. if (scene.isDisposed) {
  49864. onError("Scene has been disposed");
  49865. return;
  49866. }
  49867. scene.offlineProvider = offlineProvider;
  49868. onSuccess(plugin, data, responseURL);
  49869. };
  49870. var request = null;
  49871. var pluginDisposed = false;
  49872. var onDisposeObservable = plugin.onDisposeObservable;
  49873. if (onDisposeObservable) {
  49874. onDisposeObservable.add(function () {
  49875. pluginDisposed = true;
  49876. if (request) {
  49877. request.abort();
  49878. request = null;
  49879. }
  49880. onDispose();
  49881. });
  49882. }
  49883. var manifestChecked = function () {
  49884. if (pluginDisposed) {
  49885. return;
  49886. }
  49887. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  49888. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  49889. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  49890. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  49891. });
  49892. };
  49893. if (directLoad) {
  49894. dataCallback(directLoad);
  49895. return plugin;
  49896. }
  49897. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  49898. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  49899. var engine = scene.getEngine();
  49900. var canUseOfflineSupport = engine.enableOfflineSupport;
  49901. if (canUseOfflineSupport) {
  49902. // Also check for exceptions
  49903. var exceptionFound = false;
  49904. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  49905. var regex = _a[_i];
  49906. if (regex.test(fileInfo.url)) {
  49907. exceptionFound = true;
  49908. break;
  49909. }
  49910. }
  49911. canUseOfflineSupport = !exceptionFound;
  49912. }
  49913. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  49914. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  49915. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  49916. }
  49917. else {
  49918. manifestChecked();
  49919. }
  49920. }
  49921. // Loading file from disk via input file or drag'n'drop
  49922. else {
  49923. if (file) {
  49924. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  49925. }
  49926. else {
  49927. onError("Unable to find file named " + fileInfo.name);
  49928. }
  49929. }
  49930. return plugin;
  49931. };
  49932. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  49933. var url;
  49934. var name;
  49935. var file = null;
  49936. if (!sceneFilename) {
  49937. url = rootUrl;
  49938. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  49939. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  49940. }
  49941. else if (sceneFilename.name) {
  49942. var sceneFile = sceneFilename;
  49943. url = rootUrl + sceneFile.name;
  49944. name = sceneFile.name;
  49945. file = sceneFile;
  49946. }
  49947. else {
  49948. var filename = sceneFilename;
  49949. if (filename.substr(0, 1) === "/") {
  49950. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  49951. return null;
  49952. }
  49953. url = rootUrl + filename;
  49954. name = filename;
  49955. }
  49956. return {
  49957. url: url,
  49958. rootUrl: rootUrl,
  49959. name: name,
  49960. file: file
  49961. };
  49962. };
  49963. // Public functions
  49964. /**
  49965. * Gets a plugin that can load the given extension
  49966. * @param extension defines the extension to load
  49967. * @returns a plugin or null if none works
  49968. */
  49969. SceneLoader.GetPluginForExtension = function (extension) {
  49970. return SceneLoader._getPluginForExtension(extension).plugin;
  49971. };
  49972. /**
  49973. * Gets a boolean indicating that the given extension can be loaded
  49974. * @param extension defines the extension to load
  49975. * @returns true if the extension is supported
  49976. */
  49977. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  49978. return !!SceneLoader._registeredPlugins[extension];
  49979. };
  49980. /**
  49981. * Adds a new plugin to the list of registered plugins
  49982. * @param plugin defines the plugin to add
  49983. */
  49984. SceneLoader.RegisterPlugin = function (plugin) {
  49985. if (typeof plugin.extensions === "string") {
  49986. var extension = plugin.extensions;
  49987. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  49988. plugin: plugin,
  49989. isBinary: false
  49990. };
  49991. }
  49992. else {
  49993. var extensions = plugin.extensions;
  49994. Object.keys(extensions).forEach(function (extension) {
  49995. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  49996. plugin: plugin,
  49997. isBinary: extensions[extension].isBinary
  49998. };
  49999. });
  50000. }
  50001. };
  50002. /**
  50003. * Import meshes into a scene
  50004. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50005. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  50006. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  50007. * @param scene the instance of BABYLON.Scene to append to
  50008. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  50009. * @param onProgress a callback with a progress event for each file being loaded
  50010. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50011. * @param pluginExtension the extension used to determine the plugin
  50012. * @returns The loaded plugin
  50013. */
  50014. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  50015. if (sceneFilename === void 0) { sceneFilename = ""; }
  50016. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50017. if (onSuccess === void 0) { onSuccess = null; }
  50018. if (onProgress === void 0) { onProgress = null; }
  50019. if (onError === void 0) { onError = null; }
  50020. if (pluginExtension === void 0) { pluginExtension = null; }
  50021. if (!scene) {
  50022. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  50023. return null;
  50024. }
  50025. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  50026. if (!fileInfo) {
  50027. return null;
  50028. }
  50029. var loadingToken = {};
  50030. scene._addPendingData(loadingToken);
  50031. var disposeHandler = function () {
  50032. scene._removePendingData(loadingToken);
  50033. };
  50034. var errorHandler = function (message, exception) {
  50035. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  50036. if (onError) {
  50037. onError(scene, errorMessage, exception);
  50038. }
  50039. else {
  50040. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  50041. // should the exception be thrown?
  50042. }
  50043. disposeHandler();
  50044. };
  50045. var progressHandler = onProgress ? function (event) {
  50046. try {
  50047. onProgress(event);
  50048. }
  50049. catch (e) {
  50050. errorHandler("Error in onProgress callback", e);
  50051. }
  50052. } : undefined;
  50053. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  50054. scene.importedMeshesFiles.push(fileInfo.url);
  50055. if (onSuccess) {
  50056. try {
  50057. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  50058. }
  50059. catch (e) {
  50060. errorHandler("Error in onSuccess callback", e);
  50061. }
  50062. }
  50063. scene._removePendingData(loadingToken);
  50064. };
  50065. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  50066. if (plugin.rewriteRootURL) {
  50067. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  50068. }
  50069. if (plugin.importMesh) {
  50070. var syncedPlugin = plugin;
  50071. var meshes = new Array();
  50072. var particleSystems = new Array();
  50073. var skeletons = new Array();
  50074. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  50075. return;
  50076. }
  50077. scene.loadingPluginName = plugin.name;
  50078. successHandler(meshes, particleSystems, skeletons, []);
  50079. }
  50080. else {
  50081. var asyncedPlugin = plugin;
  50082. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  50083. scene.loadingPluginName = plugin.name;
  50084. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  50085. }).catch(function (error) {
  50086. errorHandler(error.message, error);
  50087. });
  50088. }
  50089. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  50090. };
  50091. /**
  50092. * Import meshes into a scene
  50093. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50094. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  50095. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  50096. * @param scene the instance of BABYLON.Scene to append to
  50097. * @param onProgress a callback with a progress event for each file being loaded
  50098. * @param pluginExtension the extension used to determine the plugin
  50099. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  50100. */
  50101. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  50102. if (sceneFilename === void 0) { sceneFilename = ""; }
  50103. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50104. if (onProgress === void 0) { onProgress = null; }
  50105. if (pluginExtension === void 0) { pluginExtension = null; }
  50106. return new Promise(function (resolve, reject) {
  50107. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  50108. resolve({
  50109. meshes: meshes,
  50110. particleSystems: particleSystems,
  50111. skeletons: skeletons,
  50112. animationGroups: animationGroups
  50113. });
  50114. }, onProgress, function (scene, message, exception) {
  50115. reject(exception || new Error(message));
  50116. }, pluginExtension);
  50117. });
  50118. };
  50119. /**
  50120. * Load a scene
  50121. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  50122. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  50123. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50124. * @param onSuccess a callback with the scene when import succeeds
  50125. * @param onProgress a callback with a progress event for each file being loaded
  50126. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50127. * @param pluginExtension the extension used to determine the plugin
  50128. * @returns The loaded plugin
  50129. */
  50130. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  50131. if (sceneFilename === void 0) { sceneFilename = ""; }
  50132. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  50133. if (onSuccess === void 0) { onSuccess = null; }
  50134. if (onProgress === void 0) { onProgress = null; }
  50135. if (onError === void 0) { onError = null; }
  50136. if (pluginExtension === void 0) { pluginExtension = null; }
  50137. if (!engine) {
  50138. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  50139. return null;
  50140. }
  50141. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  50142. };
  50143. /**
  50144. * Load a scene
  50145. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  50146. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  50147. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50148. * @param onProgress a callback with a progress event for each file being loaded
  50149. * @param pluginExtension the extension used to determine the plugin
  50150. * @returns The loaded scene
  50151. */
  50152. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  50153. if (sceneFilename === void 0) { sceneFilename = ""; }
  50154. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  50155. if (onProgress === void 0) { onProgress = null; }
  50156. if (pluginExtension === void 0) { pluginExtension = null; }
  50157. return new Promise(function (resolve, reject) {
  50158. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  50159. resolve(scene);
  50160. }, onProgress, function (scene, message, exception) {
  50161. reject(exception || new Error(message));
  50162. }, pluginExtension);
  50163. });
  50164. };
  50165. /**
  50166. * Append a scene
  50167. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  50168. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  50169. * @param scene is the instance of BABYLON.Scene to append to
  50170. * @param onSuccess a callback with the scene when import succeeds
  50171. * @param onProgress a callback with a progress event for each file being loaded
  50172. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50173. * @param pluginExtension the extension used to determine the plugin
  50174. * @returns The loaded plugin
  50175. */
  50176. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  50177. if (sceneFilename === void 0) { sceneFilename = ""; }
  50178. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50179. if (onSuccess === void 0) { onSuccess = null; }
  50180. if (onProgress === void 0) { onProgress = null; }
  50181. if (onError === void 0) { onError = null; }
  50182. if (pluginExtension === void 0) { pluginExtension = null; }
  50183. if (!scene) {
  50184. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  50185. return null;
  50186. }
  50187. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  50188. if (!fileInfo) {
  50189. return null;
  50190. }
  50191. if (SceneLoader.ShowLoadingScreen) {
  50192. scene.getEngine().displayLoadingUI();
  50193. }
  50194. var loadingToken = {};
  50195. scene._addPendingData(loadingToken);
  50196. var disposeHandler = function () {
  50197. scene._removePendingData(loadingToken);
  50198. scene.getEngine().hideLoadingUI();
  50199. };
  50200. var errorHandler = function (message, exception) {
  50201. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  50202. if (onError) {
  50203. onError(scene, errorMessage, exception);
  50204. }
  50205. else {
  50206. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  50207. // should the exception be thrown?
  50208. }
  50209. disposeHandler();
  50210. };
  50211. var progressHandler = onProgress ? function (event) {
  50212. try {
  50213. onProgress(event);
  50214. }
  50215. catch (e) {
  50216. errorHandler("Error in onProgress callback", e);
  50217. }
  50218. } : undefined;
  50219. var successHandler = function () {
  50220. if (onSuccess) {
  50221. try {
  50222. onSuccess(scene);
  50223. }
  50224. catch (e) {
  50225. errorHandler("Error in onSuccess callback", e);
  50226. }
  50227. }
  50228. scene._removePendingData(loadingToken);
  50229. };
  50230. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  50231. if (plugin.load) {
  50232. var syncedPlugin = plugin;
  50233. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  50234. return;
  50235. }
  50236. scene.loadingPluginName = plugin.name;
  50237. successHandler();
  50238. }
  50239. else {
  50240. var asyncedPlugin = plugin;
  50241. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  50242. scene.loadingPluginName = plugin.name;
  50243. successHandler();
  50244. }).catch(function (error) {
  50245. errorHandler(error.message, error);
  50246. });
  50247. }
  50248. if (SceneLoader.ShowLoadingScreen) {
  50249. scene.executeWhenReady(function () {
  50250. scene.getEngine().hideLoadingUI();
  50251. });
  50252. }
  50253. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  50254. };
  50255. /**
  50256. * Append a scene
  50257. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  50258. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  50259. * @param scene is the instance of BABYLON.Scene to append to
  50260. * @param onProgress a callback with a progress event for each file being loaded
  50261. * @param pluginExtension the extension used to determine the plugin
  50262. * @returns The given scene
  50263. */
  50264. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  50265. if (sceneFilename === void 0) { sceneFilename = ""; }
  50266. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50267. if (onProgress === void 0) { onProgress = null; }
  50268. if (pluginExtension === void 0) { pluginExtension = null; }
  50269. return new Promise(function (resolve, reject) {
  50270. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  50271. resolve(scene);
  50272. }, onProgress, function (scene, message, exception) {
  50273. reject(exception || new Error(message));
  50274. }, pluginExtension);
  50275. });
  50276. };
  50277. /**
  50278. * Load a scene into an asset container
  50279. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  50280. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  50281. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  50282. * @param onSuccess a callback with the scene when import succeeds
  50283. * @param onProgress a callback with a progress event for each file being loaded
  50284. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50285. * @param pluginExtension the extension used to determine the plugin
  50286. * @returns The loaded plugin
  50287. */
  50288. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  50289. if (sceneFilename === void 0) { sceneFilename = ""; }
  50290. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50291. if (onSuccess === void 0) { onSuccess = null; }
  50292. if (onProgress === void 0) { onProgress = null; }
  50293. if (onError === void 0) { onError = null; }
  50294. if (pluginExtension === void 0) { pluginExtension = null; }
  50295. if (!scene) {
  50296. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  50297. return null;
  50298. }
  50299. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  50300. if (!fileInfo) {
  50301. return null;
  50302. }
  50303. var loadingToken = {};
  50304. scene._addPendingData(loadingToken);
  50305. var disposeHandler = function () {
  50306. scene._removePendingData(loadingToken);
  50307. };
  50308. var errorHandler = function (message, exception) {
  50309. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  50310. if (onError) {
  50311. onError(scene, errorMessage, exception);
  50312. }
  50313. else {
  50314. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  50315. // should the exception be thrown?
  50316. }
  50317. disposeHandler();
  50318. };
  50319. var progressHandler = onProgress ? function (event) {
  50320. try {
  50321. onProgress(event);
  50322. }
  50323. catch (e) {
  50324. errorHandler("Error in onProgress callback", e);
  50325. }
  50326. } : undefined;
  50327. var successHandler = function (assets) {
  50328. if (onSuccess) {
  50329. try {
  50330. onSuccess(assets);
  50331. }
  50332. catch (e) {
  50333. errorHandler("Error in onSuccess callback", e);
  50334. }
  50335. }
  50336. scene._removePendingData(loadingToken);
  50337. };
  50338. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  50339. if (plugin.loadAssetContainer) {
  50340. var syncedPlugin = plugin;
  50341. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  50342. if (!assetContainer) {
  50343. return;
  50344. }
  50345. scene.loadingPluginName = plugin.name;
  50346. successHandler(assetContainer);
  50347. }
  50348. else if (plugin.loadAssetContainerAsync) {
  50349. var asyncedPlugin = plugin;
  50350. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  50351. scene.loadingPluginName = plugin.name;
  50352. successHandler(assetContainer);
  50353. }).catch(function (error) {
  50354. errorHandler(error.message, error);
  50355. });
  50356. }
  50357. else {
  50358. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  50359. }
  50360. if (SceneLoader.ShowLoadingScreen) {
  50361. scene.executeWhenReady(function () {
  50362. scene.getEngine().hideLoadingUI();
  50363. });
  50364. }
  50365. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  50366. };
  50367. /**
  50368. * Load a scene into an asset container
  50369. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  50370. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  50371. * @param scene is the instance of Scene to append to
  50372. * @param onProgress a callback with a progress event for each file being loaded
  50373. * @param pluginExtension the extension used to determine the plugin
  50374. * @returns The loaded asset container
  50375. */
  50376. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  50377. if (sceneFilename === void 0) { sceneFilename = ""; }
  50378. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50379. if (onProgress === void 0) { onProgress = null; }
  50380. if (pluginExtension === void 0) { pluginExtension = null; }
  50381. return new Promise(function (resolve, reject) {
  50382. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  50383. resolve(assetContainer);
  50384. }, onProgress, function (scene, message, exception) {
  50385. reject(exception || new Error(message));
  50386. }, pluginExtension);
  50387. });
  50388. };
  50389. /**
  50390. * No logging while loading
  50391. */
  50392. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  50393. /**
  50394. * Minimal logging while loading
  50395. */
  50396. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  50397. /**
  50398. * Summary logging while loading
  50399. */
  50400. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  50401. /**
  50402. * Detailled logging while loading
  50403. */
  50404. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  50405. // Members
  50406. /**
  50407. * Event raised when a plugin is used to load a scene
  50408. */
  50409. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  50410. SceneLoader._registeredPlugins = {};
  50411. return SceneLoader;
  50412. }());
  50413. /***/ }),
  50414. /***/ "./Loading/sceneLoaderFlags.ts":
  50415. /*!*************************************!*\
  50416. !*** ./Loading/sceneLoaderFlags.ts ***!
  50417. \*************************************/
  50418. /*! exports provided: SceneLoaderFlags */
  50419. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50420. "use strict";
  50421. __webpack_require__.r(__webpack_exports__);
  50422. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  50423. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  50424. /**
  50425. * Class used to represent data loading progression
  50426. */
  50427. var SceneLoaderFlags = /** @class */ (function () {
  50428. function SceneLoaderFlags() {
  50429. }
  50430. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  50431. /**
  50432. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  50433. */
  50434. get: function () {
  50435. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  50436. },
  50437. set: function (value) {
  50438. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  50439. },
  50440. enumerable: true,
  50441. configurable: true
  50442. });
  50443. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  50444. /**
  50445. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  50446. */
  50447. get: function () {
  50448. return SceneLoaderFlags._ShowLoadingScreen;
  50449. },
  50450. set: function (value) {
  50451. SceneLoaderFlags._ShowLoadingScreen = value;
  50452. },
  50453. enumerable: true,
  50454. configurable: true
  50455. });
  50456. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  50457. /**
  50458. * Defines the current logging level (while loading the scene)
  50459. * @ignorenaming
  50460. */
  50461. get: function () {
  50462. return SceneLoaderFlags._loggingLevel;
  50463. },
  50464. set: function (value) {
  50465. SceneLoaderFlags._loggingLevel = value;
  50466. },
  50467. enumerable: true,
  50468. configurable: true
  50469. });
  50470. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  50471. /**
  50472. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  50473. */
  50474. get: function () {
  50475. return SceneLoaderFlags._CleanBoneMatrixWeights;
  50476. },
  50477. set: function (value) {
  50478. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  50479. },
  50480. enumerable: true,
  50481. configurable: true
  50482. });
  50483. // Flags
  50484. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  50485. SceneLoaderFlags._ShowLoadingScreen = true;
  50486. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  50487. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  50488. return SceneLoaderFlags;
  50489. }());
  50490. /***/ }),
  50491. /***/ "./Materials/Background/backgroundMaterial.ts":
  50492. /*!****************************************************!*\
  50493. !*** ./Materials/Background/backgroundMaterial.ts ***!
  50494. \****************************************************/
  50495. /*! exports provided: BackgroundMaterial */
  50496. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50497. "use strict";
  50498. __webpack_require__.r(__webpack_exports__);
  50499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  50500. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  50501. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  50502. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  50503. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  50504. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  50505. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  50506. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  50507. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  50508. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  50509. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  50510. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  50511. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  50512. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  50513. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  50514. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  50515. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  50516. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  50517. /**
  50518. * Background material defines definition.
  50519. * @hidden Mainly internal Use
  50520. */
  50521. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  50522. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  50523. /**
  50524. * Constructor of the defines.
  50525. */
  50526. function BackgroundMaterialDefines() {
  50527. var _this = _super.call(this) || this;
  50528. /**
  50529. * True if the diffuse texture is in use.
  50530. */
  50531. _this.DIFFUSE = false;
  50532. /**
  50533. * The direct UV channel to use.
  50534. */
  50535. _this.DIFFUSEDIRECTUV = 0;
  50536. /**
  50537. * True if the diffuse texture is in gamma space.
  50538. */
  50539. _this.GAMMADIFFUSE = false;
  50540. /**
  50541. * True if the diffuse texture has opacity in the alpha channel.
  50542. */
  50543. _this.DIFFUSEHASALPHA = false;
  50544. /**
  50545. * True if you want the material to fade to transparent at grazing angle.
  50546. */
  50547. _this.OPACITYFRESNEL = false;
  50548. /**
  50549. * True if an extra blur needs to be added in the reflection.
  50550. */
  50551. _this.REFLECTIONBLUR = false;
  50552. /**
  50553. * True if you want the material to fade to reflection at grazing angle.
  50554. */
  50555. _this.REFLECTIONFRESNEL = false;
  50556. /**
  50557. * True if you want the material to falloff as far as you move away from the scene center.
  50558. */
  50559. _this.REFLECTIONFALLOFF = false;
  50560. /**
  50561. * False if the current Webgl implementation does not support the texture lod extension.
  50562. */
  50563. _this.TEXTURELODSUPPORT = false;
  50564. /**
  50565. * True to ensure the data are premultiplied.
  50566. */
  50567. _this.PREMULTIPLYALPHA = false;
  50568. /**
  50569. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  50570. */
  50571. _this.USERGBCOLOR = false;
  50572. /**
  50573. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  50574. * stays aligned with the desired configuration.
  50575. */
  50576. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  50577. /**
  50578. * True to add noise in order to reduce the banding effect.
  50579. */
  50580. _this.NOISE = false;
  50581. /**
  50582. * is the reflection texture in BGR color scheme?
  50583. * Mainly used to solve a bug in ios10 video tag
  50584. */
  50585. _this.REFLECTIONBGR = false;
  50586. _this.IMAGEPROCESSING = false;
  50587. _this.VIGNETTE = false;
  50588. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  50589. _this.VIGNETTEBLENDMODEOPAQUE = false;
  50590. _this.TONEMAPPING = false;
  50591. _this.TONEMAPPING_ACES = false;
  50592. _this.CONTRAST = false;
  50593. _this.COLORCURVES = false;
  50594. _this.COLORGRADING = false;
  50595. _this.COLORGRADING3D = false;
  50596. _this.SAMPLER3DGREENDEPTH = false;
  50597. _this.SAMPLER3DBGRMAP = false;
  50598. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  50599. _this.EXPOSURE = false;
  50600. _this.MULTIVIEW = false;
  50601. // Reflection.
  50602. _this.REFLECTION = false;
  50603. _this.REFLECTIONMAP_3D = false;
  50604. _this.REFLECTIONMAP_SPHERICAL = false;
  50605. _this.REFLECTIONMAP_PLANAR = false;
  50606. _this.REFLECTIONMAP_CUBIC = false;
  50607. _this.REFLECTIONMAP_PROJECTION = false;
  50608. _this.REFLECTIONMAP_SKYBOX = false;
  50609. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50610. _this.REFLECTIONMAP_EXPLICIT = false;
  50611. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50612. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50613. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50614. _this.INVERTCUBICMAP = false;
  50615. _this.REFLECTIONMAP_OPPOSITEZ = false;
  50616. _this.LODINREFLECTIONALPHA = false;
  50617. _this.GAMMAREFLECTION = false;
  50618. _this.RGBDREFLECTION = false;
  50619. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  50620. // Default BJS.
  50621. _this.MAINUV1 = false;
  50622. _this.MAINUV2 = false;
  50623. _this.UV1 = false;
  50624. _this.UV2 = false;
  50625. _this.CLIPPLANE = false;
  50626. _this.CLIPPLANE2 = false;
  50627. _this.CLIPPLANE3 = false;
  50628. _this.CLIPPLANE4 = false;
  50629. _this.POINTSIZE = false;
  50630. _this.FOG = false;
  50631. _this.NORMAL = false;
  50632. _this.NUM_BONE_INFLUENCERS = 0;
  50633. _this.BonesPerMesh = 0;
  50634. _this.INSTANCES = false;
  50635. _this.SHADOWFLOAT = false;
  50636. _this.rebuild();
  50637. return _this;
  50638. }
  50639. return BackgroundMaterialDefines;
  50640. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  50641. /**
  50642. * Background material used to create an efficient environement around your scene.
  50643. */
  50644. var BackgroundMaterial = /** @class */ (function (_super) {
  50645. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  50646. /**
  50647. * Instantiates a Background Material in the given scene
  50648. * @param name The friendly name of the material
  50649. * @param scene The scene to add the material to
  50650. */
  50651. function BackgroundMaterial(name, scene) {
  50652. var _this = _super.call(this, name, scene) || this;
  50653. /**
  50654. * Key light Color (multiply against the environement texture)
  50655. */
  50656. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  50657. _this._primaryColorShadowLevel = 0;
  50658. _this._primaryColorHighlightLevel = 0;
  50659. /**
  50660. * Reflection Texture used in the material.
  50661. * Should be author in a specific way for the best result (refer to the documentation).
  50662. */
  50663. _this.reflectionTexture = null;
  50664. /**
  50665. * Reflection Texture level of blur.
  50666. *
  50667. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50668. * texture twice.
  50669. */
  50670. _this.reflectionBlur = 0;
  50671. /**
  50672. * Diffuse Texture used in the material.
  50673. * Should be author in a specific way for the best result (refer to the documentation).
  50674. */
  50675. _this.diffuseTexture = null;
  50676. _this._shadowLights = null;
  50677. /**
  50678. * Specify the list of lights casting shadow on the material.
  50679. * All scene shadow lights will be included if null.
  50680. */
  50681. _this.shadowLights = null;
  50682. /**
  50683. * Helps adjusting the shadow to a softer level if required.
  50684. * 0 means black shadows and 1 means no shadows.
  50685. */
  50686. _this.shadowLevel = 0;
  50687. /**
  50688. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50689. * It is usually zero but might be interesting to modify according to your setup.
  50690. */
  50691. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  50692. /**
  50693. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50694. * This helps ensuring a nice transition when the camera goes under the ground.
  50695. */
  50696. _this.opacityFresnel = true;
  50697. /**
  50698. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50699. * This helps adding a mirror texture on the ground.
  50700. */
  50701. _this.reflectionFresnel = false;
  50702. /**
  50703. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50704. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50705. */
  50706. _this.reflectionFalloffDistance = 0.0;
  50707. /**
  50708. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50709. */
  50710. _this.reflectionAmount = 1.0;
  50711. /**
  50712. * This specifies the weight of the reflection at grazing angle.
  50713. */
  50714. _this.reflectionReflectance0 = 0.05;
  50715. /**
  50716. * This specifies the weight of the reflection at a perpendicular point of view.
  50717. */
  50718. _this.reflectionReflectance90 = 0.5;
  50719. /**
  50720. * Helps to directly use the maps channels instead of their level.
  50721. */
  50722. _this.useRGBColor = true;
  50723. /**
  50724. * This helps reducing the banding effect that could occur on the background.
  50725. */
  50726. _this.enableNoise = false;
  50727. _this._fovMultiplier = 1.0;
  50728. /**
  50729. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50730. */
  50731. _this.useEquirectangularFOV = false;
  50732. _this._maxSimultaneousLights = 4;
  50733. /**
  50734. * Number of Simultaneous lights allowed on the material.
  50735. */
  50736. _this.maxSimultaneousLights = 4;
  50737. /**
  50738. * Keep track of the image processing observer to allow dispose and replace.
  50739. */
  50740. _this._imageProcessingObserver = null;
  50741. /**
  50742. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50743. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50744. */
  50745. _this.switchToBGR = false;
  50746. // Temp values kept as cache in the material.
  50747. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  50748. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  50749. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  50750. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  50751. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  50752. // Setup the default processing configuration to the scene.
  50753. _this._attachImageProcessingConfiguration(null);
  50754. _this.getRenderTargetTextures = function () {
  50755. _this._renderTargets.reset();
  50756. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  50757. _this._renderTargets.push(_this._diffuseTexture);
  50758. }
  50759. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  50760. _this._renderTargets.push(_this._reflectionTexture);
  50761. }
  50762. return _this._renderTargets;
  50763. };
  50764. return _this;
  50765. }
  50766. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  50767. /**
  50768. * Experimental Internal Use Only.
  50769. *
  50770. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50771. * This acts as a helper to set the primary color to a more "human friendly" value.
  50772. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50773. * output color as close as possible from the chosen value.
  50774. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50775. * part of lighting setup.)
  50776. */
  50777. get: function () {
  50778. return this.__perceptualColor;
  50779. },
  50780. set: function (value) {
  50781. this.__perceptualColor = value;
  50782. this._computePrimaryColorFromPerceptualColor();
  50783. this._markAllSubMeshesAsLightsDirty();
  50784. },
  50785. enumerable: true,
  50786. configurable: true
  50787. });
  50788. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  50789. /**
  50790. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50791. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50792. */
  50793. get: function () {
  50794. return this._primaryColorShadowLevel;
  50795. },
  50796. set: function (value) {
  50797. this._primaryColorShadowLevel = value;
  50798. this._computePrimaryColors();
  50799. this._markAllSubMeshesAsLightsDirty();
  50800. },
  50801. enumerable: true,
  50802. configurable: true
  50803. });
  50804. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  50805. /**
  50806. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50807. * The primary color is used at the level chosen to define what the white area would look.
  50808. */
  50809. get: function () {
  50810. return this._primaryColorHighlightLevel;
  50811. },
  50812. set: function (value) {
  50813. this._primaryColorHighlightLevel = value;
  50814. this._computePrimaryColors();
  50815. this._markAllSubMeshesAsLightsDirty();
  50816. },
  50817. enumerable: true,
  50818. configurable: true
  50819. });
  50820. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  50821. /**
  50822. * Sets the reflection reflectance fresnel values according to the default standard
  50823. * empirically know to work well :-)
  50824. */
  50825. set: function (value) {
  50826. var reflectionWeight = value;
  50827. if (reflectionWeight < 0.5) {
  50828. reflectionWeight = reflectionWeight * 2.0;
  50829. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  50830. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  50831. }
  50832. else {
  50833. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  50834. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  50835. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  50836. }
  50837. },
  50838. enumerable: true,
  50839. configurable: true
  50840. });
  50841. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  50842. /**
  50843. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50844. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50845. * Recommended to be keep at 1.0 except for special cases.
  50846. */
  50847. get: function () {
  50848. return this._fovMultiplier;
  50849. },
  50850. set: function (value) {
  50851. if (isNaN(value)) {
  50852. value = 1.0;
  50853. }
  50854. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  50855. },
  50856. enumerable: true,
  50857. configurable: true
  50858. });
  50859. /**
  50860. * Attaches a new image processing configuration to the PBR Material.
  50861. * @param configuration (if null the scene configuration will be use)
  50862. */
  50863. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  50864. var _this = this;
  50865. if (configuration === this._imageProcessingConfiguration) {
  50866. return;
  50867. }
  50868. // Detaches observer.
  50869. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50870. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50871. }
  50872. // Pick the scene configuration if needed.
  50873. if (!configuration) {
  50874. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  50875. }
  50876. else {
  50877. this._imageProcessingConfiguration = configuration;
  50878. }
  50879. // Attaches observer.
  50880. if (this._imageProcessingConfiguration) {
  50881. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  50882. _this._computePrimaryColorFromPerceptualColor();
  50883. _this._markAllSubMeshesAsImageProcessingDirty();
  50884. });
  50885. }
  50886. };
  50887. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  50888. /**
  50889. * Gets the image processing configuration used either in this material.
  50890. */
  50891. get: function () {
  50892. return this._imageProcessingConfiguration;
  50893. },
  50894. /**
  50895. * Sets the Default image processing configuration used either in the this material.
  50896. *
  50897. * If sets to null, the scene one is in use.
  50898. */
  50899. set: function (value) {
  50900. this._attachImageProcessingConfiguration(value);
  50901. // Ensure the effect will be rebuilt.
  50902. this._markAllSubMeshesAsTexturesDirty();
  50903. },
  50904. enumerable: true,
  50905. configurable: true
  50906. });
  50907. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  50908. /**
  50909. * Gets wether the color curves effect is enabled.
  50910. */
  50911. get: function () {
  50912. return this.imageProcessingConfiguration.colorCurvesEnabled;
  50913. },
  50914. /**
  50915. * Sets wether the color curves effect is enabled.
  50916. */
  50917. set: function (value) {
  50918. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  50919. },
  50920. enumerable: true,
  50921. configurable: true
  50922. });
  50923. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  50924. /**
  50925. * Gets wether the color grading effect is enabled.
  50926. */
  50927. get: function () {
  50928. return this.imageProcessingConfiguration.colorGradingEnabled;
  50929. },
  50930. /**
  50931. * Gets wether the color grading effect is enabled.
  50932. */
  50933. set: function (value) {
  50934. this.imageProcessingConfiguration.colorGradingEnabled = value;
  50935. },
  50936. enumerable: true,
  50937. configurable: true
  50938. });
  50939. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  50940. /**
  50941. * Gets wether tonemapping is enabled or not.
  50942. */
  50943. get: function () {
  50944. return this._imageProcessingConfiguration.toneMappingEnabled;
  50945. },
  50946. /**
  50947. * Sets wether tonemapping is enabled or not
  50948. */
  50949. set: function (value) {
  50950. this._imageProcessingConfiguration.toneMappingEnabled = value;
  50951. },
  50952. enumerable: true,
  50953. configurable: true
  50954. });
  50955. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  50956. /**
  50957. * The camera exposure used on this material.
  50958. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50959. * This corresponds to a photographic exposure.
  50960. */
  50961. get: function () {
  50962. return this._imageProcessingConfiguration.exposure;
  50963. },
  50964. /**
  50965. * The camera exposure used on this material.
  50966. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50967. * This corresponds to a photographic exposure.
  50968. */
  50969. set: function (value) {
  50970. this._imageProcessingConfiguration.exposure = value;
  50971. },
  50972. enumerable: true,
  50973. configurable: true
  50974. });
  50975. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  50976. /**
  50977. * Gets The camera contrast used on this material.
  50978. */
  50979. get: function () {
  50980. return this._imageProcessingConfiguration.contrast;
  50981. },
  50982. /**
  50983. * Sets The camera contrast used on this material.
  50984. */
  50985. set: function (value) {
  50986. this._imageProcessingConfiguration.contrast = value;
  50987. },
  50988. enumerable: true,
  50989. configurable: true
  50990. });
  50991. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  50992. /**
  50993. * Gets the Color Grading 2D Lookup Texture.
  50994. */
  50995. get: function () {
  50996. return this._imageProcessingConfiguration.colorGradingTexture;
  50997. },
  50998. /**
  50999. * Sets the Color Grading 2D Lookup Texture.
  51000. */
  51001. set: function (value) {
  51002. this.imageProcessingConfiguration.colorGradingTexture = value;
  51003. },
  51004. enumerable: true,
  51005. configurable: true
  51006. });
  51007. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  51008. /**
  51009. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51010. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51011. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  51012. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51013. */
  51014. get: function () {
  51015. return this.imageProcessingConfiguration.colorCurves;
  51016. },
  51017. /**
  51018. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51019. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51020. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  51021. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51022. */
  51023. set: function (value) {
  51024. this.imageProcessingConfiguration.colorCurves = value;
  51025. },
  51026. enumerable: true,
  51027. configurable: true
  51028. });
  51029. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  51030. /**
  51031. * Gets a boolean indicating that current material needs to register RTT
  51032. */
  51033. get: function () {
  51034. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  51035. return true;
  51036. }
  51037. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51038. return true;
  51039. }
  51040. return false;
  51041. },
  51042. enumerable: true,
  51043. configurable: true
  51044. });
  51045. /**
  51046. * The entire material has been created in order to prevent overdraw.
  51047. * @returns false
  51048. */
  51049. BackgroundMaterial.prototype.needAlphaTesting = function () {
  51050. return true;
  51051. };
  51052. /**
  51053. * The entire material has been created in order to prevent overdraw.
  51054. * @returns true if blending is enable
  51055. */
  51056. BackgroundMaterial.prototype.needAlphaBlending = function () {
  51057. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  51058. };
  51059. /**
  51060. * Checks wether the material is ready to be rendered for a given mesh.
  51061. * @param mesh The mesh to render
  51062. * @param subMesh The submesh to check against
  51063. * @param useInstances Specify wether or not the material is used with instances
  51064. * @returns true if all the dependencies are ready (Textures, Effects...)
  51065. */
  51066. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  51067. var _this = this;
  51068. if (useInstances === void 0) { useInstances = false; }
  51069. if (subMesh.effect && this.isFrozen) {
  51070. if (this._wasPreviouslyReady) {
  51071. return true;
  51072. }
  51073. }
  51074. if (!subMesh._materialDefines) {
  51075. subMesh._materialDefines = new BackgroundMaterialDefines();
  51076. }
  51077. var scene = this.getScene();
  51078. var defines = subMesh._materialDefines;
  51079. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  51080. if (defines._renderId === scene.getRenderId()) {
  51081. return true;
  51082. }
  51083. }
  51084. var engine = scene.getEngine();
  51085. // Lights
  51086. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  51087. defines._needNormals = true;
  51088. // Multiview
  51089. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  51090. // Textures
  51091. if (defines._areTexturesDirty) {
  51092. defines._needUVs = false;
  51093. if (scene.texturesEnabled) {
  51094. if (scene.getEngine().getCaps().textureLOD) {
  51095. defines.TEXTURELODSUPPORT = true;
  51096. }
  51097. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51098. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  51099. return false;
  51100. }
  51101. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  51102. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  51103. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  51104. defines.OPACITYFRESNEL = this._opacityFresnel;
  51105. }
  51106. else {
  51107. defines.DIFFUSE = false;
  51108. defines.DIFFUSEHASALPHA = false;
  51109. defines.GAMMADIFFUSE = false;
  51110. defines.OPACITYFRESNEL = false;
  51111. }
  51112. var reflectionTexture = this._reflectionTexture;
  51113. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51114. if (!reflectionTexture.isReadyOrNotBlocking()) {
  51115. return false;
  51116. }
  51117. defines.REFLECTION = true;
  51118. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  51119. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  51120. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  51121. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  51122. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  51123. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  51124. defines.REFLECTIONBGR = this.switchToBGR;
  51125. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  51126. defines.INVERTCUBICMAP = true;
  51127. }
  51128. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  51129. switch (reflectionTexture.coordinatesMode) {
  51130. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  51131. defines.REFLECTIONMAP_EXPLICIT = true;
  51132. break;
  51133. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  51134. defines.REFLECTIONMAP_PLANAR = true;
  51135. break;
  51136. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  51137. defines.REFLECTIONMAP_PROJECTION = true;
  51138. break;
  51139. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  51140. defines.REFLECTIONMAP_SKYBOX = true;
  51141. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  51142. break;
  51143. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  51144. defines.REFLECTIONMAP_SPHERICAL = true;
  51145. break;
  51146. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  51147. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  51148. break;
  51149. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  51150. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  51151. break;
  51152. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  51153. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  51154. break;
  51155. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  51156. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  51157. default:
  51158. defines.REFLECTIONMAP_CUBIC = true;
  51159. break;
  51160. }
  51161. if (this.reflectionFresnel) {
  51162. defines.REFLECTIONFRESNEL = true;
  51163. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  51164. this._reflectionControls.x = this.reflectionAmount;
  51165. this._reflectionControls.y = this.reflectionReflectance0;
  51166. this._reflectionControls.z = this.reflectionReflectance90;
  51167. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  51168. }
  51169. else {
  51170. defines.REFLECTIONFRESNEL = false;
  51171. defines.REFLECTIONFALLOFF = false;
  51172. }
  51173. }
  51174. else {
  51175. defines.REFLECTION = false;
  51176. defines.REFLECTIONFRESNEL = false;
  51177. defines.REFLECTIONFALLOFF = false;
  51178. defines.REFLECTIONBLUR = false;
  51179. defines.REFLECTIONMAP_3D = false;
  51180. defines.REFLECTIONMAP_SPHERICAL = false;
  51181. defines.REFLECTIONMAP_PLANAR = false;
  51182. defines.REFLECTIONMAP_CUBIC = false;
  51183. defines.REFLECTIONMAP_PROJECTION = false;
  51184. defines.REFLECTIONMAP_SKYBOX = false;
  51185. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51186. defines.REFLECTIONMAP_EXPLICIT = false;
  51187. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51188. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51189. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51190. defines.INVERTCUBICMAP = false;
  51191. defines.REFLECTIONMAP_OPPOSITEZ = false;
  51192. defines.LODINREFLECTIONALPHA = false;
  51193. defines.GAMMAREFLECTION = false;
  51194. defines.RGBDREFLECTION = false;
  51195. }
  51196. }
  51197. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  51198. defines.USERGBCOLOR = this._useRGBColor;
  51199. defines.NOISE = this._enableNoise;
  51200. }
  51201. if (defines._areLightsDirty) {
  51202. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  51203. }
  51204. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  51205. if (!this._imageProcessingConfiguration.isReady()) {
  51206. return false;
  51207. }
  51208. this._imageProcessingConfiguration.prepareDefines(defines);
  51209. }
  51210. // Misc.
  51211. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  51212. // Values that need to be evaluated on every frame
  51213. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  51214. // Attribs
  51215. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  51216. if (mesh) {
  51217. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  51218. mesh.createNormals(true);
  51219. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  51220. }
  51221. }
  51222. }
  51223. // Get correct effect
  51224. if (defines.isDirty) {
  51225. defines.markAsProcessed();
  51226. scene.resetCachedMaterial();
  51227. // Fallbacks
  51228. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  51229. if (defines.FOG) {
  51230. fallbacks.addFallback(0, "FOG");
  51231. }
  51232. if (defines.POINTSIZE) {
  51233. fallbacks.addFallback(1, "POINTSIZE");
  51234. }
  51235. if (defines.MULTIVIEW) {
  51236. fallbacks.addFallback(0, "MULTIVIEW");
  51237. }
  51238. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  51239. if (defines.NUM_BONE_INFLUENCERS > 0) {
  51240. fallbacks.addCPUSkinningFallback(0, mesh);
  51241. }
  51242. //Attributes
  51243. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  51244. if (defines.NORMAL) {
  51245. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  51246. }
  51247. if (defines.UV1) {
  51248. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  51249. }
  51250. if (defines.UV2) {
  51251. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  51252. }
  51253. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  51254. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  51255. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  51256. "vFogInfos", "vFogColor", "pointSize",
  51257. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  51258. "vPrimaryColor", "vPrimaryColorShadow",
  51259. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  51260. "shadowLevel", "alpha",
  51261. "vBackgroundCenter", "vReflectionControl",
  51262. "vDiffuseInfos", "diffuseMatrix",
  51263. ];
  51264. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  51265. var uniformBuffers = ["Material", "Scene"];
  51266. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  51267. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  51268. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  51269. }
  51270. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  51271. uniformsNames: uniforms,
  51272. uniformBuffersNames: uniformBuffers,
  51273. samplers: samplers,
  51274. defines: defines,
  51275. maxSimultaneousLights: this._maxSimultaneousLights
  51276. });
  51277. var onCompiled = function (effect) {
  51278. if (_this.onCompiled) {
  51279. _this.onCompiled(effect);
  51280. }
  51281. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  51282. };
  51283. var join = defines.toString();
  51284. subMesh.setEffect(scene.getEngine().createEffect("background", {
  51285. attributes: attribs,
  51286. uniformsNames: uniforms,
  51287. uniformBuffersNames: uniformBuffers,
  51288. samplers: samplers,
  51289. defines: join,
  51290. fallbacks: fallbacks,
  51291. onCompiled: onCompiled,
  51292. onError: this.onError,
  51293. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  51294. }, engine), defines);
  51295. this.buildUniformLayout();
  51296. }
  51297. if (!subMesh.effect || !subMesh.effect.isReady()) {
  51298. return false;
  51299. }
  51300. defines._renderId = scene.getRenderId();
  51301. this._wasPreviouslyReady = true;
  51302. return true;
  51303. };
  51304. /**
  51305. * Compute the primary color according to the chosen perceptual color.
  51306. */
  51307. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  51308. if (!this.__perceptualColor) {
  51309. return;
  51310. }
  51311. this._primaryColor.copyFrom(this.__perceptualColor);
  51312. // Revert gamma space.
  51313. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  51314. // Revert image processing configuration.
  51315. if (this._imageProcessingConfiguration) {
  51316. // Revert Exposure.
  51317. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  51318. }
  51319. this._computePrimaryColors();
  51320. };
  51321. /**
  51322. * Compute the highlights and shadow colors according to their chosen levels.
  51323. */
  51324. BackgroundMaterial.prototype._computePrimaryColors = function () {
  51325. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  51326. return;
  51327. }
  51328. // Find the highlight color based on the configuration.
  51329. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  51330. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  51331. // Find the shadow color based on the configuration.
  51332. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  51333. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  51334. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  51335. };
  51336. /**
  51337. * Build the uniform buffer used in the material.
  51338. */
  51339. BackgroundMaterial.prototype.buildUniformLayout = function () {
  51340. // Order is important !
  51341. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  51342. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  51343. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  51344. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  51345. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  51346. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  51347. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  51348. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  51349. this._uniformBuffer.addUniform("pointSize", 1);
  51350. this._uniformBuffer.addUniform("shadowLevel", 1);
  51351. this._uniformBuffer.addUniform("alpha", 1);
  51352. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  51353. this._uniformBuffer.addUniform("vReflectionControl", 4);
  51354. this._uniformBuffer.create();
  51355. };
  51356. /**
  51357. * Unbind the material.
  51358. */
  51359. BackgroundMaterial.prototype.unbind = function () {
  51360. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  51361. this._uniformBuffer.setTexture("diffuseSampler", null);
  51362. }
  51363. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51364. this._uniformBuffer.setTexture("reflectionSampler", null);
  51365. }
  51366. _super.prototype.unbind.call(this);
  51367. };
  51368. /**
  51369. * Bind only the world matrix to the material.
  51370. * @param world The world matrix to bind.
  51371. */
  51372. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  51373. this._activeEffect.setMatrix("world", world);
  51374. };
  51375. /**
  51376. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51377. * @param world The world matrix to bind.
  51378. * @param subMesh The submesh to bind for.
  51379. */
  51380. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  51381. var scene = this.getScene();
  51382. var defines = subMesh._materialDefines;
  51383. if (!defines) {
  51384. return;
  51385. }
  51386. var effect = subMesh.effect;
  51387. if (!effect) {
  51388. return;
  51389. }
  51390. this._activeEffect = effect;
  51391. // Matrices
  51392. this.bindOnlyWorldMatrix(world);
  51393. // Bones
  51394. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  51395. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  51396. if (mustRebind) {
  51397. this._uniformBuffer.bindToEffect(effect, "Material");
  51398. this.bindViewProjection(effect);
  51399. var reflectionTexture = this._reflectionTexture;
  51400. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  51401. // Texture uniforms
  51402. if (scene.texturesEnabled) {
  51403. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51404. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  51405. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  51406. }
  51407. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51408. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  51409. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  51410. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  51411. }
  51412. }
  51413. if (this.shadowLevel > 0) {
  51414. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  51415. }
  51416. this._uniformBuffer.updateFloat("alpha", this.alpha);
  51417. // Point size
  51418. if (this.pointsCloud) {
  51419. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  51420. }
  51421. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  51422. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  51423. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  51424. }
  51425. else {
  51426. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  51427. }
  51428. }
  51429. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  51430. // Textures
  51431. if (scene.texturesEnabled) {
  51432. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51433. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  51434. }
  51435. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51436. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  51437. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51438. }
  51439. else if (!defines.REFLECTIONBLUR) {
  51440. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51441. }
  51442. else {
  51443. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  51444. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  51445. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  51446. }
  51447. if (defines.REFLECTIONFRESNEL) {
  51448. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  51449. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  51450. }
  51451. }
  51452. }
  51453. // Clip plane
  51454. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  51455. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  51456. }
  51457. if (mustRebind || !this.isFrozen) {
  51458. if (scene.lightsEnabled) {
  51459. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  51460. }
  51461. // View
  51462. this.bindView(effect);
  51463. // Fog
  51464. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  51465. // image processing
  51466. if (this._imageProcessingConfiguration) {
  51467. this._imageProcessingConfiguration.bind(this._activeEffect);
  51468. }
  51469. }
  51470. this._uniformBuffer.update();
  51471. this._afterBind(mesh, this._activeEffect);
  51472. };
  51473. /**
  51474. * Dispose the material.
  51475. * @param forceDisposeEffect Force disposal of the associated effect.
  51476. * @param forceDisposeTextures Force disposal of the associated textures.
  51477. */
  51478. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  51479. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  51480. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  51481. if (forceDisposeTextures) {
  51482. if (this.diffuseTexture) {
  51483. this.diffuseTexture.dispose();
  51484. }
  51485. if (this.reflectionTexture) {
  51486. this.reflectionTexture.dispose();
  51487. }
  51488. }
  51489. this._renderTargets.dispose();
  51490. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  51491. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  51492. }
  51493. _super.prototype.dispose.call(this, forceDisposeEffect);
  51494. };
  51495. /**
  51496. * Clones the material.
  51497. * @param name The cloned name.
  51498. * @returns The cloned material.
  51499. */
  51500. BackgroundMaterial.prototype.clone = function (name) {
  51501. var _this = this;
  51502. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  51503. };
  51504. /**
  51505. * Serializes the current material to its JSON representation.
  51506. * @returns The JSON representation.
  51507. */
  51508. BackgroundMaterial.prototype.serialize = function () {
  51509. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51510. serializationObject.customType = "BABYLON.BackgroundMaterial";
  51511. return serializationObject;
  51512. };
  51513. /**
  51514. * Gets the class name of the material
  51515. * @returns "BackgroundMaterial"
  51516. */
  51517. BackgroundMaterial.prototype.getClassName = function () {
  51518. return "BackgroundMaterial";
  51519. };
  51520. /**
  51521. * Parse a JSON input to create back a background material.
  51522. * @param source The JSON data to parse
  51523. * @param scene The scene to create the parsed material in
  51524. * @param rootUrl The root url of the assets the material depends upon
  51525. * @returns the instantiated BackgroundMaterial.
  51526. */
  51527. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  51528. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  51529. };
  51530. /**
  51531. * Standard reflectance value at parallel view angle.
  51532. */
  51533. BackgroundMaterial.StandardReflectance0 = 0.05;
  51534. /**
  51535. * Standard reflectance value at grazing angle.
  51536. */
  51537. BackgroundMaterial.StandardReflectance90 = 0.5;
  51538. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51539. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  51540. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  51541. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51542. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51543. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  51544. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51545. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  51546. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  51547. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51548. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51549. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  51550. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51551. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51552. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  51553. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51554. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51555. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  51556. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51557. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51558. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  51559. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51560. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51561. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  51562. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51563. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51564. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  51565. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51566. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51567. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  51568. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51569. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51570. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  51571. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51572. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51573. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  51574. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51575. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51576. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  51577. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51578. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51579. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  51580. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51581. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51582. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  51583. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51584. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  51585. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  51586. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51587. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51588. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  51589. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51590. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51591. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  51592. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51593. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51594. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  51595. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51596. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51597. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  51598. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51599. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51600. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  51601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51602. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51603. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  51604. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51605. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51606. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  51607. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51608. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51609. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  51610. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51611. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51612. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  51613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51615. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  51616. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51617. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51618. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  51619. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51620. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51621. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  51622. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51623. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51624. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  51625. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51626. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51627. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  51628. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51629. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51630. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  51631. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51632. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51633. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  51634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51636. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  51637. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51638. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51639. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  51640. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51641. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51642. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  51643. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51644. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  51645. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  51646. return BackgroundMaterial;
  51647. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  51648. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  51649. /***/ }),
  51650. /***/ "./Materials/Background/index.ts":
  51651. /*!***************************************!*\
  51652. !*** ./Materials/Background/index.ts ***!
  51653. \***************************************/
  51654. /*! exports provided: BackgroundMaterial */
  51655. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51656. "use strict";
  51657. __webpack_require__.r(__webpack_exports__);
  51658. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  51659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  51660. /***/ }),
  51661. /***/ "./Materials/PBR/index.ts":
  51662. /*!********************************!*\
  51663. !*** ./Materials/PBR/index.ts ***!
  51664. \********************************/
  51665. /*! exports provided: PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  51666. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51667. "use strict";
  51668. __webpack_require__.r(__webpack_exports__);
  51669. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRMaterialDefines"]; });
  51671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  51672. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  51673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  51674. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  51675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  51676. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  51677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  51678. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  51679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  51680. /***/ }),
  51681. /***/ "./Materials/PBR/pbrAnisotropicConfiguration.ts":
  51682. /*!******************************************************!*\
  51683. !*** ./Materials/PBR/pbrAnisotropicConfiguration.ts ***!
  51684. \******************************************************/
  51685. /*! exports provided: PBRAnisotropicConfiguration */
  51686. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51687. "use strict";
  51688. __webpack_require__.r(__webpack_exports__);
  51689. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRAnisotropicConfiguration", function() { return PBRAnisotropicConfiguration; });
  51690. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51691. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51692. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  51693. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51694. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  51695. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  51696. /**
  51697. * Define the code related to the anisotropic parameters of the pbr material.
  51698. */
  51699. var PBRAnisotropicConfiguration = /** @class */ (function () {
  51700. /**
  51701. * Instantiate a new istance of anisotropy configuration.
  51702. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51703. */
  51704. function PBRAnisotropicConfiguration(markAllSubMeshesAsTexturesDirty) {
  51705. this._isEnabled = false;
  51706. /**
  51707. * Defines if the anisotropy is enabled in the material.
  51708. */
  51709. this.isEnabled = false;
  51710. /**
  51711. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51712. */
  51713. this.intensity = 1;
  51714. /**
  51715. * Defines if the effect is along the tangents, bitangents or in between.
  51716. * By default, the effect is "strectching" the highlights along the tangents.
  51717. */
  51718. this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 0);
  51719. this._texture = null;
  51720. /**
  51721. * Stores the anisotropy values in a texture.
  51722. * rg is direction (like normal from -1 to 1)
  51723. * b is a intensity
  51724. */
  51725. this.texture = null;
  51726. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  51727. }
  51728. /** @hidden */
  51729. PBRAnisotropicConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  51730. this._internalMarkAllSubMeshesAsTexturesDirty();
  51731. };
  51732. /**
  51733. * Specifies that the submesh is ready to be used.
  51734. * @param defines the list of "defines" to update.
  51735. * @param scene defines the scene the material belongs to.
  51736. * @returns - boolean indicating that the submesh is ready or not.
  51737. */
  51738. PBRAnisotropicConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  51739. if (defines._areTexturesDirty) {
  51740. if (scene.texturesEnabled) {
  51741. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51742. if (!this._texture.isReadyOrNotBlocking()) {
  51743. return false;
  51744. }
  51745. }
  51746. }
  51747. }
  51748. return true;
  51749. };
  51750. /**
  51751. * Checks to see if a texture is used in the material.
  51752. * @param defines the list of "defines" to update.
  51753. * @param mesh the mesh we are preparing the defines for.
  51754. * @param scene defines the scene the material belongs to.
  51755. */
  51756. PBRAnisotropicConfiguration.prototype.prepareDefines = function (defines, mesh, scene) {
  51757. if (this._isEnabled) {
  51758. defines.ANISOTROPIC = this._isEnabled;
  51759. if (this._isEnabled && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  51760. defines._needUVs = true;
  51761. defines.MAINUV1 = true;
  51762. }
  51763. if (defines._areTexturesDirty) {
  51764. if (scene.texturesEnabled) {
  51765. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51766. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "ANISOTROPIC_TEXTURE");
  51767. }
  51768. else {
  51769. defines.ANISOTROPIC_TEXTURE = false;
  51770. }
  51771. }
  51772. }
  51773. }
  51774. else {
  51775. defines.ANISOTROPIC = false;
  51776. defines.ANISOTROPIC_TEXTURE = false;
  51777. }
  51778. };
  51779. /**
  51780. * Binds the material data.
  51781. * @param uniformBuffer defines the Uniform buffer to fill in.
  51782. * @param scene defines the scene the material belongs to.
  51783. * @param isFrozen defines wether the material is frozen or not.
  51784. */
  51785. PBRAnisotropicConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  51786. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  51787. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51788. uniformBuffer.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level);
  51789. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "anisotropy");
  51790. }
  51791. // Anisotropy
  51792. uniformBuffer.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity);
  51793. }
  51794. // Textures
  51795. if (scene.texturesEnabled) {
  51796. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51797. uniformBuffer.setTexture("anisotropySampler", this._texture);
  51798. }
  51799. }
  51800. };
  51801. /**
  51802. * Checks to see if a texture is used in the material.
  51803. * @param texture - Base texture to use.
  51804. * @returns - Boolean specifying if a texture is used in the material.
  51805. */
  51806. PBRAnisotropicConfiguration.prototype.hasTexture = function (texture) {
  51807. if (this._texture === texture) {
  51808. return true;
  51809. }
  51810. return false;
  51811. };
  51812. /**
  51813. * Returns an array of the actively used textures.
  51814. * @param activeTextures Array of BaseTextures
  51815. */
  51816. PBRAnisotropicConfiguration.prototype.getActiveTextures = function (activeTextures) {
  51817. if (this._texture) {
  51818. activeTextures.push(this._texture);
  51819. }
  51820. };
  51821. /**
  51822. * Returns the animatable textures.
  51823. * @param animatables Array of animatable textures.
  51824. */
  51825. PBRAnisotropicConfiguration.prototype.getAnimatables = function (animatables) {
  51826. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  51827. animatables.push(this._texture);
  51828. }
  51829. };
  51830. /**
  51831. * Disposes the resources of the material.
  51832. * @param forceDisposeTextures - Forces the disposal of all textures.
  51833. */
  51834. PBRAnisotropicConfiguration.prototype.dispose = function (forceDisposeTextures) {
  51835. if (forceDisposeTextures) {
  51836. if (this._texture) {
  51837. this._texture.dispose();
  51838. }
  51839. }
  51840. };
  51841. /**
  51842. * Get the current class name of the texture useful for serialization or dynamic coding.
  51843. * @returns "PBRAnisotropicConfiguration"
  51844. */
  51845. PBRAnisotropicConfiguration.prototype.getClassName = function () {
  51846. return "PBRAnisotropicConfiguration";
  51847. };
  51848. /**
  51849. * Add fallbacks to the effect fallbacks list.
  51850. * @param defines defines the Base texture to use.
  51851. * @param fallbacks defines the current fallback list.
  51852. * @param currentRank defines the current fallback rank.
  51853. * @returns the new fallback rank.
  51854. */
  51855. PBRAnisotropicConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  51856. if (defines.ANISOTROPIC) {
  51857. fallbacks.addFallback(currentRank++, "ANISOTROPIC");
  51858. }
  51859. return currentRank;
  51860. };
  51861. /**
  51862. * Add the required uniforms to the current list.
  51863. * @param uniforms defines the current uniform list.
  51864. */
  51865. PBRAnisotropicConfiguration.AddUniforms = function (uniforms) {
  51866. uniforms.push("vAnisotropy", "vAnisotropyInfos", "anisotropyMatrix");
  51867. };
  51868. /**
  51869. * Add the required uniforms to the current buffer.
  51870. * @param uniformBuffer defines the current uniform buffer.
  51871. */
  51872. PBRAnisotropicConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  51873. uniformBuffer.addUniform("vAnisotropy", 3);
  51874. uniformBuffer.addUniform("vAnisotropyInfos", 2);
  51875. uniformBuffer.addUniform("anisotropyMatrix", 16);
  51876. };
  51877. /**
  51878. * Add the required samplers to the current list.
  51879. * @param samplers defines the current sampler list.
  51880. */
  51881. PBRAnisotropicConfiguration.AddSamplers = function (samplers) {
  51882. samplers.push("anisotropySampler");
  51883. };
  51884. /**
  51885. * Makes a duplicate of the current configuration into another one.
  51886. * @param anisotropicConfiguration define the config where to copy the info
  51887. */
  51888. PBRAnisotropicConfiguration.prototype.copyTo = function (anisotropicConfiguration) {
  51889. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return anisotropicConfiguration; }, this);
  51890. };
  51891. /**
  51892. * Serializes this anisotropy configuration.
  51893. * @returns - An object with the serialized config.
  51894. */
  51895. PBRAnisotropicConfiguration.prototype.serialize = function () {
  51896. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51897. };
  51898. /**
  51899. * Parses a anisotropy Configuration from a serialized object.
  51900. * @param source - Serialized object.
  51901. */
  51902. PBRAnisotropicConfiguration.prototype.parse = function (source) {
  51903. var _this = this;
  51904. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  51905. };
  51906. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51907. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51908. ], PBRAnisotropicConfiguration.prototype, "_isEnabled", void 0);
  51909. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51910. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51911. ], PBRAnisotropicConfiguration.prototype, "isEnabled", void 0);
  51912. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51914. ], PBRAnisotropicConfiguration.prototype, "intensity", void 0);
  51915. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector2"])()
  51917. ], PBRAnisotropicConfiguration.prototype, "direction", void 0);
  51918. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51920. ], PBRAnisotropicConfiguration.prototype, "_texture", void 0);
  51921. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51922. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51923. ], PBRAnisotropicConfiguration.prototype, "texture", void 0);
  51924. return PBRAnisotropicConfiguration;
  51925. }());
  51926. /***/ }),
  51927. /***/ "./Materials/PBR/pbrBRDFConfiguration.ts":
  51928. /*!***********************************************!*\
  51929. !*** ./Materials/PBR/pbrBRDFConfiguration.ts ***!
  51930. \***********************************************/
  51931. /*! exports provided: PBRBRDFConfiguration */
  51932. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51933. "use strict";
  51934. __webpack_require__.r(__webpack_exports__);
  51935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBRDFConfiguration", function() { return PBRBRDFConfiguration; });
  51936. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51937. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51938. /**
  51939. * Define the code related to the BRDF parameters of the pbr material.
  51940. */
  51941. var PBRBRDFConfiguration = /** @class */ (function () {
  51942. /**
  51943. * Instantiate a new istance of clear coat configuration.
  51944. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51945. */
  51946. function PBRBRDFConfiguration(markAllSubMeshesAsMiscDirty) {
  51947. this._useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;
  51948. /**
  51949. * Defines if the material uses energy conservation.
  51950. */
  51951. this.useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;
  51952. this._useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;
  51953. /**
  51954. * LEGACY Mode set to false
  51955. * Defines if the material uses height smith correlated visibility term.
  51956. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51957. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51958. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51959. * Not relying on height correlated will also disable energy conservation.
  51960. */
  51961. this.useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;
  51962. this._internalMarkAllSubMeshesAsMiscDirty = markAllSubMeshesAsMiscDirty;
  51963. }
  51964. /** @hidden */
  51965. PBRBRDFConfiguration.prototype._markAllSubMeshesAsMiscDirty = function () {
  51966. this._internalMarkAllSubMeshesAsMiscDirty();
  51967. };
  51968. /**
  51969. * Checks to see if a texture is used in the material.
  51970. * @param defines the list of "defines" to update.
  51971. */
  51972. PBRBRDFConfiguration.prototype.prepareDefines = function (defines) {
  51973. defines.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated;
  51974. defines.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated;
  51975. };
  51976. /**
  51977. * Get the current class name of the texture useful for serialization or dynamic coding.
  51978. * @returns "PBRClearCoatConfiguration"
  51979. */
  51980. PBRBRDFConfiguration.prototype.getClassName = function () {
  51981. return "PBRClearCoatConfiguration";
  51982. };
  51983. /**
  51984. * Makes a duplicate of the current configuration into another one.
  51985. * @param brdfConfiguration define the config where to copy the info
  51986. */
  51987. PBRBRDFConfiguration.prototype.copyTo = function (brdfConfiguration) {
  51988. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return brdfConfiguration; }, this);
  51989. };
  51990. /**
  51991. * Serializes this BRDF configuration.
  51992. * @returns - An object with the serialized config.
  51993. */
  51994. PBRBRDFConfiguration.prototype.serialize = function () {
  51995. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51996. };
  51997. /**
  51998. * Parses a BRDF Configuration from a serialized object.
  51999. * @param source - Serialized object.
  52000. */
  52001. PBRBRDFConfiguration.prototype.parse = function (source) {
  52002. var _this = this;
  52003. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  52004. };
  52005. /**
  52006. * Default value used for the energy conservation.
  52007. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52008. */
  52009. PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION = true;
  52010. /**
  52011. * Default value used for the Smith Visibility Height Correlated mode.
  52012. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52013. */
  52014. PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = true;
  52015. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52017. ], PBRBRDFConfiguration.prototype, "_useEnergyConservation", void 0);
  52018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  52020. ], PBRBRDFConfiguration.prototype, "useEnergyConservation", void 0);
  52021. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52022. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52023. ], PBRBRDFConfiguration.prototype, "_useSmithVisibilityHeightCorrelated", void 0);
  52024. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52025. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  52026. ], PBRBRDFConfiguration.prototype, "useSmithVisibilityHeightCorrelated", void 0);
  52027. return PBRBRDFConfiguration;
  52028. }());
  52029. /***/ }),
  52030. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  52031. /*!******************************************!*\
  52032. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  52033. \******************************************/
  52034. /*! exports provided: PBRMaterialDefines, PBRBaseMaterial */
  52035. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52036. "use strict";
  52037. __webpack_require__.r(__webpack_exports__);
  52038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return PBRMaterialDefines; });
  52039. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  52040. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52041. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52042. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  52043. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  52044. /* harmony import */ var _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/brdfTextureTools */ "./Misc/brdfTextureTools.ts");
  52045. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  52046. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  52047. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  52048. /* harmony import */ var _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./pbrClearCoatConfiguration */ "./Materials/PBR/pbrClearCoatConfiguration.ts");
  52049. /* harmony import */ var _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pbrAnisotropicConfiguration */ "./Materials/PBR/pbrAnisotropicConfiguration.ts");
  52050. /* harmony import */ var _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pbrBRDFConfiguration */ "./Materials/PBR/pbrBRDFConfiguration.ts");
  52051. /* harmony import */ var _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./pbrSheenConfiguration */ "./Materials/PBR/pbrSheenConfiguration.ts");
  52052. /* harmony import */ var _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./pbrSubSurfaceConfiguration */ "./Materials/PBR/pbrSubSurfaceConfiguration.ts");
  52053. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  52054. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  52055. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  52056. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  52057. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  52058. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  52059. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  52060. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  52061. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  52062. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  52063. /**
  52064. * Manages the defines for the PBR Material.
  52065. * @hidden
  52066. */
  52067. var PBRMaterialDefines = /** @class */ (function (_super) {
  52068. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  52069. /**
  52070. * Initializes the PBR Material defines.
  52071. */
  52072. function PBRMaterialDefines() {
  52073. var _this = _super.call(this) || this;
  52074. _this.PBR = true;
  52075. _this.MAINUV1 = false;
  52076. _this.MAINUV2 = false;
  52077. _this.UV1 = false;
  52078. _this.UV2 = false;
  52079. _this.ALBEDO = false;
  52080. _this.ALBEDODIRECTUV = 0;
  52081. _this.VERTEXCOLOR = false;
  52082. _this.AMBIENT = false;
  52083. _this.AMBIENTDIRECTUV = 0;
  52084. _this.AMBIENTINGRAYSCALE = false;
  52085. _this.OPACITY = false;
  52086. _this.VERTEXALPHA = false;
  52087. _this.OPACITYDIRECTUV = 0;
  52088. _this.OPACITYRGB = false;
  52089. _this.ALPHATEST = false;
  52090. _this.DEPTHPREPASS = false;
  52091. _this.ALPHABLEND = false;
  52092. _this.ALPHAFROMALBEDO = false;
  52093. _this.ALPHATESTVALUE = "0.5";
  52094. _this.SPECULAROVERALPHA = false;
  52095. _this.RADIANCEOVERALPHA = false;
  52096. _this.ALPHAFRESNEL = false;
  52097. _this.LINEARALPHAFRESNEL = false;
  52098. _this.PREMULTIPLYALPHA = false;
  52099. _this.EMISSIVE = false;
  52100. _this.EMISSIVEDIRECTUV = 0;
  52101. _this.REFLECTIVITY = false;
  52102. _this.REFLECTIVITYDIRECTUV = 0;
  52103. _this.SPECULARTERM = false;
  52104. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  52105. _this.MICROSURFACEAUTOMATIC = false;
  52106. _this.LODBASEDMICROSFURACE = false;
  52107. _this.MICROSURFACEMAP = false;
  52108. _this.MICROSURFACEMAPDIRECTUV = 0;
  52109. _this.METALLICWORKFLOW = false;
  52110. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  52111. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  52112. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  52113. _this.AOSTOREINMETALMAPRED = false;
  52114. _this.ENVIRONMENTBRDF = false;
  52115. _this.ENVIRONMENTBRDF_RGBD = false;
  52116. _this.NORMAL = false;
  52117. _this.TANGENT = false;
  52118. _this.BUMP = false;
  52119. _this.BUMPDIRECTUV = 0;
  52120. _this.OBJECTSPACE_NORMALMAP = false;
  52121. _this.PARALLAX = false;
  52122. _this.PARALLAXOCCLUSION = false;
  52123. _this.NORMALXYSCALE = true;
  52124. _this.LIGHTMAP = false;
  52125. _this.LIGHTMAPDIRECTUV = 0;
  52126. _this.USELIGHTMAPASSHADOWMAP = false;
  52127. _this.GAMMALIGHTMAP = false;
  52128. _this.REFLECTION = false;
  52129. _this.REFLECTIONMAP_3D = false;
  52130. _this.REFLECTIONMAP_SPHERICAL = false;
  52131. _this.REFLECTIONMAP_PLANAR = false;
  52132. _this.REFLECTIONMAP_CUBIC = false;
  52133. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  52134. _this.REFLECTIONMAP_PROJECTION = false;
  52135. _this.REFLECTIONMAP_SKYBOX = false;
  52136. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  52137. _this.REFLECTIONMAP_EXPLICIT = false;
  52138. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  52139. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  52140. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  52141. _this.INVERTCUBICMAP = false;
  52142. _this.USESPHERICALFROMREFLECTIONMAP = false;
  52143. _this.USESPHERICALINVERTEX = false;
  52144. _this.REFLECTIONMAP_OPPOSITEZ = false;
  52145. _this.LODINREFLECTIONALPHA = false;
  52146. _this.GAMMAREFLECTION = false;
  52147. _this.RGBDREFLECTION = false;
  52148. _this.RADIANCEOCCLUSION = false;
  52149. _this.HORIZONOCCLUSION = false;
  52150. _this.INSTANCES = false;
  52151. _this.NUM_BONE_INFLUENCERS = 0;
  52152. _this.BonesPerMesh = 0;
  52153. _this.BONETEXTURE = false;
  52154. _this.NONUNIFORMSCALING = false;
  52155. _this.MORPHTARGETS = false;
  52156. _this.MORPHTARGETS_NORMAL = false;
  52157. _this.MORPHTARGETS_TANGENT = false;
  52158. _this.NUM_MORPH_INFLUENCERS = 0;
  52159. _this.IMAGEPROCESSING = false;
  52160. _this.VIGNETTE = false;
  52161. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  52162. _this.VIGNETTEBLENDMODEOPAQUE = false;
  52163. _this.TONEMAPPING = false;
  52164. _this.TONEMAPPING_ACES = false;
  52165. _this.CONTRAST = false;
  52166. _this.COLORCURVES = false;
  52167. _this.COLORGRADING = false;
  52168. _this.COLORGRADING3D = false;
  52169. _this.SAMPLER3DGREENDEPTH = false;
  52170. _this.SAMPLER3DBGRMAP = false;
  52171. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  52172. _this.EXPOSURE = false;
  52173. _this.MULTIVIEW = false;
  52174. _this.USEPHYSICALLIGHTFALLOFF = false;
  52175. _this.USEGLTFLIGHTFALLOFF = false;
  52176. _this.TWOSIDEDLIGHTING = false;
  52177. _this.SHADOWFLOAT = false;
  52178. _this.CLIPPLANE = false;
  52179. _this.CLIPPLANE2 = false;
  52180. _this.CLIPPLANE3 = false;
  52181. _this.CLIPPLANE4 = false;
  52182. _this.POINTSIZE = false;
  52183. _this.FOG = false;
  52184. _this.LOGARITHMICDEPTH = false;
  52185. _this.FORCENORMALFORWARD = false;
  52186. _this.SPECULARAA = false;
  52187. _this.CLEARCOAT = false;
  52188. _this.CLEARCOAT_DEFAULTIOR = false;
  52189. _this.CLEARCOAT_TEXTURE = false;
  52190. _this.CLEARCOAT_TEXTUREDIRECTUV = 0;
  52191. _this.CLEARCOAT_BUMP = false;
  52192. _this.CLEARCOAT_BUMPDIRECTUV = 0;
  52193. _this.CLEARCOAT_TINT = false;
  52194. _this.CLEARCOAT_TINT_TEXTURE = false;
  52195. _this.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0;
  52196. _this.ANISOTROPIC = false;
  52197. _this.ANISOTROPIC_TEXTURE = false;
  52198. _this.ANISOTROPIC_TEXTUREDIRECTUV = 0;
  52199. _this.BRDF_V_HEIGHT_CORRELATED = false;
  52200. _this.MS_BRDF_ENERGY_CONSERVATION = false;
  52201. _this.SHEEN = false;
  52202. _this.SHEEN_TEXTURE = false;
  52203. _this.SHEEN_TEXTUREDIRECTUV = 0;
  52204. _this.SHEEN_LINKWITHALBEDO = false;
  52205. _this.SUBSURFACE = false;
  52206. _this.SS_REFRACTION = false;
  52207. _this.SS_TRANSLUCENCY = false;
  52208. _this.SS_SCATERRING = false;
  52209. _this.SS_THICKNESSANDMASK_TEXTURE = false;
  52210. _this.SS_THICKNESSANDMASK_TEXTUREDIRECTUV = 0;
  52211. _this.SS_REFRACTIONMAP_3D = false;
  52212. _this.SS_REFRACTIONMAP_OPPOSITEZ = false;
  52213. _this.SS_LODINREFRACTIONALPHA = false;
  52214. _this.SS_GAMMAREFRACTION = false;
  52215. _this.SS_RGBDREFRACTION = false;
  52216. _this.SS_LINKREFRACTIONTOTRANSPARENCY = false;
  52217. _this.SS_MASK_FROM_THICKNESS_TEXTURE = false;
  52218. _this.UNLIT = false;
  52219. _this.DEBUGMODE = 0;
  52220. _this.rebuild();
  52221. return _this;
  52222. }
  52223. /**
  52224. * Resets the PBR Material defines.
  52225. */
  52226. PBRMaterialDefines.prototype.reset = function () {
  52227. _super.prototype.reset.call(this);
  52228. this.ALPHATESTVALUE = "0.5";
  52229. this.PBR = true;
  52230. };
  52231. return PBRMaterialDefines;
  52232. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_15__["MaterialDefines"]));
  52233. /**
  52234. * The Physically based material base class of BJS.
  52235. *
  52236. * This offers the main features of a standard PBR material.
  52237. * For more information, please refer to the documentation :
  52238. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  52239. */
  52240. var PBRBaseMaterial = /** @class */ (function (_super) {
  52241. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  52242. /**
  52243. * Instantiates a new PBRMaterial instance.
  52244. *
  52245. * @param name The material name
  52246. * @param scene The scene the material will be use in.
  52247. */
  52248. function PBRBaseMaterial(name, scene) {
  52249. var _this = _super.call(this, name, scene) || this;
  52250. /**
  52251. * Intensity of the direct lights e.g. the four lights available in your scene.
  52252. * This impacts both the direct diffuse and specular highlights.
  52253. */
  52254. _this._directIntensity = 1.0;
  52255. /**
  52256. * Intensity of the emissive part of the material.
  52257. * This helps controlling the emissive effect without modifying the emissive color.
  52258. */
  52259. _this._emissiveIntensity = 1.0;
  52260. /**
  52261. * Intensity of the environment e.g. how much the environment will light the object
  52262. * either through harmonics for rough material or through the refelction for shiny ones.
  52263. */
  52264. _this._environmentIntensity = 1.0;
  52265. /**
  52266. * This is a special control allowing the reduction of the specular highlights coming from the
  52267. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52268. */
  52269. _this._specularIntensity = 1.0;
  52270. /**
  52271. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  52272. */
  52273. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  52274. /**
  52275. * Debug Control allowing disabling the bump map on this material.
  52276. */
  52277. _this._disableBumpMap = false;
  52278. /**
  52279. * AKA Occlusion Texture Intensity in other nomenclature.
  52280. */
  52281. _this._ambientTextureStrength = 1.0;
  52282. /**
  52283. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52284. * 1 means it completely occludes it
  52285. * 0 mean it has no impact
  52286. */
  52287. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  52288. /**
  52289. * The color of a material in ambient lighting.
  52290. */
  52291. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  52292. /**
  52293. * AKA Diffuse Color in other nomenclature.
  52294. */
  52295. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  52296. /**
  52297. * AKA Specular Color in other nomenclature.
  52298. */
  52299. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  52300. /**
  52301. * The color applied when light is reflected from a material.
  52302. */
  52303. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  52304. /**
  52305. * The color applied when light is emitted from a material.
  52306. */
  52307. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  52308. /**
  52309. * AKA Glossiness in other nomenclature.
  52310. */
  52311. _this._microSurface = 0.9;
  52312. /**
  52313. * Specifies that the material will use the light map as a show map.
  52314. */
  52315. _this._useLightmapAsShadowmap = false;
  52316. /**
  52317. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52318. * makes the reflect vector face the model (under horizon).
  52319. */
  52320. _this._useHorizonOcclusion = true;
  52321. /**
  52322. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52323. * too much the area relying on ambient texture to define their ambient occlusion.
  52324. */
  52325. _this._useRadianceOcclusion = true;
  52326. /**
  52327. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52328. */
  52329. _this._useAlphaFromAlbedoTexture = false;
  52330. /**
  52331. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52332. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52333. */
  52334. _this._useSpecularOverAlpha = true;
  52335. /**
  52336. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52337. */
  52338. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  52339. /**
  52340. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52341. */
  52342. _this._useRoughnessFromMetallicTextureAlpha = true;
  52343. /**
  52344. * Specifies if the metallic texture contains the roughness information in its green channel.
  52345. */
  52346. _this._useRoughnessFromMetallicTextureGreen = false;
  52347. /**
  52348. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52349. */
  52350. _this._useMetallnessFromMetallicTextureBlue = false;
  52351. /**
  52352. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52353. */
  52354. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  52355. /**
  52356. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52357. */
  52358. _this._useAmbientInGrayScale = false;
  52359. /**
  52360. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52361. * The material will try to infer what glossiness each pixel should be.
  52362. */
  52363. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  52364. /**
  52365. * Defines the falloff type used in this material.
  52366. * It by default is Physical.
  52367. */
  52368. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  52369. /**
  52370. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52371. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52372. */
  52373. _this._useRadianceOverAlpha = true;
  52374. /**
  52375. * Allows using an object space normal map (instead of tangent space).
  52376. */
  52377. _this._useObjectSpaceNormalMap = false;
  52378. /**
  52379. * Allows using the bump map in parallax mode.
  52380. */
  52381. _this._useParallax = false;
  52382. /**
  52383. * Allows using the bump map in parallax occlusion mode.
  52384. */
  52385. _this._useParallaxOcclusion = false;
  52386. /**
  52387. * Controls the scale bias of the parallax mode.
  52388. */
  52389. _this._parallaxScaleBias = 0.05;
  52390. /**
  52391. * If sets to true, disables all the lights affecting the material.
  52392. */
  52393. _this._disableLighting = false;
  52394. /**
  52395. * Number of Simultaneous lights allowed on the material.
  52396. */
  52397. _this._maxSimultaneousLights = 4;
  52398. /**
  52399. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52400. */
  52401. _this._invertNormalMapX = false;
  52402. /**
  52403. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52404. */
  52405. _this._invertNormalMapY = false;
  52406. /**
  52407. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52408. */
  52409. _this._twoSidedLighting = false;
  52410. /**
  52411. * Defines the alpha limits in alpha test mode.
  52412. */
  52413. _this._alphaCutOff = 0.4;
  52414. /**
  52415. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52416. */
  52417. _this._forceAlphaTest = false;
  52418. /**
  52419. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52420. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52421. */
  52422. _this._useAlphaFresnel = false;
  52423. /**
  52424. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52425. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52426. */
  52427. _this._useLinearAlphaFresnel = false;
  52428. /**
  52429. * The transparency mode of the material.
  52430. */
  52431. _this._transparencyMode = null;
  52432. /**
  52433. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52434. * from cos thetav and roughness:
  52435. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52436. */
  52437. _this._environmentBRDFTexture = null;
  52438. /**
  52439. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52440. */
  52441. _this._forceIrradianceInFragment = false;
  52442. /**
  52443. * Force normal to face away from face.
  52444. */
  52445. _this._forceNormalForward = false;
  52446. /**
  52447. * Enables specular anti aliasing in the PBR shader.
  52448. * It will both interacts on the Geometry for analytical and IBL lighting.
  52449. * It also prefilter the roughness map based on the bump values.
  52450. */
  52451. _this._enableSpecularAntiAliasing = false;
  52452. /**
  52453. * Stores the available render targets.
  52454. */
  52455. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  52456. /**
  52457. * Sets the global ambient color for the material used in lighting calculations.
  52458. */
  52459. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  52460. /**
  52461. * If set to true, no lighting calculations will be applied.
  52462. */
  52463. _this._unlit = false;
  52464. _this._debugMode = 0;
  52465. /**
  52466. * @hidden
  52467. * This is reserved for the inspector.
  52468. * Defines the material debug mode.
  52469. * It helps seeing only some components of the material while troubleshooting.
  52470. */
  52471. _this.debugMode = 0;
  52472. /**
  52473. * @hidden
  52474. * This is reserved for the inspector.
  52475. * Specify from where on screen the debug mode should start.
  52476. * The value goes from -1 (full screen) to 1 (not visible)
  52477. * It helps with side by side comparison against the final render
  52478. * This defaults to -1
  52479. */
  52480. _this.debugLimit = -1;
  52481. /**
  52482. * @hidden
  52483. * This is reserved for the inspector.
  52484. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52485. * You can use the factor to better multiply the final value.
  52486. */
  52487. _this.debugFactor = 1;
  52488. /**
  52489. * Defines the clear coat layer parameters for the material.
  52490. */
  52491. _this.clearCoat = new _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52492. /**
  52493. * Defines the anisotropic parameters for the material.
  52494. */
  52495. _this.anisotropy = new _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52496. /**
  52497. * Defines the BRDF parameters for the material.
  52498. */
  52499. _this.brdf = new _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__["PBRBRDFConfiguration"](_this._markAllSubMeshesAsMiscDirty.bind(_this));
  52500. /**
  52501. * Defines the Sheen parameters for the material.
  52502. */
  52503. _this.sheen = new _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52504. /**
  52505. * Defines the SubSurface parameters for the material.
  52506. */
  52507. _this.subSurface = new _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52508. // Setup the default processing configuration to the scene.
  52509. _this._attachImageProcessingConfiguration(null);
  52510. _this.getRenderTargetTextures = function () {
  52511. _this._renderTargets.reset();
  52512. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  52513. _this._renderTargets.push(_this._reflectionTexture);
  52514. }
  52515. _this.subSurface.fillRenderTargetTextures(_this._renderTargets);
  52516. return _this._renderTargets;
  52517. };
  52518. _this._environmentBRDFTexture = _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_4__["BRDFTextureTools"].GetEnvironmentBRDFTexture(scene);
  52519. return _this;
  52520. }
  52521. /**
  52522. * Attaches a new image processing configuration to the PBR Material.
  52523. * @param configuration
  52524. */
  52525. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  52526. var _this = this;
  52527. if (configuration === this._imageProcessingConfiguration) {
  52528. return;
  52529. }
  52530. // Detaches observer.
  52531. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  52532. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  52533. }
  52534. // Pick the scene configuration if needed.
  52535. if (!configuration) {
  52536. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  52537. }
  52538. else {
  52539. this._imageProcessingConfiguration = configuration;
  52540. }
  52541. // Attaches observer.
  52542. if (this._imageProcessingConfiguration) {
  52543. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  52544. _this._markAllSubMeshesAsImageProcessingDirty();
  52545. });
  52546. }
  52547. };
  52548. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  52549. /**
  52550. * Gets a boolean indicating that current material needs to register RTT
  52551. */
  52552. get: function () {
  52553. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  52554. return true;
  52555. }
  52556. return this.subSurface.hasRenderTargetTextures();
  52557. },
  52558. enumerable: true,
  52559. configurable: true
  52560. });
  52561. /**
  52562. * Gets the name of the material class.
  52563. */
  52564. PBRBaseMaterial.prototype.getClassName = function () {
  52565. return "PBRBaseMaterial";
  52566. };
  52567. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  52568. /**
  52569. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52570. */
  52571. get: function () {
  52572. return this._useLogarithmicDepth;
  52573. },
  52574. /**
  52575. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52576. */
  52577. set: function (value) {
  52578. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  52579. },
  52580. enumerable: true,
  52581. configurable: true
  52582. });
  52583. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  52584. /**
  52585. * Gets the current transparency mode.
  52586. */
  52587. get: function () {
  52588. return this._transparencyMode;
  52589. },
  52590. /**
  52591. * Sets the transparency mode of the material.
  52592. *
  52593. * | Value | Type | Description |
  52594. * | ----- | ----------------------------------- | ----------- |
  52595. * | 0 | OPAQUE | |
  52596. * | 1 | ALPHATEST | |
  52597. * | 2 | ALPHABLEND | |
  52598. * | 3 | ALPHATESTANDBLEND | |
  52599. *
  52600. */
  52601. set: function (value) {
  52602. if (this._transparencyMode === value) {
  52603. return;
  52604. }
  52605. this._transparencyMode = value;
  52606. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  52607. this._markAllSubMeshesAsTexturesAndMiscDirty();
  52608. },
  52609. enumerable: true,
  52610. configurable: true
  52611. });
  52612. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  52613. /**
  52614. * Returns true if alpha blending should be disabled.
  52615. */
  52616. get: function () {
  52617. return (this.subSurface.disableAlphaBlending ||
  52618. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  52619. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  52620. },
  52621. enumerable: true,
  52622. configurable: true
  52623. });
  52624. /**
  52625. * Specifies whether or not this material should be rendered in alpha blend mode.
  52626. */
  52627. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  52628. if (this._disableAlphaBlending) {
  52629. return false;
  52630. }
  52631. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  52632. };
  52633. /**
  52634. * Specifies if the mesh will require alpha blending.
  52635. * @param mesh - BJS mesh.
  52636. */
  52637. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  52638. if (this._disableAlphaBlending && mesh.visibility >= 1.0) {
  52639. return false;
  52640. }
  52641. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  52642. };
  52643. /**
  52644. * Specifies whether or not this material should be rendered in alpha test mode.
  52645. */
  52646. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  52647. if (this._forceAlphaTest) {
  52648. return true;
  52649. }
  52650. if (this.subSurface.disableAlphaBlending) {
  52651. return false;
  52652. }
  52653. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  52654. };
  52655. /**
  52656. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52657. */
  52658. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  52659. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  52660. };
  52661. /**
  52662. * Gets the texture used for the alpha test.
  52663. */
  52664. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  52665. return this._albedoTexture;
  52666. };
  52667. /**
  52668. * Specifies that the submesh is ready to be used.
  52669. * @param mesh - BJS mesh.
  52670. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52671. * @param useInstances - Specifies that instances should be used.
  52672. * @returns - boolean indicating that the submesh is ready or not.
  52673. */
  52674. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  52675. if (subMesh.effect && this.isFrozen) {
  52676. if (this._wasPreviouslyReady) {
  52677. return true;
  52678. }
  52679. }
  52680. if (!subMesh._materialDefines) {
  52681. subMesh._materialDefines = new PBRMaterialDefines();
  52682. }
  52683. var defines = subMesh._materialDefines;
  52684. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  52685. if (defines._renderId === this.getScene().getRenderId()) {
  52686. return true;
  52687. }
  52688. }
  52689. var scene = this.getScene();
  52690. var engine = scene.getEngine();
  52691. if (defines._areTexturesDirty) {
  52692. if (scene.texturesEnabled) {
  52693. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  52694. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  52695. return false;
  52696. }
  52697. }
  52698. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].AmbientTextureEnabled) {
  52699. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  52700. return false;
  52701. }
  52702. }
  52703. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].OpacityTextureEnabled) {
  52704. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  52705. return false;
  52706. }
  52707. }
  52708. var reflectionTexture = this._getReflectionTexture();
  52709. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  52710. if (!reflectionTexture.isReadyOrNotBlocking()) {
  52711. return false;
  52712. }
  52713. }
  52714. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].LightmapTextureEnabled) {
  52715. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  52716. return false;
  52717. }
  52718. }
  52719. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled) {
  52720. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  52721. return false;
  52722. }
  52723. }
  52724. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].SpecularTextureEnabled) {
  52725. if (this._metallicTexture) {
  52726. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  52727. return false;
  52728. }
  52729. }
  52730. else if (this._reflectivityTexture) {
  52731. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  52732. return false;
  52733. }
  52734. }
  52735. if (this._microSurfaceTexture) {
  52736. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  52737. return false;
  52738. }
  52739. }
  52740. }
  52741. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52742. // Bump texture cannot be not blocking.
  52743. if (!this._bumpTexture.isReady()) {
  52744. return false;
  52745. }
  52746. }
  52747. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  52748. // This is blocking.
  52749. if (!this._environmentBRDFTexture.isReady()) {
  52750. return false;
  52751. }
  52752. }
  52753. }
  52754. }
  52755. if (!this.subSurface.isReadyForSubMesh(defines, scene) ||
  52756. !this.clearCoat.isReadyForSubMesh(defines, scene, engine, this._disableBumpMap) ||
  52757. !this.sheen.isReadyForSubMesh(defines, scene) ||
  52758. !this.anisotropy.isReadyForSubMesh(defines, scene)) {
  52759. return false;
  52760. }
  52761. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  52762. if (!this._imageProcessingConfiguration.isReady()) {
  52763. return false;
  52764. }
  52765. }
  52766. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  52767. mesh.createNormals(true);
  52768. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  52769. }
  52770. var previousEffect = subMesh.effect;
  52771. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  52772. if (effect) {
  52773. // Use previous effect while new one is compiling
  52774. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  52775. effect = previousEffect;
  52776. defines.markAsUnprocessed();
  52777. }
  52778. else {
  52779. scene.resetCachedMaterial();
  52780. subMesh.setEffect(effect, defines);
  52781. this.buildUniformLayout();
  52782. }
  52783. }
  52784. if (!subMesh.effect || !subMesh.effect.isReady()) {
  52785. return false;
  52786. }
  52787. defines._renderId = scene.getRenderId();
  52788. this._wasPreviouslyReady = true;
  52789. return true;
  52790. };
  52791. /**
  52792. * Specifies if the material uses metallic roughness workflow.
  52793. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52794. */
  52795. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  52796. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  52797. return true;
  52798. }
  52799. return false;
  52800. };
  52801. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  52802. if (onCompiled === void 0) { onCompiled = null; }
  52803. if (onError === void 0) { onError = null; }
  52804. if (useInstances === void 0) { useInstances = null; }
  52805. if (useClipPlane === void 0) { useClipPlane = null; }
  52806. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  52807. if (!defines.isDirty) {
  52808. return null;
  52809. }
  52810. defines.markAsProcessed();
  52811. var scene = this.getScene();
  52812. var engine = scene.getEngine();
  52813. // Fallbacks
  52814. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_14__["EffectFallbacks"]();
  52815. var fallbackRank = 0;
  52816. if (defines.USESPHERICALINVERTEX) {
  52817. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  52818. }
  52819. if (defines.FOG) {
  52820. fallbacks.addFallback(fallbackRank, "FOG");
  52821. }
  52822. if (defines.SPECULARAA) {
  52823. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  52824. }
  52825. if (defines.POINTSIZE) {
  52826. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  52827. }
  52828. if (defines.LOGARITHMICDEPTH) {
  52829. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  52830. }
  52831. if (defines.PARALLAX) {
  52832. fallbacks.addFallback(fallbackRank, "PARALLAX");
  52833. }
  52834. if (defines.PARALLAXOCCLUSION) {
  52835. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  52836. }
  52837. fallbackRank = _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52838. fallbackRank = _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52839. fallbackRank = _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52840. fallbackRank = _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52841. if (defines.ENVIRONMENTBRDF) {
  52842. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  52843. }
  52844. if (defines.TANGENT) {
  52845. fallbacks.addFallback(fallbackRank++, "TANGENT");
  52846. }
  52847. if (defines.BUMP) {
  52848. fallbacks.addFallback(fallbackRank++, "BUMP");
  52849. }
  52850. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  52851. if (defines.SPECULARTERM) {
  52852. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  52853. }
  52854. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  52855. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  52856. }
  52857. if (defines.LIGHTMAP) {
  52858. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  52859. }
  52860. if (defines.NORMAL) {
  52861. fallbacks.addFallback(fallbackRank++, "NORMAL");
  52862. }
  52863. if (defines.AMBIENT) {
  52864. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  52865. }
  52866. if (defines.EMISSIVE) {
  52867. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  52868. }
  52869. if (defines.VERTEXCOLOR) {
  52870. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  52871. }
  52872. if (defines.NUM_BONE_INFLUENCERS > 0) {
  52873. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  52874. }
  52875. if (defines.MORPHTARGETS) {
  52876. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  52877. }
  52878. if (defines.MULTIVIEW) {
  52879. fallbacks.addFallback(0, "MULTIVIEW");
  52880. }
  52881. //Attributes
  52882. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  52883. if (defines.NORMAL) {
  52884. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  52885. }
  52886. if (defines.TANGENT) {
  52887. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  52888. }
  52889. if (defines.UV1) {
  52890. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  52891. }
  52892. if (defines.UV2) {
  52893. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  52894. }
  52895. if (defines.VERTEXCOLOR) {
  52896. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  52897. }
  52898. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  52899. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  52900. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  52901. var shaderName = "pbr";
  52902. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "visibility", "vReflectionColor",
  52903. "vFogInfos", "vFogColor", "pointSize",
  52904. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  52905. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos",
  52906. "mBones",
  52907. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix",
  52908. "vLightingIntensity",
  52909. "logarithmicDepthConstant",
  52910. "vSphericalX", "vSphericalY", "vSphericalZ",
  52911. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  52912. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  52913. "vReflectionMicrosurfaceInfos",
  52914. "vTangentSpaceParams", "boneTextureWidth",
  52915. "vDebugMode"
  52916. ];
  52917. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  52918. "bumpSampler", "lightmapSampler", "opacitySampler",
  52919. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  52920. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  52921. var uniformBuffers = ["Material", "Scene"];
  52922. _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].AddUniforms(uniforms);
  52923. _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].AddSamplers(samplers);
  52924. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddUniforms(uniforms);
  52925. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddSamplers(samplers);
  52926. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddUniforms(uniforms);
  52927. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddSamplers(samplers);
  52928. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddUniforms(uniforms);
  52929. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddSamplers(samplers);
  52930. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__["ImageProcessingConfiguration"]) {
  52931. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  52932. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  52933. }
  52934. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareUniformsAndSamplersList({
  52935. uniformsNames: uniforms,
  52936. uniformBuffersNames: uniformBuffers,
  52937. samplers: samplers,
  52938. defines: defines,
  52939. maxSimultaneousLights: this._maxSimultaneousLights
  52940. });
  52941. if (this.customShaderNameResolve) {
  52942. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  52943. }
  52944. var join = defines.toString();
  52945. return engine.createEffect(shaderName, {
  52946. attributes: attribs,
  52947. uniformsNames: uniforms,
  52948. uniformBuffersNames: uniformBuffers,
  52949. samplers: samplers,
  52950. defines: join,
  52951. fallbacks: fallbacks,
  52952. onCompiled: onCompiled,
  52953. onError: onError,
  52954. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  52955. }, engine);
  52956. };
  52957. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  52958. if (useInstances === void 0) { useInstances = null; }
  52959. if (useClipPlane === void 0) { useClipPlane = null; }
  52960. var scene = this.getScene();
  52961. var engine = scene.getEngine();
  52962. // Lights
  52963. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  52964. defines._needNormals = true;
  52965. // Multiview
  52966. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  52967. // Textures
  52968. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  52969. if (defines._areTexturesDirty) {
  52970. defines._needUVs = false;
  52971. if (scene.texturesEnabled) {
  52972. if (scene.getEngine().getCaps().textureLOD) {
  52973. defines.LODBASEDMICROSFURACE = true;
  52974. }
  52975. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  52976. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  52977. }
  52978. else {
  52979. defines.ALBEDO = false;
  52980. }
  52981. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].AmbientTextureEnabled) {
  52982. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  52983. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  52984. }
  52985. else {
  52986. defines.AMBIENT = false;
  52987. }
  52988. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].OpacityTextureEnabled) {
  52989. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  52990. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  52991. }
  52992. else {
  52993. defines.OPACITY = false;
  52994. }
  52995. var reflectionTexture = this._getReflectionTexture();
  52996. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  52997. defines.REFLECTION = true;
  52998. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  52999. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  53000. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  53001. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  53002. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].INVCUBIC_MODE) {
  53003. defines.INVERTCUBICMAP = true;
  53004. }
  53005. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  53006. defines.REFLECTIONMAP_CUBIC = false;
  53007. defines.REFLECTIONMAP_EXPLICIT = false;
  53008. defines.REFLECTIONMAP_PLANAR = false;
  53009. defines.REFLECTIONMAP_PROJECTION = false;
  53010. defines.REFLECTIONMAP_SKYBOX = false;
  53011. defines.REFLECTIONMAP_SPHERICAL = false;
  53012. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  53013. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  53014. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  53015. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  53016. switch (reflectionTexture.coordinatesMode) {
  53017. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].EXPLICIT_MODE:
  53018. defines.REFLECTIONMAP_EXPLICIT = true;
  53019. break;
  53020. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].PLANAR_MODE:
  53021. defines.REFLECTIONMAP_PLANAR = true;
  53022. break;
  53023. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].PROJECTION_MODE:
  53024. defines.REFLECTIONMAP_PROJECTION = true;
  53025. break;
  53026. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].SKYBOX_MODE:
  53027. defines.REFLECTIONMAP_SKYBOX = true;
  53028. break;
  53029. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].SPHERICAL_MODE:
  53030. defines.REFLECTIONMAP_SPHERICAL = true;
  53031. break;
  53032. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].EQUIRECTANGULAR_MODE:
  53033. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  53034. break;
  53035. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  53036. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  53037. break;
  53038. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  53039. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  53040. break;
  53041. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].CUBIC_MODE:
  53042. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].INVCUBIC_MODE:
  53043. default:
  53044. defines.REFLECTIONMAP_CUBIC = true;
  53045. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  53046. break;
  53047. }
  53048. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].SKYBOX_MODE) {
  53049. if (reflectionTexture.sphericalPolynomial) {
  53050. defines.USESPHERICALFROMREFLECTIONMAP = true;
  53051. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  53052. defines.USESPHERICALINVERTEX = false;
  53053. }
  53054. else {
  53055. defines.USESPHERICALINVERTEX = true;
  53056. }
  53057. }
  53058. }
  53059. else {
  53060. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  53061. }
  53062. }
  53063. else {
  53064. defines.REFLECTION = false;
  53065. defines.REFLECTIONMAP_3D = false;
  53066. defines.REFLECTIONMAP_SPHERICAL = false;
  53067. defines.REFLECTIONMAP_PLANAR = false;
  53068. defines.REFLECTIONMAP_CUBIC = false;
  53069. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  53070. defines.REFLECTIONMAP_PROJECTION = false;
  53071. defines.REFLECTIONMAP_SKYBOX = false;
  53072. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  53073. defines.REFLECTIONMAP_EXPLICIT = false;
  53074. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  53075. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  53076. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  53077. defines.INVERTCUBICMAP = false;
  53078. defines.USESPHERICALFROMREFLECTIONMAP = false;
  53079. defines.USESPHERICALINVERTEX = false;
  53080. defines.REFLECTIONMAP_OPPOSITEZ = false;
  53081. defines.LODINREFLECTIONALPHA = false;
  53082. defines.GAMMAREFLECTION = false;
  53083. defines.RGBDREFLECTION = false;
  53084. }
  53085. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].LightmapTextureEnabled) {
  53086. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  53087. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  53088. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  53089. }
  53090. else {
  53091. defines.LIGHTMAP = false;
  53092. }
  53093. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled) {
  53094. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  53095. }
  53096. else {
  53097. defines.EMISSIVE = false;
  53098. }
  53099. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].SpecularTextureEnabled) {
  53100. if (this._metallicTexture) {
  53101. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  53102. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  53103. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  53104. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  53105. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  53106. }
  53107. else if (this._reflectivityTexture) {
  53108. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  53109. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  53110. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  53111. }
  53112. else {
  53113. defines.REFLECTIVITY = false;
  53114. }
  53115. if (this._microSurfaceTexture) {
  53116. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  53117. }
  53118. else {
  53119. defines.MICROSURFACEMAP = false;
  53120. }
  53121. }
  53122. else {
  53123. defines.REFLECTIVITY = false;
  53124. defines.MICROSURFACEMAP = false;
  53125. }
  53126. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  53127. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  53128. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  53129. defines.PARALLAX = true;
  53130. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  53131. }
  53132. else {
  53133. defines.PARALLAX = false;
  53134. }
  53135. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  53136. }
  53137. else {
  53138. defines.BUMP = false;
  53139. }
  53140. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  53141. defines.ENVIRONMENTBRDF = true;
  53142. // Not actual true RGBD, only the B chanel is encoded as RGBD for sheen.
  53143. defines.ENVIRONMENTBRDF_RGBD = this._environmentBRDFTexture.isRGBD;
  53144. }
  53145. else {
  53146. defines.ENVIRONMENTBRDF = false;
  53147. defines.ENVIRONMENTBRDF_RGBD = false;
  53148. }
  53149. if (this._shouldUseAlphaFromAlbedoTexture()) {
  53150. defines.ALPHAFROMALBEDO = true;
  53151. }
  53152. else {
  53153. defines.ALPHAFROMALBEDO = false;
  53154. }
  53155. }
  53156. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  53157. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  53158. defines.USEPHYSICALLIGHTFALLOFF = false;
  53159. defines.USEGLTFLIGHTFALLOFF = false;
  53160. }
  53161. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  53162. defines.USEPHYSICALLIGHTFALLOFF = false;
  53163. defines.USEGLTFLIGHTFALLOFF = true;
  53164. }
  53165. else {
  53166. defines.USEPHYSICALLIGHTFALLOFF = true;
  53167. defines.USEGLTFLIGHTFALLOFF = false;
  53168. }
  53169. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  53170. if (!this.backFaceCulling && this._twoSidedLighting) {
  53171. defines.TWOSIDEDLIGHTING = true;
  53172. }
  53173. else {
  53174. defines.TWOSIDEDLIGHTING = false;
  53175. }
  53176. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  53177. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  53178. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  53179. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  53180. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  53181. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  53182. }
  53183. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  53184. this._imageProcessingConfiguration.prepareDefines(defines);
  53185. }
  53186. defines.FORCENORMALFORWARD = this._forceNormalForward;
  53187. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  53188. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  53189. // Misc.
  53190. if (defines._areMiscDirty) {
  53191. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  53192. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  53193. defines.DEBUGMODE = this._debugMode;
  53194. }
  53195. // External config
  53196. this.subSurface.prepareDefines(defines, scene);
  53197. this.clearCoat.prepareDefines(defines, scene);
  53198. this.anisotropy.prepareDefines(defines, mesh, scene);
  53199. this.brdf.prepareDefines(defines);
  53200. this.sheen.prepareDefines(defines, scene);
  53201. // Values that need to be evaluated on every frame
  53202. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  53203. // Attribs
  53204. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  53205. };
  53206. /**
  53207. * Force shader compilation
  53208. */
  53209. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  53210. var _this = this;
  53211. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  53212. var defines = new PBRMaterialDefines();
  53213. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  53214. if (effect.isReady()) {
  53215. if (onCompiled) {
  53216. onCompiled(this);
  53217. }
  53218. }
  53219. else {
  53220. effect.onCompileObservable.add(function () {
  53221. if (onCompiled) {
  53222. onCompiled(_this);
  53223. }
  53224. });
  53225. }
  53226. };
  53227. /**
  53228. * Initializes the uniform buffer layout for the shader.
  53229. */
  53230. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  53231. // Order is important !
  53232. var ubo = this._uniformBuffer;
  53233. ubo.addUniform("vAlbedoInfos", 2);
  53234. ubo.addUniform("vAmbientInfos", 4);
  53235. ubo.addUniform("vOpacityInfos", 2);
  53236. ubo.addUniform("vEmissiveInfos", 2);
  53237. ubo.addUniform("vLightmapInfos", 2);
  53238. ubo.addUniform("vReflectivityInfos", 3);
  53239. ubo.addUniform("vMicroSurfaceSamplerInfos", 2);
  53240. ubo.addUniform("vReflectionInfos", 2);
  53241. ubo.addUniform("vReflectionPosition", 3);
  53242. ubo.addUniform("vReflectionSize", 3);
  53243. ubo.addUniform("vBumpInfos", 3);
  53244. ubo.addUniform("albedoMatrix", 16);
  53245. ubo.addUniform("ambientMatrix", 16);
  53246. ubo.addUniform("opacityMatrix", 16);
  53247. ubo.addUniform("emissiveMatrix", 16);
  53248. ubo.addUniform("lightmapMatrix", 16);
  53249. ubo.addUniform("reflectivityMatrix", 16);
  53250. ubo.addUniform("microSurfaceSamplerMatrix", 16);
  53251. ubo.addUniform("bumpMatrix", 16);
  53252. ubo.addUniform("vTangentSpaceParams", 2);
  53253. ubo.addUniform("reflectionMatrix", 16);
  53254. ubo.addUniform("vReflectionColor", 3);
  53255. ubo.addUniform("vAlbedoColor", 4);
  53256. ubo.addUniform("vLightingIntensity", 4);
  53257. ubo.addUniform("vReflectionMicrosurfaceInfos", 3);
  53258. ubo.addUniform("pointSize", 1);
  53259. ubo.addUniform("vReflectivityColor", 4);
  53260. ubo.addUniform("vEmissiveColor", 3);
  53261. ubo.addUniform("visibility", 1);
  53262. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].PrepareUniformBuffer(ubo);
  53263. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].PrepareUniformBuffer(ubo);
  53264. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].PrepareUniformBuffer(ubo);
  53265. _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].PrepareUniformBuffer(ubo);
  53266. ubo.create();
  53267. };
  53268. /**
  53269. * Unbinds the material from the mesh
  53270. */
  53271. PBRBaseMaterial.prototype.unbind = function () {
  53272. if (this._activeEffect) {
  53273. var needFlag = false;
  53274. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  53275. this._activeEffect.setTexture("reflection2DSampler", null);
  53276. needFlag = true;
  53277. }
  53278. if (this.subSurface.unbind(this._activeEffect)) {
  53279. needFlag = true;
  53280. }
  53281. if (needFlag) {
  53282. this._markAllSubMeshesAsTexturesDirty();
  53283. }
  53284. }
  53285. _super.prototype.unbind.call(this);
  53286. };
  53287. /**
  53288. * Binds the submesh data.
  53289. * @param world - The world matrix.
  53290. * @param mesh - The BJS mesh.
  53291. * @param subMesh - A submesh of the BJS mesh.
  53292. */
  53293. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  53294. var scene = this.getScene();
  53295. var defines = subMesh._materialDefines;
  53296. if (!defines) {
  53297. return;
  53298. }
  53299. var effect = subMesh.effect;
  53300. if (!effect) {
  53301. return;
  53302. }
  53303. this._activeEffect = effect;
  53304. // Matrices
  53305. if (!defines.INSTANCES) {
  53306. this.bindOnlyWorldMatrix(world);
  53307. }
  53308. // Normal Matrix
  53309. if (defines.OBJECTSPACE_NORMALMAP) {
  53310. world.toNormalMatrix(this._normalMatrix);
  53311. this.bindOnlyNormalMatrix(this._normalMatrix);
  53312. }
  53313. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  53314. // Bones
  53315. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  53316. var reflectionTexture = null;
  53317. var ubo = this._uniformBuffer;
  53318. if (mustRebind) {
  53319. var engine = scene.getEngine();
  53320. ubo.bindToEffect(effect, "Material");
  53321. this.bindViewProjection(effect);
  53322. reflectionTexture = this._getReflectionTexture();
  53323. if (!ubo.useUbo || !this.isFrozen || !ubo.isSync) {
  53324. // Texture uniforms
  53325. if (scene.texturesEnabled) {
  53326. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  53327. ubo.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  53328. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, ubo, "albedo");
  53329. }
  53330. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].AmbientTextureEnabled) {
  53331. ubo.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  53332. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, ubo, "ambient");
  53333. }
  53334. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].OpacityTextureEnabled) {
  53335. ubo.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  53336. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, ubo, "opacity");
  53337. }
  53338. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  53339. ubo.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  53340. ubo.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  53341. if (reflectionTexture.boundingBoxSize) {
  53342. var cubeTexture = reflectionTexture;
  53343. ubo.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  53344. ubo.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  53345. }
  53346. var polynomials = reflectionTexture.sphericalPolynomial;
  53347. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  53348. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  53349. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  53350. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  53351. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  53352. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  53353. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  53354. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  53355. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  53356. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  53357. }
  53358. ubo.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  53359. }
  53360. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled) {
  53361. ubo.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  53362. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, ubo, "emissive");
  53363. }
  53364. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].LightmapTextureEnabled) {
  53365. ubo.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  53366. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, ubo, "lightmap");
  53367. }
  53368. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].SpecularTextureEnabled) {
  53369. if (this._metallicTexture) {
  53370. ubo.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  53371. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, ubo, "reflectivity");
  53372. }
  53373. else if (this._reflectivityTexture) {
  53374. ubo.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  53375. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, ubo, "reflectivity");
  53376. }
  53377. if (this._microSurfaceTexture) {
  53378. ubo.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  53379. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, ubo, "microSurfaceSampler");
  53380. }
  53381. }
  53382. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  53383. ubo.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  53384. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, ubo, "bump");
  53385. if (scene._mirroredCameraPosition) {
  53386. ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  53387. }
  53388. else {
  53389. ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  53390. }
  53391. }
  53392. }
  53393. // Point size
  53394. if (this.pointsCloud) {
  53395. ubo.updateFloat("pointSize", this.pointSize);
  53396. }
  53397. // Colors
  53398. if (defines.METALLICWORKFLOW) {
  53399. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  53400. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  53401. ubo.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  53402. }
  53403. else {
  53404. ubo.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  53405. }
  53406. ubo.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  53407. ubo.updateColor3("vReflectionColor", this._reflectionColor);
  53408. ubo.updateColor4("vAlbedoColor", this._albedoColor, this.alpha);
  53409. // Visibility
  53410. ubo.updateFloat("visibility", mesh.visibility);
  53411. // Misc
  53412. this._lightingInfos.x = this._directIntensity;
  53413. this._lightingInfos.y = this._emissiveIntensity;
  53414. this._lightingInfos.z = this._environmentIntensity;
  53415. this._lightingInfos.w = this._specularIntensity;
  53416. ubo.updateVector4("vLightingIntensity", this._lightingInfos);
  53417. }
  53418. // Textures
  53419. if (scene.texturesEnabled) {
  53420. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  53421. ubo.setTexture("albedoSampler", this._albedoTexture);
  53422. }
  53423. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].AmbientTextureEnabled) {
  53424. ubo.setTexture("ambientSampler", this._ambientTexture);
  53425. }
  53426. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].OpacityTextureEnabled) {
  53427. ubo.setTexture("opacitySampler", this._opacityTexture);
  53428. }
  53429. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  53430. if (defines.LODBASEDMICROSFURACE) {
  53431. ubo.setTexture("reflectionSampler", reflectionTexture);
  53432. }
  53433. else {
  53434. ubo.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  53435. ubo.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  53436. ubo.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  53437. }
  53438. }
  53439. if (defines.ENVIRONMENTBRDF) {
  53440. ubo.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  53441. }
  53442. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled) {
  53443. ubo.setTexture("emissiveSampler", this._emissiveTexture);
  53444. }
  53445. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].LightmapTextureEnabled) {
  53446. ubo.setTexture("lightmapSampler", this._lightmapTexture);
  53447. }
  53448. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].SpecularTextureEnabled) {
  53449. if (this._metallicTexture) {
  53450. ubo.setTexture("reflectivitySampler", this._metallicTexture);
  53451. }
  53452. else if (this._reflectivityTexture) {
  53453. ubo.setTexture("reflectivitySampler", this._reflectivityTexture);
  53454. }
  53455. if (this._microSurfaceTexture) {
  53456. ubo.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  53457. }
  53458. }
  53459. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  53460. ubo.setTexture("bumpSampler", this._bumpTexture);
  53461. }
  53462. }
  53463. this.subSurface.bindForSubMesh(ubo, scene, engine, this.isFrozen, defines.LODBASEDMICROSFURACE);
  53464. this.clearCoat.bindForSubMesh(ubo, scene, engine, this._disableBumpMap, this.isFrozen, this._invertNormalMapX, this._invertNormalMapY);
  53465. this.anisotropy.bindForSubMesh(ubo, scene, this.isFrozen);
  53466. this.sheen.bindForSubMesh(ubo, scene, this.isFrozen);
  53467. // Clip plane
  53468. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  53469. // Colors
  53470. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  53471. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  53472. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  53473. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  53474. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  53475. effect.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
  53476. }
  53477. if (mustRebind || !this.isFrozen) {
  53478. // Lights
  53479. if (scene.lightsEnabled && !this._disableLighting) {
  53480. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  53481. }
  53482. // View
  53483. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  53484. this.bindView(effect);
  53485. }
  53486. // Fog
  53487. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  53488. // Morph targets
  53489. if (defines.NUM_MORPH_INFLUENCERS) {
  53490. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  53491. }
  53492. // image processing
  53493. this._imageProcessingConfiguration.bind(this._activeEffect);
  53494. // Log. depth
  53495. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  53496. }
  53497. ubo.update();
  53498. this._afterBind(mesh, this._activeEffect);
  53499. };
  53500. /**
  53501. * Returns the animatable textures.
  53502. * @returns - Array of animatable textures.
  53503. */
  53504. PBRBaseMaterial.prototype.getAnimatables = function () {
  53505. var results = [];
  53506. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  53507. results.push(this._albedoTexture);
  53508. }
  53509. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  53510. results.push(this._ambientTexture);
  53511. }
  53512. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  53513. results.push(this._opacityTexture);
  53514. }
  53515. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  53516. results.push(this._reflectionTexture);
  53517. }
  53518. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  53519. results.push(this._emissiveTexture);
  53520. }
  53521. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  53522. results.push(this._metallicTexture);
  53523. }
  53524. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  53525. results.push(this._reflectivityTexture);
  53526. }
  53527. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  53528. results.push(this._bumpTexture);
  53529. }
  53530. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  53531. results.push(this._lightmapTexture);
  53532. }
  53533. this.subSurface.getAnimatables(results);
  53534. this.clearCoat.getAnimatables(results);
  53535. this.sheen.getAnimatables(results);
  53536. this.anisotropy.getAnimatables(results);
  53537. return results;
  53538. };
  53539. /**
  53540. * Returns the texture used for reflections.
  53541. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53542. */
  53543. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  53544. if (this._reflectionTexture) {
  53545. return this._reflectionTexture;
  53546. }
  53547. return this.getScene().environmentTexture;
  53548. };
  53549. /**
  53550. * Returns an array of the actively used textures.
  53551. * @returns - Array of BaseTextures
  53552. */
  53553. PBRBaseMaterial.prototype.getActiveTextures = function () {
  53554. var activeTextures = _super.prototype.getActiveTextures.call(this);
  53555. if (this._albedoTexture) {
  53556. activeTextures.push(this._albedoTexture);
  53557. }
  53558. if (this._ambientTexture) {
  53559. activeTextures.push(this._ambientTexture);
  53560. }
  53561. if (this._opacityTexture) {
  53562. activeTextures.push(this._opacityTexture);
  53563. }
  53564. if (this._reflectionTexture) {
  53565. activeTextures.push(this._reflectionTexture);
  53566. }
  53567. if (this._emissiveTexture) {
  53568. activeTextures.push(this._emissiveTexture);
  53569. }
  53570. if (this._reflectivityTexture) {
  53571. activeTextures.push(this._reflectivityTexture);
  53572. }
  53573. if (this._metallicTexture) {
  53574. activeTextures.push(this._metallicTexture);
  53575. }
  53576. if (this._microSurfaceTexture) {
  53577. activeTextures.push(this._microSurfaceTexture);
  53578. }
  53579. if (this._bumpTexture) {
  53580. activeTextures.push(this._bumpTexture);
  53581. }
  53582. if (this._lightmapTexture) {
  53583. activeTextures.push(this._lightmapTexture);
  53584. }
  53585. this.subSurface.getActiveTextures(activeTextures);
  53586. this.clearCoat.getActiveTextures(activeTextures);
  53587. this.sheen.getActiveTextures(activeTextures);
  53588. this.anisotropy.getActiveTextures(activeTextures);
  53589. return activeTextures;
  53590. };
  53591. /**
  53592. * Checks to see if a texture is used in the material.
  53593. * @param texture - Base texture to use.
  53594. * @returns - Boolean specifying if a texture is used in the material.
  53595. */
  53596. PBRBaseMaterial.prototype.hasTexture = function (texture) {
  53597. if (_super.prototype.hasTexture.call(this, texture)) {
  53598. return true;
  53599. }
  53600. if (this._albedoTexture === texture) {
  53601. return true;
  53602. }
  53603. if (this._ambientTexture === texture) {
  53604. return true;
  53605. }
  53606. if (this._opacityTexture === texture) {
  53607. return true;
  53608. }
  53609. if (this._reflectionTexture === texture) {
  53610. return true;
  53611. }
  53612. if (this._reflectivityTexture === texture) {
  53613. return true;
  53614. }
  53615. if (this._metallicTexture === texture) {
  53616. return true;
  53617. }
  53618. if (this._microSurfaceTexture === texture) {
  53619. return true;
  53620. }
  53621. if (this._bumpTexture === texture) {
  53622. return true;
  53623. }
  53624. if (this._lightmapTexture === texture) {
  53625. return true;
  53626. }
  53627. return this.subSurface.hasTexture(texture) ||
  53628. this.clearCoat.hasTexture(texture) ||
  53629. this.sheen.hasTexture(texture) ||
  53630. this.anisotropy.hasTexture(texture);
  53631. };
  53632. /**
  53633. * Disposes the resources of the material.
  53634. * @param forceDisposeEffect - Forces the disposal of effects.
  53635. * @param forceDisposeTextures - Forces the disposal of all textures.
  53636. */
  53637. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  53638. if (forceDisposeTextures) {
  53639. if (this._albedoTexture) {
  53640. this._albedoTexture.dispose();
  53641. }
  53642. if (this._ambientTexture) {
  53643. this._ambientTexture.dispose();
  53644. }
  53645. if (this._opacityTexture) {
  53646. this._opacityTexture.dispose();
  53647. }
  53648. if (this._reflectionTexture) {
  53649. this._reflectionTexture.dispose();
  53650. }
  53651. if (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture) {
  53652. this._environmentBRDFTexture.dispose();
  53653. }
  53654. if (this._emissiveTexture) {
  53655. this._emissiveTexture.dispose();
  53656. }
  53657. if (this._metallicTexture) {
  53658. this._metallicTexture.dispose();
  53659. }
  53660. if (this._reflectivityTexture) {
  53661. this._reflectivityTexture.dispose();
  53662. }
  53663. if (this._bumpTexture) {
  53664. this._bumpTexture.dispose();
  53665. }
  53666. if (this._lightmapTexture) {
  53667. this._lightmapTexture.dispose();
  53668. }
  53669. }
  53670. this.subSurface.dispose(forceDisposeTextures);
  53671. this.clearCoat.dispose(forceDisposeTextures);
  53672. this.sheen.dispose(forceDisposeTextures);
  53673. this.anisotropy.dispose(forceDisposeTextures);
  53674. this._renderTargets.dispose();
  53675. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  53676. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  53677. }
  53678. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  53679. };
  53680. /**
  53681. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53682. */
  53683. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  53684. /**
  53685. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53686. */
  53687. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  53688. /**
  53689. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53690. */
  53691. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  53692. /**
  53693. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53694. * They are also discarded below the alpha cutoff threshold to improve performances.
  53695. */
  53696. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  53697. /**
  53698. * Defines the default value of how much AO map is occluding the analytical lights
  53699. * (point spot...).
  53700. */
  53701. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0;
  53702. /**
  53703. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53704. */
  53705. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  53706. /**
  53707. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53708. * to enhance interoperability with other engines.
  53709. */
  53710. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  53711. /**
  53712. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53713. * to enhance interoperability with other materials.
  53714. */
  53715. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  53716. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53717. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  53718. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  53719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53720. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  53721. ], PBRBaseMaterial.prototype, "debugMode", void 0);
  53722. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53723. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53724. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  53725. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53726. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53727. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  53728. return PBRBaseMaterial;
  53729. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_16__["PushMaterial"]));
  53730. /***/ }),
  53731. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  53732. /*!************************************************!*\
  53733. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  53734. \************************************************/
  53735. /*! exports provided: PBRBaseSimpleMaterial */
  53736. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53737. "use strict";
  53738. __webpack_require__.r(__webpack_exports__);
  53739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  53740. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53741. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53742. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53743. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  53744. /**
  53745. * The Physically based simple base material of BJS.
  53746. *
  53747. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53748. * It is used as the base class for both the specGloss and metalRough conventions.
  53749. */
  53750. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  53751. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  53752. /**
  53753. * Instantiates a new PBRMaterial instance.
  53754. *
  53755. * @param name The material name
  53756. * @param scene The scene the material will be use in.
  53757. */
  53758. function PBRBaseSimpleMaterial(name, scene) {
  53759. var _this = _super.call(this, name, scene) || this;
  53760. /**
  53761. * Number of Simultaneous lights allowed on the material.
  53762. */
  53763. _this.maxSimultaneousLights = 4;
  53764. /**
  53765. * If sets to true, disables all the lights affecting the material.
  53766. */
  53767. _this.disableLighting = false;
  53768. /**
  53769. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53770. */
  53771. _this.invertNormalMapX = false;
  53772. /**
  53773. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53774. */
  53775. _this.invertNormalMapY = false;
  53776. /**
  53777. * Emissivie color used to self-illuminate the model.
  53778. */
  53779. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  53780. /**
  53781. * Occlusion Channel Strenght.
  53782. */
  53783. _this.occlusionStrength = 1.0;
  53784. /**
  53785. * If true, the light map contains occlusion information instead of lighting info.
  53786. */
  53787. _this.useLightmapAsShadowmap = false;
  53788. _this._useAlphaFromAlbedoTexture = true;
  53789. _this._useAmbientInGrayScale = true;
  53790. return _this;
  53791. }
  53792. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  53793. /**
  53794. * Gets the current double sided mode.
  53795. */
  53796. get: function () {
  53797. return this._twoSidedLighting;
  53798. },
  53799. /**
  53800. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53801. */
  53802. set: function (value) {
  53803. if (this._twoSidedLighting === value) {
  53804. return;
  53805. }
  53806. this._twoSidedLighting = value;
  53807. this.backFaceCulling = !value;
  53808. this._markAllSubMeshesAsTexturesDirty();
  53809. },
  53810. enumerable: true,
  53811. configurable: true
  53812. });
  53813. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  53814. return "PBRBaseSimpleMaterial";
  53815. };
  53816. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53819. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  53820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53823. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  53824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  53827. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  53828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53831. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  53832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53835. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  53836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53838. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  53839. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  53840. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  53842. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53843. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  53844. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53845. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53846. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53847. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  53848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53850. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  53851. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  53852. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53853. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53854. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  53855. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  53856. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  53859. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  53860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53862. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  53863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53865. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  53866. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  53867. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53868. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53870. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  53871. return PBRBaseSimpleMaterial;
  53872. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  53873. /***/ }),
  53874. /***/ "./Materials/PBR/pbrClearCoatConfiguration.ts":
  53875. /*!****************************************************!*\
  53876. !*** ./Materials/PBR/pbrClearCoatConfiguration.ts ***!
  53877. \****************************************************/
  53878. /*! exports provided: PBRClearCoatConfiguration */
  53879. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53880. "use strict";
  53881. __webpack_require__.r(__webpack_exports__);
  53882. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRClearCoatConfiguration", function() { return PBRClearCoatConfiguration; });
  53883. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53884. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53885. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53886. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  53887. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  53888. /**
  53889. * Define the code related to the clear coat parameters of the pbr material.
  53890. */
  53891. var PBRClearCoatConfiguration = /** @class */ (function () {
  53892. /**
  53893. * Instantiate a new istance of clear coat configuration.
  53894. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53895. */
  53896. function PBRClearCoatConfiguration(markAllSubMeshesAsTexturesDirty) {
  53897. this._isEnabled = false;
  53898. /**
  53899. * Defines if the clear coat is enabled in the material.
  53900. */
  53901. this.isEnabled = false;
  53902. /**
  53903. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53904. */
  53905. this.intensity = 1;
  53906. /**
  53907. * Defines the clear coat layer roughness.
  53908. */
  53909. this.roughness = 0;
  53910. this._indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53911. /**
  53912. * Defines the indice of refraction of the clear coat.
  53913. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53914. * The default fits with a polyurethane material.
  53915. * Changing the default value is more performance intensive.
  53916. */
  53917. this.indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53918. this._texture = null;
  53919. /**
  53920. * Stores the clear coat values in a texture.
  53921. */
  53922. this.texture = null;
  53923. this._bumpTexture = null;
  53924. /**
  53925. * Define the clear coat specific bump texture.
  53926. */
  53927. this.bumpTexture = null;
  53928. this._isTintEnabled = false;
  53929. /**
  53930. * Defines if the clear coat tint is enabled in the material.
  53931. */
  53932. this.isTintEnabled = false;
  53933. /**
  53934. * Defines the clear coat tint of the material.
  53935. * This is only use if tint is enabled
  53936. */
  53937. this.tintColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  53938. /**
  53939. * Defines the distance at which the tint color should be found in the
  53940. * clear coat media.
  53941. * This is only use if tint is enabled
  53942. */
  53943. this.tintColorAtDistance = 1;
  53944. /**
  53945. * Defines the clear coat layer thickness.
  53946. * This is only use if tint is enabled
  53947. */
  53948. this.tintThickness = 1;
  53949. this._tintTexture = null;
  53950. /**
  53951. * Stores the clear tint values in a texture.
  53952. * rgb is tint
  53953. * a is a thickness factor
  53954. */
  53955. this.tintTexture = null;
  53956. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  53957. }
  53958. /** @hidden */
  53959. PBRClearCoatConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  53960. this._internalMarkAllSubMeshesAsTexturesDirty();
  53961. };
  53962. /**
  53963. * Gets wehter the submesh is ready to be used or not.
  53964. * @param defines the list of "defines" to update.
  53965. * @param scene defines the scene the material belongs to.
  53966. * @param engine defines the engine the material belongs to.
  53967. * @param disableBumpMap defines wether the material disables bump or not.
  53968. * @returns - boolean indicating that the submesh is ready or not.
  53969. */
  53970. PBRClearCoatConfiguration.prototype.isReadyForSubMesh = function (defines, scene, engine, disableBumpMap) {
  53971. if (defines._areTexturesDirty) {
  53972. if (scene.texturesEnabled) {
  53973. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53974. if (!this._texture.isReadyOrNotBlocking()) {
  53975. return false;
  53976. }
  53977. }
  53978. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  53979. // Bump texture cannot be not blocking.
  53980. if (!this._bumpTexture.isReady()) {
  53981. return false;
  53982. }
  53983. }
  53984. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53985. if (!this._tintTexture.isReadyOrNotBlocking()) {
  53986. return false;
  53987. }
  53988. }
  53989. }
  53990. }
  53991. return true;
  53992. };
  53993. /**
  53994. * Checks to see if a texture is used in the material.
  53995. * @param defines the list of "defines" to update.
  53996. * @param scene defines the scene to the material belongs to.
  53997. */
  53998. PBRClearCoatConfiguration.prototype.prepareDefines = function (defines, scene) {
  53999. if (this._isEnabled) {
  54000. defines.CLEARCOAT = true;
  54001. if (defines._areTexturesDirty) {
  54002. if (scene.texturesEnabled) {
  54003. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  54004. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "CLEARCOAT_TEXTURE");
  54005. }
  54006. else {
  54007. defines.CLEARCOAT_TEXTURE = false;
  54008. }
  54009. if (this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled) {
  54010. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "CLEARCOAT_BUMP");
  54011. }
  54012. else {
  54013. defines.CLEARCOAT_BUMP = false;
  54014. }
  54015. defines.CLEARCOAT_DEFAULTIOR = this._indiceOfRefraction === PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  54016. if (this._isTintEnabled) {
  54017. defines.CLEARCOAT_TINT = true;
  54018. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  54019. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._tintTexture, defines, "CLEARCOAT_TINT_TEXTURE");
  54020. }
  54021. else {
  54022. defines.CLEARCOAT_TINT_TEXTURE = false;
  54023. }
  54024. }
  54025. else {
  54026. defines.CLEARCOAT_TINT = false;
  54027. defines.CLEARCOAT_TINT_TEXTURE = false;
  54028. }
  54029. }
  54030. }
  54031. }
  54032. else {
  54033. defines.CLEARCOAT = false;
  54034. defines.CLEARCOAT_TEXTURE = false;
  54035. defines.CLEARCOAT_BUMP = false;
  54036. defines.CLEARCOAT_TINT = false;
  54037. defines.CLEARCOAT_TINT_TEXTURE = false;
  54038. }
  54039. };
  54040. /**
  54041. * Binds the material data.
  54042. * @param uniformBuffer defines the Uniform buffer to fill in.
  54043. * @param scene defines the scene the material belongs to.
  54044. * @param engine defines the engine the material belongs to.
  54045. * @param disableBumpMap defines wether the material disables bump or not.
  54046. * @param isFrozen defines wether the material is frozen or not.
  54047. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54048. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54049. */
  54050. PBRClearCoatConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, engine, disableBumpMap, isFrozen, invertNormalMapX, invertNormalMapY) {
  54051. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  54052. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  54053. uniformBuffer.updateFloat2("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level);
  54054. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "clearCoat");
  54055. }
  54056. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled && !disableBumpMap) {
  54057. uniformBuffer.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level);
  54058. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, uniformBuffer, "clearCoatBump");
  54059. if (scene._mirroredCameraPosition) {
  54060. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? 1.0 : -1.0, invertNormalMapY ? 1.0 : -1.0);
  54061. }
  54062. else {
  54063. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? -1.0 : 1.0, invertNormalMapY ? -1.0 : 1.0);
  54064. }
  54065. }
  54066. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  54067. uniformBuffer.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level);
  54068. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._tintTexture, uniformBuffer, "clearCoatTint");
  54069. }
  54070. // Clear Coat General params
  54071. uniformBuffer.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
  54072. // Clear Coat Refraction params
  54073. var a = 1 - this._indiceOfRefraction;
  54074. var b = 1 + this._indiceOfRefraction;
  54075. var f0 = Math.pow((-a / b), 2); // Schlicks approx: (ior1 - ior2) / (ior1 + ior2) where ior2 for air is close to vacuum = 1.
  54076. var eta = 1 / this._indiceOfRefraction;
  54077. uniformBuffer.updateFloat4("vClearCoatRefractionParams", f0, eta, a, b);
  54078. if (this._isTintEnabled) {
  54079. uniformBuffer.updateFloat4("vClearCoatTintParams", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(0.00001, this.tintThickness));
  54080. uniformBuffer.updateFloat("clearCoatColorAtDistance", Math.max(0.00001, this.tintColorAtDistance));
  54081. }
  54082. }
  54083. // Textures
  54084. if (scene.texturesEnabled) {
  54085. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  54086. uniformBuffer.setTexture("clearCoatSampler", this._texture);
  54087. }
  54088. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  54089. uniformBuffer.setTexture("clearCoatBumpSampler", this._bumpTexture);
  54090. }
  54091. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  54092. uniformBuffer.setTexture("clearCoatTintSampler", this._tintTexture);
  54093. }
  54094. }
  54095. };
  54096. /**
  54097. * Checks to see if a texture is used in the material.
  54098. * @param texture - Base texture to use.
  54099. * @returns - Boolean specifying if a texture is used in the material.
  54100. */
  54101. PBRClearCoatConfiguration.prototype.hasTexture = function (texture) {
  54102. if (this._texture === texture) {
  54103. return true;
  54104. }
  54105. if (this._bumpTexture === texture) {
  54106. return true;
  54107. }
  54108. if (this._tintTexture === texture) {
  54109. return true;
  54110. }
  54111. return false;
  54112. };
  54113. /**
  54114. * Returns an array of the actively used textures.
  54115. * @param activeTextures Array of BaseTextures
  54116. */
  54117. PBRClearCoatConfiguration.prototype.getActiveTextures = function (activeTextures) {
  54118. if (this._texture) {
  54119. activeTextures.push(this._texture);
  54120. }
  54121. if (this._bumpTexture) {
  54122. activeTextures.push(this._bumpTexture);
  54123. }
  54124. if (this._tintTexture) {
  54125. activeTextures.push(this._tintTexture);
  54126. }
  54127. };
  54128. /**
  54129. * Returns the animatable textures.
  54130. * @param animatables Array of animatable textures.
  54131. */
  54132. PBRClearCoatConfiguration.prototype.getAnimatables = function (animatables) {
  54133. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  54134. animatables.push(this._texture);
  54135. }
  54136. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  54137. animatables.push(this._bumpTexture);
  54138. }
  54139. if (this._tintTexture && this._tintTexture.animations && this._tintTexture.animations.length > 0) {
  54140. animatables.push(this._tintTexture);
  54141. }
  54142. };
  54143. /**
  54144. * Disposes the resources of the material.
  54145. * @param forceDisposeTextures - Forces the disposal of all textures.
  54146. */
  54147. PBRClearCoatConfiguration.prototype.dispose = function (forceDisposeTextures) {
  54148. if (forceDisposeTextures) {
  54149. if (this._texture) {
  54150. this._texture.dispose();
  54151. }
  54152. if (this._bumpTexture) {
  54153. this._bumpTexture.dispose();
  54154. }
  54155. if (this._tintTexture) {
  54156. this._tintTexture.dispose();
  54157. }
  54158. }
  54159. };
  54160. /**
  54161. * Get the current class name of the texture useful for serialization or dynamic coding.
  54162. * @returns "PBRClearCoatConfiguration"
  54163. */
  54164. PBRClearCoatConfiguration.prototype.getClassName = function () {
  54165. return "PBRClearCoatConfiguration";
  54166. };
  54167. /**
  54168. * Add fallbacks to the effect fallbacks list.
  54169. * @param defines defines the Base texture to use.
  54170. * @param fallbacks defines the current fallback list.
  54171. * @param currentRank defines the current fallback rank.
  54172. * @returns the new fallback rank.
  54173. */
  54174. PBRClearCoatConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  54175. if (defines.CLEARCOAT_BUMP) {
  54176. fallbacks.addFallback(currentRank++, "CLEARCOAT_BUMP");
  54177. }
  54178. if (defines.CLEARCOAT_TINT) {
  54179. fallbacks.addFallback(currentRank++, "CLEARCOAT_TINT");
  54180. }
  54181. if (defines.CLEARCOAT) {
  54182. fallbacks.addFallback(currentRank++, "CLEARCOAT");
  54183. }
  54184. return currentRank;
  54185. };
  54186. /**
  54187. * Add the required uniforms to the current list.
  54188. * @param uniforms defines the current uniform list.
  54189. */
  54190. PBRClearCoatConfiguration.AddUniforms = function (uniforms) {
  54191. uniforms.push("vClearCoatTangentSpaceParams", "vClearCoatParams", "vClearCoatRefractionParams", "vClearCoatTintParams", "clearCoatColorAtDistance", "clearCoatMatrix", "clearCoatBumpMatrix", "clearCoatTintMatrix", "vClearCoatInfos", "vClearCoatBumpInfos", "vClearCoatTintInfos");
  54192. };
  54193. /**
  54194. * Add the required samplers to the current list.
  54195. * @param samplers defines the current sampler list.
  54196. */
  54197. PBRClearCoatConfiguration.AddSamplers = function (samplers) {
  54198. samplers.push("clearCoatSampler", "clearCoatBumpSampler", "clearCoatTintSampler");
  54199. };
  54200. /**
  54201. * Add the required uniforms to the current buffer.
  54202. * @param uniformBuffer defines the current uniform buffer.
  54203. */
  54204. PBRClearCoatConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  54205. uniformBuffer.addUniform("vClearCoatParams", 2);
  54206. uniformBuffer.addUniform("vClearCoatRefractionParams", 4);
  54207. uniformBuffer.addUniform("vClearCoatInfos", 2);
  54208. uniformBuffer.addUniform("clearCoatMatrix", 16);
  54209. uniformBuffer.addUniform("vClearCoatBumpInfos", 2);
  54210. uniformBuffer.addUniform("vClearCoatTangentSpaceParams", 2);
  54211. uniformBuffer.addUniform("clearCoatBumpMatrix", 16);
  54212. uniformBuffer.addUniform("vClearCoatTintParams", 4);
  54213. uniformBuffer.addUniform("clearCoatColorAtDistance", 1);
  54214. uniformBuffer.addUniform("vClearCoatTintInfos", 2);
  54215. uniformBuffer.addUniform("clearCoatTintMatrix", 16);
  54216. };
  54217. /**
  54218. * Makes a duplicate of the current configuration into another one.
  54219. * @param clearCoatConfiguration define the config where to copy the info
  54220. */
  54221. PBRClearCoatConfiguration.prototype.copyTo = function (clearCoatConfiguration) {
  54222. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return clearCoatConfiguration; }, this);
  54223. };
  54224. /**
  54225. * Serializes this clear coat configuration.
  54226. * @returns - An object with the serialized config.
  54227. */
  54228. PBRClearCoatConfiguration.prototype.serialize = function () {
  54229. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54230. };
  54231. /**
  54232. * Parses a Clear Coat Configuration from a serialized object.
  54233. * @param source - Serialized object.
  54234. */
  54235. PBRClearCoatConfiguration.prototype.parse = function (source) {
  54236. var _this = this;
  54237. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  54238. };
  54239. /**
  54240. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54241. * The default fits with a polyurethane material.
  54242. */
  54243. PBRClearCoatConfiguration._DefaultIndiceOfRefraction = 1.5;
  54244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54246. ], PBRClearCoatConfiguration.prototype, "_isEnabled", void 0);
  54247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54249. ], PBRClearCoatConfiguration.prototype, "isEnabled", void 0);
  54250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54252. ], PBRClearCoatConfiguration.prototype, "intensity", void 0);
  54253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54255. ], PBRClearCoatConfiguration.prototype, "roughness", void 0);
  54256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54258. ], PBRClearCoatConfiguration.prototype, "_indiceOfRefraction", void 0);
  54259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54261. ], PBRClearCoatConfiguration.prototype, "indiceOfRefraction", void 0);
  54262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54264. ], PBRClearCoatConfiguration.prototype, "_texture", void 0);
  54265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54267. ], PBRClearCoatConfiguration.prototype, "texture", void 0);
  54268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54270. ], PBRClearCoatConfiguration.prototype, "_bumpTexture", void 0);
  54271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54273. ], PBRClearCoatConfiguration.prototype, "bumpTexture", void 0);
  54274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54276. ], PBRClearCoatConfiguration.prototype, "_isTintEnabled", void 0);
  54277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54279. ], PBRClearCoatConfiguration.prototype, "isTintEnabled", void 0);
  54280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  54282. ], PBRClearCoatConfiguration.prototype, "tintColor", void 0);
  54283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54285. ], PBRClearCoatConfiguration.prototype, "tintColorAtDistance", void 0);
  54286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54288. ], PBRClearCoatConfiguration.prototype, "tintThickness", void 0);
  54289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54291. ], PBRClearCoatConfiguration.prototype, "_tintTexture", void 0);
  54292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54294. ], PBRClearCoatConfiguration.prototype, "tintTexture", void 0);
  54295. return PBRClearCoatConfiguration;
  54296. }());
  54297. /***/ }),
  54298. /***/ "./Materials/PBR/pbrMaterial.ts":
  54299. /*!**************************************!*\
  54300. !*** ./Materials/PBR/pbrMaterial.ts ***!
  54301. \**************************************/
  54302. /*! exports provided: PBRMaterial */
  54303. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54304. "use strict";
  54305. __webpack_require__.r(__webpack_exports__);
  54306. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  54307. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54308. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54309. /* harmony import */ var _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/brdfTextureTools */ "./Misc/brdfTextureTools.ts");
  54310. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54311. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  54312. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  54313. /**
  54314. * The Physically based material of BJS.
  54315. *
  54316. * This offers the main features of a standard PBR material.
  54317. * For more information, please refer to the documentation :
  54318. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  54319. */
  54320. var PBRMaterial = /** @class */ (function (_super) {
  54321. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  54322. /**
  54323. * Instantiates a new PBRMaterial instance.
  54324. *
  54325. * @param name The material name
  54326. * @param scene The scene the material will be use in.
  54327. */
  54328. function PBRMaterial(name, scene) {
  54329. var _this = _super.call(this, name, scene) || this;
  54330. /**
  54331. * Intensity of the direct lights e.g. the four lights available in your scene.
  54332. * This impacts both the direct diffuse and specular highlights.
  54333. */
  54334. _this.directIntensity = 1.0;
  54335. /**
  54336. * Intensity of the emissive part of the material.
  54337. * This helps controlling the emissive effect without modifying the emissive color.
  54338. */
  54339. _this.emissiveIntensity = 1.0;
  54340. /**
  54341. * Intensity of the environment e.g. how much the environment will light the object
  54342. * either through harmonics for rough material or through the refelction for shiny ones.
  54343. */
  54344. _this.environmentIntensity = 1.0;
  54345. /**
  54346. * This is a special control allowing the reduction of the specular highlights coming from the
  54347. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54348. */
  54349. _this.specularIntensity = 1.0;
  54350. /**
  54351. * Debug Control allowing disabling the bump map on this material.
  54352. */
  54353. _this.disableBumpMap = false;
  54354. /**
  54355. * AKA Occlusion Texture Intensity in other nomenclature.
  54356. */
  54357. _this.ambientTextureStrength = 1.0;
  54358. /**
  54359. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54360. * 1 means it completely occludes it
  54361. * 0 mean it has no impact
  54362. */
  54363. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  54364. /**
  54365. * The color of a material in ambient lighting.
  54366. */
  54367. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  54368. /**
  54369. * AKA Diffuse Color in other nomenclature.
  54370. */
  54371. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  54372. /**
  54373. * AKA Specular Color in other nomenclature.
  54374. */
  54375. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  54376. /**
  54377. * The color reflected from the material.
  54378. */
  54379. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  54380. /**
  54381. * The color emitted from the material.
  54382. */
  54383. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  54384. /**
  54385. * AKA Glossiness in other nomenclature.
  54386. */
  54387. _this.microSurface = 1.0;
  54388. /**
  54389. * If true, the light map contains occlusion information instead of lighting info.
  54390. */
  54391. _this.useLightmapAsShadowmap = false;
  54392. /**
  54393. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54394. */
  54395. _this.useAlphaFromAlbedoTexture = false;
  54396. /**
  54397. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54398. */
  54399. _this.forceAlphaTest = false;
  54400. /**
  54401. * Defines the alpha limits in alpha test mode.
  54402. */
  54403. _this.alphaCutOff = 0.4;
  54404. /**
  54405. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54406. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54407. */
  54408. _this.useSpecularOverAlpha = true;
  54409. /**
  54410. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54411. */
  54412. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  54413. /**
  54414. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54415. */
  54416. _this.useRoughnessFromMetallicTextureAlpha = true;
  54417. /**
  54418. * Specifies if the metallic texture contains the roughness information in its green channel.
  54419. */
  54420. _this.useRoughnessFromMetallicTextureGreen = false;
  54421. /**
  54422. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54423. */
  54424. _this.useMetallnessFromMetallicTextureBlue = false;
  54425. /**
  54426. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54427. */
  54428. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  54429. /**
  54430. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54431. */
  54432. _this.useAmbientInGrayScale = false;
  54433. /**
  54434. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54435. * The material will try to infer what glossiness each pixel should be.
  54436. */
  54437. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  54438. /**
  54439. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54440. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54441. */
  54442. _this.useRadianceOverAlpha = true;
  54443. /**
  54444. * Allows using an object space normal map (instead of tangent space).
  54445. */
  54446. _this.useObjectSpaceNormalMap = false;
  54447. /**
  54448. * Allows using the bump map in parallax mode.
  54449. */
  54450. _this.useParallax = false;
  54451. /**
  54452. * Allows using the bump map in parallax occlusion mode.
  54453. */
  54454. _this.useParallaxOcclusion = false;
  54455. /**
  54456. * Controls the scale bias of the parallax mode.
  54457. */
  54458. _this.parallaxScaleBias = 0.05;
  54459. /**
  54460. * If sets to true, disables all the lights affecting the material.
  54461. */
  54462. _this.disableLighting = false;
  54463. /**
  54464. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54465. */
  54466. _this.forceIrradianceInFragment = false;
  54467. /**
  54468. * Number of Simultaneous lights allowed on the material.
  54469. */
  54470. _this.maxSimultaneousLights = 4;
  54471. /**
  54472. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54473. */
  54474. _this.invertNormalMapX = false;
  54475. /**
  54476. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54477. */
  54478. _this.invertNormalMapY = false;
  54479. /**
  54480. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54481. */
  54482. _this.twoSidedLighting = false;
  54483. /**
  54484. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54485. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54486. */
  54487. _this.useAlphaFresnel = false;
  54488. /**
  54489. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54490. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54491. */
  54492. _this.useLinearAlphaFresnel = false;
  54493. /**
  54494. * Let user defines the brdf lookup texture used for IBL.
  54495. * A default 8bit version is embedded but you could point at :
  54496. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  54497. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54498. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54499. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54500. */
  54501. _this.environmentBRDFTexture = null;
  54502. /**
  54503. * Force normal to face away from face.
  54504. */
  54505. _this.forceNormalForward = false;
  54506. /**
  54507. * Enables specular anti aliasing in the PBR shader.
  54508. * It will both interacts on the Geometry for analytical and IBL lighting.
  54509. * It also prefilter the roughness map based on the bump values.
  54510. */
  54511. _this.enableSpecularAntiAliasing = false;
  54512. /**
  54513. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54514. * makes the reflect vector face the model (under horizon).
  54515. */
  54516. _this.useHorizonOcclusion = true;
  54517. /**
  54518. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54519. * too much the area relying on ambient texture to define their ambient occlusion.
  54520. */
  54521. _this.useRadianceOcclusion = true;
  54522. /**
  54523. * If set to true, no lighting calculations will be applied.
  54524. */
  54525. _this.unlit = false;
  54526. _this._environmentBRDFTexture = _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_2__["BRDFTextureTools"].GetEnvironmentBRDFTexture(scene);
  54527. return _this;
  54528. }
  54529. Object.defineProperty(PBRMaterial.prototype, "refractionTexture", {
  54530. /**
  54531. * Stores the refracted light information in a texture.
  54532. */
  54533. get: function () {
  54534. return this.subSurface.refractionTexture;
  54535. },
  54536. set: function (value) {
  54537. this.subSurface.refractionTexture = value;
  54538. if (value) {
  54539. this.subSurface.isRefractionEnabled = true;
  54540. }
  54541. else if (!this.subSurface.linkRefractionWithTransparency) {
  54542. this.subSurface.isRefractionEnabled = false;
  54543. }
  54544. },
  54545. enumerable: true,
  54546. configurable: true
  54547. });
  54548. Object.defineProperty(PBRMaterial.prototype, "indexOfRefraction", {
  54549. /**
  54550. * source material index of refraction (IOR)' / 'destination material IOR.
  54551. */
  54552. get: function () {
  54553. return 1 / this.subSurface.indexOfRefraction;
  54554. },
  54555. set: function (value) {
  54556. this.subSurface.indexOfRefraction = 1 / value;
  54557. },
  54558. enumerable: true,
  54559. configurable: true
  54560. });
  54561. Object.defineProperty(PBRMaterial.prototype, "invertRefractionY", {
  54562. /**
  54563. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54564. */
  54565. get: function () {
  54566. return this.subSurface.invertRefractionY;
  54567. },
  54568. set: function (value) {
  54569. this.subSurface.invertRefractionY = value;
  54570. },
  54571. enumerable: true,
  54572. configurable: true
  54573. });
  54574. Object.defineProperty(PBRMaterial.prototype, "linkRefractionWithTransparency", {
  54575. /**
  54576. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54577. * Materials half opaque for instance using refraction could benefit from this control.
  54578. */
  54579. get: function () {
  54580. return this.subSurface.linkRefractionWithTransparency;
  54581. },
  54582. set: function (value) {
  54583. this.subSurface.linkRefractionWithTransparency = value;
  54584. if (value) {
  54585. this.subSurface.isRefractionEnabled = true;
  54586. }
  54587. },
  54588. enumerable: true,
  54589. configurable: true
  54590. });
  54591. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  54592. /**
  54593. * BJS is using an harcoded light falloff based on a manually sets up range.
  54594. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54595. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54596. */
  54597. get: function () {
  54598. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  54599. },
  54600. /**
  54601. * BJS is using an harcoded light falloff based on a manually sets up range.
  54602. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54603. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54604. */
  54605. set: function (value) {
  54606. if (value !== this.usePhysicalLightFalloff) {
  54607. // Ensure the effect will be rebuilt.
  54608. this._markAllSubMeshesAsTexturesDirty();
  54609. if (value) {
  54610. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  54611. }
  54612. else {
  54613. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  54614. }
  54615. }
  54616. },
  54617. enumerable: true,
  54618. configurable: true
  54619. });
  54620. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  54621. /**
  54622. * In order to support the falloff compatibility with gltf, a special mode has been added
  54623. * to reproduce the gltf light falloff.
  54624. */
  54625. get: function () {
  54626. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  54627. },
  54628. /**
  54629. * In order to support the falloff compatibility with gltf, a special mode has been added
  54630. * to reproduce the gltf light falloff.
  54631. */
  54632. set: function (value) {
  54633. if (value !== this.useGLTFLightFalloff) {
  54634. // Ensure the effect will be rebuilt.
  54635. this._markAllSubMeshesAsTexturesDirty();
  54636. if (value) {
  54637. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  54638. }
  54639. else {
  54640. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  54641. }
  54642. }
  54643. },
  54644. enumerable: true,
  54645. configurable: true
  54646. });
  54647. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  54648. /**
  54649. * Gets the image processing configuration used either in this material.
  54650. */
  54651. get: function () {
  54652. return this._imageProcessingConfiguration;
  54653. },
  54654. /**
  54655. * Sets the Default image processing configuration used either in the this material.
  54656. *
  54657. * If sets to null, the scene one is in use.
  54658. */
  54659. set: function (value) {
  54660. this._attachImageProcessingConfiguration(value);
  54661. // Ensure the effect will be rebuilt.
  54662. this._markAllSubMeshesAsTexturesDirty();
  54663. },
  54664. enumerable: true,
  54665. configurable: true
  54666. });
  54667. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  54668. /**
  54669. * Gets wether the color curves effect is enabled.
  54670. */
  54671. get: function () {
  54672. return this.imageProcessingConfiguration.colorCurvesEnabled;
  54673. },
  54674. /**
  54675. * Sets wether the color curves effect is enabled.
  54676. */
  54677. set: function (value) {
  54678. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  54679. },
  54680. enumerable: true,
  54681. configurable: true
  54682. });
  54683. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  54684. /**
  54685. * Gets wether the color grading effect is enabled.
  54686. */
  54687. get: function () {
  54688. return this.imageProcessingConfiguration.colorGradingEnabled;
  54689. },
  54690. /**
  54691. * Gets wether the color grading effect is enabled.
  54692. */
  54693. set: function (value) {
  54694. this.imageProcessingConfiguration.colorGradingEnabled = value;
  54695. },
  54696. enumerable: true,
  54697. configurable: true
  54698. });
  54699. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  54700. /**
  54701. * Gets wether tonemapping is enabled or not.
  54702. */
  54703. get: function () {
  54704. return this._imageProcessingConfiguration.toneMappingEnabled;
  54705. },
  54706. /**
  54707. * Sets wether tonemapping is enabled or not
  54708. */
  54709. set: function (value) {
  54710. this._imageProcessingConfiguration.toneMappingEnabled = value;
  54711. },
  54712. enumerable: true,
  54713. configurable: true
  54714. });
  54715. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  54716. /**
  54717. * The camera exposure used on this material.
  54718. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54719. * This corresponds to a photographic exposure.
  54720. */
  54721. get: function () {
  54722. return this._imageProcessingConfiguration.exposure;
  54723. },
  54724. /**
  54725. * The camera exposure used on this material.
  54726. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54727. * This corresponds to a photographic exposure.
  54728. */
  54729. set: function (value) {
  54730. this._imageProcessingConfiguration.exposure = value;
  54731. },
  54732. enumerable: true,
  54733. configurable: true
  54734. });
  54735. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  54736. /**
  54737. * Gets The camera contrast used on this material.
  54738. */
  54739. get: function () {
  54740. return this._imageProcessingConfiguration.contrast;
  54741. },
  54742. /**
  54743. * Sets The camera contrast used on this material.
  54744. */
  54745. set: function (value) {
  54746. this._imageProcessingConfiguration.contrast = value;
  54747. },
  54748. enumerable: true,
  54749. configurable: true
  54750. });
  54751. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  54752. /**
  54753. * Gets the Color Grading 2D Lookup Texture.
  54754. */
  54755. get: function () {
  54756. return this._imageProcessingConfiguration.colorGradingTexture;
  54757. },
  54758. /**
  54759. * Sets the Color Grading 2D Lookup Texture.
  54760. */
  54761. set: function (value) {
  54762. this._imageProcessingConfiguration.colorGradingTexture = value;
  54763. },
  54764. enumerable: true,
  54765. configurable: true
  54766. });
  54767. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  54768. /**
  54769. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54770. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54771. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  54772. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54773. */
  54774. get: function () {
  54775. return this._imageProcessingConfiguration.colorCurves;
  54776. },
  54777. /**
  54778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54780. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  54781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54782. */
  54783. set: function (value) {
  54784. this._imageProcessingConfiguration.colorCurves = value;
  54785. },
  54786. enumerable: true,
  54787. configurable: true
  54788. });
  54789. /**
  54790. * Returns the name of this material class.
  54791. */
  54792. PBRMaterial.prototype.getClassName = function () {
  54793. return "PBRMaterial";
  54794. };
  54795. /**
  54796. * Makes a duplicate of the current material.
  54797. * @param name - name to use for the new material.
  54798. */
  54799. PBRMaterial.prototype.clone = function (name) {
  54800. var _this = this;
  54801. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  54802. clone.id = name;
  54803. clone.name = name;
  54804. this.clearCoat.copyTo(clone.clearCoat);
  54805. this.anisotropy.copyTo(clone.anisotropy);
  54806. this.brdf.copyTo(clone.brdf);
  54807. this.sheen.copyTo(clone.sheen);
  54808. return clone;
  54809. };
  54810. /**
  54811. * Serializes this PBR Material.
  54812. * @returns - An object with the serialized material.
  54813. */
  54814. PBRMaterial.prototype.serialize = function () {
  54815. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54816. serializationObject.customType = "BABYLON.PBRMaterial";
  54817. serializationObject.clearCoat = this.clearCoat.serialize();
  54818. serializationObject.anisotropy = this.anisotropy.serialize();
  54819. serializationObject.brdf = this.brdf.serialize();
  54820. serializationObject.sheen = this.sheen.serialize();
  54821. return serializationObject;
  54822. };
  54823. // Statics
  54824. /**
  54825. * Parses a PBR Material from a serialized object.
  54826. * @param source - Serialized object.
  54827. * @param scene - BJS scene instance.
  54828. * @param rootUrl - url for the scene object
  54829. * @returns - PBRMaterial
  54830. */
  54831. PBRMaterial.Parse = function (source, scene, rootUrl) {
  54832. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  54833. if (source.clearCoat) {
  54834. material.clearCoat.parse(source.clearCoat);
  54835. }
  54836. if (source.anisotropy) {
  54837. material.anisotropy.parse(source.anisotropy);
  54838. }
  54839. if (source.brdf) {
  54840. material.brdf.parse(source.brdf);
  54841. }
  54842. if (source.sheen) {
  54843. material.sheen.parse(source.brdf);
  54844. }
  54845. return material;
  54846. };
  54847. /**
  54848. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54849. */
  54850. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  54851. /**
  54852. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54853. */
  54854. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  54855. /**
  54856. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54857. */
  54858. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  54859. /**
  54860. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54861. * They are also discarded below the alpha cutoff threshold to improve performances.
  54862. */
  54863. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  54864. /**
  54865. * Defines the default value of how much AO map is occluding the analytical lights
  54866. * (point spot...).
  54867. */
  54868. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  54869. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54870. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54871. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54872. ], PBRMaterial.prototype, "directIntensity", void 0);
  54873. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54874. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54875. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54876. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  54877. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54878. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54879. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54880. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  54881. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54882. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54883. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54884. ], PBRMaterial.prototype, "specularIntensity", void 0);
  54885. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54886. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54888. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  54889. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54890. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54891. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54892. ], PBRMaterial.prototype, "albedoTexture", void 0);
  54893. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54894. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54895. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54896. ], PBRMaterial.prototype, "ambientTexture", void 0);
  54897. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54898. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54899. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54900. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  54901. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54902. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54903. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54904. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  54905. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54906. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54907. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54908. ], PBRMaterial.prototype, "opacityTexture", void 0);
  54909. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54910. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54911. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54912. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  54913. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54914. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54915. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54916. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  54917. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54918. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54920. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  54921. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54922. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54923. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54924. ], PBRMaterial.prototype, "metallicTexture", void 0);
  54925. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54926. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54927. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54928. ], PBRMaterial.prototype, "metallic", void 0);
  54929. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54930. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54931. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54932. ], PBRMaterial.prototype, "roughness", void 0);
  54933. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54934. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54935. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54936. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  54937. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54938. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54939. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54940. ], PBRMaterial.prototype, "bumpTexture", void 0);
  54941. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54942. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54943. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  54944. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  54945. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54946. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  54947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54948. ], PBRMaterial.prototype, "ambientColor", void 0);
  54949. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  54951. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54952. ], PBRMaterial.prototype, "albedoColor", void 0);
  54953. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54954. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  54955. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54956. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  54957. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54958. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  54959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54960. ], PBRMaterial.prototype, "reflectionColor", void 0);
  54961. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  54963. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54964. ], PBRMaterial.prototype, "emissiveColor", void 0);
  54965. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54966. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54968. ], PBRMaterial.prototype, "microSurface", void 0);
  54969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54972. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  54973. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54975. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54976. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  54977. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54978. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54980. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  54981. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54983. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54984. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  54985. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54986. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54987. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54988. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  54989. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54990. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54992. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  54993. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54994. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54995. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54996. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  54997. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54998. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54999. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55000. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  55001. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55002. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55003. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55004. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  55005. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55006. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55007. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55008. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  55009. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55010. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55012. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  55013. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55014. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55015. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55016. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  55017. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55018. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55019. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  55020. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55021. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55022. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  55023. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55024. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55025. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55026. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  55027. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55028. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55029. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55030. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  55031. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55032. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55033. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55034. ], PBRMaterial.prototype, "useParallax", void 0);
  55035. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55038. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  55039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55041. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55042. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  55043. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55044. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  55046. ], PBRMaterial.prototype, "disableLighting", void 0);
  55047. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55050. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  55051. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55053. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  55054. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  55055. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55056. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55057. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55058. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  55059. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55060. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55061. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55062. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  55063. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55064. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55065. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55066. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  55067. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55068. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55069. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55070. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  55071. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55072. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55073. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55074. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  55075. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55076. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55077. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55078. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  55079. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55080. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55081. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55082. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  55083. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55084. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55085. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55086. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  55087. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55088. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55089. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55090. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  55091. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55092. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55093. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55094. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  55095. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55097. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  55098. ], PBRMaterial.prototype, "unlit", void 0);
  55099. return PBRMaterial;
  55100. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  55101. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  55102. /***/ }),
  55103. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  55104. /*!*******************************************************!*\
  55105. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  55106. \*******************************************************/
  55107. /*! exports provided: PBRMetallicRoughnessMaterial */
  55108. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55109. "use strict";
  55110. __webpack_require__.r(__webpack_exports__);
  55111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  55112. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55113. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55114. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  55115. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55116. /**
  55117. * The PBR material of BJS following the metal roughness convention.
  55118. *
  55119. * This fits to the PBR convention in the GLTF definition:
  55120. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55121. */
  55122. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  55123. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  55124. /**
  55125. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55126. *
  55127. * @param name The material name
  55128. * @param scene The scene the material will be use in.
  55129. */
  55130. function PBRMetallicRoughnessMaterial(name, scene) {
  55131. var _this = _super.call(this, name, scene) || this;
  55132. _this._useRoughnessFromMetallicTextureAlpha = false;
  55133. _this._useRoughnessFromMetallicTextureGreen = true;
  55134. _this._useMetallnessFromMetallicTextureBlue = true;
  55135. _this.metallic = 1.0;
  55136. _this.roughness = 1.0;
  55137. return _this;
  55138. }
  55139. /**
  55140. * Return the currrent class name of the material.
  55141. */
  55142. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  55143. return "PBRMetallicRoughnessMaterial";
  55144. };
  55145. /**
  55146. * Makes a duplicate of the current material.
  55147. * @param name - name to use for the new material.
  55148. */
  55149. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  55150. var _this = this;
  55151. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  55152. clone.id = name;
  55153. clone.name = name;
  55154. this.clearCoat.copyTo(clone.clearCoat);
  55155. this.anisotropy.copyTo(clone.anisotropy);
  55156. this.brdf.copyTo(clone.brdf);
  55157. this.sheen.copyTo(clone.sheen);
  55158. return clone;
  55159. };
  55160. /**
  55161. * Serialize the material to a parsable JSON object.
  55162. */
  55163. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  55164. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55165. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  55166. serializationObject.clearCoat = this.clearCoat.serialize();
  55167. serializationObject.anisotropy = this.anisotropy.serialize();
  55168. serializationObject.brdf = this.brdf.serialize();
  55169. serializationObject.sheen = this.sheen.serialize();
  55170. return serializationObject;
  55171. };
  55172. /**
  55173. * Parses a JSON object correponding to the serialize function.
  55174. */
  55175. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  55176. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  55177. if (source.clearCoat) {
  55178. material.clearCoat.parse(source.clearCoat);
  55179. }
  55180. if (source.anisotropy) {
  55181. material.anisotropy.parse(source.anisotropy);
  55182. }
  55183. if (source.brdf) {
  55184. material.brdf.parse(source.brdf);
  55185. }
  55186. if (source.sheen) {
  55187. material.sheen.parse(source.brdf);
  55188. }
  55189. return material;
  55190. };
  55191. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55192. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  55193. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  55194. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  55195. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55196. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55197. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  55198. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  55199. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55200. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55201. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55202. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  55203. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55204. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55205. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55206. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  55207. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55208. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55209. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  55210. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  55211. return PBRMetallicRoughnessMaterial;
  55212. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  55213. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  55214. /***/ }),
  55215. /***/ "./Materials/PBR/pbrSheenConfiguration.ts":
  55216. /*!************************************************!*\
  55217. !*** ./Materials/PBR/pbrSheenConfiguration.ts ***!
  55218. \************************************************/
  55219. /*! exports provided: PBRSheenConfiguration */
  55220. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55221. "use strict";
  55222. __webpack_require__.r(__webpack_exports__);
  55223. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSheenConfiguration", function() { return PBRSheenConfiguration; });
  55224. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55225. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55226. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55227. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  55228. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  55229. /**
  55230. * Define the code related to the Sheen parameters of the pbr material.
  55231. */
  55232. var PBRSheenConfiguration = /** @class */ (function () {
  55233. /**
  55234. * Instantiate a new istance of clear coat configuration.
  55235. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55236. */
  55237. function PBRSheenConfiguration(markAllSubMeshesAsTexturesDirty) {
  55238. this._isEnabled = false;
  55239. /**
  55240. * Defines if the material uses sheen.
  55241. */
  55242. this.isEnabled = false;
  55243. this._linkSheenWithAlbedo = false;
  55244. /**
  55245. * Defines if the sheen is linked to the sheen color.
  55246. */
  55247. this.linkSheenWithAlbedo = false;
  55248. /**
  55249. * Defines the sheen intensity.
  55250. */
  55251. this.intensity = 1;
  55252. /**
  55253. * Defines the sheen color.
  55254. */
  55255. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  55256. this._texture = null;
  55257. /**
  55258. * Stores the sheen tint values in a texture.
  55259. * rgb is tint
  55260. * a is a intensity
  55261. */
  55262. this.texture = null;
  55263. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  55264. }
  55265. /** @hidden */
  55266. PBRSheenConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  55267. this._internalMarkAllSubMeshesAsTexturesDirty();
  55268. };
  55269. /**
  55270. * Specifies that the submesh is ready to be used.
  55271. * @param defines the list of "defines" to update.
  55272. * @param scene defines the scene the material belongs to.
  55273. * @returns - boolean indicating that the submesh is ready or not.
  55274. */
  55275. PBRSheenConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  55276. if (defines._areTexturesDirty) {
  55277. if (scene.texturesEnabled) {
  55278. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55279. if (!this._texture.isReadyOrNotBlocking()) {
  55280. return false;
  55281. }
  55282. }
  55283. }
  55284. }
  55285. return true;
  55286. };
  55287. /**
  55288. * Checks to see if a texture is used in the material.
  55289. * @param defines the list of "defines" to update.
  55290. * @param scene defines the scene the material belongs to.
  55291. */
  55292. PBRSheenConfiguration.prototype.prepareDefines = function (defines, scene) {
  55293. if (this._isEnabled) {
  55294. defines.SHEEN = this._isEnabled;
  55295. defines.SHEEN_LINKWITHALBEDO = this._linkSheenWithAlbedo;
  55296. if (defines._areTexturesDirty) {
  55297. if (scene.texturesEnabled) {
  55298. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55299. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "SHEEN_TEXTURE");
  55300. }
  55301. else {
  55302. defines.SHEEN_TEXTURE = false;
  55303. }
  55304. }
  55305. }
  55306. }
  55307. else {
  55308. defines.SHEEN = false;
  55309. defines.SHEEN_TEXTURE = false;
  55310. defines.SHEEN_LINKWITHALBEDO = false;
  55311. }
  55312. };
  55313. /**
  55314. * Binds the material data.
  55315. * @param uniformBuffer defines the Uniform buffer to fill in.
  55316. * @param scene defines the scene the material belongs to.
  55317. * @param isFrozen defines wether the material is frozen or not.
  55318. */
  55319. PBRSheenConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  55320. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  55321. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55322. uniformBuffer.updateFloat2("vSheenInfos", this._texture.coordinatesIndex, this._texture.level);
  55323. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "sheen");
  55324. }
  55325. // Sheen
  55326. uniformBuffer.updateFloat4("vSheenColor", this.color.r, this.color.g, this.color.b, this.intensity);
  55327. }
  55328. // Textures
  55329. if (scene.texturesEnabled) {
  55330. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55331. uniformBuffer.setTexture("sheenSampler", this._texture);
  55332. }
  55333. }
  55334. };
  55335. /**
  55336. * Checks to see if a texture is used in the material.
  55337. * @param texture - Base texture to use.
  55338. * @returns - Boolean specifying if a texture is used in the material.
  55339. */
  55340. PBRSheenConfiguration.prototype.hasTexture = function (texture) {
  55341. if (this._texture === texture) {
  55342. return true;
  55343. }
  55344. return false;
  55345. };
  55346. /**
  55347. * Returns an array of the actively used textures.
  55348. * @param activeTextures Array of BaseTextures
  55349. */
  55350. PBRSheenConfiguration.prototype.getActiveTextures = function (activeTextures) {
  55351. if (this._texture) {
  55352. activeTextures.push(this._texture);
  55353. }
  55354. };
  55355. /**
  55356. * Returns the animatable textures.
  55357. * @param animatables Array of animatable textures.
  55358. */
  55359. PBRSheenConfiguration.prototype.getAnimatables = function (animatables) {
  55360. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  55361. animatables.push(this._texture);
  55362. }
  55363. };
  55364. /**
  55365. * Disposes the resources of the material.
  55366. * @param forceDisposeTextures - Forces the disposal of all textures.
  55367. */
  55368. PBRSheenConfiguration.prototype.dispose = function (forceDisposeTextures) {
  55369. if (forceDisposeTextures) {
  55370. if (this._texture) {
  55371. this._texture.dispose();
  55372. }
  55373. }
  55374. };
  55375. /**
  55376. * Get the current class name of the texture useful for serialization or dynamic coding.
  55377. * @returns "PBRSheenConfiguration"
  55378. */
  55379. PBRSheenConfiguration.prototype.getClassName = function () {
  55380. return "PBRSheenConfiguration";
  55381. };
  55382. /**
  55383. * Add fallbacks to the effect fallbacks list.
  55384. * @param defines defines the Base texture to use.
  55385. * @param fallbacks defines the current fallback list.
  55386. * @param currentRank defines the current fallback rank.
  55387. * @returns the new fallback rank.
  55388. */
  55389. PBRSheenConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  55390. if (defines.SHEEN) {
  55391. fallbacks.addFallback(currentRank++, "SHEEN");
  55392. }
  55393. return currentRank;
  55394. };
  55395. /**
  55396. * Add the required uniforms to the current list.
  55397. * @param uniforms defines the current uniform list.
  55398. */
  55399. PBRSheenConfiguration.AddUniforms = function (uniforms) {
  55400. uniforms.push("vSheenColor", "vSheenInfos", "sheenMatrix");
  55401. };
  55402. /**
  55403. * Add the required uniforms to the current buffer.
  55404. * @param uniformBuffer defines the current uniform buffer.
  55405. */
  55406. PBRSheenConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  55407. uniformBuffer.addUniform("vSheenColor", 4);
  55408. uniformBuffer.addUniform("vSheenInfos", 2);
  55409. uniformBuffer.addUniform("sheenMatrix", 16);
  55410. };
  55411. /**
  55412. * Add the required samplers to the current list.
  55413. * @param samplers defines the current sampler list.
  55414. */
  55415. PBRSheenConfiguration.AddSamplers = function (samplers) {
  55416. samplers.push("sheenSampler");
  55417. };
  55418. /**
  55419. * Makes a duplicate of the current configuration into another one.
  55420. * @param sheenConfiguration define the config where to copy the info
  55421. */
  55422. PBRSheenConfiguration.prototype.copyTo = function (sheenConfiguration) {
  55423. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return sheenConfiguration; }, this);
  55424. };
  55425. /**
  55426. * Serializes this BRDF configuration.
  55427. * @returns - An object with the serialized config.
  55428. */
  55429. PBRSheenConfiguration.prototype.serialize = function () {
  55430. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55431. };
  55432. /**
  55433. * Parses a Sheen Configuration from a serialized object.
  55434. * @param source - Serialized object.
  55435. */
  55436. PBRSheenConfiguration.prototype.parse = function (source) {
  55437. var _this = this;
  55438. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  55439. };
  55440. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55441. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55442. ], PBRSheenConfiguration.prototype, "_isEnabled", void 0);
  55443. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55444. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55445. ], PBRSheenConfiguration.prototype, "isEnabled", void 0);
  55446. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55447. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55448. ], PBRSheenConfiguration.prototype, "_linkSheenWithAlbedo", void 0);
  55449. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55450. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55451. ], PBRSheenConfiguration.prototype, "linkSheenWithAlbedo", void 0);
  55452. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55453. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55454. ], PBRSheenConfiguration.prototype, "intensity", void 0);
  55455. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55456. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  55457. ], PBRSheenConfiguration.prototype, "color", void 0);
  55458. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55459. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  55460. ], PBRSheenConfiguration.prototype, "_texture", void 0);
  55461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55463. ], PBRSheenConfiguration.prototype, "texture", void 0);
  55464. return PBRSheenConfiguration;
  55465. }());
  55466. /***/ }),
  55467. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  55468. /*!********************************************************!*\
  55469. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  55470. \********************************************************/
  55471. /*! exports provided: PBRSpecularGlossinessMaterial */
  55472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55473. "use strict";
  55474. __webpack_require__.r(__webpack_exports__);
  55475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  55476. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55477. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55478. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  55479. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55480. /**
  55481. * The PBR material of BJS following the specular glossiness convention.
  55482. *
  55483. * This fits to the PBR convention in the GLTF definition:
  55484. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55485. */
  55486. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  55487. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  55488. /**
  55489. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55490. *
  55491. * @param name The material name
  55492. * @param scene The scene the material will be use in.
  55493. */
  55494. function PBRSpecularGlossinessMaterial(name, scene) {
  55495. var _this = _super.call(this, name, scene) || this;
  55496. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  55497. return _this;
  55498. }
  55499. /**
  55500. * Return the currrent class name of the material.
  55501. */
  55502. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  55503. return "PBRSpecularGlossinessMaterial";
  55504. };
  55505. /**
  55506. * Makes a duplicate of the current material.
  55507. * @param name - name to use for the new material.
  55508. */
  55509. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  55510. var _this = this;
  55511. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  55512. clone.id = name;
  55513. clone.name = name;
  55514. this.clearCoat.copyTo(clone.clearCoat);
  55515. this.anisotropy.copyTo(clone.anisotropy);
  55516. this.brdf.copyTo(clone.brdf);
  55517. this.sheen.copyTo(clone.sheen);
  55518. return clone;
  55519. };
  55520. /**
  55521. * Serialize the material to a parsable JSON object.
  55522. */
  55523. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  55524. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55525. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  55526. serializationObject.clearCoat = this.clearCoat.serialize();
  55527. serializationObject.anisotropy = this.anisotropy.serialize();
  55528. serializationObject.brdf = this.brdf.serialize();
  55529. serializationObject.sheen = this.sheen.serialize();
  55530. return serializationObject;
  55531. };
  55532. /**
  55533. * Parses a JSON object correponding to the serialize function.
  55534. */
  55535. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  55536. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  55537. if (source.clearCoat) {
  55538. material.clearCoat.parse(source.clearCoat);
  55539. }
  55540. if (source.anisotropy) {
  55541. material.anisotropy.parse(source.anisotropy);
  55542. }
  55543. if (source.brdf) {
  55544. material.brdf.parse(source.brdf);
  55545. }
  55546. if (source.sheen) {
  55547. material.sheen.parse(source.brdf);
  55548. }
  55549. return material;
  55550. };
  55551. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55552. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  55553. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  55554. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  55555. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55556. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55557. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  55558. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  55559. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55560. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  55561. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  55562. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  55563. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55564. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55565. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  55566. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  55567. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55568. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55569. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  55570. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  55571. return PBRSpecularGlossinessMaterial;
  55572. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  55573. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  55574. /***/ }),
  55575. /***/ "./Materials/PBR/pbrSubSurfaceConfiguration.ts":
  55576. /*!*****************************************************!*\
  55577. !*** ./Materials/PBR/pbrSubSurfaceConfiguration.ts ***!
  55578. \*****************************************************/
  55579. /*! exports provided: PBRSubSurfaceConfiguration */
  55580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55581. "use strict";
  55582. __webpack_require__.r(__webpack_exports__);
  55583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSubSurfaceConfiguration", function() { return PBRSubSurfaceConfiguration; });
  55584. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55585. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55586. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55587. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  55588. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  55589. /**
  55590. * Define the code related to the sub surface parameters of the pbr material.
  55591. */
  55592. var PBRSubSurfaceConfiguration = /** @class */ (function () {
  55593. /**
  55594. * Instantiate a new istance of sub surface configuration.
  55595. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55596. */
  55597. function PBRSubSurfaceConfiguration(markAllSubMeshesAsTexturesDirty) {
  55598. this._isRefractionEnabled = false;
  55599. /**
  55600. * Defines if the refraction is enabled in the material.
  55601. */
  55602. this.isRefractionEnabled = false;
  55603. this._isTranslucencyEnabled = false;
  55604. /**
  55605. * Defines if the translucency is enabled in the material.
  55606. */
  55607. this.isTranslucencyEnabled = false;
  55608. this._isScatteringEnabled = false;
  55609. // /**
  55610. // * Defines if the sub surface scattering is enabled in the material.
  55611. // */
  55612. // @expandToProperty("_markAllSubMeshesAsTexturesDirty")
  55613. // public isScatteringEnabled = false;
  55614. /**
  55615. * Defines the refraction intensity of the material.
  55616. * The refraction when enabled replaces the Diffuse part of the material.
  55617. * The intensity helps transitionning between diffuse and refraction.
  55618. */
  55619. this.refractionIntensity = 1;
  55620. /**
  55621. * Defines the translucency intensity of the material.
  55622. * When translucency has been enabled, this defines how much of the "translucency"
  55623. * is addded to the diffuse part of the material.
  55624. */
  55625. this.translucencyIntensity = 1;
  55626. /**
  55627. * Defines the scattering intensity of the material.
  55628. * When scattering has been enabled, this defines how much of the "scattered light"
  55629. * is addded to the diffuse part of the material.
  55630. */
  55631. this.scatteringIntensity = 1;
  55632. this._thicknessTexture = null;
  55633. /**
  55634. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55635. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55636. * 0 would mean minimumThickness
  55637. * 1 would mean maximumThickness
  55638. * The other channels might be use as a mask to vary the different effects intensity.
  55639. */
  55640. this.thicknessTexture = null;
  55641. this._refractionTexture = null;
  55642. /**
  55643. * Defines the texture to use for refraction.
  55644. */
  55645. this.refractionTexture = null;
  55646. this._indexOfRefraction = 1;
  55647. /**
  55648. * Defines the indice of refraction used in the material.
  55649. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55650. */
  55651. this.indexOfRefraction = 1;
  55652. this._invertRefractionY = false;
  55653. /**
  55654. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55655. */
  55656. this.invertRefractionY = false;
  55657. this._linkRefractionWithTransparency = false;
  55658. /**
  55659. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55660. * Materials half opaque for instance using refraction could benefit from this control.
  55661. */
  55662. this.linkRefractionWithTransparency = false;
  55663. /**
  55664. * Defines the minimum thickness stored in the thickness map.
  55665. * If no thickness map is defined, this value will be used to simulate thickness.
  55666. */
  55667. this.minimumThickness = 0;
  55668. /**
  55669. * Defines the maximum thickness stored in the thickness map.
  55670. */
  55671. this.maximumThickness = 1;
  55672. /**
  55673. * Defines the volume tint of the material.
  55674. * This is used for both translucency and scattering.
  55675. */
  55676. this.tintColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  55677. /**
  55678. * Defines the distance at which the tint color should be found in the media.
  55679. * This is used for refraction only.
  55680. */
  55681. this.tintColorAtDistance = 1;
  55682. /**
  55683. * Defines how far each channel transmit through the media.
  55684. * It is defined as a color to simplify it selection.
  55685. */
  55686. this.diffusionDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  55687. this._useMaskFromThicknessTexture = false;
  55688. /**
  55689. * Stores the intensity of the different subsurface effects in the thickness texture.
  55690. * * the green channel is the translucency intensity.
  55691. * * the blue channel is the scattering intensity.
  55692. * * the alpha channel is the refraction intensity.
  55693. */
  55694. this.useMaskFromThicknessTexture = false;
  55695. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  55696. }
  55697. /** @hidden */
  55698. PBRSubSurfaceConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  55699. this._internalMarkAllSubMeshesAsTexturesDirty();
  55700. };
  55701. /**
  55702. * Gets wehter the submesh is ready to be used or not.
  55703. * @param defines the list of "defines" to update.
  55704. * @param scene defines the scene the material belongs to.
  55705. * @returns - boolean indicating that the submesh is ready or not.
  55706. */
  55707. PBRSubSurfaceConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  55708. if (defines._areTexturesDirty) {
  55709. if (scene.texturesEnabled) {
  55710. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  55711. if (!this._thicknessTexture.isReadyOrNotBlocking()) {
  55712. return false;
  55713. }
  55714. }
  55715. var refractionTexture = this._getRefractionTexture(scene);
  55716. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  55717. if (!refractionTexture.isReadyOrNotBlocking()) {
  55718. return false;
  55719. }
  55720. }
  55721. }
  55722. }
  55723. return true;
  55724. };
  55725. /**
  55726. * Checks to see if a texture is used in the material.
  55727. * @param defines the list of "defines" to update.
  55728. * @param scene defines the scene to the material belongs to.
  55729. */
  55730. PBRSubSurfaceConfiguration.prototype.prepareDefines = function (defines, scene) {
  55731. if (defines._areTexturesDirty) {
  55732. defines.SUBSURFACE = false;
  55733. defines.SS_TRANSLUCENCY = this._isTranslucencyEnabled;
  55734. defines.SS_SCATERRING = this._isScatteringEnabled;
  55735. defines.SS_THICKNESSANDMASK_TEXTURE = false;
  55736. defines.SS_MASK_FROM_THICKNESS_TEXTURE = false;
  55737. defines.SS_REFRACTION = false;
  55738. defines.SS_REFRACTIONMAP_3D = false;
  55739. defines.SS_GAMMAREFRACTION = false;
  55740. defines.SS_RGBDREFRACTION = false;
  55741. defines.SS_REFRACTIONMAP_OPPOSITEZ = false;
  55742. defines.SS_LODINREFRACTIONALPHA = false;
  55743. defines.SS_LINKREFRACTIONTOTRANSPARENCY = false;
  55744. if (this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) {
  55745. defines.SUBSURFACE = true;
  55746. if (defines._areTexturesDirty) {
  55747. if (scene.texturesEnabled) {
  55748. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  55749. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._thicknessTexture, defines, "SS_THICKNESSANDMASK_TEXTURE");
  55750. }
  55751. }
  55752. }
  55753. defines.SS_MASK_FROM_THICKNESS_TEXTURE = this._useMaskFromThicknessTexture;
  55754. }
  55755. if (this._isRefractionEnabled) {
  55756. if (scene.texturesEnabled) {
  55757. var refractionTexture = this._getRefractionTexture(scene);
  55758. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  55759. defines.SS_REFRACTION = true;
  55760. defines.SS_REFRACTIONMAP_3D = refractionTexture.isCube;
  55761. defines.SS_GAMMAREFRACTION = refractionTexture.gammaSpace;
  55762. defines.SS_RGBDREFRACTION = refractionTexture.isRGBD;
  55763. defines.SS_REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  55764. defines.SS_LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  55765. defines.SS_LINKREFRACTIONTOTRANSPARENCY = this._linkRefractionWithTransparency;
  55766. }
  55767. }
  55768. }
  55769. }
  55770. };
  55771. /**
  55772. * Binds the material data.
  55773. * @param uniformBuffer defines the Uniform buffer to fill in.
  55774. * @param scene defines the scene the material belongs to.
  55775. * @param engine defines the engine the material belongs to.
  55776. * @param isFrozen defines wether the material is frozen or not.
  55777. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  55778. */
  55779. PBRSubSurfaceConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, engine, isFrozen, lodBasedMicrosurface) {
  55780. var refractionTexture = this._getRefractionTexture(scene);
  55781. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  55782. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  55783. uniformBuffer.updateFloat2("vThicknessInfos", this._thicknessTexture.coordinatesIndex, this._thicknessTexture.level);
  55784. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._thicknessTexture, uniformBuffer, "thickness");
  55785. }
  55786. uniformBuffer.updateFloat2("vThicknessParam", this.minimumThickness, this.maximumThickness - this.minimumThickness);
  55787. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  55788. uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  55789. var depth = 1.0;
  55790. if (!refractionTexture.isCube) {
  55791. if (refractionTexture.depth) {
  55792. depth = refractionTexture.depth;
  55793. }
  55794. }
  55795. uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, 1 / this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  55796. uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  55797. }
  55798. uniformBuffer.updateColor3("vDiffusionDistance", this.diffusionDistance);
  55799. uniformBuffer.updateFloat4("vTintColor", this.tintColor.r, this.tintColor.g, this.tintColor.b, this.tintColorAtDistance);
  55800. uniformBuffer.updateFloat3("vSubSurfaceIntensity", this.refractionIntensity, this.translucencyIntensity, this.scatteringIntensity);
  55801. }
  55802. // Textures
  55803. if (scene.texturesEnabled) {
  55804. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  55805. uniformBuffer.setTexture("thicknessSampler", this._thicknessTexture);
  55806. }
  55807. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  55808. if (lodBasedMicrosurface) {
  55809. uniformBuffer.setTexture("refractionSampler", refractionTexture);
  55810. }
  55811. else {
  55812. uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  55813. uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  55814. uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  55815. }
  55816. }
  55817. }
  55818. };
  55819. /**
  55820. * Unbinds the material from the mesh.
  55821. * @param activeEffect defines the effect that should be unbound from.
  55822. * @returns true if unbound, otherwise false
  55823. */
  55824. PBRSubSurfaceConfiguration.prototype.unbind = function (activeEffect) {
  55825. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  55826. activeEffect.setTexture("refractionSampler", null);
  55827. return true;
  55828. }
  55829. return false;
  55830. };
  55831. /**
  55832. * Returns the texture used for refraction or null if none is used.
  55833. * @param scene defines the scene the material belongs to.
  55834. * @returns - Refraction texture if present. If no refraction texture and refraction
  55835. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55836. */
  55837. PBRSubSurfaceConfiguration.prototype._getRefractionTexture = function (scene) {
  55838. if (this._refractionTexture) {
  55839. return this._refractionTexture;
  55840. }
  55841. if (this._isRefractionEnabled) {
  55842. return scene.environmentTexture;
  55843. }
  55844. return null;
  55845. };
  55846. Object.defineProperty(PBRSubSurfaceConfiguration.prototype, "disableAlphaBlending", {
  55847. /**
  55848. * Returns true if alpha blending should be disabled.
  55849. */
  55850. get: function () {
  55851. return this.isRefractionEnabled && this._linkRefractionWithTransparency;
  55852. },
  55853. enumerable: true,
  55854. configurable: true
  55855. });
  55856. /**
  55857. * Fills the list of render target textures.
  55858. * @param renderTargets the list of render targets to update
  55859. */
  55860. PBRSubSurfaceConfiguration.prototype.fillRenderTargetTextures = function (renderTargets) {
  55861. if (_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  55862. renderTargets.push(this._refractionTexture);
  55863. }
  55864. };
  55865. /**
  55866. * Checks to see if a texture is used in the material.
  55867. * @param texture - Base texture to use.
  55868. * @returns - Boolean specifying if a texture is used in the material.
  55869. */
  55870. PBRSubSurfaceConfiguration.prototype.hasTexture = function (texture) {
  55871. if (this._thicknessTexture === texture) {
  55872. return true;
  55873. }
  55874. if (this._refractionTexture === texture) {
  55875. return true;
  55876. }
  55877. return false;
  55878. };
  55879. /**
  55880. * Gets a boolean indicating that current material needs to register RTT
  55881. * @returns true if this uses a render target otherwise false.
  55882. */
  55883. PBRSubSurfaceConfiguration.prototype.hasRenderTargetTextures = function () {
  55884. if (_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  55885. return true;
  55886. }
  55887. return false;
  55888. };
  55889. /**
  55890. * Returns an array of the actively used textures.
  55891. * @param activeTextures Array of BaseTextures
  55892. */
  55893. PBRSubSurfaceConfiguration.prototype.getActiveTextures = function (activeTextures) {
  55894. if (this._thicknessTexture) {
  55895. activeTextures.push(this._thicknessTexture);
  55896. }
  55897. if (this._refractionTexture) {
  55898. activeTextures.push(this._refractionTexture);
  55899. }
  55900. };
  55901. /**
  55902. * Returns the animatable textures.
  55903. * @param animatables Array of animatable textures.
  55904. */
  55905. PBRSubSurfaceConfiguration.prototype.getAnimatables = function (animatables) {
  55906. if (this._thicknessTexture && this._thicknessTexture.animations && this._thicknessTexture.animations.length > 0) {
  55907. animatables.push(this._thicknessTexture);
  55908. }
  55909. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  55910. animatables.push(this._refractionTexture);
  55911. }
  55912. };
  55913. /**
  55914. * Disposes the resources of the material.
  55915. * @param forceDisposeTextures - Forces the disposal of all textures.
  55916. */
  55917. PBRSubSurfaceConfiguration.prototype.dispose = function (forceDisposeTextures) {
  55918. if (forceDisposeTextures) {
  55919. if (this._thicknessTexture) {
  55920. this._thicknessTexture.dispose();
  55921. }
  55922. if (this._refractionTexture) {
  55923. this._refractionTexture.dispose();
  55924. }
  55925. }
  55926. };
  55927. /**
  55928. * Get the current class name of the texture useful for serialization or dynamic coding.
  55929. * @returns "PBRSubSurfaceConfiguration"
  55930. */
  55931. PBRSubSurfaceConfiguration.prototype.getClassName = function () {
  55932. return "PBRSubSurfaceConfiguration";
  55933. };
  55934. /**
  55935. * Add fallbacks to the effect fallbacks list.
  55936. * @param defines defines the Base texture to use.
  55937. * @param fallbacks defines the current fallback list.
  55938. * @param currentRank defines the current fallback rank.
  55939. * @returns the new fallback rank.
  55940. */
  55941. PBRSubSurfaceConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  55942. if (defines.SS_SCATERRING) {
  55943. fallbacks.addFallback(currentRank++, "SS_SCATERRING");
  55944. }
  55945. if (defines.SS_TRANSLUCENCY) {
  55946. fallbacks.addFallback(currentRank++, "SS_TRANSLUCENCY");
  55947. }
  55948. return currentRank;
  55949. };
  55950. /**
  55951. * Add the required uniforms to the current list.
  55952. * @param uniforms defines the current uniform list.
  55953. */
  55954. PBRSubSurfaceConfiguration.AddUniforms = function (uniforms) {
  55955. uniforms.push("vDiffusionDistance", "vTintColor", "vSubSurfaceIntensity", "vRefractionMicrosurfaceInfos", "vRefractionInfos", "vThicknessInfos", "vThicknessParam", "refractionMatrix", "thicknessMatrix");
  55956. };
  55957. /**
  55958. * Add the required samplers to the current list.
  55959. * @param samplers defines the current sampler list.
  55960. */
  55961. PBRSubSurfaceConfiguration.AddSamplers = function (samplers) {
  55962. samplers.push("thicknessSampler", "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh");
  55963. };
  55964. /**
  55965. * Add the required uniforms to the current buffer.
  55966. * @param uniformBuffer defines the current uniform buffer.
  55967. */
  55968. PBRSubSurfaceConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  55969. uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  55970. uniformBuffer.addUniform("vRefractionInfos", 4);
  55971. uniformBuffer.addUniform("refractionMatrix", 16);
  55972. uniformBuffer.addUniform("vThicknessInfos", 2);
  55973. uniformBuffer.addUniform("thicknessMatrix", 16);
  55974. uniformBuffer.addUniform("vThicknessParam", 2);
  55975. uniformBuffer.addUniform("vDiffusionDistance", 3);
  55976. uniformBuffer.addUniform("vTintColor", 4);
  55977. uniformBuffer.addUniform("vSubSurfaceIntensity", 3);
  55978. };
  55979. /**
  55980. * Makes a duplicate of the current configuration into another one.
  55981. * @param configuration define the config where to copy the info
  55982. */
  55983. PBRSubSurfaceConfiguration.prototype.copyTo = function (configuration) {
  55984. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return configuration; }, this);
  55985. };
  55986. /**
  55987. * Serializes this Sub Surface configuration.
  55988. * @returns - An object with the serialized config.
  55989. */
  55990. PBRSubSurfaceConfiguration.prototype.serialize = function () {
  55991. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55992. };
  55993. /**
  55994. * Parses a Sub Surface Configuration from a serialized object.
  55995. * @param source - Serialized object.
  55996. */
  55997. PBRSubSurfaceConfiguration.prototype.parse = function (source) {
  55998. var _this = this;
  55999. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  56000. };
  56001. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56002. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56003. ], PBRSubSurfaceConfiguration.prototype, "_isRefractionEnabled", void 0);
  56004. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56005. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56006. ], PBRSubSurfaceConfiguration.prototype, "isRefractionEnabled", void 0);
  56007. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56008. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56009. ], PBRSubSurfaceConfiguration.prototype, "_isTranslucencyEnabled", void 0);
  56010. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56012. ], PBRSubSurfaceConfiguration.prototype, "isTranslucencyEnabled", void 0);
  56013. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56014. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56015. ], PBRSubSurfaceConfiguration.prototype, "_isScatteringEnabled", void 0);
  56016. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56017. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56018. ], PBRSubSurfaceConfiguration.prototype, "refractionIntensity", void 0);
  56019. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56020. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56021. ], PBRSubSurfaceConfiguration.prototype, "translucencyIntensity", void 0);
  56022. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56023. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56024. ], PBRSubSurfaceConfiguration.prototype, "scatteringIntensity", void 0);
  56025. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56026. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  56027. ], PBRSubSurfaceConfiguration.prototype, "_thicknessTexture", void 0);
  56028. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56029. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56030. ], PBRSubSurfaceConfiguration.prototype, "thicknessTexture", void 0);
  56031. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56032. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56033. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56034. ], PBRSubSurfaceConfiguration.prototype, "refractionTexture", void 0);
  56035. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56038. ], PBRSubSurfaceConfiguration.prototype, "indexOfRefraction", void 0);
  56039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56041. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56042. ], PBRSubSurfaceConfiguration.prototype, "invertRefractionY", void 0);
  56043. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56044. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56046. ], PBRSubSurfaceConfiguration.prototype, "linkRefractionWithTransparency", void 0);
  56047. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56049. ], PBRSubSurfaceConfiguration.prototype, "minimumThickness", void 0);
  56050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56052. ], PBRSubSurfaceConfiguration.prototype, "maximumThickness", void 0);
  56053. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56054. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  56055. ], PBRSubSurfaceConfiguration.prototype, "tintColor", void 0);
  56056. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56057. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56058. ], PBRSubSurfaceConfiguration.prototype, "tintColorAtDistance", void 0);
  56059. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56060. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  56061. ], PBRSubSurfaceConfiguration.prototype, "diffusionDistance", void 0);
  56062. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56063. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56064. ], PBRSubSurfaceConfiguration.prototype, "_useMaskFromThicknessTexture", void 0);
  56065. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56066. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56067. ], PBRSubSurfaceConfiguration.prototype, "useMaskFromThicknessTexture", void 0);
  56068. return PBRSubSurfaceConfiguration;
  56069. }());
  56070. /***/ }),
  56071. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  56072. /*!********************************************************!*\
  56073. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  56074. \********************************************************/
  56075. /*! exports provided: _DDSTextureLoader */
  56076. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56077. "use strict";
  56078. __webpack_require__.r(__webpack_exports__);
  56079. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  56080. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  56081. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  56082. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  56083. /**
  56084. * Implementation of the DDS Texture Loader.
  56085. * @hidden
  56086. */
  56087. var _DDSTextureLoader = /** @class */ (function () {
  56088. function _DDSTextureLoader() {
  56089. /**
  56090. * Defines wether the loader supports cascade loading the different faces.
  56091. */
  56092. this.supportCascades = true;
  56093. }
  56094. /**
  56095. * This returns if the loader support the current file information.
  56096. * @param extension defines the file extension of the file being loaded
  56097. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56098. * @param fallback defines the fallback internal texture if any
  56099. * @param isBase64 defines whether the texture is encoded as a base64
  56100. * @param isBuffer defines whether the texture data are stored as a buffer
  56101. * @returns true if the loader can load the specified file
  56102. */
  56103. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  56104. return extension.indexOf(".dds") === 0;
  56105. };
  56106. /**
  56107. * Transform the url before loading if required.
  56108. * @param rootUrl the url of the texture
  56109. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56110. * @returns the transformed texture
  56111. */
  56112. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  56113. return rootUrl;
  56114. };
  56115. /**
  56116. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56117. * @param rootUrl the url of the texture
  56118. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56119. * @returns the fallback texture
  56120. */
  56121. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  56122. return null;
  56123. };
  56124. /**
  56125. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56126. * @param data contains the texture data
  56127. * @param texture defines the BabylonJS internal texture
  56128. * @param createPolynomials will be true if polynomials have been requested
  56129. * @param onLoad defines the callback to trigger once the texture is ready
  56130. * @param onError defines the callback to trigger in case of error
  56131. */
  56132. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  56133. var engine = texture.getEngine();
  56134. var info;
  56135. var loadMipmap = false;
  56136. if (Array.isArray(imgs)) {
  56137. for (var index = 0; index < imgs.length; index++) {
  56138. var data_1 = imgs[index];
  56139. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  56140. texture.width = info.width;
  56141. texture.height = info.height;
  56142. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  56143. engine._unpackFlipY(info.isCompressed);
  56144. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  56145. if (!info.isFourCC && info.mipmapCount === 1) {
  56146. engine.generateMipMapsForCubemap(texture);
  56147. }
  56148. }
  56149. }
  56150. else {
  56151. var data = imgs;
  56152. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  56153. texture.width = info.width;
  56154. texture.height = info.height;
  56155. if (createPolynomials) {
  56156. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  56157. }
  56158. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  56159. engine._unpackFlipY(info.isCompressed);
  56160. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  56161. if (!info.isFourCC && info.mipmapCount === 1) {
  56162. engine.generateMipMapsForCubemap(texture);
  56163. }
  56164. }
  56165. engine._setCubeMapTextureParams(loadMipmap);
  56166. texture.isReady = true;
  56167. if (onLoad) {
  56168. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  56169. }
  56170. };
  56171. /**
  56172. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56173. * @param data contains the texture data
  56174. * @param texture defines the BabylonJS internal texture
  56175. * @param callback defines the method to call once ready to upload
  56176. */
  56177. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  56178. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  56179. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  56180. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  56181. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  56182. });
  56183. };
  56184. return _DDSTextureLoader;
  56185. }());
  56186. // Register the loader.
  56187. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  56188. /***/ }),
  56189. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  56190. /*!********************************************************!*\
  56191. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  56192. \********************************************************/
  56193. /*! exports provided: _ENVTextureLoader */
  56194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56195. "use strict";
  56196. __webpack_require__.r(__webpack_exports__);
  56197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  56198. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  56199. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  56200. /**
  56201. * Implementation of the ENV Texture Loader.
  56202. * @hidden
  56203. */
  56204. var _ENVTextureLoader = /** @class */ (function () {
  56205. function _ENVTextureLoader() {
  56206. /**
  56207. * Defines wether the loader supports cascade loading the different faces.
  56208. */
  56209. this.supportCascades = false;
  56210. }
  56211. /**
  56212. * This returns if the loader support the current file information.
  56213. * @param extension defines the file extension of the file being loaded
  56214. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56215. * @param fallback defines the fallback internal texture if any
  56216. * @param isBase64 defines whether the texture is encoded as a base64
  56217. * @param isBuffer defines whether the texture data are stored as a buffer
  56218. * @returns true if the loader can load the specified file
  56219. */
  56220. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  56221. return extension.indexOf(".env") === 0;
  56222. };
  56223. /**
  56224. * Transform the url before loading if required.
  56225. * @param rootUrl the url of the texture
  56226. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56227. * @returns the transformed texture
  56228. */
  56229. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  56230. return rootUrl;
  56231. };
  56232. /**
  56233. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56234. * @param rootUrl the url of the texture
  56235. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56236. * @returns the fallback texture
  56237. */
  56238. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  56239. return null;
  56240. };
  56241. /**
  56242. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56243. * @param data contains the texture data
  56244. * @param texture defines the BabylonJS internal texture
  56245. * @param createPolynomials will be true if polynomials have been requested
  56246. * @param onLoad defines the callback to trigger once the texture is ready
  56247. * @param onError defines the callback to trigger in case of error
  56248. */
  56249. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  56250. if (Array.isArray(data)) {
  56251. return;
  56252. }
  56253. data = data;
  56254. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  56255. if (info) {
  56256. texture.width = info.width;
  56257. texture.height = info.width;
  56258. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  56259. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  56260. texture.isReady = true;
  56261. if (onLoad) {
  56262. onLoad();
  56263. }
  56264. });
  56265. }
  56266. else if (onError) {
  56267. onError("Can not parse the environment file", null);
  56268. }
  56269. };
  56270. /**
  56271. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56272. * @param data contains the texture data
  56273. * @param texture defines the BabylonJS internal texture
  56274. * @param callback defines the method to call once ready to upload
  56275. */
  56276. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  56277. throw ".env not supported in 2d.";
  56278. };
  56279. return _ENVTextureLoader;
  56280. }());
  56281. // Register the loader.
  56282. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  56283. /***/ }),
  56284. /***/ "./Materials/Textures/Loaders/index.ts":
  56285. /*!*********************************************!*\
  56286. !*** ./Materials/Textures/Loaders/index.ts ***!
  56287. \*********************************************/
  56288. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  56289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56290. "use strict";
  56291. __webpack_require__.r(__webpack_exports__);
  56292. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  56293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  56294. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  56295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  56296. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  56297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  56298. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  56299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  56300. /***/ }),
  56301. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  56302. /*!********************************************************!*\
  56303. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  56304. \********************************************************/
  56305. /*! exports provided: _KTXTextureLoader */
  56306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56307. "use strict";
  56308. __webpack_require__.r(__webpack_exports__);
  56309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  56310. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  56311. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  56312. /**
  56313. * Implementation of the KTX Texture Loader.
  56314. * @hidden
  56315. */
  56316. var _KTXTextureLoader = /** @class */ (function () {
  56317. function _KTXTextureLoader() {
  56318. /**
  56319. * Defines wether the loader supports cascade loading the different faces.
  56320. */
  56321. this.supportCascades = false;
  56322. }
  56323. /**
  56324. * This returns if the loader support the current file information.
  56325. * @param extension defines the file extension of the file being loaded
  56326. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56327. * @param fallback defines the fallback internal texture if any
  56328. * @param isBase64 defines whether the texture is encoded as a base64
  56329. * @param isBuffer defines whether the texture data are stored as a buffer
  56330. * @returns true if the loader can load the specified file
  56331. */
  56332. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  56333. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  56334. return true;
  56335. }
  56336. return false;
  56337. };
  56338. /**
  56339. * Transform the url before loading if required.
  56340. * @param rootUrl the url of the texture
  56341. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56342. * @returns the transformed texture
  56343. */
  56344. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  56345. var lastDot = rootUrl.lastIndexOf('.');
  56346. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  56347. // Already transformed
  56348. return rootUrl;
  56349. }
  56350. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  56351. };
  56352. /**
  56353. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56354. * @param rootUrl the url of the texture
  56355. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56356. * @returns the fallback texture
  56357. */
  56358. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  56359. // remove the format appended to the rootUrl in the original createCubeTexture call.
  56360. var exp = new RegExp("" + textureFormatInUse + "$");
  56361. return rootUrl.replace(exp, "");
  56362. };
  56363. /**
  56364. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56365. * @param data contains the texture data
  56366. * @param texture defines the BabylonJS internal texture
  56367. * @param createPolynomials will be true if polynomials have been requested
  56368. * @param onLoad defines the callback to trigger once the texture is ready
  56369. * @param onError defines the callback to trigger in case of error
  56370. */
  56371. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  56372. if (Array.isArray(data)) {
  56373. return;
  56374. }
  56375. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  56376. texture._invertVScale = !texture.invertY;
  56377. var engine = texture.getEngine();
  56378. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  56379. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  56380. engine._unpackFlipY(true);
  56381. ktx.uploadLevels(texture, texture.generateMipMaps);
  56382. texture.width = ktx.pixelWidth;
  56383. texture.height = ktx.pixelHeight;
  56384. engine._setCubeMapTextureParams(loadMipmap);
  56385. texture.isReady = true;
  56386. };
  56387. /**
  56388. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56389. * @param data contains the texture data
  56390. * @param texture defines the BabylonJS internal texture
  56391. * @param callback defines the method to call once ready to upload
  56392. */
  56393. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  56394. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  56395. texture._invertVScale = !texture.invertY;
  56396. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  56397. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  56398. ktx.uploadLevels(texture, texture.generateMipMaps);
  56399. }, ktx.isInvalid);
  56400. };
  56401. return _KTXTextureLoader;
  56402. }());
  56403. // Register the loader.
  56404. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  56405. /***/ }),
  56406. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  56407. /*!********************************************************!*\
  56408. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  56409. \********************************************************/
  56410. /*! exports provided: _TGATextureLoader */
  56411. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56412. "use strict";
  56413. __webpack_require__.r(__webpack_exports__);
  56414. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  56415. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  56416. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  56417. /**
  56418. * Implementation of the TGA Texture Loader.
  56419. * @hidden
  56420. */
  56421. var _TGATextureLoader = /** @class */ (function () {
  56422. function _TGATextureLoader() {
  56423. /**
  56424. * Defines wether the loader supports cascade loading the different faces.
  56425. */
  56426. this.supportCascades = false;
  56427. }
  56428. /**
  56429. * This returns if the loader support the current file information.
  56430. * @param extension defines the file extension of the file being loaded
  56431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56432. * @param fallback defines the fallback internal texture if any
  56433. * @param isBase64 defines whether the texture is encoded as a base64
  56434. * @param isBuffer defines whether the texture data are stored as a buffer
  56435. * @returns true if the loader can load the specified file
  56436. */
  56437. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  56438. return extension.indexOf(".tga") === 0;
  56439. };
  56440. /**
  56441. * Transform the url before loading if required.
  56442. * @param rootUrl the url of the texture
  56443. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56444. * @returns the transformed texture
  56445. */
  56446. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  56447. return rootUrl;
  56448. };
  56449. /**
  56450. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56451. * @param rootUrl the url of the texture
  56452. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56453. * @returns the fallback texture
  56454. */
  56455. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  56456. return null;
  56457. };
  56458. /**
  56459. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56460. * @param data contains the texture data
  56461. * @param texture defines the BabylonJS internal texture
  56462. * @param createPolynomials will be true if polynomials have been requested
  56463. * @param onLoad defines the callback to trigger once the texture is ready
  56464. * @param onError defines the callback to trigger in case of error
  56465. */
  56466. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  56467. throw ".env not supported in Cube.";
  56468. };
  56469. /**
  56470. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56471. * @param data contains the texture data
  56472. * @param texture defines the BabylonJS internal texture
  56473. * @param callback defines the method to call once ready to upload
  56474. */
  56475. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  56476. var uintData = new Uint8Array(data);
  56477. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  56478. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  56479. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  56480. });
  56481. };
  56482. return _TGATextureLoader;
  56483. }());
  56484. // Register the loader.
  56485. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  56486. /***/ }),
  56487. /***/ "./Materials/Textures/MultiviewRenderTarget.ts":
  56488. /*!*****************************************************!*\
  56489. !*** ./Materials/Textures/MultiviewRenderTarget.ts ***!
  56490. \*****************************************************/
  56491. /*! exports provided: MultiviewRenderTarget */
  56492. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56493. "use strict";
  56494. __webpack_require__.r(__webpack_exports__);
  56495. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiviewRenderTarget", function() { return MultiviewRenderTarget; });
  56496. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56497. /* harmony import */ var _Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56498. /* harmony import */ var _Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  56499. /**
  56500. * Renders to multiple views with a single draw call
  56501. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  56502. */
  56503. var MultiviewRenderTarget = /** @class */ (function (_super) {
  56504. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiviewRenderTarget, _super);
  56505. /**
  56506. * Creates a multiview render target
  56507. * @param scene scene used with the render target
  56508. * @param size the size of the render target (used for each view)
  56509. */
  56510. function MultiviewRenderTarget(scene, size) {
  56511. if (size === void 0) { size = 512; }
  56512. var _this = _super.call(this, "multiview rtt", size, scene, false, true, _Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"].DATASOURCE_UNKNOWN, false, undefined, false, false, true, undefined, true) || this;
  56513. var internalTexture = scene.getEngine().createMultiviewRenderTargetTexture(_this.getRenderWidth(), _this.getRenderHeight());
  56514. internalTexture.isMultiview = true;
  56515. _this._texture = internalTexture;
  56516. return _this;
  56517. }
  56518. /**
  56519. * @hidden
  56520. * @param faceIndex the face index, if its a cube texture
  56521. */
  56522. MultiviewRenderTarget.prototype._bindFrameBuffer = function (faceIndex) {
  56523. if (faceIndex === void 0) { faceIndex = 0; }
  56524. if (!this._texture) {
  56525. return;
  56526. }
  56527. this.getScene().getEngine().bindMultiviewFramebuffer(this._texture);
  56528. };
  56529. /**
  56530. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  56531. * @returns the view count
  56532. */
  56533. MultiviewRenderTarget.prototype.getViewCount = function () {
  56534. return 2;
  56535. };
  56536. return MultiviewRenderTarget;
  56537. }(_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__["RenderTargetTexture"]));
  56538. /***/ }),
  56539. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  56540. /*!*******************************************************************!*\
  56541. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  56542. \*******************************************************************/
  56543. /*! exports provided: CustomProceduralTexture */
  56544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56545. "use strict";
  56546. __webpack_require__.r(__webpack_exports__);
  56547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  56548. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56549. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  56550. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  56551. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56552. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  56553. /* harmony import */ var _Misc_webRequest__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Misc/webRequest */ "./Misc/webRequest.ts");
  56554. /**
  56555. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  56556. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56557. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56558. */
  56559. var CustomProceduralTexture = /** @class */ (function (_super) {
  56560. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  56561. /**
  56562. * Instantiates a new Custom Procedural Texture.
  56563. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  56564. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56565. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56566. * @param name Define the name of the texture
  56567. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56568. * @param size Define the size of the texture to create
  56569. * @param scene Define the scene the texture belongs to
  56570. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56571. * @param generateMipMaps Define if the texture should creates mip maps or not
  56572. */
  56573. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  56574. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  56575. _this._animate = true;
  56576. _this._time = 0;
  56577. _this._texturePath = texturePath;
  56578. //Try to load json
  56579. _this._loadJson(texturePath);
  56580. _this.refreshRate = 1;
  56581. return _this;
  56582. }
  56583. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  56584. var _this = this;
  56585. var noConfigFile = function () {
  56586. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  56587. try {
  56588. _this.setFragment(_this._texturePath);
  56589. }
  56590. catch (ex) {
  56591. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  56592. }
  56593. };
  56594. var configFileUrl = jsonUrl + "/config.json";
  56595. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_5__["WebRequest"]();
  56596. xhr.open("GET", configFileUrl);
  56597. xhr.addEventListener("load", function () {
  56598. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  56599. try {
  56600. _this._config = JSON.parse(xhr.response);
  56601. _this.updateShaderUniforms();
  56602. _this.updateTextures();
  56603. _this.setFragment(_this._texturePath + "/custom");
  56604. _this._animate = _this._config.animate;
  56605. _this.refreshRate = _this._config.refreshrate;
  56606. }
  56607. catch (ex) {
  56608. noConfigFile();
  56609. }
  56610. }
  56611. else {
  56612. noConfigFile();
  56613. }
  56614. }, false);
  56615. xhr.addEventListener("error", function () {
  56616. noConfigFile();
  56617. }, false);
  56618. try {
  56619. xhr.send();
  56620. }
  56621. catch (ex) {
  56622. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  56623. }
  56624. };
  56625. /**
  56626. * Is the texture ready to be used ? (rendered at least once)
  56627. * @returns true if ready, otherwise, false.
  56628. */
  56629. CustomProceduralTexture.prototype.isReady = function () {
  56630. if (!_super.prototype.isReady.call(this)) {
  56631. return false;
  56632. }
  56633. for (var name in this._textures) {
  56634. var texture = this._textures[name];
  56635. if (!texture.isReady()) {
  56636. return false;
  56637. }
  56638. }
  56639. return true;
  56640. };
  56641. /**
  56642. * Render the texture to its associated render target.
  56643. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56644. */
  56645. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  56646. var scene = this.getScene();
  56647. if (this._animate && scene) {
  56648. this._time += scene.getAnimationRatio() * 0.03;
  56649. this.updateShaderUniforms();
  56650. }
  56651. _super.prototype.render.call(this, useCameraPostProcess);
  56652. };
  56653. /**
  56654. * Update the list of dependant textures samplers in the shader.
  56655. */
  56656. CustomProceduralTexture.prototype.updateTextures = function () {
  56657. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  56658. this.setTexture(this._config.sampler2Ds[i].sample2Dname, new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"](this._texturePath + "/" + this._config.sampler2Ds[i].textureRelativeUrl, this.getScene()));
  56659. }
  56660. };
  56661. /**
  56662. * Update the uniform values of the procedural texture in the shader.
  56663. */
  56664. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  56665. if (this._config) {
  56666. for (var j = 0; j < this._config.uniforms.length; j++) {
  56667. var uniform = this._config.uniforms[j];
  56668. switch (uniform.type) {
  56669. case "float":
  56670. this.setFloat(uniform.name, uniform.value);
  56671. break;
  56672. case "color3":
  56673. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](uniform.r, uniform.g, uniform.b));
  56674. break;
  56675. case "color4":
  56676. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  56677. break;
  56678. case "vector2":
  56679. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](uniform.x, uniform.y));
  56680. break;
  56681. case "vector3":
  56682. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](uniform.x, uniform.y, uniform.z));
  56683. break;
  56684. }
  56685. }
  56686. }
  56687. this.setFloat("time", this._time);
  56688. };
  56689. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  56690. /**
  56691. * Define if the texture animates or not.
  56692. */
  56693. get: function () {
  56694. return this._animate;
  56695. },
  56696. set: function (value) {
  56697. this._animate = value;
  56698. },
  56699. enumerable: true,
  56700. configurable: true
  56701. });
  56702. return CustomProceduralTexture;
  56703. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_4__["ProceduralTexture"]));
  56704. /***/ }),
  56705. /***/ "./Materials/Textures/Procedurals/index.ts":
  56706. /*!*************************************************!*\
  56707. !*** ./Materials/Textures/Procedurals/index.ts ***!
  56708. \*************************************************/
  56709. /*! exports provided: ProceduralTexture, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  56710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56711. "use strict";
  56712. __webpack_require__.r(__webpack_exports__);
  56713. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  56714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  56715. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  56716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  56717. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  56718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  56719. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  56720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  56721. /***/ }),
  56722. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  56723. /*!******************************************************************!*\
  56724. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  56725. \******************************************************************/
  56726. /*! exports provided: NoiseProceduralTexture */
  56727. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56728. "use strict";
  56729. __webpack_require__.r(__webpack_exports__);
  56730. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  56731. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56732. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  56733. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  56734. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  56735. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  56736. /**
  56737. * Class used to generate noise procedural textures
  56738. */
  56739. var NoiseProceduralTexture = /** @class */ (function (_super) {
  56740. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  56741. /**
  56742. * Creates a new NoiseProceduralTexture
  56743. * @param name defines the name fo the texture
  56744. * @param size defines the size of the texture (default is 256)
  56745. * @param scene defines the hosting scene
  56746. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56747. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56748. */
  56749. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  56750. if (size === void 0) { size = 256; }
  56751. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  56752. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  56753. _this._time = 0;
  56754. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56755. _this.brightness = 0.2;
  56756. /** Defines the number of octaves to process */
  56757. _this.octaves = 3;
  56758. /** Defines the level of persistence (0.8 by default) */
  56759. _this.persistence = 0.8;
  56760. /** Gets or sets animation speed factor (default is 1) */
  56761. _this.animationSpeedFactor = 1;
  56762. _this.autoClear = false;
  56763. _this._updateShaderUniforms();
  56764. return _this;
  56765. }
  56766. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  56767. var scene = this.getScene();
  56768. if (!scene) {
  56769. return;
  56770. }
  56771. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  56772. this.setFloat("brightness", this.brightness);
  56773. this.setFloat("persistence", this.persistence);
  56774. this.setFloat("timeScale", this._time);
  56775. };
  56776. NoiseProceduralTexture.prototype._getDefines = function () {
  56777. return "#define OCTAVES " + (this.octaves | 0);
  56778. };
  56779. /** Generate the current state of the procedural texture */
  56780. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  56781. this._updateShaderUniforms();
  56782. _super.prototype.render.call(this, useCameraPostProcess);
  56783. };
  56784. /**
  56785. * Serializes this noise procedural texture
  56786. * @returns a serialized noise procedural texture object
  56787. */
  56788. NoiseProceduralTexture.prototype.serialize = function () {
  56789. var serializationObject = {};
  56790. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  56791. serializationObject.brightness = this.brightness;
  56792. serializationObject.octaves = this.octaves;
  56793. serializationObject.persistence = this.persistence;
  56794. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  56795. serializationObject.size = this.getSize().width;
  56796. serializationObject.generateMipMaps = this._generateMipMaps;
  56797. return serializationObject;
  56798. };
  56799. /**
  56800. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56801. * @param parsedTexture defines parsed texture data
  56802. * @param scene defines the current scene
  56803. * @param rootUrl defines the root URL containing noise procedural texture information
  56804. * @returns a parsed NoiseProceduralTexture
  56805. */
  56806. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  56807. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  56808. texture.brightness = parsedTexture.brightness;
  56809. texture.octaves = parsedTexture.octaves;
  56810. texture.persistence = parsedTexture.persistence;
  56811. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  56812. return texture;
  56813. };
  56814. return NoiseProceduralTexture;
  56815. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  56816. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  56817. /***/ }),
  56818. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  56819. /*!*************************************************************!*\
  56820. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  56821. \*************************************************************/
  56822. /*! exports provided: ProceduralTexture */
  56823. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56824. "use strict";
  56825. __webpack_require__.r(__webpack_exports__);
  56826. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  56827. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56828. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  56829. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  56830. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  56831. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  56832. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  56833. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56834. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56835. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  56836. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  56837. /**
  56838. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  56839. * This is the base class of any Procedural texture and contains most of the shareable code.
  56840. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  56841. */
  56842. var ProceduralTexture = /** @class */ (function (_super) {
  56843. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  56844. /**
  56845. * Instantiates a new procedural texture.
  56846. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  56847. * This is the base class of any Procedural texture and contains most of the shareable code.
  56848. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  56849. * @param name Define the name of the texture
  56850. * @param size Define the size of the texture to create
  56851. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  56852. * @param scene Define the scene the texture belongs to
  56853. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56854. * @param generateMipMaps Define if the texture should creates mip maps or not
  56855. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  56856. */
  56857. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  56858. if (fallbackTexture === void 0) { fallbackTexture = null; }
  56859. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56860. if (isCube === void 0) { isCube = false; }
  56861. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  56862. _this.isCube = isCube;
  56863. /**
  56864. * Define if the texture is enabled or not (disabled texture will not render)
  56865. */
  56866. _this.isEnabled = true;
  56867. /**
  56868. * Define if the texture must be cleared before rendering (default is true)
  56869. */
  56870. _this.autoClear = true;
  56871. /**
  56872. * Event raised when the texture is generated
  56873. */
  56874. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  56875. /** @hidden */
  56876. _this._textures = {};
  56877. _this._currentRefreshId = -1;
  56878. _this._refreshRate = 1;
  56879. _this._vertexBuffers = {};
  56880. _this._uniforms = new Array();
  56881. _this._samplers = new Array();
  56882. _this._floats = {};
  56883. _this._ints = {};
  56884. _this._floatsArrays = {};
  56885. _this._colors3 = {};
  56886. _this._colors4 = {};
  56887. _this._vectors2 = {};
  56888. _this._vectors3 = {};
  56889. _this._matrices = {};
  56890. _this._fallbackTextureUsed = false;
  56891. _this._cachedDefines = "";
  56892. _this._contentUpdateId = -1;
  56893. scene = _this.getScene();
  56894. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  56895. if (!component) {
  56896. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  56897. scene._addComponent(component);
  56898. }
  56899. scene.proceduralTextures.push(_this);
  56900. _this._engine = scene.getEngine();
  56901. _this.name = name;
  56902. _this.isRenderTarget = true;
  56903. _this._size = size;
  56904. _this._generateMipMaps = generateMipMaps;
  56905. _this.setFragment(fragment);
  56906. _this._fallbackTexture = fallbackTexture;
  56907. if (isCube) {
  56908. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  56909. _this.setFloat("face", 0);
  56910. }
  56911. else {
  56912. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  56913. }
  56914. // VBO
  56915. var vertices = [];
  56916. vertices.push(1, 1);
  56917. vertices.push(-1, 1);
  56918. vertices.push(-1, -1);
  56919. vertices.push(1, -1);
  56920. _this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](_this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  56921. _this._createIndexBuffer();
  56922. return _this;
  56923. }
  56924. /**
  56925. * The effect that is created when initializing the post process.
  56926. * @returns The created effect corrisponding the the postprocess.
  56927. */
  56928. ProceduralTexture.prototype.getEffect = function () {
  56929. return this._effect;
  56930. };
  56931. /**
  56932. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  56933. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  56934. */
  56935. ProceduralTexture.prototype.getContent = function () {
  56936. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  56937. return this._contentData;
  56938. }
  56939. this._contentData = this.readPixels(0, 0, this._contentData);
  56940. this._contentUpdateId = this._currentRefreshId;
  56941. return this._contentData;
  56942. };
  56943. ProceduralTexture.prototype._createIndexBuffer = function () {
  56944. var engine = this._engine;
  56945. // Indices
  56946. var indices = [];
  56947. indices.push(0);
  56948. indices.push(1);
  56949. indices.push(2);
  56950. indices.push(0);
  56951. indices.push(2);
  56952. indices.push(3);
  56953. this._indexBuffer = engine.createIndexBuffer(indices);
  56954. };
  56955. /** @hidden */
  56956. ProceduralTexture.prototype._rebuild = function () {
  56957. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  56958. if (vb) {
  56959. vb._rebuild();
  56960. }
  56961. this._createIndexBuffer();
  56962. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  56963. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  56964. }
  56965. };
  56966. /**
  56967. * Resets the texture in order to recreate its associated resources.
  56968. * This can be called in case of context loss
  56969. */
  56970. ProceduralTexture.prototype.reset = function () {
  56971. if (this._effect === undefined) {
  56972. return;
  56973. }
  56974. this._effect.dispose();
  56975. };
  56976. ProceduralTexture.prototype._getDefines = function () {
  56977. return "";
  56978. };
  56979. /**
  56980. * Is the texture ready to be used ? (rendered at least once)
  56981. * @returns true if ready, otherwise, false.
  56982. */
  56983. ProceduralTexture.prototype.isReady = function () {
  56984. var _this = this;
  56985. var engine = this._engine;
  56986. var shaders;
  56987. if (!this._fragment) {
  56988. return false;
  56989. }
  56990. if (this._fallbackTextureUsed) {
  56991. return true;
  56992. }
  56993. var defines = this._getDefines();
  56994. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  56995. return true;
  56996. }
  56997. if (this._fragment.fragmentElement !== undefined) {
  56998. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  56999. }
  57000. else {
  57001. shaders = { vertex: "procedural", fragment: this._fragment };
  57002. }
  57003. this._cachedDefines = defines;
  57004. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  57005. _this.releaseInternalTexture();
  57006. if (_this._fallbackTexture) {
  57007. _this._texture = _this._fallbackTexture._texture;
  57008. if (_this._texture) {
  57009. _this._texture.incrementReferences();
  57010. }
  57011. }
  57012. _this._fallbackTextureUsed = true;
  57013. });
  57014. return this._effect.isReady();
  57015. };
  57016. /**
  57017. * Resets the refresh counter of the texture and start bak from scratch.
  57018. * Could be useful to regenerate the texture if it is setup to render only once.
  57019. */
  57020. ProceduralTexture.prototype.resetRefreshCounter = function () {
  57021. this._currentRefreshId = -1;
  57022. };
  57023. /**
  57024. * Set the fragment shader to use in order to render the texture.
  57025. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  57026. */
  57027. ProceduralTexture.prototype.setFragment = function (fragment) {
  57028. this._fragment = fragment;
  57029. };
  57030. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  57031. /**
  57032. * Define the refresh rate of the texture or the rendering frequency.
  57033. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  57034. */
  57035. get: function () {
  57036. return this._refreshRate;
  57037. },
  57038. set: function (value) {
  57039. this._refreshRate = value;
  57040. this.resetRefreshCounter();
  57041. },
  57042. enumerable: true,
  57043. configurable: true
  57044. });
  57045. /** @hidden */
  57046. ProceduralTexture.prototype._shouldRender = function () {
  57047. if (!this.isEnabled || !this.isReady() || !this._texture) {
  57048. if (this._texture) {
  57049. this._texture.isReady = false;
  57050. }
  57051. return false;
  57052. }
  57053. if (this._fallbackTextureUsed) {
  57054. return false;
  57055. }
  57056. if (this._currentRefreshId === -1) { // At least render once
  57057. this._currentRefreshId = 1;
  57058. return true;
  57059. }
  57060. if (this.refreshRate === this._currentRefreshId) {
  57061. this._currentRefreshId = 1;
  57062. return true;
  57063. }
  57064. this._currentRefreshId++;
  57065. return false;
  57066. };
  57067. /**
  57068. * Get the size the texture is rendering at.
  57069. * @returns the size (texture is always squared)
  57070. */
  57071. ProceduralTexture.prototype.getRenderSize = function () {
  57072. return this._size;
  57073. };
  57074. /**
  57075. * Resize the texture to new value.
  57076. * @param size Define the new size the texture should have
  57077. * @param generateMipMaps Define whether the new texture should create mip maps
  57078. */
  57079. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  57080. if (this._fallbackTextureUsed) {
  57081. return;
  57082. }
  57083. this.releaseInternalTexture();
  57084. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  57085. // Update properties
  57086. this._size = size;
  57087. this._generateMipMaps = generateMipMaps;
  57088. };
  57089. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  57090. if (this._uniforms.indexOf(uniformName) === -1) {
  57091. this._uniforms.push(uniformName);
  57092. }
  57093. };
  57094. /**
  57095. * Set a texture in the shader program used to render.
  57096. * @param name Define the name of the uniform samplers as defined in the shader
  57097. * @param texture Define the texture to bind to this sampler
  57098. * @return the texture itself allowing "fluent" like uniform updates
  57099. */
  57100. ProceduralTexture.prototype.setTexture = function (name, texture) {
  57101. if (this._samplers.indexOf(name) === -1) {
  57102. this._samplers.push(name);
  57103. }
  57104. this._textures[name] = texture;
  57105. return this;
  57106. };
  57107. /**
  57108. * Set a float in the shader.
  57109. * @param name Define the name of the uniform as defined in the shader
  57110. * @param value Define the value to give to the uniform
  57111. * @return the texture itself allowing "fluent" like uniform updates
  57112. */
  57113. ProceduralTexture.prototype.setFloat = function (name, value) {
  57114. this._checkUniform(name);
  57115. this._floats[name] = value;
  57116. return this;
  57117. };
  57118. /**
  57119. * Set a int in the shader.
  57120. * @param name Define the name of the uniform as defined in the shader
  57121. * @param value Define the value to give to the uniform
  57122. * @return the texture itself allowing "fluent" like uniform updates
  57123. */
  57124. ProceduralTexture.prototype.setInt = function (name, value) {
  57125. this._checkUniform(name);
  57126. this._ints[name] = value;
  57127. return this;
  57128. };
  57129. /**
  57130. * Set an array of floats in the shader.
  57131. * @param name Define the name of the uniform as defined in the shader
  57132. * @param value Define the value to give to the uniform
  57133. * @return the texture itself allowing "fluent" like uniform updates
  57134. */
  57135. ProceduralTexture.prototype.setFloats = function (name, value) {
  57136. this._checkUniform(name);
  57137. this._floatsArrays[name] = value;
  57138. return this;
  57139. };
  57140. /**
  57141. * Set a vec3 in the shader from a Color3.
  57142. * @param name Define the name of the uniform as defined in the shader
  57143. * @param value Define the value to give to the uniform
  57144. * @return the texture itself allowing "fluent" like uniform updates
  57145. */
  57146. ProceduralTexture.prototype.setColor3 = function (name, value) {
  57147. this._checkUniform(name);
  57148. this._colors3[name] = value;
  57149. return this;
  57150. };
  57151. /**
  57152. * Set a vec4 in the shader from a Color4.
  57153. * @param name Define the name of the uniform as defined in the shader
  57154. * @param value Define the value to give to the uniform
  57155. * @return the texture itself allowing "fluent" like uniform updates
  57156. */
  57157. ProceduralTexture.prototype.setColor4 = function (name, value) {
  57158. this._checkUniform(name);
  57159. this._colors4[name] = value;
  57160. return this;
  57161. };
  57162. /**
  57163. * Set a vec2 in the shader from a Vector2.
  57164. * @param name Define the name of the uniform as defined in the shader
  57165. * @param value Define the value to give to the uniform
  57166. * @return the texture itself allowing "fluent" like uniform updates
  57167. */
  57168. ProceduralTexture.prototype.setVector2 = function (name, value) {
  57169. this._checkUniform(name);
  57170. this._vectors2[name] = value;
  57171. return this;
  57172. };
  57173. /**
  57174. * Set a vec3 in the shader from a Vector3.
  57175. * @param name Define the name of the uniform as defined in the shader
  57176. * @param value Define the value to give to the uniform
  57177. * @return the texture itself allowing "fluent" like uniform updates
  57178. */
  57179. ProceduralTexture.prototype.setVector3 = function (name, value) {
  57180. this._checkUniform(name);
  57181. this._vectors3[name] = value;
  57182. return this;
  57183. };
  57184. /**
  57185. * Set a mat4 in the shader from a MAtrix.
  57186. * @param name Define the name of the uniform as defined in the shader
  57187. * @param value Define the value to give to the uniform
  57188. * @return the texture itself allowing "fluent" like uniform updates
  57189. */
  57190. ProceduralTexture.prototype.setMatrix = function (name, value) {
  57191. this._checkUniform(name);
  57192. this._matrices[name] = value;
  57193. return this;
  57194. };
  57195. /**
  57196. * Render the texture to its associated render target.
  57197. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57198. */
  57199. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  57200. var scene = this.getScene();
  57201. if (!scene) {
  57202. return;
  57203. }
  57204. var engine = this._engine;
  57205. // Render
  57206. engine.enableEffect(this._effect);
  57207. engine.setState(false);
  57208. // Texture
  57209. for (var name in this._textures) {
  57210. this._effect.setTexture(name, this._textures[name]);
  57211. }
  57212. // Float
  57213. for (name in this._ints) {
  57214. this._effect.setInt(name, this._ints[name]);
  57215. }
  57216. // Float
  57217. for (name in this._floats) {
  57218. this._effect.setFloat(name, this._floats[name]);
  57219. }
  57220. // Floats
  57221. for (name in this._floatsArrays) {
  57222. this._effect.setArray(name, this._floatsArrays[name]);
  57223. }
  57224. // Color3
  57225. for (name in this._colors3) {
  57226. this._effect.setColor3(name, this._colors3[name]);
  57227. }
  57228. // Color4
  57229. for (name in this._colors4) {
  57230. var color = this._colors4[name];
  57231. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  57232. }
  57233. // Vector2
  57234. for (name in this._vectors2) {
  57235. this._effect.setVector2(name, this._vectors2[name]);
  57236. }
  57237. // Vector3
  57238. for (name in this._vectors3) {
  57239. this._effect.setVector3(name, this._vectors3[name]);
  57240. }
  57241. // Matrix
  57242. for (name in this._matrices) {
  57243. this._effect.setMatrix(name, this._matrices[name]);
  57244. }
  57245. if (!this._texture) {
  57246. return;
  57247. }
  57248. if (this.isCube) {
  57249. for (var face = 0; face < 6; face++) {
  57250. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  57251. // VBOs
  57252. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  57253. this._effect.setFloat("face", face);
  57254. // Clear
  57255. if (this.autoClear) {
  57256. engine.clear(scene.clearColor, true, false, false);
  57257. }
  57258. // Draw order
  57259. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  57260. // Mipmaps
  57261. if (face === 5) {
  57262. engine.generateMipMapsForCubemap(this._texture);
  57263. }
  57264. }
  57265. }
  57266. else {
  57267. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  57268. // VBOs
  57269. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  57270. // Clear
  57271. if (this.autoClear) {
  57272. engine.clear(scene.clearColor, true, false, false);
  57273. }
  57274. // Draw order
  57275. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  57276. }
  57277. // Unbind
  57278. engine.unBindFramebuffer(this._texture, this.isCube);
  57279. if (this.onGenerated) {
  57280. this.onGenerated();
  57281. }
  57282. this.onGeneratedObservable.notifyObservers(this);
  57283. };
  57284. /**
  57285. * Clone the texture.
  57286. * @returns the cloned texture
  57287. */
  57288. ProceduralTexture.prototype.clone = function () {
  57289. var textureSize = this.getSize();
  57290. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  57291. // Base texture
  57292. newTexture.hasAlpha = this.hasAlpha;
  57293. newTexture.level = this.level;
  57294. // RenderTarget Texture
  57295. newTexture.coordinatesMode = this.coordinatesMode;
  57296. return newTexture;
  57297. };
  57298. /**
  57299. * Dispose the texture and release its asoociated resources.
  57300. */
  57301. ProceduralTexture.prototype.dispose = function () {
  57302. var scene = this.getScene();
  57303. if (!scene) {
  57304. return;
  57305. }
  57306. var index = scene.proceduralTextures.indexOf(this);
  57307. if (index >= 0) {
  57308. scene.proceduralTextures.splice(index, 1);
  57309. }
  57310. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  57311. if (vertexBuffer) {
  57312. vertexBuffer.dispose();
  57313. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  57314. }
  57315. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  57316. this._indexBuffer = null;
  57317. }
  57318. _super.prototype.dispose.call(this);
  57319. };
  57320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57322. ], ProceduralTexture.prototype, "isEnabled", void 0);
  57323. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57324. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57325. ], ProceduralTexture.prototype, "autoClear", void 0);
  57326. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57328. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  57329. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57331. ], ProceduralTexture.prototype, "_size", void 0);
  57332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57334. ], ProceduralTexture.prototype, "refreshRate", null);
  57335. return ProceduralTexture;
  57336. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  57337. /***/ }),
  57338. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  57339. /*!***************************************************************************!*\
  57340. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  57341. \***************************************************************************/
  57342. /*! exports provided: ProceduralTextureSceneComponent */
  57343. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57344. "use strict";
  57345. __webpack_require__.r(__webpack_exports__);
  57346. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  57347. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  57348. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  57349. /**
  57350. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  57351. * in a given scene.
  57352. */
  57353. var ProceduralTextureSceneComponent = /** @class */ (function () {
  57354. /**
  57355. * Creates a new instance of the component for the given scene
  57356. * @param scene Defines the scene to register the component in
  57357. */
  57358. function ProceduralTextureSceneComponent(scene) {
  57359. /**
  57360. * The component name helpfull to identify the component in the list of scene components.
  57361. */
  57362. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  57363. this.scene = scene;
  57364. this.scene.proceduralTextures = new Array();
  57365. scene.layers = new Array();
  57366. }
  57367. /**
  57368. * Registers the component in a given scene
  57369. */
  57370. ProceduralTextureSceneComponent.prototype.register = function () {
  57371. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  57372. };
  57373. /**
  57374. * Rebuilds the elements related to this component in case of
  57375. * context lost for instance.
  57376. */
  57377. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  57378. // Nothing to do here.
  57379. };
  57380. /**
  57381. * Disposes the component and the associated ressources.
  57382. */
  57383. ProceduralTextureSceneComponent.prototype.dispose = function () {
  57384. // Nothing to do here.
  57385. };
  57386. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  57387. if (this.scene.proceduralTexturesEnabled) {
  57388. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  57389. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  57390. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  57391. if (proceduralTexture._shouldRender()) {
  57392. proceduralTexture.render();
  57393. }
  57394. }
  57395. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  57396. }
  57397. };
  57398. return ProceduralTextureSceneComponent;
  57399. }());
  57400. /***/ }),
  57401. /***/ "./Materials/Textures/baseTexture.ts":
  57402. /*!*******************************************!*\
  57403. !*** ./Materials/Textures/baseTexture.ts ***!
  57404. \*******************************************/
  57405. /*! exports provided: BaseTexture */
  57406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57407. "use strict";
  57408. __webpack_require__.r(__webpack_exports__);
  57409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  57410. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57411. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  57412. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  57413. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  57414. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  57415. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57416. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  57417. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57418. /**
  57419. * Base class of all the textures in babylon.
  57420. * It groups all the common properties the materials, post process, lights... might need
  57421. * in order to make a correct use of the texture.
  57422. */
  57423. var BaseTexture = /** @class */ (function () {
  57424. /**
  57425. * Instantiates a new BaseTexture.
  57426. * Base class of all the textures in babylon.
  57427. * It groups all the common properties the materials, post process, lights... might need
  57428. * in order to make a correct use of the texture.
  57429. * @param scene Define the scene the texture blongs to
  57430. */
  57431. function BaseTexture(scene) {
  57432. /**
  57433. * Gets or sets an object used to store user defined information.
  57434. */
  57435. this.metadata = null;
  57436. /**
  57437. * For internal use only. Please do not use.
  57438. */
  57439. this.reservedDataStore = null;
  57440. this._hasAlpha = false;
  57441. /**
  57442. * Defines if the alpha value should be determined via the rgb values.
  57443. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  57444. */
  57445. this.getAlphaFromRGB = false;
  57446. /**
  57447. * Intensity or strength of the texture.
  57448. * It is commonly used by materials to fine tune the intensity of the texture
  57449. */
  57450. this.level = 1;
  57451. /**
  57452. * Define the UV chanel to use starting from 0 and defaulting to 0.
  57453. * This is part of the texture as textures usually maps to one uv set.
  57454. */
  57455. this.coordinatesIndex = 0;
  57456. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  57457. /**
  57458. * | Value | Type | Description |
  57459. * | ----- | ------------------ | ----------- |
  57460. * | 0 | CLAMP_ADDRESSMODE | |
  57461. * | 1 | WRAP_ADDRESSMODE | |
  57462. * | 2 | MIRROR_ADDRESSMODE | |
  57463. */
  57464. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  57465. /**
  57466. * | Value | Type | Description |
  57467. * | ----- | ------------------ | ----------- |
  57468. * | 0 | CLAMP_ADDRESSMODE | |
  57469. * | 1 | WRAP_ADDRESSMODE | |
  57470. * | 2 | MIRROR_ADDRESSMODE | |
  57471. */
  57472. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  57473. /**
  57474. * | Value | Type | Description |
  57475. * | ----- | ------------------ | ----------- |
  57476. * | 0 | CLAMP_ADDRESSMODE | |
  57477. * | 1 | WRAP_ADDRESSMODE | |
  57478. * | 2 | MIRROR_ADDRESSMODE | |
  57479. */
  57480. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  57481. /**
  57482. * With compliant hardware and browser (supporting anisotropic filtering)
  57483. * this defines the level of anisotropic filtering in the texture.
  57484. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  57485. */
  57486. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  57487. /**
  57488. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  57489. * HDR texture are usually stored in linear space.
  57490. * This only impacts the PBR and Background materials
  57491. */
  57492. this.gammaSpace = true;
  57493. /**
  57494. * Is Z inverted in the texture (useful in a cube texture).
  57495. */
  57496. this.invertZ = false;
  57497. /**
  57498. * @hidden
  57499. */
  57500. this.lodLevelInAlpha = false;
  57501. /**
  57502. * Define if the texture is a render target.
  57503. */
  57504. this.isRenderTarget = false;
  57505. /**
  57506. * Define the list of animation attached to the texture.
  57507. */
  57508. this.animations = new Array();
  57509. /**
  57510. * An event triggered when the texture is disposed.
  57511. */
  57512. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  57513. /**
  57514. * Define the current state of the loading sequence when in delayed load mode.
  57515. */
  57516. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  57517. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  57518. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  57519. if (this._scene) {
  57520. this.uniqueId = this._scene.getUniqueId();
  57521. this._scene.addTexture(this);
  57522. }
  57523. this._uid = null;
  57524. }
  57525. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  57526. get: function () {
  57527. return this._hasAlpha;
  57528. },
  57529. /**
  57530. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  57531. */
  57532. set: function (value) {
  57533. if (this._hasAlpha === value) {
  57534. return;
  57535. }
  57536. this._hasAlpha = value;
  57537. if (this._scene) {
  57538. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  57539. }
  57540. },
  57541. enumerable: true,
  57542. configurable: true
  57543. });
  57544. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  57545. get: function () {
  57546. return this._coordinatesMode;
  57547. },
  57548. /**
  57549. * How a texture is mapped.
  57550. *
  57551. * | Value | Type | Description |
  57552. * | ----- | ----------------------------------- | ----------- |
  57553. * | 0 | EXPLICIT_MODE | |
  57554. * | 1 | SPHERICAL_MODE | |
  57555. * | 2 | PLANAR_MODE | |
  57556. * | 3 | CUBIC_MODE | |
  57557. * | 4 | PROJECTION_MODE | |
  57558. * | 5 | SKYBOX_MODE | |
  57559. * | 6 | INVCUBIC_MODE | |
  57560. * | 7 | EQUIRECTANGULAR_MODE | |
  57561. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  57562. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  57563. */
  57564. set: function (value) {
  57565. if (this._coordinatesMode === value) {
  57566. return;
  57567. }
  57568. this._coordinatesMode = value;
  57569. if (this._scene) {
  57570. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  57571. }
  57572. },
  57573. enumerable: true,
  57574. configurable: true
  57575. });
  57576. Object.defineProperty(BaseTexture.prototype, "isCube", {
  57577. /**
  57578. * Define if the texture is a cube texture or if false a 2d texture.
  57579. */
  57580. get: function () {
  57581. if (!this._texture) {
  57582. return false;
  57583. }
  57584. return this._texture.isCube;
  57585. },
  57586. set: function (value) {
  57587. if (!this._texture) {
  57588. return;
  57589. }
  57590. this._texture.isCube = value;
  57591. },
  57592. enumerable: true,
  57593. configurable: true
  57594. });
  57595. Object.defineProperty(BaseTexture.prototype, "is3D", {
  57596. /**
  57597. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  57598. */
  57599. get: function () {
  57600. if (!this._texture) {
  57601. return false;
  57602. }
  57603. return this._texture.is3D;
  57604. },
  57605. set: function (value) {
  57606. if (!this._texture) {
  57607. return;
  57608. }
  57609. this._texture.is3D = value;
  57610. },
  57611. enumerable: true,
  57612. configurable: true
  57613. });
  57614. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  57615. /**
  57616. * Gets whether or not the texture contains RGBD data.
  57617. */
  57618. get: function () {
  57619. return this._texture != null && this._texture._isRGBD;
  57620. },
  57621. enumerable: true,
  57622. configurable: true
  57623. });
  57624. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  57625. /**
  57626. * Are mip maps generated for this texture or not.
  57627. */
  57628. get: function () {
  57629. return false;
  57630. },
  57631. enumerable: true,
  57632. configurable: true
  57633. });
  57634. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  57635. /**
  57636. * With prefiltered texture, defined the offset used during the prefiltering steps.
  57637. */
  57638. get: function () {
  57639. if (this._texture) {
  57640. return this._texture._lodGenerationOffset;
  57641. }
  57642. return 0.0;
  57643. },
  57644. set: function (value) {
  57645. if (this._texture) {
  57646. this._texture._lodGenerationOffset = value;
  57647. }
  57648. },
  57649. enumerable: true,
  57650. configurable: true
  57651. });
  57652. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  57653. /**
  57654. * With prefiltered texture, defined the scale used during the prefiltering steps.
  57655. */
  57656. get: function () {
  57657. if (this._texture) {
  57658. return this._texture._lodGenerationScale;
  57659. }
  57660. return 0.0;
  57661. },
  57662. set: function (value) {
  57663. if (this._texture) {
  57664. this._texture._lodGenerationScale = value;
  57665. }
  57666. },
  57667. enumerable: true,
  57668. configurable: true
  57669. });
  57670. Object.defineProperty(BaseTexture.prototype, "uid", {
  57671. /**
  57672. * Define the unique id of the texture in the scene.
  57673. */
  57674. get: function () {
  57675. if (!this._uid) {
  57676. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  57677. }
  57678. return this._uid;
  57679. },
  57680. enumerable: true,
  57681. configurable: true
  57682. });
  57683. /**
  57684. * Return a string representation of the texture.
  57685. * @returns the texture as a string
  57686. */
  57687. BaseTexture.prototype.toString = function () {
  57688. return this.name;
  57689. };
  57690. /**
  57691. * Get the class name of the texture.
  57692. * @returns "BaseTexture"
  57693. */
  57694. BaseTexture.prototype.getClassName = function () {
  57695. return "BaseTexture";
  57696. };
  57697. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  57698. /**
  57699. * Callback triggered when the texture has been disposed.
  57700. * Kept for back compatibility, you can use the onDisposeObservable instead.
  57701. */
  57702. set: function (callback) {
  57703. if (this._onDisposeObserver) {
  57704. this.onDisposeObservable.remove(this._onDisposeObserver);
  57705. }
  57706. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  57707. },
  57708. enumerable: true,
  57709. configurable: true
  57710. });
  57711. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  57712. /**
  57713. * Define if the texture is preventinga material to render or not.
  57714. * If not and the texture is not ready, the engine will use a default black texture instead.
  57715. */
  57716. get: function () {
  57717. return true;
  57718. },
  57719. enumerable: true,
  57720. configurable: true
  57721. });
  57722. /**
  57723. * Get the scene the texture belongs to.
  57724. * @returns the scene or null if undefined
  57725. */
  57726. BaseTexture.prototype.getScene = function () {
  57727. return this._scene;
  57728. };
  57729. /**
  57730. * Get the texture transform matrix used to offset tile the texture for istance.
  57731. * @returns the transformation matrix
  57732. */
  57733. BaseTexture.prototype.getTextureMatrix = function () {
  57734. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  57735. };
  57736. /**
  57737. * Get the texture reflection matrix used to rotate/transform the reflection.
  57738. * @returns the reflection matrix
  57739. */
  57740. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  57741. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  57742. };
  57743. /**
  57744. * Get the underlying lower level texture from Babylon.
  57745. * @returns the insternal texture
  57746. */
  57747. BaseTexture.prototype.getInternalTexture = function () {
  57748. return this._texture;
  57749. };
  57750. /**
  57751. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  57752. * @returns true if ready or not blocking
  57753. */
  57754. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  57755. return !this.isBlocking || this.isReady();
  57756. };
  57757. /**
  57758. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  57759. * @returns true if fully ready
  57760. */
  57761. BaseTexture.prototype.isReady = function () {
  57762. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  57763. this.delayLoad();
  57764. return false;
  57765. }
  57766. if (this._texture) {
  57767. return this._texture.isReady;
  57768. }
  57769. return false;
  57770. };
  57771. /**
  57772. * Get the size of the texture.
  57773. * @returns the texture size.
  57774. */
  57775. BaseTexture.prototype.getSize = function () {
  57776. if (this._texture) {
  57777. if (this._texture.width) {
  57778. this._cachedSize.width = this._texture.width;
  57779. this._cachedSize.height = this._texture.height;
  57780. return this._cachedSize;
  57781. }
  57782. if (this._texture._size) {
  57783. this._cachedSize.width = this._texture._size;
  57784. this._cachedSize.height = this._texture._size;
  57785. return this._cachedSize;
  57786. }
  57787. }
  57788. return this._cachedSize;
  57789. };
  57790. /**
  57791. * Get the base size of the texture.
  57792. * It can be different from the size if the texture has been resized for POT for instance
  57793. * @returns the base size
  57794. */
  57795. BaseTexture.prototype.getBaseSize = function () {
  57796. if (!this.isReady() || !this._texture) {
  57797. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  57798. }
  57799. if (this._texture._size) {
  57800. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  57801. }
  57802. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  57803. };
  57804. /**
  57805. * Update the sampling mode of the texture.
  57806. * Default is Trilinear mode.
  57807. *
  57808. * | Value | Type | Description |
  57809. * | ----- | ------------------ | ----------- |
  57810. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  57811. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  57812. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  57813. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  57814. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  57815. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  57816. * | 7 | NEAREST_LINEAR | |
  57817. * | 8 | NEAREST_NEAREST | |
  57818. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  57819. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  57820. * | 11 | LINEAR_LINEAR | |
  57821. * | 12 | LINEAR_NEAREST | |
  57822. *
  57823. * > _mag_: magnification filter (close to the viewer)
  57824. * > _min_: minification filter (far from the viewer)
  57825. * > _mip_: filter used between mip map levels
  57826. *@param samplingMode Define the new sampling mode of the texture
  57827. */
  57828. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  57829. if (!this._texture) {
  57830. return;
  57831. }
  57832. var scene = this.getScene();
  57833. if (!scene) {
  57834. return;
  57835. }
  57836. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  57837. };
  57838. /**
  57839. * Scales the texture if is `canRescale()`
  57840. * @param ratio the resize factor we want to use to rescale
  57841. */
  57842. BaseTexture.prototype.scale = function (ratio) {
  57843. };
  57844. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  57845. /**
  57846. * Get if the texture can rescale.
  57847. */
  57848. get: function () {
  57849. return false;
  57850. },
  57851. enumerable: true,
  57852. configurable: true
  57853. });
  57854. /** @hidden */
  57855. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling, invertY) {
  57856. if (!this._scene) {
  57857. return null;
  57858. }
  57859. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  57860. for (var index = 0; index < texturesCache.length; index++) {
  57861. var texturesCacheEntry = texturesCache[index];
  57862. if (invertY === undefined || invertY === texturesCacheEntry.invertY) {
  57863. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  57864. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  57865. texturesCacheEntry.incrementReferences();
  57866. return texturesCacheEntry;
  57867. }
  57868. }
  57869. }
  57870. }
  57871. return null;
  57872. };
  57873. /** @hidden */
  57874. BaseTexture.prototype._rebuild = function () {
  57875. };
  57876. /**
  57877. * Triggers the load sequence in delayed load mode.
  57878. */
  57879. BaseTexture.prototype.delayLoad = function () {
  57880. };
  57881. /**
  57882. * Clones the texture.
  57883. * @returns the cloned texture
  57884. */
  57885. BaseTexture.prototype.clone = function () {
  57886. return null;
  57887. };
  57888. Object.defineProperty(BaseTexture.prototype, "textureType", {
  57889. /**
  57890. * Get the texture underlying type (INT, FLOAT...)
  57891. */
  57892. get: function () {
  57893. if (!this._texture) {
  57894. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  57895. }
  57896. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  57897. },
  57898. enumerable: true,
  57899. configurable: true
  57900. });
  57901. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  57902. /**
  57903. * Get the texture underlying format (RGB, RGBA...)
  57904. */
  57905. get: function () {
  57906. if (!this._texture) {
  57907. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  57908. }
  57909. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  57910. },
  57911. enumerable: true,
  57912. configurable: true
  57913. });
  57914. /**
  57915. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  57916. * This will returns an RGBA array buffer containing either in values (0-255) or
  57917. * float values (0-1) depending of the underlying buffer type.
  57918. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  57919. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  57920. * @param buffer defines a user defined buffer to fill with data (can be null)
  57921. * @returns The Array buffer containing the pixels data.
  57922. */
  57923. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  57924. if (faceIndex === void 0) { faceIndex = 0; }
  57925. if (level === void 0) { level = 0; }
  57926. if (buffer === void 0) { buffer = null; }
  57927. if (!this._texture) {
  57928. return null;
  57929. }
  57930. var size = this.getSize();
  57931. var width = size.width;
  57932. var height = size.height;
  57933. var scene = this.getScene();
  57934. if (!scene) {
  57935. return null;
  57936. }
  57937. var engine = scene.getEngine();
  57938. if (level != 0) {
  57939. width = width / Math.pow(2, level);
  57940. height = height / Math.pow(2, level);
  57941. width = Math.round(width);
  57942. height = Math.round(height);
  57943. }
  57944. if (this._texture.isCube) {
  57945. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  57946. }
  57947. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  57948. };
  57949. /**
  57950. * Release and destroy the underlying lower level texture aka internalTexture.
  57951. */
  57952. BaseTexture.prototype.releaseInternalTexture = function () {
  57953. if (this._texture) {
  57954. this._texture.dispose();
  57955. this._texture = null;
  57956. }
  57957. };
  57958. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  57959. /**
  57960. * Get the polynomial representation of the texture data.
  57961. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  57962. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  57963. */
  57964. get: function () {
  57965. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  57966. return null;
  57967. }
  57968. if (!this._texture._sphericalPolynomial) {
  57969. this._texture._sphericalPolynomial =
  57970. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  57971. }
  57972. return this._texture._sphericalPolynomial;
  57973. },
  57974. set: function (value) {
  57975. if (this._texture) {
  57976. this._texture._sphericalPolynomial = value;
  57977. }
  57978. },
  57979. enumerable: true,
  57980. configurable: true
  57981. });
  57982. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  57983. /** @hidden */
  57984. get: function () {
  57985. if (this._texture) {
  57986. return this._texture._lodTextureHigh;
  57987. }
  57988. return null;
  57989. },
  57990. enumerable: true,
  57991. configurable: true
  57992. });
  57993. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  57994. /** @hidden */
  57995. get: function () {
  57996. if (this._texture) {
  57997. return this._texture._lodTextureMid;
  57998. }
  57999. return null;
  58000. },
  58001. enumerable: true,
  58002. configurable: true
  58003. });
  58004. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  58005. /** @hidden */
  58006. get: function () {
  58007. if (this._texture) {
  58008. return this._texture._lodTextureLow;
  58009. }
  58010. return null;
  58011. },
  58012. enumerable: true,
  58013. configurable: true
  58014. });
  58015. /**
  58016. * Dispose the texture and release its associated resources.
  58017. */
  58018. BaseTexture.prototype.dispose = function () {
  58019. if (!this._scene) {
  58020. return;
  58021. }
  58022. // Animations
  58023. this._scene.stopAnimation(this);
  58024. // Remove from scene
  58025. this._scene._removePendingData(this);
  58026. var index = this._scene.textures.indexOf(this);
  58027. if (index >= 0) {
  58028. this._scene.textures.splice(index, 1);
  58029. }
  58030. this._scene.onTextureRemovedObservable.notifyObservers(this);
  58031. if (this._texture === undefined) {
  58032. return;
  58033. }
  58034. // Release
  58035. this.releaseInternalTexture();
  58036. // Callback
  58037. this.onDisposeObservable.notifyObservers(this);
  58038. this.onDisposeObservable.clear();
  58039. };
  58040. /**
  58041. * Serialize the texture into a JSON representation that can be parsed later on.
  58042. * @returns the JSON representation of the texture
  58043. */
  58044. BaseTexture.prototype.serialize = function () {
  58045. if (!this.name) {
  58046. return null;
  58047. }
  58048. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  58049. // Animations
  58050. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  58051. return serializationObject;
  58052. };
  58053. /**
  58054. * Helper function to be called back once a list of texture contains only ready textures.
  58055. * @param textures Define the list of textures to wait for
  58056. * @param callback Define the callback triggered once the entire list will be ready
  58057. */
  58058. BaseTexture.WhenAllReady = function (textures, callback) {
  58059. var numRemaining = textures.length;
  58060. if (numRemaining === 0) {
  58061. callback();
  58062. return;
  58063. }
  58064. var _loop_1 = function () {
  58065. texture = textures[i];
  58066. if (texture.isReady()) {
  58067. if (--numRemaining === 0) {
  58068. callback();
  58069. }
  58070. }
  58071. else {
  58072. onLoadObservable = texture.onLoadObservable;
  58073. var onLoadCallback_1 = function () {
  58074. onLoadObservable.removeCallback(onLoadCallback_1);
  58075. if (--numRemaining === 0) {
  58076. callback();
  58077. }
  58078. };
  58079. onLoadObservable.add(onLoadCallback_1);
  58080. }
  58081. };
  58082. var texture, onLoadObservable;
  58083. for (var i = 0; i < textures.length; i++) {
  58084. _loop_1();
  58085. }
  58086. };
  58087. /**
  58088. * Default anisotropic filtering level for the application.
  58089. * It is set to 4 as a good tradeoff between perf and quality.
  58090. */
  58091. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  58092. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58093. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58094. ], BaseTexture.prototype, "uniqueId", void 0);
  58095. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58097. ], BaseTexture.prototype, "name", void 0);
  58098. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58100. ], BaseTexture.prototype, "metadata", void 0);
  58101. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58102. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  58103. ], BaseTexture.prototype, "_hasAlpha", void 0);
  58104. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58105. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58106. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  58107. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58109. ], BaseTexture.prototype, "level", void 0);
  58110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58112. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  58113. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58114. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  58115. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  58116. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58118. ], BaseTexture.prototype, "wrapU", void 0);
  58119. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58121. ], BaseTexture.prototype, "wrapV", void 0);
  58122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58124. ], BaseTexture.prototype, "wrapR", void 0);
  58125. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58126. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58127. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  58128. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58129. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58130. ], BaseTexture.prototype, "isCube", null);
  58131. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58133. ], BaseTexture.prototype, "is3D", null);
  58134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58136. ], BaseTexture.prototype, "gammaSpace", void 0);
  58137. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58138. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58139. ], BaseTexture.prototype, "invertZ", void 0);
  58140. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58141. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58142. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  58143. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58145. ], BaseTexture.prototype, "lodGenerationOffset", null);
  58146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58148. ], BaseTexture.prototype, "lodGenerationScale", null);
  58149. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58150. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58151. ], BaseTexture.prototype, "isRenderTarget", void 0);
  58152. return BaseTexture;
  58153. }());
  58154. /***/ }),
  58155. /***/ "./Materials/Textures/colorGradingTexture.ts":
  58156. /*!***************************************************!*\
  58157. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  58158. \***************************************************/
  58159. /*! exports provided: ColorGradingTexture */
  58160. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58161. "use strict";
  58162. __webpack_require__.r(__webpack_exports__);
  58163. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  58164. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58165. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58166. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  58167. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58168. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  58169. /**
  58170. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58171. * It can help converting any input color in a desired output one. This can then be used to create effects
  58172. * from sepia, black and white to sixties or futuristic rendering...
  58173. *
  58174. * The only supported format is currently 3dl.
  58175. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58176. */
  58177. var ColorGradingTexture = /** @class */ (function (_super) {
  58178. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  58179. /**
  58180. * Instantiates a ColorGradingTexture from the following parameters.
  58181. *
  58182. * @param url The location of the color gradind data (currently only supporting 3dl)
  58183. * @param scene The scene the texture will be used in
  58184. */
  58185. function ColorGradingTexture(url, scene) {
  58186. var _this = _super.call(this, scene) || this;
  58187. if (!url) {
  58188. return _this;
  58189. }
  58190. _this._engine = scene.getEngine();
  58191. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  58192. _this.name = url;
  58193. _this.url = url;
  58194. _this.hasAlpha = false;
  58195. _this.isCube = false;
  58196. _this.is3D = _this._engine.webGLVersion > 1;
  58197. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  58198. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  58199. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  58200. _this.anisotropicFilteringLevel = 1;
  58201. _this._texture = _this._getFromCache(url, true);
  58202. if (!_this._texture) {
  58203. if (!scene.useDelayedTextureLoading) {
  58204. _this.loadTexture();
  58205. }
  58206. else {
  58207. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58208. }
  58209. }
  58210. return _this;
  58211. }
  58212. /**
  58213. * Returns the texture matrix used in most of the material.
  58214. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58215. */
  58216. ColorGradingTexture.prototype.getTextureMatrix = function () {
  58217. return this._textureMatrix;
  58218. };
  58219. /**
  58220. * Occurs when the file being loaded is a .3dl LUT file.
  58221. */
  58222. ColorGradingTexture.prototype.load3dlTexture = function () {
  58223. var engine = this._engine;
  58224. var texture;
  58225. if (engine.webGLVersion === 1) {
  58226. texture = engine.createRawTexture(null, 1, 1, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false, false, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE);
  58227. }
  58228. else {
  58229. texture = engine.createRawTexture3D(null, 1, 1, 1, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false, false, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE);
  58230. }
  58231. this._texture = texture;
  58232. var callback = function (text) {
  58233. if (typeof text !== "string") {
  58234. return;
  58235. }
  58236. var data = null;
  58237. var tempData = null;
  58238. var line;
  58239. var lines = text.split('\n');
  58240. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  58241. var maxColor = 0;
  58242. for (var i = 0; i < lines.length; i++) {
  58243. line = lines[i];
  58244. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  58245. continue;
  58246. }
  58247. if (line.indexOf('#') === 0) {
  58248. continue;
  58249. }
  58250. var words = line.split(" ");
  58251. if (size === 0) {
  58252. // Number of space + one
  58253. size = words.length;
  58254. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  58255. tempData = new Float32Array(size * size * size * 4);
  58256. continue;
  58257. }
  58258. if (size != 0) {
  58259. var r = Math.max(parseInt(words[0]), 0);
  58260. var g = Math.max(parseInt(words[1]), 0);
  58261. var b = Math.max(parseInt(words[2]), 0);
  58262. maxColor = Math.max(r, maxColor);
  58263. maxColor = Math.max(g, maxColor);
  58264. maxColor = Math.max(b, maxColor);
  58265. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  58266. if (tempData) {
  58267. tempData[pixelStorageIndex + 0] = r;
  58268. tempData[pixelStorageIndex + 1] = g;
  58269. tempData[pixelStorageIndex + 2] = b;
  58270. }
  58271. // Keep for reference in case of back compat problems.
  58272. // pixelIndexSlice++;
  58273. // if (pixelIndexSlice % size == 0) {
  58274. // pixelIndexH++;
  58275. // pixelIndexSlice = 0;
  58276. // if (pixelIndexH % size == 0) {
  58277. // pixelIndexW++;
  58278. // pixelIndexH = 0;
  58279. // }
  58280. // }
  58281. pixelIndexH++;
  58282. if (pixelIndexH % size == 0) {
  58283. pixelIndexSlice++;
  58284. pixelIndexH = 0;
  58285. if (pixelIndexSlice % size == 0) {
  58286. pixelIndexW++;
  58287. pixelIndexSlice = 0;
  58288. }
  58289. }
  58290. }
  58291. }
  58292. if (tempData && data) {
  58293. for (var i = 0; i < tempData.length; i++) {
  58294. if (i > 0 && (i + 1) % 4 === 0) {
  58295. data[i] = 255;
  58296. }
  58297. else {
  58298. var value = tempData[i];
  58299. data[i] = (value / maxColor * 255);
  58300. }
  58301. }
  58302. }
  58303. if (texture.is3D) {
  58304. texture.updateSize(size, size, size);
  58305. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  58306. }
  58307. else {
  58308. texture.updateSize(size * size, size);
  58309. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  58310. }
  58311. };
  58312. var scene = this.getScene();
  58313. if (scene) {
  58314. scene._loadFile(this.url, callback);
  58315. }
  58316. else {
  58317. this._engine._loadFile(this.url, callback);
  58318. }
  58319. return this._texture;
  58320. };
  58321. /**
  58322. * Starts the loading process of the texture.
  58323. */
  58324. ColorGradingTexture.prototype.loadTexture = function () {
  58325. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  58326. this.load3dlTexture();
  58327. }
  58328. };
  58329. /**
  58330. * Clones the color gradind texture.
  58331. */
  58332. ColorGradingTexture.prototype.clone = function () {
  58333. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  58334. // Base texture
  58335. newTexture.level = this.level;
  58336. return newTexture;
  58337. };
  58338. /**
  58339. * Called during delayed load for textures.
  58340. */
  58341. ColorGradingTexture.prototype.delayLoad = function () {
  58342. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  58343. return;
  58344. }
  58345. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  58346. this._texture = this._getFromCache(this.url, true);
  58347. if (!this._texture) {
  58348. this.loadTexture();
  58349. }
  58350. };
  58351. /**
  58352. * Parses a color grading texture serialized by Babylon.
  58353. * @param parsedTexture The texture information being parsedTexture
  58354. * @param scene The scene to load the texture in
  58355. * @param rootUrl The root url of the data assets to load
  58356. * @return A color gradind texture
  58357. */
  58358. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  58359. var texture = null;
  58360. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  58361. texture = new ColorGradingTexture(parsedTexture.name, scene);
  58362. texture.name = parsedTexture.name;
  58363. texture.level = parsedTexture.level;
  58364. }
  58365. return texture;
  58366. };
  58367. /**
  58368. * Serializes the LUT texture to json format.
  58369. */
  58370. ColorGradingTexture.prototype.serialize = function () {
  58371. if (!this.name) {
  58372. return null;
  58373. }
  58374. var serializationObject = {};
  58375. serializationObject.name = this.name;
  58376. serializationObject.level = this.level;
  58377. serializationObject.customType = "BABYLON.ColorGradingTexture";
  58378. return serializationObject;
  58379. };
  58380. /**
  58381. * Empty line regex stored for GC.
  58382. */
  58383. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  58384. return ColorGradingTexture;
  58385. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  58386. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  58387. /***/ }),
  58388. /***/ "./Materials/Textures/cubeTexture.ts":
  58389. /*!*******************************************!*\
  58390. !*** ./Materials/Textures/cubeTexture.ts ***!
  58391. \*******************************************/
  58392. /*! exports provided: CubeTexture */
  58393. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58394. "use strict";
  58395. __webpack_require__.r(__webpack_exports__);
  58396. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  58397. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58398. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  58399. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58400. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58401. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  58402. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58403. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58404. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  58405. /**
  58406. * Class for creating a cube texture
  58407. */
  58408. var CubeTexture = /** @class */ (function (_super) {
  58409. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  58410. /**
  58411. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  58412. * as prefiltered data.
  58413. * @param rootUrl defines the url of the texture or the root name of the six images
  58414. * @param scene defines the scene the texture is attached to
  58415. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  58416. * @param noMipmap defines if mipmaps should be created or not
  58417. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  58418. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  58419. * @param onError defines a callback triggered in case of error during load
  58420. * @param format defines the internal format to use for the texture once loaded
  58421. * @param prefiltered defines whether or not the texture is created from prefiltered data
  58422. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  58423. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  58424. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58425. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58426. * @return the cube texture
  58427. */
  58428. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  58429. if (extensions === void 0) { extensions = null; }
  58430. if (noMipmap === void 0) { noMipmap = false; }
  58431. if (files === void 0) { files = null; }
  58432. if (onLoad === void 0) { onLoad = null; }
  58433. if (onError === void 0) { onError = null; }
  58434. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  58435. if (prefiltered === void 0) { prefiltered = false; }
  58436. if (forcedExtension === void 0) { forcedExtension = null; }
  58437. if (createPolynomials === void 0) { createPolynomials = false; }
  58438. if (lodScale === void 0) { lodScale = 0.8; }
  58439. if (lodOffset === void 0) { lodOffset = 0; }
  58440. var _this = _super.call(this, scene) || this;
  58441. /**
  58442. * Gets or sets the center of the bounding box associated with the cube texture.
  58443. * It must define where the camera used to render the texture was set
  58444. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  58445. */
  58446. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  58447. _this._rotationY = 0;
  58448. /** @hidden */
  58449. _this._prefiltered = false;
  58450. _this.name = rootUrl;
  58451. _this.url = rootUrl;
  58452. _this._noMipmap = noMipmap;
  58453. _this.hasAlpha = false;
  58454. _this._format = format;
  58455. _this.isCube = true;
  58456. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  58457. _this._createPolynomials = createPolynomials;
  58458. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  58459. if (!rootUrl && !files) {
  58460. return _this;
  58461. }
  58462. var lastDot = rootUrl.lastIndexOf(".");
  58463. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  58464. var isDDS = (extension === ".dds");
  58465. var isEnv = (extension === ".env");
  58466. if (isEnv) {
  58467. _this.gammaSpace = false;
  58468. _this._prefiltered = false;
  58469. }
  58470. else {
  58471. _this._prefiltered = prefiltered;
  58472. if (prefiltered) {
  58473. _this.gammaSpace = false;
  58474. }
  58475. }
  58476. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  58477. if (!files) {
  58478. if (!isEnv && !isDDS && !extensions) {
  58479. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  58480. }
  58481. files = [];
  58482. if (extensions) {
  58483. for (var index = 0; index < extensions.length; index++) {
  58484. files.push(rootUrl + extensions[index]);
  58485. }
  58486. }
  58487. }
  58488. _this._files = files;
  58489. if (!_this._texture) {
  58490. if (!scene.useDelayedTextureLoading) {
  58491. if (prefiltered) {
  58492. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  58493. }
  58494. else {
  58495. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  58496. }
  58497. }
  58498. else {
  58499. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58500. }
  58501. }
  58502. else if (onLoad) {
  58503. if (_this._texture.isReady) {
  58504. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  58505. }
  58506. else {
  58507. _this._texture.onLoadedObservable.add(onLoad);
  58508. }
  58509. }
  58510. return _this;
  58511. }
  58512. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  58513. /**
  58514. * Returns the bounding box size
  58515. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  58516. */
  58517. get: function () {
  58518. return this._boundingBoxSize;
  58519. },
  58520. /**
  58521. * Gets or sets the size of the bounding box associated with the cube texture
  58522. * When defined, the cubemap will switch to local mode
  58523. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58524. * @example https://www.babylonjs-playground.com/#RNASML
  58525. */
  58526. set: function (value) {
  58527. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  58528. return;
  58529. }
  58530. this._boundingBoxSize = value;
  58531. var scene = this.getScene();
  58532. if (scene) {
  58533. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  58534. }
  58535. },
  58536. enumerable: true,
  58537. configurable: true
  58538. });
  58539. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  58540. /**
  58541. * Gets texture matrix rotation angle around Y axis radians.
  58542. */
  58543. get: function () {
  58544. return this._rotationY;
  58545. },
  58546. /**
  58547. * Sets texture matrix rotation angle around Y axis in radians.
  58548. */
  58549. set: function (value) {
  58550. this._rotationY = value;
  58551. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  58552. },
  58553. enumerable: true,
  58554. configurable: true
  58555. });
  58556. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  58557. /**
  58558. * Are mip maps generated for this texture or not.
  58559. */
  58560. get: function () {
  58561. return this._noMipmap;
  58562. },
  58563. enumerable: true,
  58564. configurable: true
  58565. });
  58566. /**
  58567. * Creates a cube texture from an array of image urls
  58568. * @param files defines an array of image urls
  58569. * @param scene defines the hosting scene
  58570. * @param noMipmap specifies if mip maps are not used
  58571. * @returns a cube texture
  58572. */
  58573. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  58574. var rootUrlKey = "";
  58575. files.forEach(function (url) { return rootUrlKey += url; });
  58576. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  58577. };
  58578. /**
  58579. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  58580. * @param url defines the url of the prefiltered texture
  58581. * @param scene defines the scene the texture is attached to
  58582. * @param forcedExtension defines the extension of the file if different from the url
  58583. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  58584. * @return the prefiltered texture
  58585. */
  58586. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  58587. if (forcedExtension === void 0) { forcedExtension = null; }
  58588. if (createPolynomials === void 0) { createPolynomials = true; }
  58589. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  58590. };
  58591. /**
  58592. * Get the current class name of the texture useful for serialization or dynamic coding.
  58593. * @returns "CubeTexture"
  58594. */
  58595. CubeTexture.prototype.getClassName = function () {
  58596. return "CubeTexture";
  58597. };
  58598. /**
  58599. * Update the url (and optional buffer) of this texture if url was null during construction.
  58600. * @param url the url of the texture
  58601. * @param forcedExtension defines the extension to use
  58602. * @param onLoad callback called when the texture is loaded (defaults to null)
  58603. */
  58604. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  58605. if (this.url) {
  58606. this.releaseInternalTexture();
  58607. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  58608. }
  58609. this.url = url;
  58610. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58611. this._prefiltered = false;
  58612. if (onLoad) {
  58613. this._delayedOnLoad = onLoad;
  58614. }
  58615. this.delayLoad(forcedExtension);
  58616. };
  58617. /**
  58618. * Delays loading of the cube texture
  58619. * @param forcedExtension defines the extension to use
  58620. */
  58621. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  58622. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  58623. return;
  58624. }
  58625. var scene = this.getScene();
  58626. if (!scene) {
  58627. return;
  58628. }
  58629. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  58630. this._texture = this._getFromCache(this.url, this._noMipmap);
  58631. if (!this._texture) {
  58632. if (this._prefiltered) {
  58633. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  58634. }
  58635. else {
  58636. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  58637. }
  58638. }
  58639. };
  58640. /**
  58641. * Returns the reflection texture matrix
  58642. * @returns the reflection texture matrix
  58643. */
  58644. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  58645. return this._textureMatrix;
  58646. };
  58647. /**
  58648. * Sets the reflection texture matrix
  58649. * @param value Reflection texture matrix
  58650. */
  58651. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  58652. var _this = this;
  58653. if (value.updateFlag === this._textureMatrix.updateFlag) {
  58654. return;
  58655. }
  58656. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  58657. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  58658. }
  58659. this._textureMatrix = value;
  58660. };
  58661. /**
  58662. * Parses text to create a cube texture
  58663. * @param parsedTexture define the serialized text to read from
  58664. * @param scene defines the hosting scene
  58665. * @param rootUrl defines the root url of the cube texture
  58666. * @returns a cube texture
  58667. */
  58668. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  58669. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  58670. var prefiltered = false;
  58671. if (parsedTexture.prefiltered) {
  58672. prefiltered = parsedTexture.prefiltered;
  58673. }
  58674. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  58675. }, parsedTexture, scene);
  58676. // Local Cubemaps
  58677. if (parsedTexture.boundingBoxPosition) {
  58678. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  58679. }
  58680. if (parsedTexture.boundingBoxSize) {
  58681. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  58682. }
  58683. // Animations
  58684. if (parsedTexture.animations) {
  58685. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  58686. var parsedAnimation = parsedTexture.animations[animationIndex];
  58687. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  58688. if (internalClass) {
  58689. texture.animations.push(internalClass.Parse(parsedAnimation));
  58690. }
  58691. }
  58692. }
  58693. return texture;
  58694. };
  58695. /**
  58696. * Makes a clone, or deep copy, of the cube texture
  58697. * @returns a new cube texture
  58698. */
  58699. CubeTexture.prototype.clone = function () {
  58700. var _this = this;
  58701. var scene = this.getScene();
  58702. var uniqueId = 0;
  58703. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  58704. if (!scene) {
  58705. return _this;
  58706. }
  58707. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  58708. uniqueId = cubeTexture.uniqueId;
  58709. return cubeTexture;
  58710. }, this);
  58711. newCubeTexture.uniqueId = uniqueId;
  58712. return newCubeTexture;
  58713. };
  58714. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58715. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  58716. ], CubeTexture.prototype, "rotationY", null);
  58717. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58718. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMatrix"])("textureMatrix")
  58719. ], CubeTexture.prototype, "_textureMatrix", void 0);
  58720. return CubeTexture;
  58721. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  58722. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  58723. // Some exporters relies on Tools.Instantiate
  58724. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.CubeTexture"] = CubeTexture;
  58725. /***/ }),
  58726. /***/ "./Materials/Textures/dynamicTexture.ts":
  58727. /*!**********************************************!*\
  58728. !*** ./Materials/Textures/dynamicTexture.ts ***!
  58729. \**********************************************/
  58730. /*! exports provided: DynamicTexture */
  58731. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58732. "use strict";
  58733. __webpack_require__.r(__webpack_exports__);
  58734. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  58735. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58736. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  58737. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58738. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58739. /**
  58740. * A class extending Texture allowing drawing on a texture
  58741. * @see http://doc.babylonjs.com/how_to/dynamictexture
  58742. */
  58743. var DynamicTexture = /** @class */ (function (_super) {
  58744. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  58745. /**
  58746. * Creates a DynamicTexture
  58747. * @param name defines the name of the texture
  58748. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  58749. * @param scene defines the scene where you want the texture
  58750. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  58751. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58752. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  58753. */
  58754. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  58755. if (scene === void 0) { scene = null; }
  58756. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  58757. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  58758. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  58759. _this.name = name;
  58760. _this._engine = _this.getScene().getEngine();
  58761. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  58762. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  58763. _this._generateMipMaps = generateMipMaps;
  58764. if (options.getContext) {
  58765. _this._canvas = options;
  58766. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  58767. }
  58768. else {
  58769. _this._canvas = document.createElement("canvas");
  58770. if (options.width || options.width === 0) {
  58771. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  58772. }
  58773. else {
  58774. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  58775. }
  58776. }
  58777. var textureSize = _this.getSize();
  58778. _this._canvas.width = textureSize.width;
  58779. _this._canvas.height = textureSize.height;
  58780. _this._context = _this._canvas.getContext("2d");
  58781. return _this;
  58782. }
  58783. /**
  58784. * Get the current class name of the texture useful for serialization or dynamic coding.
  58785. * @returns "DynamicTexture"
  58786. */
  58787. DynamicTexture.prototype.getClassName = function () {
  58788. return "DynamicTexture";
  58789. };
  58790. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  58791. /**
  58792. * Gets the current state of canRescale
  58793. */
  58794. get: function () {
  58795. return true;
  58796. },
  58797. enumerable: true,
  58798. configurable: true
  58799. });
  58800. DynamicTexture.prototype._recreate = function (textureSize) {
  58801. this._canvas.width = textureSize.width;
  58802. this._canvas.height = textureSize.height;
  58803. this.releaseInternalTexture();
  58804. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  58805. };
  58806. /**
  58807. * Scales the texture
  58808. * @param ratio the scale factor to apply to both width and height
  58809. */
  58810. DynamicTexture.prototype.scale = function (ratio) {
  58811. var textureSize = this.getSize();
  58812. textureSize.width *= ratio;
  58813. textureSize.height *= ratio;
  58814. this._recreate(textureSize);
  58815. };
  58816. /**
  58817. * Resizes the texture
  58818. * @param width the new width
  58819. * @param height the new height
  58820. */
  58821. DynamicTexture.prototype.scaleTo = function (width, height) {
  58822. var textureSize = this.getSize();
  58823. textureSize.width = width;
  58824. textureSize.height = height;
  58825. this._recreate(textureSize);
  58826. };
  58827. /**
  58828. * Gets the context of the canvas used by the texture
  58829. * @returns the canvas context of the dynamic texture
  58830. */
  58831. DynamicTexture.prototype.getContext = function () {
  58832. return this._context;
  58833. };
  58834. /**
  58835. * Clears the texture
  58836. */
  58837. DynamicTexture.prototype.clear = function () {
  58838. var size = this.getSize();
  58839. this._context.fillRect(0, 0, size.width, size.height);
  58840. };
  58841. /**
  58842. * Updates the texture
  58843. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  58844. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  58845. */
  58846. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  58847. if (premulAlpha === void 0) { premulAlpha = false; }
  58848. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  58849. };
  58850. /**
  58851. * Draws text onto the texture
  58852. * @param text defines the text to be drawn
  58853. * @param x defines the placement of the text from the left
  58854. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  58855. * @param font defines the font to be used with font-style, font-size, font-name
  58856. * @param color defines the color used for the text
  58857. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  58858. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  58859. * @param update defines whether texture is immediately update (default is true)
  58860. */
  58861. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  58862. if (update === void 0) { update = true; }
  58863. var size = this.getSize();
  58864. if (clearColor) {
  58865. this._context.fillStyle = clearColor;
  58866. this._context.fillRect(0, 0, size.width, size.height);
  58867. }
  58868. this._context.font = font;
  58869. if (x === null || x === undefined) {
  58870. var textSize = this._context.measureText(text);
  58871. x = (size.width - textSize.width) / 2;
  58872. }
  58873. if (y === null || y === undefined) {
  58874. var fontSize = parseInt((font.replace(/\D/g, '')));
  58875. y = (size.height / 2) + (fontSize / 3.65);
  58876. }
  58877. this._context.fillStyle = color;
  58878. this._context.fillText(text, x, y);
  58879. if (update) {
  58880. this.update(invertY);
  58881. }
  58882. };
  58883. /**
  58884. * Clones the texture
  58885. * @returns the clone of the texture.
  58886. */
  58887. DynamicTexture.prototype.clone = function () {
  58888. var scene = this.getScene();
  58889. if (!scene) {
  58890. return this;
  58891. }
  58892. var textureSize = this.getSize();
  58893. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  58894. // Base texture
  58895. newTexture.hasAlpha = this.hasAlpha;
  58896. newTexture.level = this.level;
  58897. // Dynamic Texture
  58898. newTexture.wrapU = this.wrapU;
  58899. newTexture.wrapV = this.wrapV;
  58900. return newTexture;
  58901. };
  58902. /**
  58903. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  58904. * @returns a serialized dynamic texture object
  58905. */
  58906. DynamicTexture.prototype.serialize = function () {
  58907. var scene = this.getScene();
  58908. if (scene && !scene.isReady()) {
  58909. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  58910. }
  58911. var serializationObject = _super.prototype.serialize.call(this);
  58912. serializationObject.base64String = this._canvas.toDataURL();
  58913. serializationObject.invertY = this._invertY;
  58914. serializationObject.samplingMode = this.samplingMode;
  58915. return serializationObject;
  58916. };
  58917. /** @hidden */
  58918. DynamicTexture.prototype._rebuild = function () {
  58919. this.update();
  58920. };
  58921. return DynamicTexture;
  58922. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  58923. /***/ }),
  58924. /***/ "./Materials/Textures/equiRectangularCubeTexture.ts":
  58925. /*!**********************************************************!*\
  58926. !*** ./Materials/Textures/equiRectangularCubeTexture.ts ***!
  58927. \**********************************************************/
  58928. /*! exports provided: EquiRectangularCubeTexture */
  58929. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58930. "use strict";
  58931. __webpack_require__.r(__webpack_exports__);
  58932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return EquiRectangularCubeTexture; });
  58933. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58934. /* harmony import */ var _Misc_HighDynamicRange_panoramaToCubemap__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  58935. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  58936. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  58937. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  58938. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58939. /**
  58940. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58941. */
  58942. var EquiRectangularCubeTexture = /** @class */ (function (_super) {
  58943. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](EquiRectangularCubeTexture, _super);
  58944. /**
  58945. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58946. * @param url The location of the image
  58947. * @param scene The scene the texture will be used in
  58948. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58949. * @param noMipmap Forces to not generate the mipmap if true
  58950. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58951. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58952. * @param onLoad — defines a callback called when texture is loaded
  58953. * @param onError — defines a callback called if there is an error
  58954. */
  58955. function EquiRectangularCubeTexture(url, scene, size, noMipmap, gammaSpace, onLoad, onError) {
  58956. if (noMipmap === void 0) { noMipmap = false; }
  58957. if (gammaSpace === void 0) { gammaSpace = true; }
  58958. if (onLoad === void 0) { onLoad = null; }
  58959. if (onError === void 0) { onError = null; }
  58960. var _this = _super.call(this, scene) || this;
  58961. _this._onLoad = null;
  58962. _this._onError = null;
  58963. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58964. _this.coordinatesMode = _texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  58965. if (!url) {
  58966. throw new Error('Image url is not set');
  58967. }
  58968. _this.name = url;
  58969. _this.url = url;
  58970. _this._size = size;
  58971. _this._noMipmap = noMipmap;
  58972. _this.gammaSpace = gammaSpace;
  58973. _this._onLoad = onLoad;
  58974. _this._onError = onError;
  58975. _this.hasAlpha = false;
  58976. _this.isCube = true;
  58977. _this._texture = _this._getFromCache(url, _this._noMipmap);
  58978. if (!_this._texture) {
  58979. if (!scene.useDelayedTextureLoading) {
  58980. _this.loadImage(_this.loadTexture.bind(_this), _this._onError);
  58981. }
  58982. else {
  58983. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  58984. }
  58985. }
  58986. else if (onLoad) {
  58987. if (_this._texture.isReady) {
  58988. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].SetImmediate(function () { return onLoad(); });
  58989. }
  58990. else {
  58991. _this._texture.onLoadedObservable.add(onLoad);
  58992. }
  58993. }
  58994. return _this;
  58995. }
  58996. /**
  58997. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58998. */
  58999. EquiRectangularCubeTexture.prototype.loadImage = function (loadTextureCallback, onError) {
  59000. var _this = this;
  59001. var canvas = document.createElement('canvas');
  59002. var image = new Image();
  59003. image.addEventListener('load', function () {
  59004. _this._width = image.width;
  59005. _this._height = image.height;
  59006. canvas.width = _this._width;
  59007. canvas.height = _this._height;
  59008. var ctx = canvas.getContext('2d');
  59009. ctx.drawImage(image, 0, 0);
  59010. var imageData = ctx.getImageData(0, 0, image.width, image.height);
  59011. _this._buffer = imageData.data.buffer;
  59012. canvas.remove();
  59013. loadTextureCallback();
  59014. });
  59015. image.addEventListener('error', function (error) {
  59016. if (onError) {
  59017. onError(_this.getClassName() + " could not be loaded", error);
  59018. }
  59019. });
  59020. image.src = this.url;
  59021. };
  59022. /**
  59023. * Convert the image buffer into a cubemap and create a CubeTexture.
  59024. */
  59025. EquiRectangularCubeTexture.prototype.loadTexture = function () {
  59026. var _this = this;
  59027. var scene = this.getScene();
  59028. var callback = function () {
  59029. var imageData = _this.getFloat32ArrayFromArrayBuffer(_this._buffer);
  59030. // Extract the raw linear data.
  59031. var data = _Misc_HighDynamicRange_panoramaToCubemap__WEBPACK_IMPORTED_MODULE_1__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(imageData, _this._width, _this._height, _this._size);
  59032. var results = [];
  59033. // Push each faces.
  59034. for (var i = 0; i < 6; i++) {
  59035. var dataFace = data[EquiRectangularCubeTexture._FacesMapping[i]];
  59036. results.push(dataFace);
  59037. }
  59038. return results;
  59039. };
  59040. if (!scene) {
  59041. return;
  59042. }
  59043. this._texture = scene
  59044. .getEngine()
  59045. .createRawCubeTextureFromUrl(this.url, scene, this._size, _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat
  59046. ? _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_FLOAT
  59047. : _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_UNSIGNED_INTEGER, this._noMipmap, callback, null, this._onLoad, this._onError);
  59048. };
  59049. /**
  59050. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59051. * @param buffer The ArrayBuffer that should be converted.
  59052. * @returns The buffer as Float32Array.
  59053. */
  59054. EquiRectangularCubeTexture.prototype.getFloat32ArrayFromArrayBuffer = function (buffer) {
  59055. var dataView = new DataView(buffer);
  59056. var floatImageData = new Float32Array((buffer.byteLength * 3) / 4);
  59057. var k = 0;
  59058. for (var i = 0; i < buffer.byteLength; i++) {
  59059. // We drop the transparency channel, because we do not need/want it
  59060. if ((i + 1) % 4 !== 0) {
  59061. floatImageData[k++] = dataView.getUint8(i) / 255;
  59062. }
  59063. }
  59064. return floatImageData;
  59065. };
  59066. /**
  59067. * Get the current class name of the texture useful for serialization or dynamic coding.
  59068. * @returns "EquiRectangularCubeTexture"
  59069. */
  59070. EquiRectangularCubeTexture.prototype.getClassName = function () {
  59071. return "EquiRectangularCubeTexture";
  59072. };
  59073. /**
  59074. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59075. * @returns A clone of the current EquiRectangularCubeTexture.
  59076. */
  59077. EquiRectangularCubeTexture.prototype.clone = function () {
  59078. var scene = this.getScene();
  59079. if (!scene) {
  59080. return this;
  59081. }
  59082. var newTexture = new EquiRectangularCubeTexture(this.url, scene, this._size, this._noMipmap, this.gammaSpace);
  59083. // Base texture
  59084. newTexture.level = this.level;
  59085. newTexture.wrapU = this.wrapU;
  59086. newTexture.wrapV = this.wrapV;
  59087. newTexture.coordinatesIndex = this.coordinatesIndex;
  59088. newTexture.coordinatesMode = this.coordinatesMode;
  59089. return newTexture;
  59090. };
  59091. /** The six faces of the cube. */
  59092. EquiRectangularCubeTexture._FacesMapping = ['right', 'left', 'up', 'down', 'front', 'back'];
  59093. return EquiRectangularCubeTexture;
  59094. }(_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  59095. /***/ }),
  59096. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  59097. /*!**********************************************!*\
  59098. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  59099. \**********************************************/
  59100. /*! exports provided: HDRCubeTexture */
  59101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59102. "use strict";
  59103. __webpack_require__.r(__webpack_exports__);
  59104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  59105. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59106. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  59107. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  59108. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  59109. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59110. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59111. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  59112. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  59113. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  59114. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  59115. /**
  59116. * This represents a texture coming from an HDR input.
  59117. *
  59118. * The only supported format is currently panorama picture stored in RGBE format.
  59119. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59120. */
  59121. var HDRCubeTexture = /** @class */ (function (_super) {
  59122. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  59123. /**
  59124. * Instantiates an HDRTexture from the following parameters.
  59125. *
  59126. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59127. * @param scene The scene the texture will be used in
  59128. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59129. * @param noMipmap Forces to not generate the mipmap if true
  59130. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59131. * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  59132. * @param reserved Reserved flag for internal use.
  59133. */
  59134. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  59135. if (noMipmap === void 0) { noMipmap = false; }
  59136. if (generateHarmonics === void 0) { generateHarmonics = true; }
  59137. if (gammaSpace === void 0) { gammaSpace = false; }
  59138. if (reserved === void 0) { reserved = false; }
  59139. if (onLoad === void 0) { onLoad = null; }
  59140. if (onError === void 0) { onError = null; }
  59141. var _this = _super.call(this, scene) || this;
  59142. _this._generateHarmonics = true;
  59143. _this._onLoad = null;
  59144. _this._onError = null;
  59145. /**
  59146. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59147. */
  59148. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  59149. _this._isBlocking = true;
  59150. _this._rotationY = 0;
  59151. /**
  59152. * Gets or sets the center of the bounding box associated with the cube texture
  59153. * It must define where the camera used to render the texture was set
  59154. */
  59155. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  59156. if (!url) {
  59157. return _this;
  59158. }
  59159. _this.name = url;
  59160. _this.url = url;
  59161. _this.hasAlpha = false;
  59162. _this.isCube = true;
  59163. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  59164. _this._onLoad = onLoad;
  59165. _this._onError = onError;
  59166. _this.gammaSpace = gammaSpace;
  59167. _this._noMipmap = noMipmap;
  59168. _this._size = size;
  59169. _this._texture = _this._getFromCache(url, _this._noMipmap);
  59170. if (!_this._texture) {
  59171. if (!scene.useDelayedTextureLoading) {
  59172. _this.loadTexture();
  59173. }
  59174. else {
  59175. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  59176. }
  59177. }
  59178. else if (onLoad) {
  59179. if (_this._texture.isReady) {
  59180. _Misc_tools__WEBPACK_IMPORTED_MODULE_9__["Tools"].SetImmediate(function () { return onLoad(); });
  59181. }
  59182. else {
  59183. _this._texture.onLoadedObservable.add(onLoad);
  59184. }
  59185. }
  59186. return _this;
  59187. }
  59188. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  59189. /**
  59190. * Gets wether or not the texture is blocking during loading.
  59191. */
  59192. get: function () {
  59193. return this._isBlocking;
  59194. },
  59195. /**
  59196. * Sets wether or not the texture is blocking during loading.
  59197. */
  59198. set: function (value) {
  59199. this._isBlocking = value;
  59200. },
  59201. enumerable: true,
  59202. configurable: true
  59203. });
  59204. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  59205. /**
  59206. * Gets texture matrix rotation angle around Y axis radians.
  59207. */
  59208. get: function () {
  59209. return this._rotationY;
  59210. },
  59211. /**
  59212. * Sets texture matrix rotation angle around Y axis in radians.
  59213. */
  59214. set: function (value) {
  59215. this._rotationY = value;
  59216. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  59217. },
  59218. enumerable: true,
  59219. configurable: true
  59220. });
  59221. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  59222. get: function () {
  59223. return this._boundingBoxSize;
  59224. },
  59225. /**
  59226. * Gets or sets the size of the bounding box associated with the cube texture
  59227. * When defined, the cubemap will switch to local mode
  59228. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59229. * @example https://www.babylonjs-playground.com/#RNASML
  59230. */
  59231. set: function (value) {
  59232. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  59233. return;
  59234. }
  59235. this._boundingBoxSize = value;
  59236. var scene = this.getScene();
  59237. if (scene) {
  59238. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  59239. }
  59240. },
  59241. enumerable: true,
  59242. configurable: true
  59243. });
  59244. /**
  59245. * Get the current class name of the texture useful for serialization or dynamic coding.
  59246. * @returns "HDRCubeTexture"
  59247. */
  59248. HDRCubeTexture.prototype.getClassName = function () {
  59249. return "HDRCubeTexture";
  59250. };
  59251. /**
  59252. * Occurs when the file is raw .hdr file.
  59253. */
  59254. HDRCubeTexture.prototype.loadTexture = function () {
  59255. var _this = this;
  59256. var callback = function (buffer) {
  59257. _this.lodGenerationOffset = 0.0;
  59258. _this.lodGenerationScale = 0.8;
  59259. var scene = _this.getScene();
  59260. if (!scene) {
  59261. return null;
  59262. }
  59263. // Extract the raw linear data.
  59264. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  59265. // Generate harmonics if needed.
  59266. if (_this._generateHarmonics) {
  59267. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  59268. _this.sphericalPolynomial = sphericalPolynomial;
  59269. }
  59270. var results = [];
  59271. var byteArray = null;
  59272. // Push each faces.
  59273. for (var j = 0; j < 6; j++) {
  59274. // Create uintarray fallback.
  59275. if (!scene.getEngine().getCaps().textureFloat) {
  59276. // 3 channels of 1 bytes per pixel in bytes.
  59277. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  59278. byteArray = new Uint8Array(byteBuffer);
  59279. }
  59280. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  59281. // If special cases.
  59282. if (_this.gammaSpace || byteArray) {
  59283. for (var i = 0; i < _this._size * _this._size; i++) {
  59284. // Put in gamma space if requested.
  59285. if (_this.gammaSpace) {
  59286. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  59287. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  59288. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  59289. }
  59290. // Convert to int texture for fallback.
  59291. if (byteArray) {
  59292. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  59293. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  59294. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  59295. // May use luminance instead if the result is not accurate.
  59296. var max = Math.max(Math.max(r, g), b);
  59297. if (max > 255) {
  59298. var scale = 255 / max;
  59299. r *= scale;
  59300. g *= scale;
  59301. b *= scale;
  59302. }
  59303. byteArray[(i * 3) + 0] = r;
  59304. byteArray[(i * 3) + 1] = g;
  59305. byteArray[(i * 3) + 2] = b;
  59306. }
  59307. }
  59308. }
  59309. if (byteArray) {
  59310. results.push(byteArray);
  59311. }
  59312. else {
  59313. results.push(dataFace);
  59314. }
  59315. }
  59316. return results;
  59317. };
  59318. var scene = this.getScene();
  59319. if (scene) {
  59320. this._texture = scene.getEngine().createRawCubeTextureFromUrl(this.url, scene, this._size, _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat ? _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_FLOAT : _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_UNSIGNED_INT, this._noMipmap, callback, null, this._onLoad, this._onError);
  59321. }
  59322. };
  59323. HDRCubeTexture.prototype.clone = function () {
  59324. var scene = this.getScene();
  59325. if (!scene) {
  59326. return this;
  59327. }
  59328. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  59329. // Base texture
  59330. newTexture.level = this.level;
  59331. newTexture.wrapU = this.wrapU;
  59332. newTexture.wrapV = this.wrapV;
  59333. newTexture.coordinatesIndex = this.coordinatesIndex;
  59334. newTexture.coordinatesMode = this.coordinatesMode;
  59335. return newTexture;
  59336. };
  59337. // Methods
  59338. HDRCubeTexture.prototype.delayLoad = function () {
  59339. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  59340. return;
  59341. }
  59342. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  59343. this._texture = this._getFromCache(this.url, this._noMipmap);
  59344. if (!this._texture) {
  59345. this.loadTexture();
  59346. }
  59347. };
  59348. /**
  59349. * Get the texture reflection matrix used to rotate/transform the reflection.
  59350. * @returns the reflection matrix
  59351. */
  59352. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  59353. return this._textureMatrix;
  59354. };
  59355. /**
  59356. * Set the texture reflection matrix used to rotate/transform the reflection.
  59357. * @param value Define the reflection matrix to set
  59358. */
  59359. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  59360. var _this = this;
  59361. this._textureMatrix = value;
  59362. if (value.updateFlag === this._textureMatrix.updateFlag) {
  59363. return;
  59364. }
  59365. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  59366. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  59367. }
  59368. };
  59369. /**
  59370. * Parses a JSON representation of an HDR Texture in order to create the texture
  59371. * @param parsedTexture Define the JSON representation
  59372. * @param scene Define the scene the texture should be created in
  59373. * @param rootUrl Define the root url in case we need to load relative dependencies
  59374. * @returns the newly created texture after parsing
  59375. */
  59376. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  59377. var texture = null;
  59378. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  59379. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  59380. texture.name = parsedTexture.name;
  59381. texture.hasAlpha = parsedTexture.hasAlpha;
  59382. texture.level = parsedTexture.level;
  59383. texture.coordinatesMode = parsedTexture.coordinatesMode;
  59384. texture.isBlocking = parsedTexture.isBlocking;
  59385. }
  59386. if (texture) {
  59387. if (parsedTexture.boundingBoxPosition) {
  59388. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  59389. }
  59390. if (parsedTexture.boundingBoxSize) {
  59391. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  59392. }
  59393. if (parsedTexture.rotationY) {
  59394. texture.rotationY = parsedTexture.rotationY;
  59395. }
  59396. }
  59397. return texture;
  59398. };
  59399. HDRCubeTexture.prototype.serialize = function () {
  59400. if (!this.name) {
  59401. return null;
  59402. }
  59403. var serializationObject = {};
  59404. serializationObject.name = this.name;
  59405. serializationObject.hasAlpha = this.hasAlpha;
  59406. serializationObject.isCube = true;
  59407. serializationObject.level = this.level;
  59408. serializationObject.size = this._size;
  59409. serializationObject.coordinatesMode = this.coordinatesMode;
  59410. serializationObject.useInGammaSpace = this.gammaSpace;
  59411. serializationObject.generateHarmonics = this._generateHarmonics;
  59412. serializationObject.customType = "BABYLON.HDRCubeTexture";
  59413. serializationObject.noMipmap = this._noMipmap;
  59414. serializationObject.isBlocking = this._isBlocking;
  59415. serializationObject.rotationY = this._rotationY;
  59416. return serializationObject;
  59417. };
  59418. HDRCubeTexture._facesMapping = [
  59419. "right",
  59420. "left",
  59421. "up",
  59422. "down",
  59423. "front",
  59424. "back"
  59425. ];
  59426. return HDRCubeTexture;
  59427. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  59428. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  59429. /***/ }),
  59430. /***/ "./Materials/Textures/index.ts":
  59431. /*!*************************************!*\
  59432. !*** ./Materials/Textures/index.ts ***!
  59433. \*************************************/
  59434. /*! exports provided: BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  59435. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59436. "use strict";
  59437. __webpack_require__.r(__webpack_exports__);
  59438. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  59439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  59440. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  59441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  59442. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  59443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  59444. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  59445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  59446. /* harmony import */ var _equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./equiRectangularCubeTexture */ "./Materials/Textures/equiRectangularCubeTexture.ts");
  59447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_4__["EquiRectangularCubeTexture"]; });
  59448. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  59449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_5__["HDRCubeTexture"]; });
  59450. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  59451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_6__["InternalTexture"]; });
  59452. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  59453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_DDSTextureLoader"]; });
  59454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_ENVTextureLoader"]; });
  59455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_KTXTextureLoader"]; });
  59456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_TGATextureLoader"]; });
  59457. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  59458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]; });
  59459. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  59460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__["MultiRenderTarget"]; });
  59461. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  59462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTexture"]; });
  59463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["CustomProceduralTexture"]; });
  59464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["NoiseProceduralTexture"]; });
  59465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTextureSceneComponent"]; });
  59466. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  59467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__["RawCubeTexture"]; });
  59468. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  59469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_12__["RawTexture"]; });
  59470. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  59471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  59472. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  59473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_14__["RefractionTexture"]; });
  59474. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  59475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__["RenderTargetTexture"]; });
  59476. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  59477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_16__["Texture"]; });
  59478. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  59479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_17__["VideoTexture"]; });
  59480. /***/ }),
  59481. /***/ "./Materials/Textures/internalTexture.ts":
  59482. /*!***********************************************!*\
  59483. !*** ./Materials/Textures/internalTexture.ts ***!
  59484. \***********************************************/
  59485. /*! exports provided: InternalTexture */
  59486. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59487. "use strict";
  59488. __webpack_require__.r(__webpack_exports__);
  59489. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  59490. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  59491. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  59492. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59493. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  59494. /**
  59495. * Class used to store data associated with WebGL texture data for the engine
  59496. * This class should not be used directly
  59497. */
  59498. var InternalTexture = /** @class */ (function () {
  59499. /**
  59500. * Creates a new InternalTexture
  59501. * @param engine defines the engine to use
  59502. * @param dataSource defines the type of data that will be used
  59503. * @param delayAllocation if the texture allocation should be delayed (default: false)
  59504. */
  59505. function InternalTexture(engine, dataSource, delayAllocation) {
  59506. if (delayAllocation === void 0) { delayAllocation = false; }
  59507. /**
  59508. * Observable called when the texture is loaded
  59509. */
  59510. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  59511. // Private
  59512. /** @hidden */
  59513. this._invertVScale = false;
  59514. /** @hidden */
  59515. this._associatedChannel = -1;
  59516. /** @hidden */
  59517. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  59518. /** @hidden */
  59519. this._comparisonFunction = 0;
  59520. /** @hidden */
  59521. this._sphericalPolynomial = null;
  59522. /** @hidden */
  59523. this._lodGenerationScale = 0;
  59524. /** @hidden */
  59525. this._lodGenerationOffset = 0;
  59526. /** @hidden */
  59527. this._isRGBD = false;
  59528. /** @hidden */
  59529. this._references = 1;
  59530. this._engine = engine;
  59531. this._dataSource = dataSource;
  59532. if (!delayAllocation) {
  59533. this._webGLTexture = engine._createTexture();
  59534. }
  59535. }
  59536. /**
  59537. * Gets the Engine the texture belongs to.
  59538. * @returns The babylon engine
  59539. */
  59540. InternalTexture.prototype.getEngine = function () {
  59541. return this._engine;
  59542. };
  59543. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  59544. /**
  59545. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  59546. */
  59547. get: function () {
  59548. return this._dataSource;
  59549. },
  59550. enumerable: true,
  59551. configurable: true
  59552. });
  59553. /**
  59554. * Increments the number of references (ie. the number of Texture that point to it)
  59555. */
  59556. InternalTexture.prototype.incrementReferences = function () {
  59557. this._references++;
  59558. };
  59559. /**
  59560. * Change the size of the texture (not the size of the content)
  59561. * @param width defines the new width
  59562. * @param height defines the new height
  59563. * @param depth defines the new depth (1 by default)
  59564. */
  59565. InternalTexture.prototype.updateSize = function (width, height, depth) {
  59566. if (depth === void 0) { depth = 1; }
  59567. this.width = width;
  59568. this.height = height;
  59569. this.depth = depth;
  59570. this.baseWidth = width;
  59571. this.baseHeight = height;
  59572. this.baseDepth = depth;
  59573. this._size = width * height * depth;
  59574. };
  59575. /** @hidden */
  59576. InternalTexture.prototype._rebuild = function () {
  59577. var _this = this;
  59578. var proxy;
  59579. this.isReady = false;
  59580. this._cachedCoordinatesMode = null;
  59581. this._cachedWrapU = null;
  59582. this._cachedWrapV = null;
  59583. this._cachedAnisotropicFilteringLevel = null;
  59584. switch (this._dataSource) {
  59585. case InternalTexture.DATASOURCE_TEMP:
  59586. return;
  59587. case InternalTexture.DATASOURCE_URL:
  59588. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  59589. proxy._swapAndDie(_this);
  59590. _this.isReady = true;
  59591. }, null, this._buffer, undefined, this.format);
  59592. return;
  59593. case InternalTexture.DATASOURCE_RAW:
  59594. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  59595. proxy._swapAndDie(this);
  59596. this.isReady = true;
  59597. return;
  59598. case InternalTexture.DATASOURCE_RAW3D:
  59599. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  59600. proxy._swapAndDie(this);
  59601. this.isReady = true;
  59602. return;
  59603. case InternalTexture.DATASOURCE_DYNAMIC:
  59604. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  59605. proxy._swapAndDie(this);
  59606. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  59607. // The engine will make sure to update content so no need to flag it as isReady = true
  59608. return;
  59609. case InternalTexture.DATASOURCE_RENDERTARGET:
  59610. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  59611. options.generateDepthBuffer = this._generateDepthBuffer;
  59612. options.generateMipMaps = this.generateMipMaps;
  59613. options.generateStencilBuffer = this._generateStencilBuffer;
  59614. options.samplingMode = this.samplingMode;
  59615. options.type = this.type;
  59616. if (this.isCube) {
  59617. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  59618. }
  59619. else {
  59620. var size = {
  59621. width: this.width,
  59622. height: this.height
  59623. };
  59624. proxy = this._engine.createRenderTargetTexture(size, options);
  59625. }
  59626. proxy._swapAndDie(this);
  59627. this.isReady = true;
  59628. return;
  59629. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  59630. var depthTextureOptions = {
  59631. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  59632. comparisonFunction: this._comparisonFunction,
  59633. generateStencil: this._generateStencilBuffer,
  59634. isCube: this.isCube
  59635. };
  59636. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  59637. proxy._swapAndDie(this);
  59638. this.isReady = true;
  59639. return;
  59640. case InternalTexture.DATASOURCE_CUBE:
  59641. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  59642. proxy._swapAndDie(_this);
  59643. _this.isReady = true;
  59644. }, null, this.format, this._extension);
  59645. return;
  59646. case InternalTexture.DATASOURCE_CUBERAW:
  59647. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  59648. proxy._swapAndDie(this);
  59649. this.isReady = true;
  59650. return;
  59651. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  59652. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  59653. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  59654. proxy._swapAndDie(_this);
  59655. _this.isReady = true;
  59656. });
  59657. return;
  59658. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  59659. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  59660. if (proxy) {
  59661. proxy._swapAndDie(_this);
  59662. }
  59663. _this.isReady = true;
  59664. }, null, this.format, this._extension);
  59665. proxy._sphericalPolynomial = this._sphericalPolynomial;
  59666. return;
  59667. }
  59668. };
  59669. /** @hidden */
  59670. InternalTexture.prototype._swapAndDie = function (target) {
  59671. target._webGLTexture = this._webGLTexture;
  59672. target._isRGBD = this._isRGBD;
  59673. if (this._framebuffer) {
  59674. target._framebuffer = this._framebuffer;
  59675. }
  59676. if (this._depthStencilBuffer) {
  59677. target._depthStencilBuffer = this._depthStencilBuffer;
  59678. }
  59679. if (this._lodTextureHigh) {
  59680. if (target._lodTextureHigh) {
  59681. target._lodTextureHigh.dispose();
  59682. }
  59683. target._lodTextureHigh = this._lodTextureHigh;
  59684. }
  59685. if (this._lodTextureMid) {
  59686. if (target._lodTextureMid) {
  59687. target._lodTextureMid.dispose();
  59688. }
  59689. target._lodTextureMid = this._lodTextureMid;
  59690. }
  59691. if (this._lodTextureLow) {
  59692. if (target._lodTextureLow) {
  59693. target._lodTextureLow.dispose();
  59694. }
  59695. target._lodTextureLow = this._lodTextureLow;
  59696. }
  59697. var cache = this._engine.getLoadedTexturesCache();
  59698. var index = cache.indexOf(this);
  59699. if (index !== -1) {
  59700. cache.splice(index, 1);
  59701. }
  59702. };
  59703. /**
  59704. * Dispose the current allocated resources
  59705. */
  59706. InternalTexture.prototype.dispose = function () {
  59707. if (!this._webGLTexture) {
  59708. return;
  59709. }
  59710. this._references--;
  59711. if (this._references === 0) {
  59712. this._engine._releaseTexture(this);
  59713. this._webGLTexture = null;
  59714. }
  59715. };
  59716. /** hidden */
  59717. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  59718. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("environmentTextureTools");
  59719. };
  59720. /**
  59721. * The source of the texture data is unknown
  59722. */
  59723. InternalTexture.DATASOURCE_UNKNOWN = 0;
  59724. /**
  59725. * Texture data comes from an URL
  59726. */
  59727. InternalTexture.DATASOURCE_URL = 1;
  59728. /**
  59729. * Texture data is only used for temporary storage
  59730. */
  59731. InternalTexture.DATASOURCE_TEMP = 2;
  59732. /**
  59733. * Texture data comes from raw data (ArrayBuffer)
  59734. */
  59735. InternalTexture.DATASOURCE_RAW = 3;
  59736. /**
  59737. * Texture content is dynamic (video or dynamic texture)
  59738. */
  59739. InternalTexture.DATASOURCE_DYNAMIC = 4;
  59740. /**
  59741. * Texture content is generated by rendering to it
  59742. */
  59743. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  59744. /**
  59745. * Texture content is part of a multi render target process
  59746. */
  59747. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  59748. /**
  59749. * Texture data comes from a cube data file
  59750. */
  59751. InternalTexture.DATASOURCE_CUBE = 7;
  59752. /**
  59753. * Texture data comes from a raw cube data
  59754. */
  59755. InternalTexture.DATASOURCE_CUBERAW = 8;
  59756. /**
  59757. * Texture data come from a prefiltered cube data file
  59758. */
  59759. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  59760. /**
  59761. * Texture content is raw 3D data
  59762. */
  59763. InternalTexture.DATASOURCE_RAW3D = 10;
  59764. /**
  59765. * Texture content is a depth texture
  59766. */
  59767. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  59768. /**
  59769. * Texture data comes from a raw cube data encoded with RGBD
  59770. */
  59771. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  59772. return InternalTexture;
  59773. }());
  59774. /***/ }),
  59775. /***/ "./Materials/Textures/mirrorTexture.ts":
  59776. /*!*********************************************!*\
  59777. !*** ./Materials/Textures/mirrorTexture.ts ***!
  59778. \*********************************************/
  59779. /*! exports provided: MirrorTexture */
  59780. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59781. "use strict";
  59782. __webpack_require__.r(__webpack_exports__);
  59783. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  59784. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59785. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  59786. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59787. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  59788. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  59789. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59790. /**
  59791. * Mirror texture can be used to simulate the view from a mirror in a scene.
  59792. * It will dynamically be rendered every frame to adapt to the camera point of view.
  59793. * You can then easily use it as a reflectionTexture on a flat surface.
  59794. * In case the surface is not a plane, please consider relying on reflection probes.
  59795. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  59796. */
  59797. var MirrorTexture = /** @class */ (function (_super) {
  59798. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  59799. /**
  59800. * Instantiates a Mirror Texture.
  59801. * Mirror texture can be used to simulate the view from a mirror in a scene.
  59802. * It will dynamically be rendered every frame to adapt to the camera point of view.
  59803. * You can then easily use it as a reflectionTexture on a flat surface.
  59804. * In case the surface is not a plane, please consider relying on reflection probes.
  59805. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  59806. * @param name
  59807. * @param size
  59808. * @param scene
  59809. * @param generateMipMaps
  59810. * @param type
  59811. * @param samplingMode
  59812. * @param generateDepthBuffer
  59813. */
  59814. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  59815. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59816. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  59817. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  59818. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  59819. _this.scene = scene;
  59820. /**
  59821. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  59822. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  59823. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  59824. */
  59825. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  59826. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  59827. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  59828. _this._adaptiveBlurKernel = 0;
  59829. _this._blurKernelX = 0;
  59830. _this._blurKernelY = 0;
  59831. _this._blurRatio = 1.0;
  59832. _this.ignoreCameraViewport = true;
  59833. _this._updateGammaSpace();
  59834. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  59835. _this._updateGammaSpace;
  59836. });
  59837. _this.onBeforeRenderObservable.add(function () {
  59838. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  59839. _this._savedViewMatrix = scene.getViewMatrix();
  59840. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  59841. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  59842. scene.clipPlane = _this.mirrorPlane;
  59843. scene.getEngine().cullBackFaces = false;
  59844. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  59845. });
  59846. _this.onAfterRenderObservable.add(function () {
  59847. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  59848. scene.getEngine().cullBackFaces = true;
  59849. scene._mirroredCameraPosition = null;
  59850. delete scene.clipPlane;
  59851. });
  59852. return _this;
  59853. }
  59854. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  59855. get: function () {
  59856. return this._blurRatio;
  59857. },
  59858. /**
  59859. * Define the blur ratio used to blur the reflection if needed.
  59860. */
  59861. set: function (value) {
  59862. if (this._blurRatio === value) {
  59863. return;
  59864. }
  59865. this._blurRatio = value;
  59866. this._preparePostProcesses();
  59867. },
  59868. enumerable: true,
  59869. configurable: true
  59870. });
  59871. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  59872. /**
  59873. * Define the adaptive blur kernel used to blur the reflection if needed.
  59874. * This will autocompute the closest best match for the `blurKernel`
  59875. */
  59876. set: function (value) {
  59877. this._adaptiveBlurKernel = value;
  59878. this._autoComputeBlurKernel();
  59879. },
  59880. enumerable: true,
  59881. configurable: true
  59882. });
  59883. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  59884. /**
  59885. * Define the blur kernel used to blur the reflection if needed.
  59886. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  59887. */
  59888. set: function (value) {
  59889. this.blurKernelX = value;
  59890. this.blurKernelY = value;
  59891. },
  59892. enumerable: true,
  59893. configurable: true
  59894. });
  59895. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  59896. get: function () {
  59897. return this._blurKernelX;
  59898. },
  59899. /**
  59900. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  59901. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  59902. */
  59903. set: function (value) {
  59904. if (this._blurKernelX === value) {
  59905. return;
  59906. }
  59907. this._blurKernelX = value;
  59908. this._preparePostProcesses();
  59909. },
  59910. enumerable: true,
  59911. configurable: true
  59912. });
  59913. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  59914. get: function () {
  59915. return this._blurKernelY;
  59916. },
  59917. /**
  59918. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  59919. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  59920. */
  59921. set: function (value) {
  59922. if (this._blurKernelY === value) {
  59923. return;
  59924. }
  59925. this._blurKernelY = value;
  59926. this._preparePostProcesses();
  59927. },
  59928. enumerable: true,
  59929. configurable: true
  59930. });
  59931. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  59932. var engine = this.getScene().getEngine();
  59933. var dw = this.getRenderWidth() / engine.getRenderWidth();
  59934. var dh = this.getRenderHeight() / engine.getRenderHeight();
  59935. this.blurKernelX = this._adaptiveBlurKernel * dw;
  59936. this.blurKernelY = this._adaptiveBlurKernel * dh;
  59937. };
  59938. MirrorTexture.prototype._onRatioRescale = function () {
  59939. if (this._sizeRatio) {
  59940. this.resize(this._initialSizeParameter);
  59941. if (!this._adaptiveBlurKernel) {
  59942. this._preparePostProcesses();
  59943. }
  59944. }
  59945. if (this._adaptiveBlurKernel) {
  59946. this._autoComputeBlurKernel();
  59947. }
  59948. };
  59949. MirrorTexture.prototype._updateGammaSpace = function () {
  59950. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  59951. };
  59952. MirrorTexture.prototype._preparePostProcesses = function () {
  59953. this.clearPostProcesses(true);
  59954. if (this._blurKernelX && this._blurKernelY) {
  59955. var engine = this.getScene().getEngine();
  59956. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  59957. this._blurX = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]("horizontal blur", new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1.0, 0), this._blurKernelX, this._blurRatio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, textureType);
  59958. this._blurX.autoClear = false;
  59959. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  59960. this._blurX.inputTexture = this._texture;
  59961. }
  59962. else {
  59963. this._blurX.alwaysForcePOT = true;
  59964. }
  59965. this._blurY = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]("vertical blur", new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 1.0), this._blurKernelY, this._blurRatio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, textureType);
  59966. this._blurY.autoClear = false;
  59967. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  59968. this.addPostProcess(this._blurX);
  59969. this.addPostProcess(this._blurY);
  59970. }
  59971. else {
  59972. if (this._blurY) {
  59973. this.removePostProcess(this._blurY);
  59974. this._blurY.dispose();
  59975. this._blurY = null;
  59976. }
  59977. if (this._blurX) {
  59978. this.removePostProcess(this._blurX);
  59979. this._blurX.dispose();
  59980. this._blurX = null;
  59981. }
  59982. }
  59983. };
  59984. /**
  59985. * Clone the mirror texture.
  59986. * @returns the cloned texture
  59987. */
  59988. MirrorTexture.prototype.clone = function () {
  59989. var scene = this.getScene();
  59990. if (!scene) {
  59991. return this;
  59992. }
  59993. var textureSize = this.getSize();
  59994. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  59995. // Base texture
  59996. newTexture.hasAlpha = this.hasAlpha;
  59997. newTexture.level = this.level;
  59998. // Mirror Texture
  59999. newTexture.mirrorPlane = this.mirrorPlane.clone();
  60000. if (this.renderList) {
  60001. newTexture.renderList = this.renderList.slice(0);
  60002. }
  60003. return newTexture;
  60004. };
  60005. /**
  60006. * Serialize the texture to a JSON representation you could use in Parse later on
  60007. * @returns the serialized JSON representation
  60008. */
  60009. MirrorTexture.prototype.serialize = function () {
  60010. if (!this.name) {
  60011. return null;
  60012. }
  60013. var serializationObject = _super.prototype.serialize.call(this);
  60014. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  60015. return serializationObject;
  60016. };
  60017. /**
  60018. * Dispose the texture and release its associated resources.
  60019. */
  60020. MirrorTexture.prototype.dispose = function () {
  60021. _super.prototype.dispose.call(this);
  60022. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  60023. };
  60024. return MirrorTexture;
  60025. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  60026. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  60027. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  60028. };
  60029. /***/ }),
  60030. /***/ "./Materials/Textures/multiRenderTarget.ts":
  60031. /*!*************************************************!*\
  60032. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  60033. \*************************************************/
  60034. /*! exports provided: MultiRenderTarget */
  60035. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60036. "use strict";
  60037. __webpack_require__.r(__webpack_exports__);
  60038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  60039. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60040. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60041. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  60042. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60043. /**
  60044. * A multi render target, like a render target provides the ability to render to a texture.
  60045. * Unlike the render target, it can render to several draw buffers in one draw.
  60046. * This is specially interesting in deferred rendering or for any effects requiring more than
  60047. * just one color from a single pass.
  60048. */
  60049. var MultiRenderTarget = /** @class */ (function (_super) {
  60050. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  60051. /**
  60052. * Instantiate a new multi render target texture.
  60053. * A multi render target, like a render target provides the ability to render to a texture.
  60054. * Unlike the render target, it can render to several draw buffers in one draw.
  60055. * This is specially interesting in deferred rendering or for any effects requiring more than
  60056. * just one color from a single pass.
  60057. * @param name Define the name of the texture
  60058. * @param size Define the size of the buffers to render to
  60059. * @param count Define the number of target we are rendering into
  60060. * @param scene Define the scene the texture belongs to
  60061. * @param options Define the options used to create the multi render target
  60062. */
  60063. function MultiRenderTarget(name, size, count, scene, options) {
  60064. var _this = this;
  60065. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  60066. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  60067. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  60068. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  60069. _this._engine = scene.getEngine();
  60070. if (!_this.isSupported) {
  60071. _this.dispose();
  60072. return;
  60073. }
  60074. var types = [];
  60075. var samplingModes = [];
  60076. for (var i = 0; i < count; i++) {
  60077. if (options && options.types && options.types[i] !== undefined) {
  60078. types.push(options.types[i]);
  60079. }
  60080. else {
  60081. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  60082. }
  60083. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  60084. samplingModes.push(options.samplingModes[i]);
  60085. }
  60086. else {
  60087. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  60088. }
  60089. }
  60090. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  60091. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  60092. _this._size = size;
  60093. _this._multiRenderTargetOptions = {
  60094. samplingModes: samplingModes,
  60095. generateMipMaps: generateMipMaps,
  60096. generateDepthBuffer: generateDepthBuffer,
  60097. generateStencilBuffer: generateStencilBuffer,
  60098. generateDepthTexture: generateDepthTexture,
  60099. types: types,
  60100. textureCount: count
  60101. };
  60102. _this._createInternalTextures();
  60103. _this._createTextures();
  60104. return _this;
  60105. }
  60106. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  60107. /**
  60108. * Get if draw buffers are currently supported by the used hardware and browser.
  60109. */
  60110. get: function () {
  60111. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  60112. },
  60113. enumerable: true,
  60114. configurable: true
  60115. });
  60116. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  60117. /**
  60118. * Get the list of textures generated by the multi render target.
  60119. */
  60120. get: function () {
  60121. return this._textures;
  60122. },
  60123. enumerable: true,
  60124. configurable: true
  60125. });
  60126. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  60127. /**
  60128. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  60129. */
  60130. get: function () {
  60131. return this._textures[this._textures.length - 1];
  60132. },
  60133. enumerable: true,
  60134. configurable: true
  60135. });
  60136. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  60137. /**
  60138. * Set the wrapping mode on U of all the textures we are rendering to.
  60139. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  60140. */
  60141. set: function (wrap) {
  60142. if (this._textures) {
  60143. for (var i = 0; i < this._textures.length; i++) {
  60144. this._textures[i].wrapU = wrap;
  60145. }
  60146. }
  60147. },
  60148. enumerable: true,
  60149. configurable: true
  60150. });
  60151. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  60152. /**
  60153. * Set the wrapping mode on V of all the textures we are rendering to.
  60154. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  60155. */
  60156. set: function (wrap) {
  60157. if (this._textures) {
  60158. for (var i = 0; i < this._textures.length; i++) {
  60159. this._textures[i].wrapV = wrap;
  60160. }
  60161. }
  60162. },
  60163. enumerable: true,
  60164. configurable: true
  60165. });
  60166. /** @hidden */
  60167. MultiRenderTarget.prototype._rebuild = function () {
  60168. this.releaseInternalTextures();
  60169. this._createInternalTextures();
  60170. for (var i = 0; i < this._internalTextures.length; i++) {
  60171. var texture = this._textures[i];
  60172. texture._texture = this._internalTextures[i];
  60173. }
  60174. // Keeps references to frame buffer and stencil/depth buffer
  60175. this._texture = this._internalTextures[0];
  60176. };
  60177. MultiRenderTarget.prototype._createInternalTextures = function () {
  60178. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  60179. };
  60180. MultiRenderTarget.prototype._createTextures = function () {
  60181. this._textures = [];
  60182. for (var i = 0; i < this._internalTextures.length; i++) {
  60183. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  60184. texture._texture = this._internalTextures[i];
  60185. this._textures.push(texture);
  60186. }
  60187. // Keeps references to frame buffer and stencil/depth buffer
  60188. this._texture = this._internalTextures[0];
  60189. };
  60190. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  60191. /**
  60192. * Define the number of samples used if MSAA is enabled.
  60193. */
  60194. get: function () {
  60195. return this._samples;
  60196. },
  60197. set: function (value) {
  60198. if (this._samples === value) {
  60199. return;
  60200. }
  60201. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  60202. },
  60203. enumerable: true,
  60204. configurable: true
  60205. });
  60206. /**
  60207. * Resize all the textures in the multi render target.
  60208. * Be carrefull as it will recreate all the data in the new texture.
  60209. * @param size Define the new size
  60210. */
  60211. MultiRenderTarget.prototype.resize = function (size) {
  60212. this.releaseInternalTextures();
  60213. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  60214. this._createInternalTextures();
  60215. };
  60216. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  60217. var _this = this;
  60218. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  60219. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  60220. });
  60221. };
  60222. /**
  60223. * Dispose the render targets and their associated resources
  60224. */
  60225. MultiRenderTarget.prototype.dispose = function () {
  60226. this.releaseInternalTextures();
  60227. _super.prototype.dispose.call(this);
  60228. };
  60229. /**
  60230. * Release all the underlying texture used as draw buffers.
  60231. */
  60232. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  60233. if (!this._internalTextures) {
  60234. return;
  60235. }
  60236. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  60237. if (this._internalTextures[i] !== undefined) {
  60238. this._internalTextures[i].dispose();
  60239. this._internalTextures.splice(i, 1);
  60240. }
  60241. }
  60242. };
  60243. return MultiRenderTarget;
  60244. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  60245. /***/ }),
  60246. /***/ "./Materials/Textures/rawCubeTexture.ts":
  60247. /*!**********************************************!*\
  60248. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  60249. \**********************************************/
  60250. /*! exports provided: RawCubeTexture */
  60251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60252. "use strict";
  60253. __webpack_require__.r(__webpack_exports__);
  60254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  60255. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60256. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  60257. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  60258. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  60259. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  60260. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60261. /**
  60262. * Raw cube texture where the raw buffers are passed in
  60263. */
  60264. var RawCubeTexture = /** @class */ (function (_super) {
  60265. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  60266. /**
  60267. * Creates a cube texture where the raw buffers are passed in.
  60268. * @param scene defines the scene the texture is attached to
  60269. * @param data defines the array of data to use to create each face
  60270. * @param size defines the size of the textures
  60271. * @param format defines the format of the data
  60272. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60273. * @param generateMipMaps defines if the engine should generate the mip levels
  60274. * @param invertY defines if data must be stored with Y axis inverted
  60275. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60276. * @param compression defines the compression used (null by default)
  60277. */
  60278. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  60279. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  60280. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60281. if (generateMipMaps === void 0) { generateMipMaps = false; }
  60282. if (invertY === void 0) { invertY = false; }
  60283. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60284. if (compression === void 0) { compression = null; }
  60285. var _this = _super.call(this, "", scene) || this;
  60286. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  60287. return _this;
  60288. }
  60289. /**
  60290. * Updates the raw cube texture.
  60291. * @param data defines the data to store
  60292. * @param format defines the data format
  60293. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60294. * @param invertY defines if data must be stored with Y axis inverted
  60295. * @param compression defines the compression used (null by default)
  60296. * @param level defines which level of the texture to update
  60297. */
  60298. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  60299. if (compression === void 0) { compression = null; }
  60300. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  60301. };
  60302. /**
  60303. * Updates a raw cube texture with RGBD encoded data.
  60304. * @param data defines the array of data [mipmap][face] to use to create each face
  60305. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60306. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60307. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60308. * @returns a promsie that resolves when the operation is complete
  60309. */
  60310. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  60311. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  60312. if (lodScale === void 0) { lodScale = 0.8; }
  60313. if (lodOffset === void 0) { lodOffset = 0; }
  60314. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  60315. };
  60316. /**
  60317. * Clones the raw cube texture.
  60318. * @return a new cube texture
  60319. */
  60320. RawCubeTexture.prototype.clone = function () {
  60321. var _this = this;
  60322. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  60323. var scene = _this.getScene();
  60324. var internalTexture = _this._texture;
  60325. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  60326. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  60327. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  60328. }
  60329. return texture;
  60330. }, this);
  60331. };
  60332. /** @hidden */
  60333. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  60334. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  60335. internalTexture._bufferViewArrayArray = data;
  60336. internalTexture._lodGenerationScale = lodScale;
  60337. internalTexture._lodGenerationOffset = lodOffset;
  60338. internalTexture._sphericalPolynomial = sphericalPolynomial;
  60339. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  60340. internalTexture.isReady = true;
  60341. });
  60342. };
  60343. return RawCubeTexture;
  60344. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  60345. /***/ }),
  60346. /***/ "./Materials/Textures/rawTexture.ts":
  60347. /*!******************************************!*\
  60348. !*** ./Materials/Textures/rawTexture.ts ***!
  60349. \******************************************/
  60350. /*! exports provided: RawTexture */
  60351. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60352. "use strict";
  60353. __webpack_require__.r(__webpack_exports__);
  60354. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  60355. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60356. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60357. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60358. /**
  60359. * Raw texture can help creating a texture directly from an array of data.
  60360. * This can be super useful if you either get the data from an uncompressed source or
  60361. * if you wish to create your texture pixel by pixel.
  60362. */
  60363. var RawTexture = /** @class */ (function (_super) {
  60364. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  60365. /**
  60366. * Instantiates a new RawTexture.
  60367. * Raw texture can help creating a texture directly from an array of data.
  60368. * This can be super useful if you either get the data from an uncompressed source or
  60369. * if you wish to create your texture pixel by pixel.
  60370. * @param data define the array of data to use to create the texture
  60371. * @param width define the width of the texture
  60372. * @param height define the height of the texture
  60373. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  60374. * @param scene define the scene the texture belongs to
  60375. * @param generateMipMaps define whether mip maps should be generated or not
  60376. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60377. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60378. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  60379. */
  60380. function RawTexture(data, width, height,
  60381. /**
  60382. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  60383. */
  60384. format, scene, generateMipMaps, invertY, samplingMode, type) {
  60385. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60386. if (invertY === void 0) { invertY = false; }
  60387. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60388. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60389. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  60390. _this.format = format;
  60391. _this._engine = scene.getEngine();
  60392. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  60393. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  60394. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  60395. return _this;
  60396. }
  60397. /**
  60398. * Updates the texture underlying data.
  60399. * @param data Define the new data of the texture
  60400. */
  60401. RawTexture.prototype.update = function (data) {
  60402. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  60403. };
  60404. /**
  60405. * Creates a luminance texture from some data.
  60406. * @param data Define the texture data
  60407. * @param width Define the width of the texture
  60408. * @param height Define the height of the texture
  60409. * @param scene Define the scene the texture belongs to
  60410. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60411. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60412. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60413. * @returns the luminance texture
  60414. */
  60415. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  60416. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60417. if (invertY === void 0) { invertY = false; }
  60418. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60419. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  60420. };
  60421. /**
  60422. * Creates a luminance alpha texture from some data.
  60423. * @param data Define the texture data
  60424. * @param width Define the width of the texture
  60425. * @param height Define the height of the texture
  60426. * @param scene Define the scene the texture belongs to
  60427. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60428. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60429. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60430. * @returns the luminance alpha texture
  60431. */
  60432. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  60433. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60434. if (invertY === void 0) { invertY = false; }
  60435. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60436. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  60437. };
  60438. /**
  60439. * Creates an alpha texture from some data.
  60440. * @param data Define the texture data
  60441. * @param width Define the width of the texture
  60442. * @param height Define the height of the texture
  60443. * @param scene Define the scene the texture belongs to
  60444. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60445. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60446. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60447. * @returns the alpha texture
  60448. */
  60449. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  60450. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60451. if (invertY === void 0) { invertY = false; }
  60452. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60453. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  60454. };
  60455. /**
  60456. * Creates a RGB texture from some data.
  60457. * @param data Define the texture data
  60458. * @param width Define the width of the texture
  60459. * @param height Define the height of the texture
  60460. * @param scene Define the scene the texture belongs to
  60461. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60462. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60463. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60464. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  60465. * @returns the RGB alpha texture
  60466. */
  60467. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  60468. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60469. if (invertY === void 0) { invertY = false; }
  60470. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60471. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60472. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  60473. };
  60474. /**
  60475. * Creates a RGBA texture from some data.
  60476. * @param data Define the texture data
  60477. * @param width Define the width of the texture
  60478. * @param height Define the height of the texture
  60479. * @param scene Define the scene the texture belongs to
  60480. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60481. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60482. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60483. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  60484. * @returns the RGBA texture
  60485. */
  60486. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  60487. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60488. if (invertY === void 0) { invertY = false; }
  60489. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60490. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60491. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  60492. };
  60493. /**
  60494. * Creates a R texture from some data.
  60495. * @param data Define the texture data
  60496. * @param width Define the width of the texture
  60497. * @param height Define the height of the texture
  60498. * @param scene Define the scene the texture belongs to
  60499. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60500. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60501. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60502. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  60503. * @returns the R texture
  60504. */
  60505. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  60506. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60507. if (invertY === void 0) { invertY = false; }
  60508. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  60509. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  60510. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  60511. };
  60512. return RawTexture;
  60513. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  60514. /***/ }),
  60515. /***/ "./Materials/Textures/rawTexture3D.ts":
  60516. /*!********************************************!*\
  60517. !*** ./Materials/Textures/rawTexture3D.ts ***!
  60518. \********************************************/
  60519. /*! exports provided: RawTexture3D */
  60520. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60521. "use strict";
  60522. __webpack_require__.r(__webpack_exports__);
  60523. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  60524. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60525. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60526. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60527. /**
  60528. * Class used to store 3D textures containing user data
  60529. */
  60530. var RawTexture3D = /** @class */ (function (_super) {
  60531. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  60532. /**
  60533. * Create a new RawTexture3D
  60534. * @param data defines the data of the texture
  60535. * @param width defines the width of the texture
  60536. * @param height defines the height of the texture
  60537. * @param depth defines the depth of the texture
  60538. * @param format defines the texture format to use
  60539. * @param scene defines the hosting scene
  60540. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60541. * @param invertY defines if texture must be stored with Y axis inverted
  60542. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60543. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60544. */
  60545. function RawTexture3D(data, width, height, depth,
  60546. /** Gets or sets the texture format to use */
  60547. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  60548. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60549. if (invertY === void 0) { invertY = false; }
  60550. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  60551. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60552. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  60553. _this.format = format;
  60554. _this._engine = scene.getEngine();
  60555. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  60556. _this.is3D = true;
  60557. return _this;
  60558. }
  60559. /**
  60560. * Update the texture with new data
  60561. * @param data defines the data to store in the texture
  60562. */
  60563. RawTexture3D.prototype.update = function (data) {
  60564. if (!this._texture) {
  60565. return;
  60566. }
  60567. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  60568. };
  60569. return RawTexture3D;
  60570. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  60571. /***/ }),
  60572. /***/ "./Materials/Textures/refractionTexture.ts":
  60573. /*!*************************************************!*\
  60574. !*** ./Materials/Textures/refractionTexture.ts ***!
  60575. \*************************************************/
  60576. /*! exports provided: RefractionTexture */
  60577. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60578. "use strict";
  60579. __webpack_require__.r(__webpack_exports__);
  60580. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  60581. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60582. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  60583. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  60584. /**
  60585. * Creates a refraction texture used by refraction channel of the standard material.
  60586. * It is like a mirror but to see through a material.
  60587. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60588. */
  60589. var RefractionTexture = /** @class */ (function (_super) {
  60590. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  60591. /**
  60592. * Creates a refraction texture used by refraction channel of the standard material.
  60593. * It is like a mirror but to see through a material.
  60594. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60595. * @param name Define the texture name
  60596. * @param size Define the size of the underlying texture
  60597. * @param scene Define the scene the refraction belongs to
  60598. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60599. */
  60600. function RefractionTexture(name, size, scene, generateMipMaps) {
  60601. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  60602. /**
  60603. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60604. * It is possible to directly set the refractionPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  60605. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60606. */
  60607. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  60608. /**
  60609. * Define how deep under the surface we should see.
  60610. */
  60611. _this.depth = 2.0;
  60612. _this.onBeforeRenderObservable.add(function () {
  60613. scene.clipPlane = _this.refractionPlane;
  60614. });
  60615. _this.onAfterRenderObservable.add(function () {
  60616. delete scene.clipPlane;
  60617. });
  60618. return _this;
  60619. }
  60620. /**
  60621. * Clone the refraction texture.
  60622. * @returns the cloned texture
  60623. */
  60624. RefractionTexture.prototype.clone = function () {
  60625. var scene = this.getScene();
  60626. if (!scene) {
  60627. return this;
  60628. }
  60629. var textureSize = this.getSize();
  60630. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  60631. // Base texture
  60632. newTexture.hasAlpha = this.hasAlpha;
  60633. newTexture.level = this.level;
  60634. // Refraction Texture
  60635. newTexture.refractionPlane = this.refractionPlane.clone();
  60636. if (this.renderList) {
  60637. newTexture.renderList = this.renderList.slice(0);
  60638. }
  60639. newTexture.depth = this.depth;
  60640. return newTexture;
  60641. };
  60642. /**
  60643. * Serialize the texture to a JSON representation you could use in Parse later on
  60644. * @returns the serialized JSON representation
  60645. */
  60646. RefractionTexture.prototype.serialize = function () {
  60647. if (!this.name) {
  60648. return null;
  60649. }
  60650. var serializationObject = _super.prototype.serialize.call(this);
  60651. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  60652. serializationObject.depth = this.depth;
  60653. return serializationObject;
  60654. };
  60655. return RefractionTexture;
  60656. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  60657. /***/ }),
  60658. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  60659. /*!***********************************************************!*\
  60660. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  60661. \***********************************************************/
  60662. /*! exports provided: RenderTargetCreationOptions */
  60663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60664. "use strict";
  60665. __webpack_require__.r(__webpack_exports__);
  60666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  60667. /**
  60668. * Define options used to create a render target texture
  60669. */
  60670. var RenderTargetCreationOptions = /** @class */ (function () {
  60671. function RenderTargetCreationOptions() {
  60672. }
  60673. return RenderTargetCreationOptions;
  60674. }());
  60675. /***/ }),
  60676. /***/ "./Materials/Textures/renderTargetTexture.ts":
  60677. /*!***************************************************!*\
  60678. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  60679. \***************************************************/
  60680. /*! exports provided: RenderTargetTexture */
  60681. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60682. "use strict";
  60683. __webpack_require__.r(__webpack_exports__);
  60684. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  60685. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60686. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  60687. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  60688. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  60689. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60690. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  60691. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  60692. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60693. /**
  60694. * This Helps creating a texture that will be created from a camera in your scene.
  60695. * It is basically a dynamic texture that could be used to create special effects for instance.
  60696. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  60697. */
  60698. var RenderTargetTexture = /** @class */ (function (_super) {
  60699. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  60700. /**
  60701. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  60702. * or used a shadow, depth texture...
  60703. * @param name The friendly name of the texture
  60704. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  60705. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  60706. * @param generateMipMaps True if mip maps need to be generated after render.
  60707. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  60708. * @param type The type of the buffer in the RTT (int, half float, float...)
  60709. * @param isCube True if a cube texture needs to be created
  60710. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  60711. * @param generateDepthBuffer True to generate a depth buffer
  60712. * @param generateStencilBuffer True to generate a stencil buffer
  60713. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  60714. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  60715. * @param delayAllocation if the texture allocation should be delayed (default: false)
  60716. */
  60717. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  60718. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  60719. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60720. if (isCube === void 0) { isCube = false; }
  60721. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  60722. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  60723. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  60724. if (isMulti === void 0) { isMulti = false; }
  60725. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  60726. if (delayAllocation === void 0) { delayAllocation = false; }
  60727. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  60728. _this.isCube = isCube;
  60729. /**
  60730. * Define if particles should be rendered in your texture.
  60731. */
  60732. _this.renderParticles = true;
  60733. /**
  60734. * Define if sprites should be rendered in your texture.
  60735. */
  60736. _this.renderSprites = false;
  60737. /**
  60738. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  60739. */
  60740. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  60741. /**
  60742. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  60743. */
  60744. _this.ignoreCameraViewport = false;
  60745. /**
  60746. * An event triggered when the texture is unbind.
  60747. */
  60748. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60749. /**
  60750. * An event triggered when the texture is unbind.
  60751. */
  60752. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60753. /**
  60754. * An event triggered before rendering the texture
  60755. */
  60756. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60757. /**
  60758. * An event triggered after rendering the texture
  60759. */
  60760. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60761. /**
  60762. * An event triggered after the texture clear
  60763. */
  60764. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60765. _this._currentRefreshId = -1;
  60766. _this._refreshRate = 1;
  60767. _this._samples = 1;
  60768. /**
  60769. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  60770. * It must define where the camera used to render the texture is set
  60771. */
  60772. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  60773. scene = _this.getScene();
  60774. if (!scene) {
  60775. return _this;
  60776. }
  60777. _this.renderList = new Array();
  60778. _this._engine = scene.getEngine();
  60779. _this.name = name;
  60780. _this.isRenderTarget = true;
  60781. _this._initialSizeParameter = size;
  60782. _this._processSizeParameter(size);
  60783. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  60784. });
  60785. _this._generateMipMaps = generateMipMaps ? true : false;
  60786. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  60787. // Rendering groups
  60788. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  60789. _this._renderingManager._useSceneAutoClearSetup = true;
  60790. if (isMulti) {
  60791. return _this;
  60792. }
  60793. _this._renderTargetOptions = {
  60794. generateMipMaps: generateMipMaps,
  60795. type: type,
  60796. format: format,
  60797. samplingMode: samplingMode,
  60798. generateDepthBuffer: generateDepthBuffer,
  60799. generateStencilBuffer: generateStencilBuffer
  60800. };
  60801. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  60802. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  60803. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  60804. }
  60805. if (!delayAllocation) {
  60806. if (isCube) {
  60807. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  60808. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  60809. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  60810. }
  60811. else {
  60812. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  60813. }
  60814. }
  60815. return _this;
  60816. }
  60817. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  60818. /**
  60819. * Use this list to define the list of mesh you want to render.
  60820. */
  60821. get: function () {
  60822. return this._renderList;
  60823. },
  60824. set: function (value) {
  60825. this._renderList = value;
  60826. if (this._renderList) {
  60827. this._hookArray(this._renderList);
  60828. }
  60829. },
  60830. enumerable: true,
  60831. configurable: true
  60832. });
  60833. RenderTargetTexture.prototype._hookArray = function (array) {
  60834. var _this = this;
  60835. var oldPush = array.push;
  60836. array.push = function () {
  60837. var items = [];
  60838. for (var _i = 0; _i < arguments.length; _i++) {
  60839. items[_i] = arguments[_i];
  60840. }
  60841. var wasEmpty = array.length === 0;
  60842. var result = oldPush.apply(array, items);
  60843. if (wasEmpty) {
  60844. _this.getScene().meshes.forEach(function (mesh) {
  60845. mesh._markSubMeshesAsLightDirty();
  60846. });
  60847. }
  60848. return result;
  60849. };
  60850. var oldSplice = array.splice;
  60851. array.splice = function (index, deleteCount) {
  60852. var deleted = oldSplice.apply(array, [index, deleteCount]);
  60853. if (array.length === 0) {
  60854. _this.getScene().meshes.forEach(function (mesh) {
  60855. mesh._markSubMeshesAsLightDirty();
  60856. });
  60857. }
  60858. return deleted;
  60859. };
  60860. };
  60861. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  60862. /**
  60863. * Set a after unbind callback in the texture.
  60864. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  60865. */
  60866. set: function (callback) {
  60867. if (this._onAfterUnbindObserver) {
  60868. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  60869. }
  60870. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  60871. },
  60872. enumerable: true,
  60873. configurable: true
  60874. });
  60875. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  60876. /**
  60877. * Set a before render callback in the texture.
  60878. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  60879. */
  60880. set: function (callback) {
  60881. if (this._onBeforeRenderObserver) {
  60882. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  60883. }
  60884. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  60885. },
  60886. enumerable: true,
  60887. configurable: true
  60888. });
  60889. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  60890. /**
  60891. * Set a after render callback in the texture.
  60892. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  60893. */
  60894. set: function (callback) {
  60895. if (this._onAfterRenderObserver) {
  60896. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  60897. }
  60898. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  60899. },
  60900. enumerable: true,
  60901. configurable: true
  60902. });
  60903. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  60904. /**
  60905. * Set a clear callback in the texture.
  60906. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  60907. */
  60908. set: function (callback) {
  60909. if (this._onClearObserver) {
  60910. this.onClearObservable.remove(this._onClearObserver);
  60911. }
  60912. this._onClearObserver = this.onClearObservable.add(callback);
  60913. },
  60914. enumerable: true,
  60915. configurable: true
  60916. });
  60917. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  60918. /**
  60919. * Gets render target creation options that were used.
  60920. */
  60921. get: function () {
  60922. return this._renderTargetOptions;
  60923. },
  60924. enumerable: true,
  60925. configurable: true
  60926. });
  60927. RenderTargetTexture.prototype._onRatioRescale = function () {
  60928. if (this._sizeRatio) {
  60929. this.resize(this._initialSizeParameter);
  60930. }
  60931. };
  60932. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  60933. get: function () {
  60934. return this._boundingBoxSize;
  60935. },
  60936. /**
  60937. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  60938. * When defined, the cubemap will switch to local mode
  60939. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60940. * @example https://www.babylonjs-playground.com/#RNASML
  60941. */
  60942. set: function (value) {
  60943. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  60944. return;
  60945. }
  60946. this._boundingBoxSize = value;
  60947. var scene = this.getScene();
  60948. if (scene) {
  60949. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  60950. }
  60951. },
  60952. enumerable: true,
  60953. configurable: true
  60954. });
  60955. /**
  60956. * Creates a depth stencil texture.
  60957. * This is only available in WebGL 2 or with the depth texture extension available.
  60958. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  60959. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  60960. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  60961. */
  60962. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  60963. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  60964. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  60965. if (generateStencil === void 0) { generateStencil = false; }
  60966. if (!this.getScene()) {
  60967. return;
  60968. }
  60969. var engine = this.getScene().getEngine();
  60970. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  60971. bilinearFiltering: bilinearFiltering,
  60972. comparisonFunction: comparisonFunction,
  60973. generateStencil: generateStencil,
  60974. isCube: this.isCube
  60975. });
  60976. engine.setFrameBufferDepthStencilTexture(this);
  60977. };
  60978. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  60979. if (size.ratio) {
  60980. this._sizeRatio = size.ratio;
  60981. this._size = {
  60982. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  60983. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  60984. };
  60985. }
  60986. else {
  60987. this._size = size;
  60988. }
  60989. };
  60990. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  60991. /**
  60992. * Define the number of samples to use in case of MSAA.
  60993. * It defaults to one meaning no MSAA has been enabled.
  60994. */
  60995. get: function () {
  60996. return this._samples;
  60997. },
  60998. set: function (value) {
  60999. if (this._samples === value) {
  61000. return;
  61001. }
  61002. var scene = this.getScene();
  61003. if (!scene) {
  61004. return;
  61005. }
  61006. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  61007. },
  61008. enumerable: true,
  61009. configurable: true
  61010. });
  61011. /**
  61012. * Resets the refresh counter of the texture and start bak from scratch.
  61013. * Could be useful to regenerate the texture if it is setup to render only once.
  61014. */
  61015. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  61016. this._currentRefreshId = -1;
  61017. };
  61018. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  61019. /**
  61020. * Define the refresh rate of the texture or the rendering frequency.
  61021. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  61022. */
  61023. get: function () {
  61024. return this._refreshRate;
  61025. },
  61026. set: function (value) {
  61027. this._refreshRate = value;
  61028. this.resetRefreshCounter();
  61029. },
  61030. enumerable: true,
  61031. configurable: true
  61032. });
  61033. /**
  61034. * Adds a post process to the render target rendering passes.
  61035. * @param postProcess define the post process to add
  61036. */
  61037. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  61038. if (!this._postProcessManager) {
  61039. var scene = this.getScene();
  61040. if (!scene) {
  61041. return;
  61042. }
  61043. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  61044. this._postProcesses = new Array();
  61045. }
  61046. this._postProcesses.push(postProcess);
  61047. this._postProcesses[0].autoClear = false;
  61048. };
  61049. /**
  61050. * Clear all the post processes attached to the render target
  61051. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  61052. */
  61053. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  61054. if (dispose === void 0) { dispose = false; }
  61055. if (!this._postProcesses) {
  61056. return;
  61057. }
  61058. if (dispose) {
  61059. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  61060. var postProcess = _a[_i];
  61061. postProcess.dispose();
  61062. }
  61063. }
  61064. this._postProcesses = [];
  61065. };
  61066. /**
  61067. * Remove one of the post process from the list of attached post processes to the texture
  61068. * @param postProcess define the post process to remove from the list
  61069. */
  61070. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  61071. if (!this._postProcesses) {
  61072. return;
  61073. }
  61074. var index = this._postProcesses.indexOf(postProcess);
  61075. if (index === -1) {
  61076. return;
  61077. }
  61078. this._postProcesses.splice(index, 1);
  61079. if (this._postProcesses.length > 0) {
  61080. this._postProcesses[0].autoClear = false;
  61081. }
  61082. };
  61083. /** @hidden */
  61084. RenderTargetTexture.prototype._shouldRender = function () {
  61085. if (this._currentRefreshId === -1) { // At least render once
  61086. this._currentRefreshId = 1;
  61087. return true;
  61088. }
  61089. if (this.refreshRate === this._currentRefreshId) {
  61090. this._currentRefreshId = 1;
  61091. return true;
  61092. }
  61093. this._currentRefreshId++;
  61094. return false;
  61095. };
  61096. /**
  61097. * Gets the actual render size of the texture.
  61098. * @returns the width of the render size
  61099. */
  61100. RenderTargetTexture.prototype.getRenderSize = function () {
  61101. return this.getRenderWidth();
  61102. };
  61103. /**
  61104. * Gets the actual render width of the texture.
  61105. * @returns the width of the render size
  61106. */
  61107. RenderTargetTexture.prototype.getRenderWidth = function () {
  61108. if (this._size.width) {
  61109. return this._size.width;
  61110. }
  61111. return this._size;
  61112. };
  61113. /**
  61114. * Gets the actual render height of the texture.
  61115. * @returns the height of the render size
  61116. */
  61117. RenderTargetTexture.prototype.getRenderHeight = function () {
  61118. if (this._size.width) {
  61119. return this._size.height;
  61120. }
  61121. return this._size;
  61122. };
  61123. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  61124. /**
  61125. * Get if the texture can be rescaled or not.
  61126. */
  61127. get: function () {
  61128. return true;
  61129. },
  61130. enumerable: true,
  61131. configurable: true
  61132. });
  61133. /**
  61134. * Resize the texture using a ratio.
  61135. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  61136. */
  61137. RenderTargetTexture.prototype.scale = function (ratio) {
  61138. var newSize = this.getRenderSize() * ratio;
  61139. this.resize(newSize);
  61140. };
  61141. /**
  61142. * Get the texture reflection matrix used to rotate/transform the reflection.
  61143. * @returns the reflection matrix
  61144. */
  61145. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  61146. if (this.isCube) {
  61147. return this._textureMatrix;
  61148. }
  61149. return _super.prototype.getReflectionTextureMatrix.call(this);
  61150. };
  61151. /**
  61152. * Resize the texture to a new desired size.
  61153. * Be carrefull as it will recreate all the data in the new texture.
  61154. * @param size Define the new size. It can be:
  61155. * - a number for squared texture,
  61156. * - an object containing { width: number, height: number }
  61157. * - or an object containing a ratio { ratio: number }
  61158. */
  61159. RenderTargetTexture.prototype.resize = function (size) {
  61160. var wasCube = this.isCube;
  61161. this.releaseInternalTexture();
  61162. var scene = this.getScene();
  61163. if (!scene) {
  61164. return;
  61165. }
  61166. this._processSizeParameter(size);
  61167. if (wasCube) {
  61168. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  61169. }
  61170. else {
  61171. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  61172. }
  61173. };
  61174. /**
  61175. * Renders all the objects from the render list into the texture.
  61176. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  61177. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  61178. */
  61179. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  61180. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  61181. if (dumpForDebug === void 0) { dumpForDebug = false; }
  61182. var scene = this.getScene();
  61183. if (!scene) {
  61184. return;
  61185. }
  61186. var engine = scene.getEngine();
  61187. if (this.useCameraPostProcesses !== undefined) {
  61188. useCameraPostProcess = this.useCameraPostProcesses;
  61189. }
  61190. if (this._waitingRenderList) {
  61191. this.renderList = [];
  61192. for (var index = 0; index < this._waitingRenderList.length; index++) {
  61193. var id = this._waitingRenderList[index];
  61194. var mesh_1 = scene.getMeshByID(id);
  61195. if (mesh_1) {
  61196. this.renderList.push(mesh_1);
  61197. }
  61198. }
  61199. delete this._waitingRenderList;
  61200. }
  61201. // Is predicate defined?
  61202. if (this.renderListPredicate) {
  61203. if (this.renderList) {
  61204. this.renderList.length = 0; // Clear previous renderList
  61205. }
  61206. else {
  61207. this.renderList = [];
  61208. }
  61209. var scene = this.getScene();
  61210. if (!scene) {
  61211. return;
  61212. }
  61213. var sceneMeshes = scene.meshes;
  61214. for (var index = 0; index < sceneMeshes.length; index++) {
  61215. var mesh = sceneMeshes[index];
  61216. if (this.renderListPredicate(mesh)) {
  61217. this.renderList.push(mesh);
  61218. }
  61219. }
  61220. }
  61221. this.onBeforeBindObservable.notifyObservers(this);
  61222. // Set custom projection.
  61223. // Needs to be before binding to prevent changing the aspect ratio.
  61224. var camera;
  61225. if (this.activeCamera) {
  61226. camera = this.activeCamera;
  61227. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  61228. if (this.activeCamera !== scene.activeCamera) {
  61229. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  61230. }
  61231. }
  61232. else {
  61233. camera = scene.activeCamera;
  61234. if (camera) {
  61235. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  61236. }
  61237. }
  61238. // Prepare renderingManager
  61239. this._renderingManager.reset();
  61240. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  61241. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  61242. var sceneRenderId = scene.getRenderId();
  61243. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  61244. var mesh = currentRenderList[meshIndex];
  61245. if (mesh) {
  61246. if (!mesh.isReady(this.refreshRate === 0)) {
  61247. this.resetRefreshCounter();
  61248. continue;
  61249. }
  61250. mesh._preActivateForIntermediateRendering(sceneRenderId);
  61251. var isMasked = void 0;
  61252. if (!this.renderList && camera) {
  61253. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  61254. }
  61255. else {
  61256. isMasked = false;
  61257. }
  61258. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  61259. mesh._activate(sceneRenderId);
  61260. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  61261. var subMesh = mesh.subMeshes[subIndex];
  61262. scene._activeIndices.addCount(subMesh.indexCount, false);
  61263. this._renderingManager.dispatch(subMesh, mesh);
  61264. }
  61265. }
  61266. }
  61267. }
  61268. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  61269. var particleSystem = scene.particleSystems[particleIndex];
  61270. var emitter = particleSystem.emitter;
  61271. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  61272. continue;
  61273. }
  61274. if (currentRenderList.indexOf(emitter) >= 0) {
  61275. this._renderingManager.dispatchParticles(particleSystem);
  61276. }
  61277. }
  61278. if (this.isCube) {
  61279. for (var face = 0; face < 6; face++) {
  61280. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  61281. scene.incrementRenderId();
  61282. scene.resetCachedMaterial();
  61283. }
  61284. }
  61285. else {
  61286. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  61287. }
  61288. this.onAfterUnbindObservable.notifyObservers(this);
  61289. if (scene.activeCamera) {
  61290. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  61291. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  61292. }
  61293. engine.setViewport(scene.activeCamera.viewport);
  61294. }
  61295. scene.resetCachedMaterial();
  61296. };
  61297. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  61298. var minimum = 128;
  61299. var x = renderDimension * scale;
  61300. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  61301. // Ensure we don't exceed the render dimension (while staying POT)
  61302. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  61303. };
  61304. /**
  61305. * @hidden
  61306. * @param faceIndex face index to bind to if this is a cubetexture
  61307. */
  61308. RenderTargetTexture.prototype._bindFrameBuffer = function (faceIndex) {
  61309. if (faceIndex === void 0) { faceIndex = 0; }
  61310. var scene = this.getScene();
  61311. if (!scene) {
  61312. return;
  61313. }
  61314. var engine = scene.getEngine();
  61315. if (this._texture) {
  61316. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  61317. }
  61318. };
  61319. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  61320. var _this = this;
  61321. if (!this._texture) {
  61322. return;
  61323. }
  61324. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  61325. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  61326. });
  61327. };
  61328. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  61329. var scene = this.getScene();
  61330. if (!scene) {
  61331. return;
  61332. }
  61333. var engine = scene.getEngine();
  61334. if (!this._texture) {
  61335. return;
  61336. }
  61337. // Bind
  61338. if (this._postProcessManager) {
  61339. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  61340. }
  61341. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  61342. this._bindFrameBuffer(faceIndex);
  61343. }
  61344. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  61345. // Clear
  61346. if (this.onClearObservable.hasObservers()) {
  61347. this.onClearObservable.notifyObservers(engine);
  61348. }
  61349. else {
  61350. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  61351. }
  61352. if (!this._doNotChangeAspectRatio) {
  61353. scene.updateTransformMatrix(true);
  61354. }
  61355. // Before Camera Draw
  61356. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  61357. var step = _a[_i];
  61358. step.action(this);
  61359. }
  61360. // Render
  61361. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  61362. // After Camera Draw
  61363. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  61364. var step = _c[_b];
  61365. step.action(this);
  61366. }
  61367. if (this._postProcessManager) {
  61368. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  61369. }
  61370. else if (useCameraPostProcess) {
  61371. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  61372. }
  61373. if (!this._doNotChangeAspectRatio) {
  61374. scene.updateTransformMatrix(true);
  61375. }
  61376. // Dump ?
  61377. if (dumpForDebug) {
  61378. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  61379. }
  61380. // Unbind
  61381. if (!this.isCube || faceIndex === 5) {
  61382. if (this.isCube) {
  61383. if (faceIndex === 5) {
  61384. engine.generateMipMapsForCubemap(this._texture);
  61385. }
  61386. }
  61387. this.unbindFrameBuffer(engine, faceIndex);
  61388. }
  61389. else {
  61390. this.onAfterRenderObservable.notifyObservers(faceIndex);
  61391. }
  61392. };
  61393. /**
  61394. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  61395. * This allowed control for front to back rendering or reversly depending of the special needs.
  61396. *
  61397. * @param renderingGroupId The rendering group id corresponding to its index
  61398. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  61399. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  61400. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  61401. */
  61402. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  61403. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  61404. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  61405. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  61406. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  61407. };
  61408. /**
  61409. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  61410. *
  61411. * @param renderingGroupId The rendering group id corresponding to its index
  61412. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61413. */
  61414. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  61415. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  61416. this._renderingManager._useSceneAutoClearSetup = false;
  61417. };
  61418. /**
  61419. * Clones the texture.
  61420. * @returns the cloned texture
  61421. */
  61422. RenderTargetTexture.prototype.clone = function () {
  61423. var textureSize = this.getSize();
  61424. var newTexture = new RenderTargetTexture(this.name, textureSize, this.getScene(), this._renderTargetOptions.generateMipMaps, this._doNotChangeAspectRatio, this._renderTargetOptions.type, this.isCube, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer, this._renderTargetOptions.generateStencilBuffer);
  61425. // Base texture
  61426. newTexture.hasAlpha = this.hasAlpha;
  61427. newTexture.level = this.level;
  61428. // RenderTarget Texture
  61429. newTexture.coordinatesMode = this.coordinatesMode;
  61430. if (this.renderList) {
  61431. newTexture.renderList = this.renderList.slice(0);
  61432. }
  61433. return newTexture;
  61434. };
  61435. /**
  61436. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  61437. * @returns The JSON representation of the texture
  61438. */
  61439. RenderTargetTexture.prototype.serialize = function () {
  61440. if (!this.name) {
  61441. return null;
  61442. }
  61443. var serializationObject = _super.prototype.serialize.call(this);
  61444. serializationObject.renderTargetSize = this.getRenderSize();
  61445. serializationObject.renderList = [];
  61446. if (this.renderList) {
  61447. for (var index = 0; index < this.renderList.length; index++) {
  61448. serializationObject.renderList.push(this.renderList[index].id);
  61449. }
  61450. }
  61451. return serializationObject;
  61452. };
  61453. /**
  61454. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  61455. */
  61456. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  61457. var objBuffer = this.getInternalTexture();
  61458. var scene = this.getScene();
  61459. if (objBuffer && scene) {
  61460. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  61461. }
  61462. };
  61463. /**
  61464. * Dispose the texture and release its associated resources.
  61465. */
  61466. RenderTargetTexture.prototype.dispose = function () {
  61467. if (this._postProcessManager) {
  61468. this._postProcessManager.dispose();
  61469. this._postProcessManager = null;
  61470. }
  61471. this.clearPostProcesses(true);
  61472. if (this._resizeObserver) {
  61473. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  61474. this._resizeObserver = null;
  61475. }
  61476. this.renderList = null;
  61477. // Remove from custom render targets
  61478. var scene = this.getScene();
  61479. if (!scene) {
  61480. return;
  61481. }
  61482. var index = scene.customRenderTargets.indexOf(this);
  61483. if (index >= 0) {
  61484. scene.customRenderTargets.splice(index, 1);
  61485. }
  61486. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  61487. var camera = _a[_i];
  61488. index = camera.customRenderTargets.indexOf(this);
  61489. if (index >= 0) {
  61490. camera.customRenderTargets.splice(index, 1);
  61491. }
  61492. }
  61493. _super.prototype.dispose.call(this);
  61494. };
  61495. /** @hidden */
  61496. RenderTargetTexture.prototype._rebuild = function () {
  61497. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  61498. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  61499. }
  61500. if (this._postProcessManager) {
  61501. this._postProcessManager._rebuild();
  61502. }
  61503. };
  61504. /**
  61505. * Clear the info related to rendering groups preventing retention point in material dispose.
  61506. */
  61507. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  61508. if (this._renderingManager) {
  61509. this._renderingManager.freeRenderingGroups();
  61510. }
  61511. };
  61512. /**
  61513. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  61514. * @returns the view count
  61515. */
  61516. RenderTargetTexture.prototype.getViewCount = function () {
  61517. return 1;
  61518. };
  61519. /**
  61520. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  61521. */
  61522. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  61523. /**
  61524. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  61525. */
  61526. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  61527. /**
  61528. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  61529. * the central point of your effect and can save a lot of performances.
  61530. */
  61531. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  61532. return RenderTargetTexture;
  61533. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  61534. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  61535. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  61536. };
  61537. /***/ }),
  61538. /***/ "./Materials/Textures/texture.ts":
  61539. /*!***************************************!*\
  61540. !*** ./Materials/Textures/texture.ts ***!
  61541. \***************************************/
  61542. /*! exports provided: Texture */
  61543. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61544. "use strict";
  61545. __webpack_require__.r(__webpack_exports__);
  61546. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  61547. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61548. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  61549. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  61550. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  61551. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  61552. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  61553. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  61554. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  61555. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  61556. /**
  61557. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  61558. * @see http://doc.babylonjs.com/babylon101/materials#texture
  61559. */
  61560. var Texture = /** @class */ (function (_super) {
  61561. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  61562. /**
  61563. * Instantiates a new texture.
  61564. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  61565. * @see http://doc.babylonjs.com/babylon101/materials#texture
  61566. * @param url define the url of the picture to load as a texture
  61567. * @param scene define the scene the texture will belong to
  61568. * @param noMipmap define if the texture will require mip maps or not
  61569. * @param invertY define if the texture needs to be inverted on the y axis during loading
  61570. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  61571. * @param onLoad define a callback triggered when the texture has been loaded
  61572. * @param onError define a callback triggered when an error occurred during the loading session
  61573. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  61574. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  61575. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  61576. */
  61577. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  61578. if (noMipmap === void 0) { noMipmap = false; }
  61579. if (invertY === void 0) { invertY = true; }
  61580. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  61581. if (onLoad === void 0) { onLoad = null; }
  61582. if (onError === void 0) { onError = null; }
  61583. if (buffer === void 0) { buffer = null; }
  61584. if (deleteBuffer === void 0) { deleteBuffer = false; }
  61585. var _this = _super.call(this, scene) || this;
  61586. /**
  61587. * Define an offset on the texture to offset the u coordinates of the UVs
  61588. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  61589. */
  61590. _this.uOffset = 0;
  61591. /**
  61592. * Define an offset on the texture to offset the v coordinates of the UVs
  61593. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  61594. */
  61595. _this.vOffset = 0;
  61596. /**
  61597. * Define an offset on the texture to scale the u coordinates of the UVs
  61598. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  61599. */
  61600. _this.uScale = 1.0;
  61601. /**
  61602. * Define an offset on the texture to scale the v coordinates of the UVs
  61603. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  61604. */
  61605. _this.vScale = 1.0;
  61606. /**
  61607. * Define an offset on the texture to rotate around the u coordinates of the UVs
  61608. * @see http://doc.babylonjs.com/how_to/more_materials
  61609. */
  61610. _this.uAng = 0;
  61611. /**
  61612. * Define an offset on the texture to rotate around the v coordinates of the UVs
  61613. * @see http://doc.babylonjs.com/how_to/more_materials
  61614. */
  61615. _this.vAng = 0;
  61616. /**
  61617. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  61618. * @see http://doc.babylonjs.com/how_to/more_materials
  61619. */
  61620. _this.wAng = 0;
  61621. /**
  61622. * Defines the center of rotation (U)
  61623. */
  61624. _this.uRotationCenter = 0.5;
  61625. /**
  61626. * Defines the center of rotation (V)
  61627. */
  61628. _this.vRotationCenter = 0.5;
  61629. /**
  61630. * Defines the center of rotation (W)
  61631. */
  61632. _this.wRotationCenter = 0.5;
  61633. /** @hidden */
  61634. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  61635. /**
  61636. * Observable triggered once the texture has been loaded.
  61637. */
  61638. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  61639. _this._isBlocking = true;
  61640. _this.name = url || "";
  61641. _this.url = url;
  61642. _this._noMipmap = noMipmap;
  61643. _this._invertY = invertY;
  61644. _this._initialSamplingMode = samplingMode;
  61645. _this._buffer = buffer;
  61646. _this._deleteBuffer = deleteBuffer;
  61647. if (format) {
  61648. _this._format = format;
  61649. }
  61650. scene = _this.getScene();
  61651. if (!scene) {
  61652. return _this;
  61653. }
  61654. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  61655. var load = function () {
  61656. if (_this._texture && _this._texture._invertVScale) {
  61657. _this.vScale = -1;
  61658. }
  61659. if (_this.onLoadObservable.hasObservers()) {
  61660. _this.onLoadObservable.notifyObservers(_this);
  61661. }
  61662. if (onLoad) {
  61663. onLoad();
  61664. }
  61665. if (!_this.isBlocking && scene) {
  61666. scene.resetCachedMaterial();
  61667. }
  61668. };
  61669. if (!_this.url) {
  61670. _this._delayedOnLoad = load;
  61671. _this._delayedOnError = onError;
  61672. return _this;
  61673. }
  61674. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode, invertY);
  61675. if (!_this._texture) {
  61676. if (!scene.useDelayedTextureLoading) {
  61677. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  61678. if (deleteBuffer) {
  61679. delete _this._buffer;
  61680. }
  61681. }
  61682. else {
  61683. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  61684. _this._delayedOnLoad = load;
  61685. _this._delayedOnError = onError;
  61686. }
  61687. }
  61688. else {
  61689. if (_this._texture.isReady) {
  61690. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  61691. }
  61692. else {
  61693. _this._texture.onLoadedObservable.add(load);
  61694. }
  61695. }
  61696. return _this;
  61697. }
  61698. Object.defineProperty(Texture.prototype, "noMipmap", {
  61699. /**
  61700. * Are mip maps generated for this texture or not.
  61701. */
  61702. get: function () {
  61703. return this._noMipmap;
  61704. },
  61705. enumerable: true,
  61706. configurable: true
  61707. });
  61708. Object.defineProperty(Texture.prototype, "isBlocking", {
  61709. get: function () {
  61710. return this._isBlocking;
  61711. },
  61712. /**
  61713. * Is the texture preventing material to render while loading.
  61714. * If false, a default texture will be used instead of the loading one during the preparation step.
  61715. */
  61716. set: function (value) {
  61717. this._isBlocking = value;
  61718. },
  61719. enumerable: true,
  61720. configurable: true
  61721. });
  61722. Object.defineProperty(Texture.prototype, "samplingMode", {
  61723. /**
  61724. * Get the current sampling mode associated with the texture.
  61725. */
  61726. get: function () {
  61727. if (!this._texture) {
  61728. return this._initialSamplingMode;
  61729. }
  61730. return this._texture.samplingMode;
  61731. },
  61732. enumerable: true,
  61733. configurable: true
  61734. });
  61735. Object.defineProperty(Texture.prototype, "invertY", {
  61736. /**
  61737. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  61738. */
  61739. get: function () {
  61740. return this._invertY;
  61741. },
  61742. enumerable: true,
  61743. configurable: true
  61744. });
  61745. /**
  61746. * Update the url (and optional buffer) of this texture if url was null during construction.
  61747. * @param url the url of the texture
  61748. * @param buffer the buffer of the texture (defaults to null)
  61749. * @param onLoad callback called when the texture is loaded (defaults to null)
  61750. */
  61751. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  61752. if (buffer === void 0) { buffer = null; }
  61753. if (this.url) {
  61754. this.releaseInternalTexture();
  61755. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  61756. }
  61757. this.url = url;
  61758. this._buffer = buffer;
  61759. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  61760. if (onLoad) {
  61761. this._delayedOnLoad = onLoad;
  61762. }
  61763. this.delayLoad();
  61764. };
  61765. /**
  61766. * Finish the loading sequence of a texture flagged as delayed load.
  61767. * @hidden
  61768. */
  61769. Texture.prototype.delayLoad = function () {
  61770. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  61771. return;
  61772. }
  61773. var scene = this.getScene();
  61774. if (!scene) {
  61775. return;
  61776. }
  61777. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  61778. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY);
  61779. if (!this._texture) {
  61780. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  61781. if (this._deleteBuffer) {
  61782. delete this._buffer;
  61783. }
  61784. }
  61785. else {
  61786. if (this._delayedOnLoad) {
  61787. if (this._texture.isReady) {
  61788. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  61789. }
  61790. else {
  61791. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  61792. }
  61793. }
  61794. }
  61795. this._delayedOnLoad = null;
  61796. this._delayedOnError = null;
  61797. };
  61798. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  61799. x *= this.uScale;
  61800. y *= this.vScale;
  61801. x -= this.uRotationCenter * this.uScale;
  61802. y -= this.vRotationCenter * this.vScale;
  61803. z -= this.wRotationCenter;
  61804. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  61805. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  61806. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  61807. t.z += this.wRotationCenter;
  61808. };
  61809. /**
  61810. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  61811. * @returns the transform matrix of the texture.
  61812. */
  61813. Texture.prototype.getTextureMatrix = function () {
  61814. var _this = this;
  61815. if (this.uOffset === this._cachedUOffset &&
  61816. this.vOffset === this._cachedVOffset &&
  61817. this.uScale === this._cachedUScale &&
  61818. this.vScale === this._cachedVScale &&
  61819. this.uAng === this._cachedUAng &&
  61820. this.vAng === this._cachedVAng &&
  61821. this.wAng === this._cachedWAng) {
  61822. return this._cachedTextureMatrix;
  61823. }
  61824. this._cachedUOffset = this.uOffset;
  61825. this._cachedVOffset = this.vOffset;
  61826. this._cachedUScale = this.uScale;
  61827. this._cachedVScale = this.vScale;
  61828. this._cachedUAng = this.uAng;
  61829. this._cachedVAng = this.vAng;
  61830. this._cachedWAng = this.wAng;
  61831. if (!this._cachedTextureMatrix) {
  61832. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  61833. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  61834. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  61835. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  61836. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  61837. }
  61838. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  61839. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  61840. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  61841. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  61842. this._t1.subtractInPlace(this._t0);
  61843. this._t2.subtractInPlace(this._t0);
  61844. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromValuesToRef(this._t1.x, this._t1.y, this._t1.z, 0.0, this._t2.x, this._t2.y, this._t2.z, 0.0, this._t0.x, this._t0.y, this._t0.z, 0.0, 0.0, 0.0, 0.0, 1.0, this._cachedTextureMatrix);
  61845. var scene = this.getScene();
  61846. if (!scene) {
  61847. return this._cachedTextureMatrix;
  61848. }
  61849. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  61850. return mat.hasTexture(_this);
  61851. });
  61852. return this._cachedTextureMatrix;
  61853. };
  61854. /**
  61855. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  61856. * @returns The reflection texture transform
  61857. */
  61858. Texture.prototype.getReflectionTextureMatrix = function () {
  61859. var _this = this;
  61860. var scene = this.getScene();
  61861. if (!scene) {
  61862. return this._cachedTextureMatrix;
  61863. }
  61864. if (this.uOffset === this._cachedUOffset &&
  61865. this.vOffset === this._cachedVOffset &&
  61866. this.uScale === this._cachedUScale &&
  61867. this.vScale === this._cachedVScale &&
  61868. this.coordinatesMode === this._cachedCoordinatesMode) {
  61869. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  61870. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  61871. return this._cachedTextureMatrix;
  61872. }
  61873. }
  61874. else {
  61875. return this._cachedTextureMatrix;
  61876. }
  61877. }
  61878. if (!this._cachedTextureMatrix) {
  61879. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  61880. }
  61881. if (!this._projectionModeMatrix) {
  61882. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  61883. }
  61884. this._cachedUOffset = this.uOffset;
  61885. this._cachedVOffset = this.vOffset;
  61886. this._cachedUScale = this.uScale;
  61887. this._cachedVScale = this.vScale;
  61888. this._cachedCoordinatesMode = this.coordinatesMode;
  61889. switch (this.coordinatesMode) {
  61890. case Texture.PLANAR_MODE:
  61891. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  61892. this._cachedTextureMatrix[0] = this.uScale;
  61893. this._cachedTextureMatrix[5] = this.vScale;
  61894. this._cachedTextureMatrix[12] = this.uOffset;
  61895. this._cachedTextureMatrix[13] = this.vOffset;
  61896. break;
  61897. case Texture.PROJECTION_MODE:
  61898. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromValuesToRef(0.5, 0.0, 0.0, 0.0, 0.0, -0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 1.0, 1.0, this._projectionModeMatrix);
  61899. var projectionMatrix = scene.getProjectionMatrix();
  61900. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  61901. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  61902. break;
  61903. default:
  61904. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  61905. break;
  61906. }
  61907. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  61908. return (mat.getActiveTextures().indexOf(_this) !== -1);
  61909. });
  61910. return this._cachedTextureMatrix;
  61911. };
  61912. /**
  61913. * Clones the texture.
  61914. * @returns the cloned texture
  61915. */
  61916. Texture.prototype.clone = function () {
  61917. var _this = this;
  61918. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  61919. return new Texture(_this._texture ? _this._texture.url : null, _this.getScene(), _this._noMipmap, _this._invertY, _this.samplingMode, undefined, undefined, _this._texture ? _this._texture._buffer : undefined);
  61920. }, this);
  61921. };
  61922. /**
  61923. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  61924. * @returns The JSON representation of the texture
  61925. */
  61926. Texture.prototype.serialize = function () {
  61927. var serializationObject = _super.prototype.serialize.call(this);
  61928. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  61929. serializationObject.base64String = this._buffer;
  61930. serializationObject.name = serializationObject.name.replace("data:", "");
  61931. }
  61932. serializationObject.invertY = this._invertY;
  61933. serializationObject.samplingMode = this.samplingMode;
  61934. return serializationObject;
  61935. };
  61936. /**
  61937. * Get the current class name of the texture useful for serialization or dynamic coding.
  61938. * @returns "Texture"
  61939. */
  61940. Texture.prototype.getClassName = function () {
  61941. return "Texture";
  61942. };
  61943. /**
  61944. * Dispose the texture and release its associated resources.
  61945. */
  61946. Texture.prototype.dispose = function () {
  61947. _super.prototype.dispose.call(this);
  61948. this.onLoadObservable.clear();
  61949. this._delayedOnLoad = null;
  61950. this._delayedOnError = null;
  61951. };
  61952. /**
  61953. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  61954. * @param parsedTexture Define the JSON representation of the texture
  61955. * @param scene Define the scene the parsed texture should be instantiated in
  61956. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61957. * @returns The parsed texture if successful
  61958. */
  61959. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  61960. if (parsedTexture.customType) {
  61961. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  61962. // Update Sampling Mode
  61963. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  61964. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  61965. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  61966. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  61967. }
  61968. }
  61969. return parsedCustomTexture;
  61970. }
  61971. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  61972. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  61973. }
  61974. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  61975. return null;
  61976. }
  61977. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  61978. var generateMipMaps = true;
  61979. if (parsedTexture.noMipmap) {
  61980. generateMipMaps = false;
  61981. }
  61982. if (parsedTexture.mirrorPlane) {
  61983. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  61984. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  61985. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  61986. return mirrorTexture;
  61987. }
  61988. else if (parsedTexture.isRenderTarget) {
  61989. var renderTargetTexture = null;
  61990. if (parsedTexture.isCube) {
  61991. // Search for an existing reflection probe (which contains a cube render target texture)
  61992. if (scene.reflectionProbes) {
  61993. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  61994. var probe = scene.reflectionProbes[index];
  61995. if (probe.name === parsedTexture.name) {
  61996. return probe.cubeTexture;
  61997. }
  61998. }
  61999. }
  62000. }
  62001. else {
  62002. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  62003. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  62004. }
  62005. return renderTargetTexture;
  62006. }
  62007. else {
  62008. var texture;
  62009. if (parsedTexture.base64String) {
  62010. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  62011. }
  62012. else {
  62013. var url = rootUrl + parsedTexture.name;
  62014. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  62015. url = parsedTexture.url;
  62016. }
  62017. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  62018. }
  62019. return texture;
  62020. }
  62021. }, parsedTexture, scene);
  62022. // Update Sampling Mode
  62023. if (parsedTexture.samplingMode) {
  62024. var sampling = parsedTexture.samplingMode;
  62025. if (texture && texture.samplingMode !== sampling) {
  62026. texture.updateSamplingMode(sampling);
  62027. }
  62028. }
  62029. // Animations
  62030. if (texture && parsedTexture.animations) {
  62031. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  62032. var parsedAnimation = parsedTexture.animations[animationIndex];
  62033. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  62034. if (internalClass) {
  62035. texture.animations.push(internalClass.Parse(parsedAnimation));
  62036. }
  62037. }
  62038. }
  62039. return texture;
  62040. };
  62041. /**
  62042. * Creates a texture from its base 64 representation.
  62043. * @param data Define the base64 payload without the data: prefix
  62044. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  62045. * @param scene Define the scene the texture should belong to
  62046. * @param noMipmap Forces the texture to not create mip map information if true
  62047. * @param invertY define if the texture needs to be inverted on the y axis during loading
  62048. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  62049. * @param onLoad define a callback triggered when the texture has been loaded
  62050. * @param onError define a callback triggered when an error occurred during the loading session
  62051. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  62052. * @returns the created texture
  62053. */
  62054. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  62055. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  62056. if (onLoad === void 0) { onLoad = null; }
  62057. if (onError === void 0) { onError = null; }
  62058. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  62059. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  62060. };
  62061. /**
  62062. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  62063. * @param data Define the base64 payload without the data: prefix
  62064. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  62065. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  62066. * @param scene Define the scene the texture should belong to
  62067. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  62068. * @param noMipmap Forces the texture to not create mip map information if true
  62069. * @param invertY define if the texture needs to be inverted on the y axis during loading
  62070. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  62071. * @param onLoad define a callback triggered when the texture has been loaded
  62072. * @param onError define a callback triggered when an error occurred during the loading session
  62073. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  62074. * @returns the created texture
  62075. */
  62076. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  62077. if (deleteBuffer === void 0) { deleteBuffer = false; }
  62078. if (noMipmap === void 0) { noMipmap = false; }
  62079. if (invertY === void 0) { invertY = true; }
  62080. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  62081. if (onLoad === void 0) { onLoad = null; }
  62082. if (onError === void 0) { onError = null; }
  62083. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  62084. if (name.substr(0, 5) !== "data:") {
  62085. name = "data:" + name;
  62086. }
  62087. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  62088. };
  62089. /** @hidden */
  62090. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  62091. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("CubeTexture");
  62092. };
  62093. /** @hidden */
  62094. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  62095. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("MirrorTexture");
  62096. };
  62097. /** @hidden */
  62098. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  62099. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("RenderTargetTexture");
  62100. };
  62101. /** nearest is mag = nearest and min = nearest and mip = linear */
  62102. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  62103. /** nearest is mag = nearest and min = nearest and mip = linear */
  62104. Texture.NEAREST_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR; // nearest is mag = nearest and min = nearest and mip = linear
  62105. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62106. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  62107. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62108. Texture.LINEAR_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST; // Bilinear is mag = linear and min = linear and mip = nearest
  62109. /** Trilinear is mag = linear and min = linear and mip = linear */
  62110. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  62111. /** Trilinear is mag = linear and min = linear and mip = linear */
  62112. Texture.LINEAR_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR; // Trilinear is mag = linear and min = linear and mip = linear
  62113. /** mag = nearest and min = nearest and mip = nearest */
  62114. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  62115. /** mag = nearest and min = linear and mip = nearest */
  62116. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  62117. /** mag = nearest and min = linear and mip = linear */
  62118. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  62119. /** mag = nearest and min = linear and mip = none */
  62120. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  62121. /** mag = nearest and min = nearest and mip = none */
  62122. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  62123. /** mag = linear and min = nearest and mip = nearest */
  62124. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  62125. /** mag = linear and min = nearest and mip = linear */
  62126. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  62127. /** mag = linear and min = linear and mip = none */
  62128. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  62129. /** mag = linear and min = nearest and mip = none */
  62130. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  62131. /** Explicit coordinates mode */
  62132. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  62133. /** Spherical coordinates mode */
  62134. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  62135. /** Planar coordinates mode */
  62136. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  62137. /** Cubic coordinates mode */
  62138. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  62139. /** Projection coordinates mode */
  62140. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  62141. /** Inverse Cubic coordinates mode */
  62142. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  62143. /** Inverse Cubic coordinates mode */
  62144. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  62145. /** Equirectangular coordinates mode */
  62146. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  62147. /** Equirectangular Fixed coordinates mode */
  62148. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  62149. /** Equirectangular Fixed Mirrored coordinates mode */
  62150. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  62151. /** Texture is not repeating outside of 0..1 UVs */
  62152. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  62153. /** Texture is repeating outside of 0..1 UVs */
  62154. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  62155. /** Texture is repeating and mirrored */
  62156. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  62157. /**
  62158. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  62159. */
  62160. Texture.UseSerializedUrlIfAny = false;
  62161. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62162. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62163. ], Texture.prototype, "url", void 0);
  62164. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62165. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62166. ], Texture.prototype, "uOffset", void 0);
  62167. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62168. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62169. ], Texture.prototype, "vOffset", void 0);
  62170. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62171. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62172. ], Texture.prototype, "uScale", void 0);
  62173. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62174. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62175. ], Texture.prototype, "vScale", void 0);
  62176. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62177. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62178. ], Texture.prototype, "uAng", void 0);
  62179. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62180. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62181. ], Texture.prototype, "vAng", void 0);
  62182. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62183. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62184. ], Texture.prototype, "wAng", void 0);
  62185. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62186. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62187. ], Texture.prototype, "uRotationCenter", void 0);
  62188. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62189. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62190. ], Texture.prototype, "vRotationCenter", void 0);
  62191. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62192. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62193. ], Texture.prototype, "wRotationCenter", void 0);
  62194. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62195. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62196. ], Texture.prototype, "isBlocking", null);
  62197. return Texture;
  62198. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  62199. // References the dependencies.
  62200. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  62201. /***/ }),
  62202. /***/ "./Materials/Textures/videoTexture.ts":
  62203. /*!********************************************!*\
  62204. !*** ./Materials/Textures/videoTexture.ts ***!
  62205. \********************************************/
  62206. /*! exports provided: VideoTexture */
  62207. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62208. "use strict";
  62209. __webpack_require__.r(__webpack_exports__);
  62210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  62211. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62212. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  62213. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  62214. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  62215. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  62216. /**
  62217. * If you want to display a video in your scene, this is the special texture for that.
  62218. * This special texture works similar to other textures, with the exception of a few parameters.
  62219. * @see https://doc.babylonjs.com/how_to/video_texture
  62220. */
  62221. var VideoTexture = /** @class */ (function (_super) {
  62222. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  62223. /**
  62224. * Creates a video texture.
  62225. * If you want to display a video in your scene, this is the special texture for that.
  62226. * This special texture works similar to other textures, with the exception of a few parameters.
  62227. * @see https://doc.babylonjs.com/how_to/video_texture
  62228. * @param name optional name, will detect from video source, if not defined
  62229. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  62230. * @param scene is obviously the current scene.
  62231. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  62232. * @param invertY is false by default but can be used to invert video on Y axis
  62233. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  62234. * @param settings allows finer control over video usage
  62235. */
  62236. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  62237. if (generateMipMaps === void 0) { generateMipMaps = false; }
  62238. if (invertY === void 0) { invertY = false; }
  62239. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  62240. if (settings === void 0) { settings = {
  62241. autoPlay: true,
  62242. loop: true,
  62243. autoUpdateTexture: true,
  62244. }; }
  62245. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  62246. _this._onUserActionRequestedObservable = null;
  62247. _this._stillImageCaptured = false;
  62248. _this._displayingPosterTexture = false;
  62249. _this._createInternalTexture = function () {
  62250. if (_this._texture != null) {
  62251. if (_this._displayingPosterTexture) {
  62252. _this._texture.dispose();
  62253. _this._displayingPosterTexture = false;
  62254. }
  62255. else {
  62256. return;
  62257. }
  62258. }
  62259. if (!_this._engine.needPOTTextures ||
  62260. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  62261. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  62262. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  62263. }
  62264. else {
  62265. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  62266. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  62267. _this._generateMipMaps = false;
  62268. }
  62269. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  62270. if (!_this.video.autoplay && !_this._settings.poster) {
  62271. var oldHandler_1 = _this.video.onplaying;
  62272. var error_1 = false;
  62273. var oldMuted_1 = _this.video.muted;
  62274. _this.video.muted = true;
  62275. _this.video.onplaying = function () {
  62276. _this.video.muted = oldMuted_1;
  62277. _this.video.onplaying = oldHandler_1;
  62278. _this._texture.isReady = true;
  62279. _this._updateInternalTexture();
  62280. if (!error_1) {
  62281. _this.video.pause();
  62282. }
  62283. if (_this.onLoadObservable.hasObservers()) {
  62284. _this.onLoadObservable.notifyObservers(_this);
  62285. }
  62286. };
  62287. var playing = _this.video.play();
  62288. if (playing) {
  62289. playing.then(function () {
  62290. // Everything is good.
  62291. })
  62292. .catch(function () {
  62293. error_1 = true;
  62294. // On Chrome for instance, new policies might prevent playing without user interaction.
  62295. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  62296. _this._onUserActionRequestedObservable.notifyObservers(_this);
  62297. }
  62298. });
  62299. }
  62300. else {
  62301. _this.video.onplaying = oldHandler_1;
  62302. _this._texture.isReady = true;
  62303. _this._updateInternalTexture();
  62304. if (_this.onLoadObservable.hasObservers()) {
  62305. _this.onLoadObservable.notifyObservers(_this);
  62306. }
  62307. }
  62308. }
  62309. else {
  62310. _this._texture.isReady = true;
  62311. _this._updateInternalTexture();
  62312. if (_this.onLoadObservable.hasObservers()) {
  62313. _this.onLoadObservable.notifyObservers(_this);
  62314. }
  62315. }
  62316. };
  62317. _this.reset = function () {
  62318. if (_this._texture == null) {
  62319. return;
  62320. }
  62321. if (!_this._displayingPosterTexture) {
  62322. _this._texture.dispose();
  62323. _this._texture = null;
  62324. }
  62325. };
  62326. _this._updateInternalTexture = function () {
  62327. if (_this._texture == null || !_this._texture.isReady) {
  62328. return;
  62329. }
  62330. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  62331. return;
  62332. }
  62333. if (_this._displayingPosterTexture) {
  62334. return;
  62335. }
  62336. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  62337. };
  62338. _this._engine = _this.getScene().getEngine();
  62339. _this._generateMipMaps = generateMipMaps;
  62340. _this._initialSamplingMode = samplingMode;
  62341. _this.autoUpdateTexture = settings.autoUpdateTexture;
  62342. _this.name = name || _this._getName(src);
  62343. _this.video = _this._getVideo(src);
  62344. _this._settings = settings;
  62345. if (settings.poster) {
  62346. _this.video.poster = settings.poster;
  62347. }
  62348. if (settings.autoPlay !== undefined) {
  62349. _this.video.autoplay = settings.autoPlay;
  62350. }
  62351. if (settings.loop !== undefined) {
  62352. _this.video.loop = settings.loop;
  62353. }
  62354. _this.video.setAttribute("playsinline", "");
  62355. _this.video.addEventListener("paused", _this._updateInternalTexture);
  62356. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  62357. _this.video.addEventListener("emptied", _this.reset);
  62358. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  62359. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  62360. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  62361. if (settings.poster &&
  62362. (!settings.autoPlay || !videoHasEnoughData)) {
  62363. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  62364. _this._displayingPosterTexture = true;
  62365. }
  62366. else if (videoHasEnoughData) {
  62367. _this._createInternalTexture();
  62368. }
  62369. return _this;
  62370. }
  62371. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  62372. /**
  62373. * Event triggerd when a dom action is required by the user to play the video.
  62374. * This happens due to recent changes in browser policies preventing video to auto start.
  62375. */
  62376. get: function () {
  62377. if (!this._onUserActionRequestedObservable) {
  62378. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  62379. }
  62380. return this._onUserActionRequestedObservable;
  62381. },
  62382. enumerable: true,
  62383. configurable: true
  62384. });
  62385. VideoTexture.prototype._getName = function (src) {
  62386. if (src instanceof HTMLVideoElement) {
  62387. return src.currentSrc;
  62388. }
  62389. if (typeof src === "object") {
  62390. return src.toString();
  62391. }
  62392. return src;
  62393. };
  62394. VideoTexture.prototype._getVideo = function (src) {
  62395. if (src instanceof HTMLVideoElement) {
  62396. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  62397. return src;
  62398. }
  62399. var video = document.createElement("video");
  62400. if (typeof src === "string") {
  62401. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  62402. video.src = src;
  62403. }
  62404. else {
  62405. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  62406. src.forEach(function (url) {
  62407. var source = document.createElement("source");
  62408. source.src = url;
  62409. video.appendChild(source);
  62410. });
  62411. }
  62412. return video;
  62413. };
  62414. /**
  62415. * @hidden Internal method to initiate `update`.
  62416. */
  62417. VideoTexture.prototype._rebuild = function () {
  62418. this.update();
  62419. };
  62420. /**
  62421. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  62422. */
  62423. VideoTexture.prototype.update = function () {
  62424. if (!this.autoUpdateTexture) {
  62425. // Expecting user to call `updateTexture` manually
  62426. return;
  62427. }
  62428. this.updateTexture(true);
  62429. };
  62430. /**
  62431. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  62432. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  62433. */
  62434. VideoTexture.prototype.updateTexture = function (isVisible) {
  62435. if (!isVisible) {
  62436. return;
  62437. }
  62438. if (this.video.paused && this._stillImageCaptured) {
  62439. return;
  62440. }
  62441. this._stillImageCaptured = true;
  62442. this._updateInternalTexture();
  62443. };
  62444. /**
  62445. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  62446. * @param url New url.
  62447. */
  62448. VideoTexture.prototype.updateURL = function (url) {
  62449. this.video.src = url;
  62450. };
  62451. /**
  62452. * Dispose the texture and release its associated resources.
  62453. */
  62454. VideoTexture.prototype.dispose = function () {
  62455. _super.prototype.dispose.call(this);
  62456. if (this._onUserActionRequestedObservable) {
  62457. this._onUserActionRequestedObservable.clear();
  62458. this._onUserActionRequestedObservable = null;
  62459. }
  62460. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  62461. this.video.removeEventListener("paused", this._updateInternalTexture);
  62462. this.video.removeEventListener("seeked", this._updateInternalTexture);
  62463. this.video.removeEventListener("emptied", this.reset);
  62464. this.video.pause();
  62465. };
  62466. /**
  62467. * Creates a video texture straight from a stream.
  62468. * @param scene Define the scene the texture should be created in
  62469. * @param stream Define the stream the texture should be created from
  62470. * @returns The created video texture as a promise
  62471. */
  62472. VideoTexture.CreateFromStreamAsync = function (scene, stream) {
  62473. var video = document.createElement("video");
  62474. video.setAttribute('autoplay', '');
  62475. video.setAttribute('muted', 'true');
  62476. video.setAttribute('playsinline', '');
  62477. video.muted = true;
  62478. if (video.mozSrcObject !== undefined) {
  62479. // hack for Firefox < 19
  62480. video.mozSrcObject = stream;
  62481. }
  62482. else {
  62483. if (typeof video.srcObject == "object") {
  62484. video.srcObject = stream;
  62485. }
  62486. else {
  62487. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  62488. video.src = (window.URL && window.URL.createObjectURL(stream));
  62489. }
  62490. }
  62491. return new Promise(function (resolve) {
  62492. var onPlaying = function () {
  62493. resolve(new VideoTexture("video", video, scene, true, true));
  62494. video.removeEventListener("playing", onPlaying);
  62495. };
  62496. video.addEventListener("playing", onPlaying);
  62497. video.play();
  62498. });
  62499. };
  62500. /**
  62501. * Creates a video texture straight from your WebCam video feed.
  62502. * @param scene Define the scene the texture should be created in
  62503. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  62504. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  62505. * @returns The created video texture as a promise
  62506. */
  62507. VideoTexture.CreateFromWebCamAsync = function (scene, constraints, audioConstaints) {
  62508. var _this = this;
  62509. if (audioConstaints === void 0) { audioConstaints = false; }
  62510. var constraintsDeviceId;
  62511. if (constraints && constraints.deviceId) {
  62512. constraintsDeviceId = {
  62513. exact: constraints.deviceId,
  62514. };
  62515. }
  62516. if (navigator.mediaDevices) {
  62517. return navigator.mediaDevices.getUserMedia({
  62518. video: constraints,
  62519. audio: audioConstaints
  62520. })
  62521. .then(function (stream) {
  62522. return _this.CreateFromStreamAsync(scene, stream);
  62523. });
  62524. }
  62525. else {
  62526. navigator.getUserMedia =
  62527. navigator.getUserMedia ||
  62528. navigator.webkitGetUserMedia ||
  62529. navigator.mozGetUserMedia ||
  62530. navigator.msGetUserMedia;
  62531. if (navigator.getUserMedia) {
  62532. navigator.getUserMedia({
  62533. video: {
  62534. deviceId: constraintsDeviceId,
  62535. width: {
  62536. min: (constraints && constraints.minWidth) || 256,
  62537. max: (constraints && constraints.maxWidth) || 640,
  62538. },
  62539. height: {
  62540. min: (constraints && constraints.minHeight) || 256,
  62541. max: (constraints && constraints.maxHeight) || 480,
  62542. },
  62543. },
  62544. audio: audioConstaints
  62545. }, function (stream) {
  62546. return _this.CreateFromStreamAsync(scene, stream);
  62547. }, function (e) {
  62548. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  62549. });
  62550. }
  62551. }
  62552. return Promise.reject("No support for userMedia on this device");
  62553. };
  62554. /**
  62555. * Creates a video texture straight from your WebCam video feed.
  62556. * @param scene Define the scene the texture should be created in
  62557. * @param onReady Define a callback to triggered once the texture will be ready
  62558. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  62559. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  62560. */
  62561. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints, audioConstaints) {
  62562. if (audioConstaints === void 0) { audioConstaints = false; }
  62563. this.CreateFromWebCamAsync(scene, constraints, audioConstaints)
  62564. .then(function (videoTexture) {
  62565. if (onReady) {
  62566. onReady(videoTexture);
  62567. }
  62568. })
  62569. .catch(function (err) {
  62570. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  62571. });
  62572. };
  62573. return VideoTexture;
  62574. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  62575. /***/ }),
  62576. /***/ "./Materials/colorCurves.ts":
  62577. /*!**********************************!*\
  62578. !*** ./Materials/colorCurves.ts ***!
  62579. \**********************************/
  62580. /*! exports provided: ColorCurves */
  62581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62582. "use strict";
  62583. __webpack_require__.r(__webpack_exports__);
  62584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  62585. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62586. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  62587. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  62588. /**
  62589. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  62590. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  62591. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  62592. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  62593. */
  62594. var ColorCurves = /** @class */ (function () {
  62595. function ColorCurves() {
  62596. this._dirty = true;
  62597. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62598. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62599. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62600. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62601. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62602. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62603. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62604. this._globalHue = 30;
  62605. this._globalDensity = 0;
  62606. this._globalSaturation = 0;
  62607. this._globalExposure = 0;
  62608. this._highlightsHue = 30;
  62609. this._highlightsDensity = 0;
  62610. this._highlightsSaturation = 0;
  62611. this._highlightsExposure = 0;
  62612. this._midtonesHue = 30;
  62613. this._midtonesDensity = 0;
  62614. this._midtonesSaturation = 0;
  62615. this._midtonesExposure = 0;
  62616. this._shadowsHue = 30;
  62617. this._shadowsDensity = 0;
  62618. this._shadowsSaturation = 0;
  62619. this._shadowsExposure = 0;
  62620. }
  62621. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  62622. /**
  62623. * Gets the global Hue value.
  62624. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  62625. */
  62626. get: function () {
  62627. return this._globalHue;
  62628. },
  62629. /**
  62630. * Sets the global Hue value.
  62631. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  62632. */
  62633. set: function (value) {
  62634. this._globalHue = value;
  62635. this._dirty = true;
  62636. },
  62637. enumerable: true,
  62638. configurable: true
  62639. });
  62640. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  62641. /**
  62642. * Gets the global Density value.
  62643. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  62644. * Values less than zero provide a filter of opposite hue.
  62645. */
  62646. get: function () {
  62647. return this._globalDensity;
  62648. },
  62649. /**
  62650. * Sets the global Density value.
  62651. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  62652. * Values less than zero provide a filter of opposite hue.
  62653. */
  62654. set: function (value) {
  62655. this._globalDensity = value;
  62656. this._dirty = true;
  62657. },
  62658. enumerable: true,
  62659. configurable: true
  62660. });
  62661. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  62662. /**
  62663. * Gets the global Saturation value.
  62664. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  62665. */
  62666. get: function () {
  62667. return this._globalSaturation;
  62668. },
  62669. /**
  62670. * Sets the global Saturation value.
  62671. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  62672. */
  62673. set: function (value) {
  62674. this._globalSaturation = value;
  62675. this._dirty = true;
  62676. },
  62677. enumerable: true,
  62678. configurable: true
  62679. });
  62680. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  62681. /**
  62682. * Gets the global Exposure value.
  62683. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  62684. */
  62685. get: function () {
  62686. return this._globalExposure;
  62687. },
  62688. /**
  62689. * Sets the global Exposure value.
  62690. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  62691. */
  62692. set: function (value) {
  62693. this._globalExposure = value;
  62694. this._dirty = true;
  62695. },
  62696. enumerable: true,
  62697. configurable: true
  62698. });
  62699. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  62700. /**
  62701. * Gets the highlights Hue value.
  62702. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  62703. */
  62704. get: function () {
  62705. return this._highlightsHue;
  62706. },
  62707. /**
  62708. * Sets the highlights Hue value.
  62709. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  62710. */
  62711. set: function (value) {
  62712. this._highlightsHue = value;
  62713. this._dirty = true;
  62714. },
  62715. enumerable: true,
  62716. configurable: true
  62717. });
  62718. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  62719. /**
  62720. * Gets the highlights Density value.
  62721. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  62722. * Values less than zero provide a filter of opposite hue.
  62723. */
  62724. get: function () {
  62725. return this._highlightsDensity;
  62726. },
  62727. /**
  62728. * Sets the highlights Density value.
  62729. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  62730. * Values less than zero provide a filter of opposite hue.
  62731. */
  62732. set: function (value) {
  62733. this._highlightsDensity = value;
  62734. this._dirty = true;
  62735. },
  62736. enumerable: true,
  62737. configurable: true
  62738. });
  62739. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  62740. /**
  62741. * Gets the highlights Saturation value.
  62742. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  62743. */
  62744. get: function () {
  62745. return this._highlightsSaturation;
  62746. },
  62747. /**
  62748. * Sets the highlights Saturation value.
  62749. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  62750. */
  62751. set: function (value) {
  62752. this._highlightsSaturation = value;
  62753. this._dirty = true;
  62754. },
  62755. enumerable: true,
  62756. configurable: true
  62757. });
  62758. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  62759. /**
  62760. * Gets the highlights Exposure value.
  62761. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  62762. */
  62763. get: function () {
  62764. return this._highlightsExposure;
  62765. },
  62766. /**
  62767. * Sets the highlights Exposure value.
  62768. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  62769. */
  62770. set: function (value) {
  62771. this._highlightsExposure = value;
  62772. this._dirty = true;
  62773. },
  62774. enumerable: true,
  62775. configurable: true
  62776. });
  62777. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  62778. /**
  62779. * Gets the midtones Hue value.
  62780. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  62781. */
  62782. get: function () {
  62783. return this._midtonesHue;
  62784. },
  62785. /**
  62786. * Sets the midtones Hue value.
  62787. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  62788. */
  62789. set: function (value) {
  62790. this._midtonesHue = value;
  62791. this._dirty = true;
  62792. },
  62793. enumerable: true,
  62794. configurable: true
  62795. });
  62796. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  62797. /**
  62798. * Gets the midtones Density value.
  62799. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  62800. * Values less than zero provide a filter of opposite hue.
  62801. */
  62802. get: function () {
  62803. return this._midtonesDensity;
  62804. },
  62805. /**
  62806. * Sets the midtones Density value.
  62807. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  62808. * Values less than zero provide a filter of opposite hue.
  62809. */
  62810. set: function (value) {
  62811. this._midtonesDensity = value;
  62812. this._dirty = true;
  62813. },
  62814. enumerable: true,
  62815. configurable: true
  62816. });
  62817. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  62818. /**
  62819. * Gets the midtones Saturation value.
  62820. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  62821. */
  62822. get: function () {
  62823. return this._midtonesSaturation;
  62824. },
  62825. /**
  62826. * Sets the midtones Saturation value.
  62827. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  62828. */
  62829. set: function (value) {
  62830. this._midtonesSaturation = value;
  62831. this._dirty = true;
  62832. },
  62833. enumerable: true,
  62834. configurable: true
  62835. });
  62836. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  62837. /**
  62838. * Gets the midtones Exposure value.
  62839. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  62840. */
  62841. get: function () {
  62842. return this._midtonesExposure;
  62843. },
  62844. /**
  62845. * Sets the midtones Exposure value.
  62846. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  62847. */
  62848. set: function (value) {
  62849. this._midtonesExposure = value;
  62850. this._dirty = true;
  62851. },
  62852. enumerable: true,
  62853. configurable: true
  62854. });
  62855. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  62856. /**
  62857. * Gets the shadows Hue value.
  62858. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  62859. */
  62860. get: function () {
  62861. return this._shadowsHue;
  62862. },
  62863. /**
  62864. * Sets the shadows Hue value.
  62865. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  62866. */
  62867. set: function (value) {
  62868. this._shadowsHue = value;
  62869. this._dirty = true;
  62870. },
  62871. enumerable: true,
  62872. configurable: true
  62873. });
  62874. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  62875. /**
  62876. * Gets the shadows Density value.
  62877. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  62878. * Values less than zero provide a filter of opposite hue.
  62879. */
  62880. get: function () {
  62881. return this._shadowsDensity;
  62882. },
  62883. /**
  62884. * Sets the shadows Density value.
  62885. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  62886. * Values less than zero provide a filter of opposite hue.
  62887. */
  62888. set: function (value) {
  62889. this._shadowsDensity = value;
  62890. this._dirty = true;
  62891. },
  62892. enumerable: true,
  62893. configurable: true
  62894. });
  62895. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  62896. /**
  62897. * Gets the shadows Saturation value.
  62898. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  62899. */
  62900. get: function () {
  62901. return this._shadowsSaturation;
  62902. },
  62903. /**
  62904. * Sets the shadows Saturation value.
  62905. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  62906. */
  62907. set: function (value) {
  62908. this._shadowsSaturation = value;
  62909. this._dirty = true;
  62910. },
  62911. enumerable: true,
  62912. configurable: true
  62913. });
  62914. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  62915. /**
  62916. * Gets the shadows Exposure value.
  62917. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  62918. */
  62919. get: function () {
  62920. return this._shadowsExposure;
  62921. },
  62922. /**
  62923. * Sets the shadows Exposure value.
  62924. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  62925. */
  62926. set: function (value) {
  62927. this._shadowsExposure = value;
  62928. this._dirty = true;
  62929. },
  62930. enumerable: true,
  62931. configurable: true
  62932. });
  62933. /**
  62934. * Returns the class name
  62935. * @returns The class name
  62936. */
  62937. ColorCurves.prototype.getClassName = function () {
  62938. return "ColorCurves";
  62939. };
  62940. /**
  62941. * Binds the color curves to the shader.
  62942. * @param colorCurves The color curve to bind
  62943. * @param effect The effect to bind to
  62944. * @param positiveUniform The positive uniform shader parameter
  62945. * @param neutralUniform The neutral uniform shader parameter
  62946. * @param negativeUniform The negative uniform shader parameter
  62947. */
  62948. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  62949. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  62950. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  62951. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  62952. if (colorCurves._dirty) {
  62953. colorCurves._dirty = false;
  62954. // Fill in global info.
  62955. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  62956. // Compute highlights info.
  62957. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  62958. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  62959. // Compute midtones info.
  62960. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  62961. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  62962. // Compute shadows info.
  62963. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  62964. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  62965. // Compute deltas (neutral is midtones).
  62966. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  62967. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  62968. }
  62969. if (effect) {
  62970. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  62971. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  62972. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  62973. }
  62974. };
  62975. /**
  62976. * Prepare the list of uniforms associated with the ColorCurves effects.
  62977. * @param uniformsList The list of uniforms used in the effect
  62978. */
  62979. ColorCurves.PrepareUniforms = function (uniformsList) {
  62980. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  62981. };
  62982. /**
  62983. * Returns color grading data based on a hue, density, saturation and exposure value.
  62984. * @param filterHue The hue of the color filter.
  62985. * @param filterDensity The density of the color filter.
  62986. * @param saturation The saturation.
  62987. * @param exposure The exposure.
  62988. * @param result The result data container.
  62989. */
  62990. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  62991. if (hue == null) {
  62992. return;
  62993. }
  62994. hue = ColorCurves.clamp(hue, 0, 360);
  62995. density = ColorCurves.clamp(density, -100, 100);
  62996. saturation = ColorCurves.clamp(saturation, -100, 100);
  62997. exposure = ColorCurves.clamp(exposure, -100, 100);
  62998. // Remap the slider/config filter density with non-linear mapping and also scale by half
  62999. // so that the maximum filter density is only 50% control. This provides fine control
  63000. // for small values and reasonable range.
  63001. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  63002. density *= 0.5;
  63003. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  63004. if (density < 0) {
  63005. density *= -1;
  63006. hue = (hue + 180) % 360;
  63007. }
  63008. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  63009. result.scaleToRef(2, result);
  63010. result.a = 1 + 0.01 * saturation;
  63011. };
  63012. /**
  63013. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  63014. * @param value The input slider value in range [-100,100].
  63015. * @returns Adjusted value.
  63016. */
  63017. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  63018. value /= 100;
  63019. var x = Math.abs(value);
  63020. x = Math.pow(x, 2);
  63021. if (value < 0) {
  63022. x *= -1;
  63023. }
  63024. x *= 100;
  63025. return x;
  63026. };
  63027. /**
  63028. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  63029. * @param hue The hue (H) input.
  63030. * @param saturation The saturation (S) input.
  63031. * @param brightness The brightness (B) input.
  63032. * @result An RGBA color represented as Vector4.
  63033. */
  63034. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  63035. var h = ColorCurves.clamp(hue, 0, 360);
  63036. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  63037. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  63038. if (s === 0) {
  63039. result.r = v;
  63040. result.g = v;
  63041. result.b = v;
  63042. }
  63043. else {
  63044. // sector 0 to 5
  63045. h /= 60;
  63046. var i = Math.floor(h);
  63047. // fractional part of h
  63048. var f = h - i;
  63049. var p = v * (1 - s);
  63050. var q = v * (1 - s * f);
  63051. var t = v * (1 - s * (1 - f));
  63052. switch (i) {
  63053. case 0:
  63054. result.r = v;
  63055. result.g = t;
  63056. result.b = p;
  63057. break;
  63058. case 1:
  63059. result.r = q;
  63060. result.g = v;
  63061. result.b = p;
  63062. break;
  63063. case 2:
  63064. result.r = p;
  63065. result.g = v;
  63066. result.b = t;
  63067. break;
  63068. case 3:
  63069. result.r = p;
  63070. result.g = q;
  63071. result.b = v;
  63072. break;
  63073. case 4:
  63074. result.r = t;
  63075. result.g = p;
  63076. result.b = v;
  63077. break;
  63078. default: // case 5:
  63079. result.r = v;
  63080. result.g = p;
  63081. result.b = q;
  63082. break;
  63083. }
  63084. }
  63085. result.a = 1;
  63086. };
  63087. /**
  63088. * Returns a value clamped between min and max
  63089. * @param value The value to clamp
  63090. * @param min The minimum of value
  63091. * @param max The maximum of value
  63092. * @returns The clamped value.
  63093. */
  63094. ColorCurves.clamp = function (value, min, max) {
  63095. return Math.min(Math.max(value, min), max);
  63096. };
  63097. /**
  63098. * Clones the current color curve instance.
  63099. * @return The cloned curves
  63100. */
  63101. ColorCurves.prototype.clone = function () {
  63102. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  63103. };
  63104. /**
  63105. * Serializes the current color curve instance to a json representation.
  63106. * @return a JSON representation
  63107. */
  63108. ColorCurves.prototype.serialize = function () {
  63109. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  63110. };
  63111. /**
  63112. * Parses the color curve from a json representation.
  63113. * @param source the JSON source to parse
  63114. * @return The parsed curves
  63115. */
  63116. ColorCurves.Parse = function (source) {
  63117. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  63118. };
  63119. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63121. ], ColorCurves.prototype, "_globalHue", void 0);
  63122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63124. ], ColorCurves.prototype, "_globalDensity", void 0);
  63125. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63126. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63127. ], ColorCurves.prototype, "_globalSaturation", void 0);
  63128. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63129. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63130. ], ColorCurves.prototype, "_globalExposure", void 0);
  63131. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63133. ], ColorCurves.prototype, "_highlightsHue", void 0);
  63134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63136. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  63137. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63138. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63139. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  63140. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63141. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63142. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  63143. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63145. ], ColorCurves.prototype, "_midtonesHue", void 0);
  63146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63148. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  63149. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63150. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63151. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  63152. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63153. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63154. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  63155. return ColorCurves;
  63156. }());
  63157. // References the dependencies.
  63158. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  63159. /***/ }),
  63160. /***/ "./Materials/effect.ts":
  63161. /*!*****************************!*\
  63162. !*** ./Materials/effect.ts ***!
  63163. \*****************************/
  63164. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  63165. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63166. "use strict";
  63167. __webpack_require__.r(__webpack_exports__);
  63168. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  63169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  63170. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  63171. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  63172. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  63173. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  63174. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  63175. /**
  63176. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  63177. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  63178. */
  63179. var EffectFallbacks = /** @class */ (function () {
  63180. function EffectFallbacks() {
  63181. this._defines = {};
  63182. this._currentRank = 32;
  63183. this._maxRank = -1;
  63184. }
  63185. /**
  63186. * Removes the fallback from the bound mesh.
  63187. */
  63188. EffectFallbacks.prototype.unBindMesh = function () {
  63189. this._mesh = null;
  63190. };
  63191. /**
  63192. * Adds a fallback on the specified property.
  63193. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  63194. * @param define The name of the define in the shader
  63195. */
  63196. EffectFallbacks.prototype.addFallback = function (rank, define) {
  63197. if (!this._defines[rank]) {
  63198. if (rank < this._currentRank) {
  63199. this._currentRank = rank;
  63200. }
  63201. if (rank > this._maxRank) {
  63202. this._maxRank = rank;
  63203. }
  63204. this._defines[rank] = new Array();
  63205. }
  63206. this._defines[rank].push(define);
  63207. };
  63208. /**
  63209. * Sets the mesh to use CPU skinning when needing to fallback.
  63210. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  63211. * @param mesh The mesh to use the fallbacks.
  63212. */
  63213. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  63214. this._mesh = mesh;
  63215. if (rank < this._currentRank) {
  63216. this._currentRank = rank;
  63217. }
  63218. if (rank > this._maxRank) {
  63219. this._maxRank = rank;
  63220. }
  63221. };
  63222. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  63223. /**
  63224. * Checks to see if more fallbacks are still availible.
  63225. */
  63226. get: function () {
  63227. return this._currentRank <= this._maxRank;
  63228. },
  63229. enumerable: true,
  63230. configurable: true
  63231. });
  63232. /**
  63233. * Removes the defines that shoould be removed when falling back.
  63234. * @param currentDefines defines the current define statements for the shader.
  63235. * @param effect defines the current effect we try to compile
  63236. * @returns The resulting defines with defines of the current rank removed.
  63237. */
  63238. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  63239. // First we try to switch to CPU skinning
  63240. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  63241. this._mesh.computeBonesUsingShaders = false;
  63242. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  63243. effect._bonesComputationForcedToCPU = true;
  63244. var scene = this._mesh.getScene();
  63245. for (var index = 0; index < scene.meshes.length; index++) {
  63246. var otherMesh = scene.meshes[index];
  63247. if (!otherMesh.material) {
  63248. continue;
  63249. }
  63250. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  63251. continue;
  63252. }
  63253. if (otherMesh.material.getEffect() === effect) {
  63254. otherMesh.computeBonesUsingShaders = false;
  63255. }
  63256. else if (otherMesh.subMeshes) {
  63257. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  63258. var subMesh = _a[_i];
  63259. var subMeshEffect = subMesh.effect;
  63260. if (subMeshEffect === effect) {
  63261. otherMesh.computeBonesUsingShaders = false;
  63262. break;
  63263. }
  63264. }
  63265. }
  63266. }
  63267. }
  63268. else {
  63269. var currentFallbacks = this._defines[this._currentRank];
  63270. if (currentFallbacks) {
  63271. for (var index = 0; index < currentFallbacks.length; index++) {
  63272. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  63273. }
  63274. }
  63275. this._currentRank++;
  63276. }
  63277. return currentDefines;
  63278. };
  63279. return EffectFallbacks;
  63280. }());
  63281. /**
  63282. * Options to be used when creating an effect.
  63283. */
  63284. var EffectCreationOptions = /** @class */ (function () {
  63285. function EffectCreationOptions() {
  63286. }
  63287. return EffectCreationOptions;
  63288. }());
  63289. /**
  63290. * Effect containing vertex and fragment shader that can be executed on an object.
  63291. */
  63292. var Effect = /** @class */ (function () {
  63293. /**
  63294. * Instantiates an effect.
  63295. * An effect can be used to create/manage/execute vertex and fragment shaders.
  63296. * @param baseName Name of the effect.
  63297. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  63298. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  63299. * @param samplers List of sampler variables that will be passed to the shader.
  63300. * @param engine Engine to be used to render the effect
  63301. * @param defines Define statements to be added to the shader.
  63302. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  63303. * @param onCompiled Callback that will be called when the shader is compiled.
  63304. * @param onError Callback that will be called if an error occurs during shader compilation.
  63305. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  63306. */
  63307. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  63308. if (samplers === void 0) { samplers = null; }
  63309. if (defines === void 0) { defines = null; }
  63310. if (fallbacks === void 0) { fallbacks = null; }
  63311. if (onCompiled === void 0) { onCompiled = null; }
  63312. if (onError === void 0) { onError = null; }
  63313. var _this = this;
  63314. /**
  63315. * Unique ID of the effect.
  63316. */
  63317. this.uniqueId = 0;
  63318. /**
  63319. * Observable that will be called when the shader is compiled.
  63320. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  63321. */
  63322. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  63323. /**
  63324. * Observable that will be called if an error occurs during shader compilation.
  63325. */
  63326. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  63327. /** @hidden */
  63328. this._bonesComputationForcedToCPU = false;
  63329. this._uniformBuffersNames = {};
  63330. this._samplers = {};
  63331. this._isReady = false;
  63332. this._compilationError = "";
  63333. this._uniforms = {};
  63334. this.name = baseName;
  63335. if (attributesNamesOrOptions.attributes) {
  63336. var options = attributesNamesOrOptions;
  63337. this._engine = uniformsNamesOrEngine;
  63338. this._attributesNames = options.attributes;
  63339. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  63340. this._samplerList = options.samplers.slice();
  63341. this.defines = options.defines;
  63342. this.onError = options.onError;
  63343. this.onCompiled = options.onCompiled;
  63344. this._fallbacks = options.fallbacks;
  63345. this._indexParameters = options.indexParameters;
  63346. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  63347. if (options.uniformBuffersNames) {
  63348. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  63349. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  63350. }
  63351. }
  63352. }
  63353. else {
  63354. this._engine = engine;
  63355. this.defines = (defines == null ? "" : defines);
  63356. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  63357. this._samplerList = samplers ? samplers.slice() : [];
  63358. this._attributesNames = attributesNamesOrOptions;
  63359. this.onError = onError;
  63360. this.onCompiled = onCompiled;
  63361. this._indexParameters = indexParameters;
  63362. this._fallbacks = fallbacks;
  63363. }
  63364. this.uniqueId = Effect._uniqueIdSeed++;
  63365. var vertexSource;
  63366. var fragmentSource;
  63367. if (baseName.vertexElement) {
  63368. vertexSource = document.getElementById(baseName.vertexElement);
  63369. if (!vertexSource) {
  63370. vertexSource = baseName.vertexElement;
  63371. }
  63372. }
  63373. else {
  63374. vertexSource = baseName.vertex || baseName;
  63375. }
  63376. if (baseName.fragmentElement) {
  63377. fragmentSource = document.getElementById(baseName.fragmentElement);
  63378. if (!fragmentSource) {
  63379. fragmentSource = baseName.fragmentElement;
  63380. }
  63381. }
  63382. else {
  63383. fragmentSource = baseName.fragment || baseName;
  63384. }
  63385. this._loadVertexShader(vertexSource, function (vertexCode) {
  63386. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  63387. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  63388. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  63389. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  63390. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  63391. if (baseName) {
  63392. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  63393. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  63394. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  63395. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  63396. }
  63397. else {
  63398. _this._vertexSourceCode = migratedVertexCode;
  63399. _this._fragmentSourceCode = migratedFragmentCode;
  63400. }
  63401. _this._prepareEffect();
  63402. });
  63403. });
  63404. });
  63405. });
  63406. });
  63407. });
  63408. }
  63409. Object.defineProperty(Effect.prototype, "onBindObservable", {
  63410. /**
  63411. * Observable that will be called when effect is bound.
  63412. */
  63413. get: function () {
  63414. if (!this._onBindObservable) {
  63415. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  63416. }
  63417. return this._onBindObservable;
  63418. },
  63419. enumerable: true,
  63420. configurable: true
  63421. });
  63422. Object.defineProperty(Effect.prototype, "key", {
  63423. /**
  63424. * Unique key for this effect
  63425. */
  63426. get: function () {
  63427. return this._key;
  63428. },
  63429. enumerable: true,
  63430. configurable: true
  63431. });
  63432. /**
  63433. * If the effect has been compiled and prepared.
  63434. * @returns if the effect is compiled and prepared.
  63435. */
  63436. Effect.prototype.isReady = function () {
  63437. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  63438. return this._engine._isProgramCompiled(this._program);
  63439. }
  63440. return this._isReady;
  63441. };
  63442. /**
  63443. * The engine the effect was initialized with.
  63444. * @returns the engine.
  63445. */
  63446. Effect.prototype.getEngine = function () {
  63447. return this._engine;
  63448. };
  63449. /**
  63450. * The compiled webGL program for the effect
  63451. * @returns the webGL program.
  63452. */
  63453. Effect.prototype.getProgram = function () {
  63454. return this._program;
  63455. };
  63456. /**
  63457. * The set of names of attribute variables for the shader.
  63458. * @returns An array of attribute names.
  63459. */
  63460. Effect.prototype.getAttributesNames = function () {
  63461. return this._attributesNames;
  63462. };
  63463. /**
  63464. * Returns the attribute at the given index.
  63465. * @param index The index of the attribute.
  63466. * @returns The location of the attribute.
  63467. */
  63468. Effect.prototype.getAttributeLocation = function (index) {
  63469. return this._attributes[index];
  63470. };
  63471. /**
  63472. * Returns the attribute based on the name of the variable.
  63473. * @param name of the attribute to look up.
  63474. * @returns the attribute location.
  63475. */
  63476. Effect.prototype.getAttributeLocationByName = function (name) {
  63477. var index = this._attributesNames.indexOf(name);
  63478. return this._attributes[index];
  63479. };
  63480. /**
  63481. * The number of attributes.
  63482. * @returns the numnber of attributes.
  63483. */
  63484. Effect.prototype.getAttributesCount = function () {
  63485. return this._attributes.length;
  63486. };
  63487. /**
  63488. * Gets the index of a uniform variable.
  63489. * @param uniformName of the uniform to look up.
  63490. * @returns the index.
  63491. */
  63492. Effect.prototype.getUniformIndex = function (uniformName) {
  63493. return this._uniformsNames.indexOf(uniformName);
  63494. };
  63495. /**
  63496. * Returns the attribute based on the name of the variable.
  63497. * @param uniformName of the uniform to look up.
  63498. * @returns the location of the uniform.
  63499. */
  63500. Effect.prototype.getUniform = function (uniformName) {
  63501. return this._uniforms[uniformName];
  63502. };
  63503. /**
  63504. * Returns an array of sampler variable names
  63505. * @returns The array of sampler variable neames.
  63506. */
  63507. Effect.prototype.getSamplers = function () {
  63508. return this._samplerList;
  63509. };
  63510. /**
  63511. * The error from the last compilation.
  63512. * @returns the error string.
  63513. */
  63514. Effect.prototype.getCompilationError = function () {
  63515. return this._compilationError;
  63516. };
  63517. /**
  63518. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  63519. * @param func The callback to be used.
  63520. */
  63521. Effect.prototype.executeWhenCompiled = function (func) {
  63522. var _this = this;
  63523. if (this.isReady()) {
  63524. func(this);
  63525. return;
  63526. }
  63527. this.onCompileObservable.add(function (effect) {
  63528. func(effect);
  63529. });
  63530. if (!this._program || this._program.isParallelCompiled) {
  63531. setTimeout(function () {
  63532. _this._checkIsReady();
  63533. }, 16);
  63534. }
  63535. };
  63536. Effect.prototype._checkIsReady = function () {
  63537. var _this = this;
  63538. if (this.isReady()) {
  63539. return;
  63540. }
  63541. setTimeout(function () {
  63542. _this._checkIsReady();
  63543. }, 16);
  63544. };
  63545. /** @hidden */
  63546. Effect.prototype._loadVertexShader = function (vertex, callback) {
  63547. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  63548. // DOM element ?
  63549. if (vertex instanceof HTMLElement) {
  63550. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  63551. callback(vertexCode);
  63552. return;
  63553. }
  63554. }
  63555. // Base64 encoded ?
  63556. if (vertex.substr(0, 7) === "base64:") {
  63557. var vertexBinary = window.atob(vertex.substr(7));
  63558. callback(vertexBinary);
  63559. return;
  63560. }
  63561. // Is in local store ?
  63562. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  63563. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  63564. return;
  63565. }
  63566. var vertexShaderUrl;
  63567. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  63568. vertexShaderUrl = vertex;
  63569. }
  63570. else {
  63571. vertexShaderUrl = Effect.ShadersRepository + vertex;
  63572. }
  63573. // Vertex shader
  63574. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  63575. };
  63576. /** @hidden */
  63577. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  63578. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  63579. // DOM element ?
  63580. if (fragment instanceof HTMLElement) {
  63581. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  63582. callback(fragmentCode);
  63583. return;
  63584. }
  63585. }
  63586. // Base64 encoded ?
  63587. if (fragment.substr(0, 7) === "base64:") {
  63588. var fragmentBinary = window.atob(fragment.substr(7));
  63589. callback(fragmentBinary);
  63590. return;
  63591. }
  63592. // Is in local store ?
  63593. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  63594. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  63595. return;
  63596. }
  63597. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  63598. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  63599. return;
  63600. }
  63601. var fragmentShaderUrl;
  63602. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  63603. fragmentShaderUrl = fragment;
  63604. }
  63605. else {
  63606. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  63607. }
  63608. // Fragment shader
  63609. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  63610. };
  63611. /** @hidden */
  63612. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  63613. // Rebuild shaders source code
  63614. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  63615. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  63616. vertexCode = prefix + vertexCode;
  63617. fragmentCode = prefix + fragmentCode;
  63618. // Number lines of shaders source code
  63619. var i = 2;
  63620. var regex = /\n/gm;
  63621. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  63622. i = 2;
  63623. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  63624. // Dump shaders name and formatted source code
  63625. if (this.name.vertexElement) {
  63626. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  63627. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  63628. }
  63629. else if (this.name.vertex) {
  63630. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  63631. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  63632. }
  63633. else {
  63634. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  63635. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  63636. }
  63637. };
  63638. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  63639. var preparedSourceCode = this._processPrecision(sourceCode);
  63640. if (this._engine.webGLVersion == 1) {
  63641. callback(preparedSourceCode);
  63642. return;
  63643. }
  63644. // Already converted
  63645. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  63646. callback(preparedSourceCode.replace("#version 300 es", ""));
  63647. return;
  63648. }
  63649. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  63650. // Remove extensions
  63651. // #extension GL_OES_standard_derivatives : enable
  63652. // #extension GL_EXT_shader_texture_lod : enable
  63653. // #extension GL_EXT_frag_depth : enable
  63654. // #extension GL_EXT_draw_buffers : require
  63655. var regex = /#extension.+(GL_OVR_multiview|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  63656. var result = preparedSourceCode.replace(regex, "");
  63657. // Migrate to GLSL v300
  63658. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  63659. result = result.replace(/attribute[ \t]/g, "in ");
  63660. result = result.replace(/[ \t]attribute/g, " in");
  63661. result = result.replace(/texture2D\s*\(/g, "texture(");
  63662. if (isFragment) {
  63663. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  63664. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  63665. result = result.replace(/textureCube\s*\(/g, "texture(");
  63666. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  63667. result = result.replace(/gl_FragColor/g, "glFragColor");
  63668. result = result.replace(/gl_FragData/g, "glFragData");
  63669. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  63670. }
  63671. // Add multiview setup to top of file when defined
  63672. var hasMultiviewExtension = this.defines.indexOf("#define MULTIVIEW\n") !== -1;
  63673. if (hasMultiviewExtension && !isFragment) {
  63674. result = "#extension GL_OVR_multiview : require\nlayout (num_views = 2) in;\n" + result;
  63675. }
  63676. callback(result);
  63677. };
  63678. Effect.prototype._processIncludes = function (sourceCode, callback) {
  63679. var _this = this;
  63680. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  63681. var match = regex.exec(sourceCode);
  63682. var returnValue = new String(sourceCode);
  63683. while (match != null) {
  63684. var includeFile = match[1];
  63685. // Uniform declaration
  63686. if (includeFile.indexOf("__decl__") !== -1) {
  63687. includeFile = includeFile.replace(/__decl__/, "");
  63688. if (this._engine.supportsUniformBuffers) {
  63689. includeFile = includeFile.replace(/Vertex/, "Ubo");
  63690. includeFile = includeFile.replace(/Fragment/, "Ubo");
  63691. }
  63692. includeFile = includeFile + "Declaration";
  63693. }
  63694. if (Effect.IncludesShadersStore[includeFile]) {
  63695. // Substitution
  63696. var includeContent = Effect.IncludesShadersStore[includeFile];
  63697. if (match[2]) {
  63698. var splits = match[3].split(",");
  63699. for (var index = 0; index < splits.length; index += 2) {
  63700. var source = new RegExp(splits[index], "g");
  63701. var dest = splits[index + 1];
  63702. includeContent = includeContent.replace(source, dest);
  63703. }
  63704. }
  63705. if (match[4]) {
  63706. var indexString = match[5];
  63707. if (indexString.indexOf("..") !== -1) {
  63708. var indexSplits = indexString.split("..");
  63709. var minIndex = parseInt(indexSplits[0]);
  63710. var maxIndex = parseInt(indexSplits[1]);
  63711. var sourceIncludeContent = includeContent.slice(0);
  63712. includeContent = "";
  63713. if (isNaN(maxIndex)) {
  63714. maxIndex = this._indexParameters[indexSplits[1]];
  63715. }
  63716. for (var i = minIndex; i < maxIndex; i++) {
  63717. if (!this._engine.supportsUniformBuffers) {
  63718. // Ubo replacement
  63719. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  63720. return p1 + "{X}";
  63721. });
  63722. }
  63723. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  63724. }
  63725. }
  63726. else {
  63727. if (!this._engine.supportsUniformBuffers) {
  63728. // Ubo replacement
  63729. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  63730. return p1 + "{X}";
  63731. });
  63732. }
  63733. includeContent = includeContent.replace(/\{X\}/g, indexString);
  63734. }
  63735. }
  63736. // Replace
  63737. returnValue = returnValue.replace(match[0], includeContent);
  63738. }
  63739. else {
  63740. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  63741. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  63742. Effect.IncludesShadersStore[includeFile] = fileContent;
  63743. _this._processIncludes(returnValue, callback);
  63744. });
  63745. return;
  63746. }
  63747. match = regex.exec(sourceCode);
  63748. }
  63749. callback(returnValue);
  63750. };
  63751. Effect.prototype._processPrecision = function (source) {
  63752. var shouldUseHighPrecisionShader = this._engine._shouldUseHighPrecisionShader;
  63753. if (source.indexOf("precision highp float") === -1) {
  63754. if (!shouldUseHighPrecisionShader) {
  63755. source = "precision mediump float;\n" + source;
  63756. }
  63757. else {
  63758. source = "precision highp float;\n" + source;
  63759. }
  63760. }
  63761. else {
  63762. if (!shouldUseHighPrecisionShader) { // Moving highp to mediump
  63763. source = source.replace("precision highp float", "precision mediump float");
  63764. }
  63765. }
  63766. return source;
  63767. };
  63768. /**
  63769. * Recompiles the webGL program
  63770. * @param vertexSourceCode The source code for the vertex shader.
  63771. * @param fragmentSourceCode The source code for the fragment shader.
  63772. * @param onCompiled Callback called when completed.
  63773. * @param onError Callback called on error.
  63774. * @hidden
  63775. */
  63776. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  63777. var _this = this;
  63778. this._isReady = false;
  63779. this._vertexSourceCodeOverride = vertexSourceCode;
  63780. this._fragmentSourceCodeOverride = fragmentSourceCode;
  63781. this.onError = function (effect, error) {
  63782. if (onError) {
  63783. onError(error);
  63784. }
  63785. };
  63786. this.onCompiled = function () {
  63787. var scenes = _this.getEngine().scenes;
  63788. for (var i = 0; i < scenes.length; i++) {
  63789. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_AllDirtyFlag);
  63790. }
  63791. if (onCompiled) {
  63792. onCompiled(_this._program);
  63793. }
  63794. };
  63795. this._fallbacks = null;
  63796. this._prepareEffect();
  63797. };
  63798. /**
  63799. * Gets the uniform locations of the the specified variable names
  63800. * @param names THe names of the variables to lookup.
  63801. * @returns Array of locations in the same order as variable names.
  63802. */
  63803. Effect.prototype.getSpecificUniformLocations = function (names) {
  63804. var engine = this._engine;
  63805. return engine.getUniforms(this._program, names);
  63806. };
  63807. /**
  63808. * Prepares the effect
  63809. * @hidden
  63810. */
  63811. Effect.prototype._prepareEffect = function () {
  63812. var _this = this;
  63813. var attributesNames = this._attributesNames;
  63814. var defines = this.defines;
  63815. var fallbacks = this._fallbacks;
  63816. this._valueCache = {};
  63817. var previousProgram = this._program;
  63818. try {
  63819. var engine_1 = this._engine;
  63820. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  63821. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  63822. }
  63823. else {
  63824. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  63825. }
  63826. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  63827. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  63828. if (engine_1.supportsUniformBuffers) {
  63829. for (var name in _this._uniformBuffersNames) {
  63830. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  63831. }
  63832. }
  63833. var uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  63834. uniforms.forEach(function (uniform, index) {
  63835. _this._uniforms[_this._uniformsNames[index]] = uniform;
  63836. });
  63837. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  63838. var index;
  63839. for (index = 0; index < _this._samplerList.length; index++) {
  63840. var sampler = _this.getUniform(_this._samplerList[index]);
  63841. if (sampler == null) {
  63842. _this._samplerList.splice(index, 1);
  63843. index--;
  63844. }
  63845. }
  63846. _this._samplerList.forEach(function (name, index) {
  63847. _this._samplers[name] = index;
  63848. });
  63849. engine_1.bindSamplers(_this);
  63850. _this._compilationError = "";
  63851. _this._isReady = true;
  63852. if (_this.onCompiled) {
  63853. _this.onCompiled(_this);
  63854. }
  63855. _this.onCompileObservable.notifyObservers(_this);
  63856. _this.onCompileObservable.clear();
  63857. // Unbind mesh reference in fallbacks
  63858. if (_this._fallbacks) {
  63859. _this._fallbacks.unBindMesh();
  63860. }
  63861. if (previousProgram) {
  63862. _this.getEngine()._deleteProgram(previousProgram);
  63863. }
  63864. });
  63865. if (this._program.isParallelCompiled) {
  63866. this._checkIsReady();
  63867. }
  63868. }
  63869. catch (e) {
  63870. this._compilationError = e.message;
  63871. // Let's go through fallbacks then
  63872. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  63873. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  63874. return " " + uniform;
  63875. }));
  63876. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  63877. return " " + attribute;
  63878. }));
  63879. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  63880. if (previousProgram) {
  63881. this._program = previousProgram;
  63882. this._isReady = true;
  63883. if (this.onError) {
  63884. this.onError(this, this._compilationError);
  63885. }
  63886. this.onErrorObservable.notifyObservers(this);
  63887. }
  63888. if (fallbacks && fallbacks.isMoreFallbacks) {
  63889. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  63890. this.defines = fallbacks.reduce(this.defines, this);
  63891. this._prepareEffect();
  63892. }
  63893. else { // Sorry we did everything we can
  63894. if (this.onError) {
  63895. this.onError(this, this._compilationError);
  63896. }
  63897. this.onErrorObservable.notifyObservers(this);
  63898. this.onErrorObservable.clear();
  63899. // Unbind mesh reference in fallbacks
  63900. if (this._fallbacks) {
  63901. this._fallbacks.unBindMesh();
  63902. }
  63903. }
  63904. }
  63905. };
  63906. Object.defineProperty(Effect.prototype, "isSupported", {
  63907. /**
  63908. * Checks if the effect is supported. (Must be called after compilation)
  63909. */
  63910. get: function () {
  63911. return this._compilationError === "";
  63912. },
  63913. enumerable: true,
  63914. configurable: true
  63915. });
  63916. /**
  63917. * Binds a texture to the engine to be used as output of the shader.
  63918. * @param channel Name of the output variable.
  63919. * @param texture Texture to bind.
  63920. * @hidden
  63921. */
  63922. Effect.prototype._bindTexture = function (channel, texture) {
  63923. this._engine._bindTexture(this._samplers[channel], texture);
  63924. };
  63925. /**
  63926. * Sets a texture on the engine to be used in the shader.
  63927. * @param channel Name of the sampler variable.
  63928. * @param texture Texture to set.
  63929. */
  63930. Effect.prototype.setTexture = function (channel, texture) {
  63931. this._engine.setTexture(this._samplers[channel], this._uniforms[channel], texture);
  63932. };
  63933. /**
  63934. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  63935. * @param channel Name of the sampler variable.
  63936. * @param texture Texture to set.
  63937. */
  63938. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  63939. this._engine.setDepthStencilTexture(this._samplers[channel], this._uniforms[channel], texture);
  63940. };
  63941. /**
  63942. * Sets an array of textures on the engine to be used in the shader.
  63943. * @param channel Name of the variable.
  63944. * @param textures Textures to set.
  63945. */
  63946. Effect.prototype.setTextureArray = function (channel, textures) {
  63947. var exName = channel + "Ex";
  63948. if (this._samplerList.indexOf(exName) === -1) {
  63949. var initialPos = this._samplers[channel];
  63950. for (var index = 1; index < textures.length; index++) {
  63951. this._samplerList.splice(initialPos + index, 0, exName);
  63952. this._samplers[exName] = initialPos + index;
  63953. }
  63954. }
  63955. this._engine.setTextureArray(this._samplers[channel], this._uniforms[channel], textures);
  63956. };
  63957. /**
  63958. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  63959. * @param channel Name of the sampler variable.
  63960. * @param postProcess Post process to get the input texture from.
  63961. */
  63962. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  63963. this._engine.setTextureFromPostProcess(this._samplers[channel], postProcess);
  63964. };
  63965. /**
  63966. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  63967. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  63968. * @param channel Name of the sampler variable.
  63969. * @param postProcess Post process to get the output texture from.
  63970. */
  63971. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  63972. this._engine.setTextureFromPostProcessOutput(this._samplers[channel], postProcess);
  63973. };
  63974. /** @hidden */
  63975. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  63976. var cache = this._valueCache[uniformName];
  63977. var flag = matrix.updateFlag;
  63978. if (cache !== undefined && cache === flag) {
  63979. return false;
  63980. }
  63981. this._valueCache[uniformName] = flag;
  63982. return true;
  63983. };
  63984. /** @hidden */
  63985. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  63986. var cache = this._valueCache[uniformName];
  63987. if (!cache) {
  63988. cache = [x, y];
  63989. this._valueCache[uniformName] = cache;
  63990. return true;
  63991. }
  63992. var changed = false;
  63993. if (cache[0] !== x) {
  63994. cache[0] = x;
  63995. changed = true;
  63996. }
  63997. if (cache[1] !== y) {
  63998. cache[1] = y;
  63999. changed = true;
  64000. }
  64001. return changed;
  64002. };
  64003. /** @hidden */
  64004. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  64005. var cache = this._valueCache[uniformName];
  64006. if (!cache) {
  64007. cache = [x, y, z];
  64008. this._valueCache[uniformName] = cache;
  64009. return true;
  64010. }
  64011. var changed = false;
  64012. if (cache[0] !== x) {
  64013. cache[0] = x;
  64014. changed = true;
  64015. }
  64016. if (cache[1] !== y) {
  64017. cache[1] = y;
  64018. changed = true;
  64019. }
  64020. if (cache[2] !== z) {
  64021. cache[2] = z;
  64022. changed = true;
  64023. }
  64024. return changed;
  64025. };
  64026. /** @hidden */
  64027. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  64028. var cache = this._valueCache[uniformName];
  64029. if (!cache) {
  64030. cache = [x, y, z, w];
  64031. this._valueCache[uniformName] = cache;
  64032. return true;
  64033. }
  64034. var changed = false;
  64035. if (cache[0] !== x) {
  64036. cache[0] = x;
  64037. changed = true;
  64038. }
  64039. if (cache[1] !== y) {
  64040. cache[1] = y;
  64041. changed = true;
  64042. }
  64043. if (cache[2] !== z) {
  64044. cache[2] = z;
  64045. changed = true;
  64046. }
  64047. if (cache[3] !== w) {
  64048. cache[3] = w;
  64049. changed = true;
  64050. }
  64051. return changed;
  64052. };
  64053. /**
  64054. * Binds a buffer to a uniform.
  64055. * @param buffer Buffer to bind.
  64056. * @param name Name of the uniform variable to bind to.
  64057. */
  64058. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  64059. var bufferName = this._uniformBuffersNames[name];
  64060. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  64061. return;
  64062. }
  64063. Effect._baseCache[bufferName] = buffer;
  64064. this._engine.bindUniformBufferBase(buffer, bufferName);
  64065. };
  64066. /**
  64067. * Binds block to a uniform.
  64068. * @param blockName Name of the block to bind.
  64069. * @param index Index to bind.
  64070. */
  64071. Effect.prototype.bindUniformBlock = function (blockName, index) {
  64072. this._engine.bindUniformBlock(this._program, blockName, index);
  64073. };
  64074. /**
  64075. * Sets an interger value on a uniform variable.
  64076. * @param uniformName Name of the variable.
  64077. * @param value Value to be set.
  64078. * @returns this effect.
  64079. */
  64080. Effect.prototype.setInt = function (uniformName, value) {
  64081. var cache = this._valueCache[uniformName];
  64082. if (cache !== undefined && cache === value) {
  64083. return this;
  64084. }
  64085. this._valueCache[uniformName] = value;
  64086. this._engine.setInt(this._uniforms[uniformName], value);
  64087. return this;
  64088. };
  64089. /**
  64090. * Sets an int array on a uniform variable.
  64091. * @param uniformName Name of the variable.
  64092. * @param array array to be set.
  64093. * @returns this effect.
  64094. */
  64095. Effect.prototype.setIntArray = function (uniformName, array) {
  64096. this._valueCache[uniformName] = null;
  64097. this._engine.setIntArray(this._uniforms[uniformName], array);
  64098. return this;
  64099. };
  64100. /**
  64101. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  64102. * @param uniformName Name of the variable.
  64103. * @param array array to be set.
  64104. * @returns this effect.
  64105. */
  64106. Effect.prototype.setIntArray2 = function (uniformName, array) {
  64107. this._valueCache[uniformName] = null;
  64108. this._engine.setIntArray2(this._uniforms[uniformName], array);
  64109. return this;
  64110. };
  64111. /**
  64112. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  64113. * @param uniformName Name of the variable.
  64114. * @param array array to be set.
  64115. * @returns this effect.
  64116. */
  64117. Effect.prototype.setIntArray3 = function (uniformName, array) {
  64118. this._valueCache[uniformName] = null;
  64119. this._engine.setIntArray3(this._uniforms[uniformName], array);
  64120. return this;
  64121. };
  64122. /**
  64123. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  64124. * @param uniformName Name of the variable.
  64125. * @param array array to be set.
  64126. * @returns this effect.
  64127. */
  64128. Effect.prototype.setIntArray4 = function (uniformName, array) {
  64129. this._valueCache[uniformName] = null;
  64130. this._engine.setIntArray4(this._uniforms[uniformName], array);
  64131. return this;
  64132. };
  64133. /**
  64134. * Sets an float array on a uniform variable.
  64135. * @param uniformName Name of the variable.
  64136. * @param array array to be set.
  64137. * @returns this effect.
  64138. */
  64139. Effect.prototype.setFloatArray = function (uniformName, array) {
  64140. this._valueCache[uniformName] = null;
  64141. this._engine.setFloatArray(this._uniforms[uniformName], array);
  64142. return this;
  64143. };
  64144. /**
  64145. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  64146. * @param uniformName Name of the variable.
  64147. * @param array array to be set.
  64148. * @returns this effect.
  64149. */
  64150. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  64151. this._valueCache[uniformName] = null;
  64152. this._engine.setFloatArray2(this._uniforms[uniformName], array);
  64153. return this;
  64154. };
  64155. /**
  64156. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  64157. * @param uniformName Name of the variable.
  64158. * @param array array to be set.
  64159. * @returns this effect.
  64160. */
  64161. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  64162. this._valueCache[uniformName] = null;
  64163. this._engine.setFloatArray3(this._uniforms[uniformName], array);
  64164. return this;
  64165. };
  64166. /**
  64167. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  64168. * @param uniformName Name of the variable.
  64169. * @param array array to be set.
  64170. * @returns this effect.
  64171. */
  64172. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  64173. this._valueCache[uniformName] = null;
  64174. this._engine.setFloatArray4(this._uniforms[uniformName], array);
  64175. return this;
  64176. };
  64177. /**
  64178. * Sets an array on a uniform variable.
  64179. * @param uniformName Name of the variable.
  64180. * @param array array to be set.
  64181. * @returns this effect.
  64182. */
  64183. Effect.prototype.setArray = function (uniformName, array) {
  64184. this._valueCache[uniformName] = null;
  64185. this._engine.setArray(this._uniforms[uniformName], array);
  64186. return this;
  64187. };
  64188. /**
  64189. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  64190. * @param uniformName Name of the variable.
  64191. * @param array array to be set.
  64192. * @returns this effect.
  64193. */
  64194. Effect.prototype.setArray2 = function (uniformName, array) {
  64195. this._valueCache[uniformName] = null;
  64196. this._engine.setArray2(this._uniforms[uniformName], array);
  64197. return this;
  64198. };
  64199. /**
  64200. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  64201. * @param uniformName Name of the variable.
  64202. * @param array array to be set.
  64203. * @returns this effect.
  64204. */
  64205. Effect.prototype.setArray3 = function (uniformName, array) {
  64206. this._valueCache[uniformName] = null;
  64207. this._engine.setArray3(this._uniforms[uniformName], array);
  64208. return this;
  64209. };
  64210. /**
  64211. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  64212. * @param uniformName Name of the variable.
  64213. * @param array array to be set.
  64214. * @returns this effect.
  64215. */
  64216. Effect.prototype.setArray4 = function (uniformName, array) {
  64217. this._valueCache[uniformName] = null;
  64218. this._engine.setArray4(this._uniforms[uniformName], array);
  64219. return this;
  64220. };
  64221. /**
  64222. * Sets matrices on a uniform variable.
  64223. * @param uniformName Name of the variable.
  64224. * @param matrices matrices to be set.
  64225. * @returns this effect.
  64226. */
  64227. Effect.prototype.setMatrices = function (uniformName, matrices) {
  64228. if (!matrices) {
  64229. return this;
  64230. }
  64231. this._valueCache[uniformName] = null;
  64232. this._engine.setMatrices(this._uniforms[uniformName], matrices);
  64233. return this;
  64234. };
  64235. /**
  64236. * Sets matrix on a uniform variable.
  64237. * @param uniformName Name of the variable.
  64238. * @param matrix matrix to be set.
  64239. * @returns this effect.
  64240. */
  64241. Effect.prototype.setMatrix = function (uniformName, matrix) {
  64242. if (this._cacheMatrix(uniformName, matrix)) {
  64243. this._engine.setMatrix(this._uniforms[uniformName], matrix);
  64244. }
  64245. return this;
  64246. };
  64247. /**
  64248. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  64249. * @param uniformName Name of the variable.
  64250. * @param matrix matrix to be set.
  64251. * @returns this effect.
  64252. */
  64253. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  64254. this._valueCache[uniformName] = null;
  64255. this._engine.setMatrix3x3(this._uniforms[uniformName], matrix);
  64256. return this;
  64257. };
  64258. /**
  64259. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  64260. * @param uniformName Name of the variable.
  64261. * @param matrix matrix to be set.
  64262. * @returns this effect.
  64263. */
  64264. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  64265. this._valueCache[uniformName] = null;
  64266. this._engine.setMatrix2x2(this._uniforms[uniformName], matrix);
  64267. return this;
  64268. };
  64269. /**
  64270. * Sets a float on a uniform variable.
  64271. * @param uniformName Name of the variable.
  64272. * @param value value to be set.
  64273. * @returns this effect.
  64274. */
  64275. Effect.prototype.setFloat = function (uniformName, value) {
  64276. var cache = this._valueCache[uniformName];
  64277. if (cache !== undefined && cache === value) {
  64278. return this;
  64279. }
  64280. this._valueCache[uniformName] = value;
  64281. this._engine.setFloat(this._uniforms[uniformName], value);
  64282. return this;
  64283. };
  64284. /**
  64285. * Sets a boolean on a uniform variable.
  64286. * @param uniformName Name of the variable.
  64287. * @param bool value to be set.
  64288. * @returns this effect.
  64289. */
  64290. Effect.prototype.setBool = function (uniformName, bool) {
  64291. var cache = this._valueCache[uniformName];
  64292. if (cache !== undefined && cache === bool) {
  64293. return this;
  64294. }
  64295. this._valueCache[uniformName] = bool;
  64296. this._engine.setBool(this._uniforms[uniformName], bool ? 1 : 0);
  64297. return this;
  64298. };
  64299. /**
  64300. * Sets a Vector2 on a uniform variable.
  64301. * @param uniformName Name of the variable.
  64302. * @param vector2 vector2 to be set.
  64303. * @returns this effect.
  64304. */
  64305. Effect.prototype.setVector2 = function (uniformName, vector2) {
  64306. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  64307. this._engine.setFloat2(this._uniforms[uniformName], vector2.x, vector2.y);
  64308. }
  64309. return this;
  64310. };
  64311. /**
  64312. * Sets a float2 on a uniform variable.
  64313. * @param uniformName Name of the variable.
  64314. * @param x First float in float2.
  64315. * @param y Second float in float2.
  64316. * @returns this effect.
  64317. */
  64318. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  64319. if (this._cacheFloat2(uniformName, x, y)) {
  64320. this._engine.setFloat2(this._uniforms[uniformName], x, y);
  64321. }
  64322. return this;
  64323. };
  64324. /**
  64325. * Sets a Vector3 on a uniform variable.
  64326. * @param uniformName Name of the variable.
  64327. * @param vector3 Value to be set.
  64328. * @returns this effect.
  64329. */
  64330. Effect.prototype.setVector3 = function (uniformName, vector3) {
  64331. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  64332. this._engine.setFloat3(this._uniforms[uniformName], vector3.x, vector3.y, vector3.z);
  64333. }
  64334. return this;
  64335. };
  64336. /**
  64337. * Sets a float3 on a uniform variable.
  64338. * @param uniformName Name of the variable.
  64339. * @param x First float in float3.
  64340. * @param y Second float in float3.
  64341. * @param z Third float in float3.
  64342. * @returns this effect.
  64343. */
  64344. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  64345. if (this._cacheFloat3(uniformName, x, y, z)) {
  64346. this._engine.setFloat3(this._uniforms[uniformName], x, y, z);
  64347. }
  64348. return this;
  64349. };
  64350. /**
  64351. * Sets a Vector4 on a uniform variable.
  64352. * @param uniformName Name of the variable.
  64353. * @param vector4 Value to be set.
  64354. * @returns this effect.
  64355. */
  64356. Effect.prototype.setVector4 = function (uniformName, vector4) {
  64357. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  64358. this._engine.setFloat4(this._uniforms[uniformName], vector4.x, vector4.y, vector4.z, vector4.w);
  64359. }
  64360. return this;
  64361. };
  64362. /**
  64363. * Sets a float4 on a uniform variable.
  64364. * @param uniformName Name of the variable.
  64365. * @param x First float in float4.
  64366. * @param y Second float in float4.
  64367. * @param z Third float in float4.
  64368. * @param w Fourth float in float4.
  64369. * @returns this effect.
  64370. */
  64371. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  64372. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  64373. this._engine.setFloat4(this._uniforms[uniformName], x, y, z, w);
  64374. }
  64375. return this;
  64376. };
  64377. /**
  64378. * Sets a Color3 on a uniform variable.
  64379. * @param uniformName Name of the variable.
  64380. * @param color3 Value to be set.
  64381. * @returns this effect.
  64382. */
  64383. Effect.prototype.setColor3 = function (uniformName, color3) {
  64384. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  64385. this._engine.setColor3(this._uniforms[uniformName], color3);
  64386. }
  64387. return this;
  64388. };
  64389. /**
  64390. * Sets a Color4 on a uniform variable.
  64391. * @param uniformName Name of the variable.
  64392. * @param color3 Value to be set.
  64393. * @param alpha Alpha value to be set.
  64394. * @returns this effect.
  64395. */
  64396. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  64397. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  64398. this._engine.setColor4(this._uniforms[uniformName], color3, alpha);
  64399. }
  64400. return this;
  64401. };
  64402. /**
  64403. * Sets a Color4 on a uniform variable
  64404. * @param uniformName defines the name of the variable
  64405. * @param color4 defines the value to be set
  64406. * @returns this effect.
  64407. */
  64408. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  64409. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  64410. this._engine.setDirectColor4(this._uniforms[uniformName], color4);
  64411. }
  64412. return this;
  64413. };
  64414. /** Release all associated resources */
  64415. Effect.prototype.dispose = function () {
  64416. this._engine._releaseEffect(this);
  64417. };
  64418. /**
  64419. * This function will add a new shader to the shader store
  64420. * @param name the name of the shader
  64421. * @param pixelShader optional pixel shader content
  64422. * @param vertexShader optional vertex shader content
  64423. */
  64424. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  64425. if (pixelShader) {
  64426. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  64427. }
  64428. if (vertexShader) {
  64429. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  64430. }
  64431. };
  64432. /**
  64433. * Resets the cache of effects.
  64434. */
  64435. Effect.ResetCache = function () {
  64436. Effect._baseCache = {};
  64437. };
  64438. /**
  64439. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  64440. */
  64441. Effect.ShadersRepository = "src/Shaders/";
  64442. Effect._uniqueIdSeed = 0;
  64443. Effect._baseCache = {};
  64444. /**
  64445. * Store of each shader (The can be looked up using effect.key)
  64446. */
  64447. Effect.ShadersStore = {};
  64448. /**
  64449. * Store of each included file for a shader (The can be looked up using effect.key)
  64450. */
  64451. Effect.IncludesShadersStore = {};
  64452. return Effect;
  64453. }());
  64454. /***/ }),
  64455. /***/ "./Materials/fresnelParameters.ts":
  64456. /*!****************************************!*\
  64457. !*** ./Materials/fresnelParameters.ts ***!
  64458. \****************************************/
  64459. /*! exports provided: FresnelParameters */
  64460. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64461. "use strict";
  64462. __webpack_require__.r(__webpack_exports__);
  64463. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  64464. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  64465. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64466. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  64467. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64468. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  64469. /**
  64470. * This represents all the required information to add a fresnel effect on a material:
  64471. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  64472. */
  64473. var FresnelParameters = /** @class */ (function () {
  64474. function FresnelParameters() {
  64475. this._isEnabled = true;
  64476. /**
  64477. * Define the color used on edges (grazing angle)
  64478. */
  64479. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  64480. /**
  64481. * Define the color used on center
  64482. */
  64483. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  64484. /**
  64485. * Define bias applied to computed fresnel term
  64486. */
  64487. this.bias = 0;
  64488. /**
  64489. * Defined the power exponent applied to fresnel term
  64490. */
  64491. this.power = 1;
  64492. }
  64493. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  64494. /**
  64495. * Define if the fresnel effect is enable or not.
  64496. */
  64497. get: function () {
  64498. return this._isEnabled;
  64499. },
  64500. set: function (value) {
  64501. if (this._isEnabled === value) {
  64502. return;
  64503. }
  64504. this._isEnabled = value;
  64505. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].MATERIAL_FresnelDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].MATERIAL_MiscDirtyFlag);
  64506. },
  64507. enumerable: true,
  64508. configurable: true
  64509. });
  64510. /**
  64511. * Clones the current fresnel and its valuues
  64512. * @returns a clone fresnel configuration
  64513. */
  64514. FresnelParameters.prototype.clone = function () {
  64515. var newFresnelParameters = new FresnelParameters();
  64516. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  64517. return newFresnelParameters;
  64518. };
  64519. /**
  64520. * Serializes the current fresnel parameters to a JSON representation.
  64521. * @return the JSON serialization
  64522. */
  64523. FresnelParameters.prototype.serialize = function () {
  64524. var serializationObject = {};
  64525. serializationObject.isEnabled = this.isEnabled;
  64526. serializationObject.leftColor = this.leftColor.asArray();
  64527. serializationObject.rightColor = this.rightColor.asArray();
  64528. serializationObject.bias = this.bias;
  64529. serializationObject.power = this.power;
  64530. return serializationObject;
  64531. };
  64532. /**
  64533. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  64534. * @param parsedFresnelParameters Define the JSON representation
  64535. * @returns the parsed parameters
  64536. */
  64537. FresnelParameters.Parse = function (parsedFresnelParameters) {
  64538. var fresnelParameters = new FresnelParameters();
  64539. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  64540. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  64541. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  64542. fresnelParameters.bias = parsedFresnelParameters.bias;
  64543. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  64544. return fresnelParameters;
  64545. };
  64546. return FresnelParameters;
  64547. }());
  64548. // References the dependencies.
  64549. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  64550. /***/ }),
  64551. /***/ "./Materials/imageProcessingConfiguration.ts":
  64552. /*!***************************************************!*\
  64553. !*** ./Materials/imageProcessingConfiguration.ts ***!
  64554. \***************************************************/
  64555. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  64556. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64557. "use strict";
  64558. __webpack_require__.r(__webpack_exports__);
  64559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  64560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  64561. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64562. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64563. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  64564. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  64565. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64566. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  64567. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  64568. /**
  64569. * @hidden
  64570. */
  64571. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  64572. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  64573. function ImageProcessingConfigurationDefines() {
  64574. var _this = _super.call(this) || this;
  64575. _this.IMAGEPROCESSING = false;
  64576. _this.VIGNETTE = false;
  64577. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  64578. _this.VIGNETTEBLENDMODEOPAQUE = false;
  64579. _this.TONEMAPPING = false;
  64580. _this.TONEMAPPING_ACES = false;
  64581. _this.CONTRAST = false;
  64582. _this.COLORCURVES = false;
  64583. _this.COLORGRADING = false;
  64584. _this.COLORGRADING3D = false;
  64585. _this.SAMPLER3DGREENDEPTH = false;
  64586. _this.SAMPLER3DBGRMAP = false;
  64587. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  64588. _this.EXPOSURE = false;
  64589. _this.rebuild();
  64590. return _this;
  64591. }
  64592. return ImageProcessingConfigurationDefines;
  64593. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  64594. /**
  64595. * This groups together the common properties used for image processing either in direct forward pass
  64596. * or through post processing effect depending on the use of the image processing pipeline in your scene
  64597. * or not.
  64598. */
  64599. var ImageProcessingConfiguration = /** @class */ (function () {
  64600. function ImageProcessingConfiguration() {
  64601. /**
  64602. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  64603. */
  64604. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  64605. this._colorCurvesEnabled = false;
  64606. this._colorGradingEnabled = false;
  64607. this._colorGradingWithGreenDepth = true;
  64608. this._colorGradingBGR = true;
  64609. /** @hidden */
  64610. this._exposure = 1.0;
  64611. this._toneMappingEnabled = false;
  64612. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  64613. this._contrast = 1.0;
  64614. /**
  64615. * Vignette stretch size.
  64616. */
  64617. this.vignetteStretch = 0;
  64618. /**
  64619. * Vignette centre X Offset.
  64620. */
  64621. this.vignetteCentreX = 0;
  64622. /**
  64623. * Vignette centre Y Offset.
  64624. */
  64625. this.vignetteCentreY = 0;
  64626. /**
  64627. * Vignette weight or intensity of the vignette effect.
  64628. */
  64629. this.vignetteWeight = 1.5;
  64630. /**
  64631. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  64632. * if vignetteEnabled is set to true.
  64633. */
  64634. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  64635. /**
  64636. * Camera field of view used by the Vignette effect.
  64637. */
  64638. this.vignetteCameraFov = 0.5;
  64639. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  64640. this._vignetteEnabled = false;
  64641. this._applyByPostProcess = false;
  64642. this._isEnabled = true;
  64643. /**
  64644. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  64645. */
  64646. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  64647. }
  64648. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  64649. /**
  64650. * Gets wether the color curves effect is enabled.
  64651. */
  64652. get: function () {
  64653. return this._colorCurvesEnabled;
  64654. },
  64655. /**
  64656. * Sets wether the color curves effect is enabled.
  64657. */
  64658. set: function (value) {
  64659. if (this._colorCurvesEnabled === value) {
  64660. return;
  64661. }
  64662. this._colorCurvesEnabled = value;
  64663. this._updateParameters();
  64664. },
  64665. enumerable: true,
  64666. configurable: true
  64667. });
  64668. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  64669. /**
  64670. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  64671. */
  64672. get: function () {
  64673. return this._colorGradingTexture;
  64674. },
  64675. /**
  64676. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  64677. */
  64678. set: function (value) {
  64679. if (this._colorGradingTexture === value) {
  64680. return;
  64681. }
  64682. this._colorGradingTexture = value;
  64683. this._updateParameters();
  64684. },
  64685. enumerable: true,
  64686. configurable: true
  64687. });
  64688. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  64689. /**
  64690. * Gets wether the color grading effect is enabled.
  64691. */
  64692. get: function () {
  64693. return this._colorGradingEnabled;
  64694. },
  64695. /**
  64696. * Sets wether the color grading effect is enabled.
  64697. */
  64698. set: function (value) {
  64699. if (this._colorGradingEnabled === value) {
  64700. return;
  64701. }
  64702. this._colorGradingEnabled = value;
  64703. this._updateParameters();
  64704. },
  64705. enumerable: true,
  64706. configurable: true
  64707. });
  64708. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  64709. /**
  64710. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  64711. */
  64712. get: function () {
  64713. return this._colorGradingWithGreenDepth;
  64714. },
  64715. /**
  64716. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  64717. */
  64718. set: function (value) {
  64719. if (this._colorGradingWithGreenDepth === value) {
  64720. return;
  64721. }
  64722. this._colorGradingWithGreenDepth = value;
  64723. this._updateParameters();
  64724. },
  64725. enumerable: true,
  64726. configurable: true
  64727. });
  64728. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  64729. /**
  64730. * Gets wether the color grading texture contains BGR values.
  64731. */
  64732. get: function () {
  64733. return this._colorGradingBGR;
  64734. },
  64735. /**
  64736. * Sets wether the color grading texture contains BGR values.
  64737. */
  64738. set: function (value) {
  64739. if (this._colorGradingBGR === value) {
  64740. return;
  64741. }
  64742. this._colorGradingBGR = value;
  64743. this._updateParameters();
  64744. },
  64745. enumerable: true,
  64746. configurable: true
  64747. });
  64748. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  64749. /**
  64750. * Gets the Exposure used in the effect.
  64751. */
  64752. get: function () {
  64753. return this._exposure;
  64754. },
  64755. /**
  64756. * Sets the Exposure used in the effect.
  64757. */
  64758. set: function (value) {
  64759. if (this._exposure === value) {
  64760. return;
  64761. }
  64762. this._exposure = value;
  64763. this._updateParameters();
  64764. },
  64765. enumerable: true,
  64766. configurable: true
  64767. });
  64768. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  64769. /**
  64770. * Gets wether the tone mapping effect is enabled.
  64771. */
  64772. get: function () {
  64773. return this._toneMappingEnabled;
  64774. },
  64775. /**
  64776. * Sets wether the tone mapping effect is enabled.
  64777. */
  64778. set: function (value) {
  64779. if (this._toneMappingEnabled === value) {
  64780. return;
  64781. }
  64782. this._toneMappingEnabled = value;
  64783. this._updateParameters();
  64784. },
  64785. enumerable: true,
  64786. configurable: true
  64787. });
  64788. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  64789. /**
  64790. * Gets the type of tone mapping effect.
  64791. */
  64792. get: function () {
  64793. return this._toneMappingType;
  64794. },
  64795. /**
  64796. * Sets the type of tone mapping effect used in BabylonJS.
  64797. */
  64798. set: function (value) {
  64799. if (this._toneMappingType === value) {
  64800. return;
  64801. }
  64802. this._toneMappingType = value;
  64803. this._updateParameters();
  64804. },
  64805. enumerable: true,
  64806. configurable: true
  64807. });
  64808. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  64809. /**
  64810. * Gets the contrast used in the effect.
  64811. */
  64812. get: function () {
  64813. return this._contrast;
  64814. },
  64815. /**
  64816. * Sets the contrast used in the effect.
  64817. */
  64818. set: function (value) {
  64819. if (this._contrast === value) {
  64820. return;
  64821. }
  64822. this._contrast = value;
  64823. this._updateParameters();
  64824. },
  64825. enumerable: true,
  64826. configurable: true
  64827. });
  64828. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  64829. /**
  64830. * Gets the vignette blend mode allowing different kind of effect.
  64831. */
  64832. get: function () {
  64833. return this._vignetteBlendMode;
  64834. },
  64835. /**
  64836. * Sets the vignette blend mode allowing different kind of effect.
  64837. */
  64838. set: function (value) {
  64839. if (this._vignetteBlendMode === value) {
  64840. return;
  64841. }
  64842. this._vignetteBlendMode = value;
  64843. this._updateParameters();
  64844. },
  64845. enumerable: true,
  64846. configurable: true
  64847. });
  64848. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  64849. /**
  64850. * Gets wether the vignette effect is enabled.
  64851. */
  64852. get: function () {
  64853. return this._vignetteEnabled;
  64854. },
  64855. /**
  64856. * Sets wether the vignette effect is enabled.
  64857. */
  64858. set: function (value) {
  64859. if (this._vignetteEnabled === value) {
  64860. return;
  64861. }
  64862. this._vignetteEnabled = value;
  64863. this._updateParameters();
  64864. },
  64865. enumerable: true,
  64866. configurable: true
  64867. });
  64868. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  64869. /**
  64870. * Gets wether the image processing is applied through a post process or not.
  64871. */
  64872. get: function () {
  64873. return this._applyByPostProcess;
  64874. },
  64875. /**
  64876. * Sets wether the image processing is applied through a post process or not.
  64877. */
  64878. set: function (value) {
  64879. if (this._applyByPostProcess === value) {
  64880. return;
  64881. }
  64882. this._applyByPostProcess = value;
  64883. this._updateParameters();
  64884. },
  64885. enumerable: true,
  64886. configurable: true
  64887. });
  64888. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  64889. /**
  64890. * Gets wether the image processing is enabled or not.
  64891. */
  64892. get: function () {
  64893. return this._isEnabled;
  64894. },
  64895. /**
  64896. * Sets wether the image processing is enabled or not.
  64897. */
  64898. set: function (value) {
  64899. if (this._isEnabled === value) {
  64900. return;
  64901. }
  64902. this._isEnabled = value;
  64903. this._updateParameters();
  64904. },
  64905. enumerable: true,
  64906. configurable: true
  64907. });
  64908. /**
  64909. * Method called each time the image processing information changes requires to recompile the effect.
  64910. */
  64911. ImageProcessingConfiguration.prototype._updateParameters = function () {
  64912. this.onUpdateParameters.notifyObservers(this);
  64913. };
  64914. /**
  64915. * Gets the current class name.
  64916. * @return "ImageProcessingConfiguration"
  64917. */
  64918. ImageProcessingConfiguration.prototype.getClassName = function () {
  64919. return "ImageProcessingConfiguration";
  64920. };
  64921. /**
  64922. * Prepare the list of uniforms associated with the Image Processing effects.
  64923. * @param uniforms The list of uniforms used in the effect
  64924. * @param defines the list of defines currently in use
  64925. */
  64926. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  64927. if (defines.EXPOSURE) {
  64928. uniforms.push("exposureLinear");
  64929. }
  64930. if (defines.CONTRAST) {
  64931. uniforms.push("contrast");
  64932. }
  64933. if (defines.COLORGRADING) {
  64934. uniforms.push("colorTransformSettings");
  64935. }
  64936. if (defines.VIGNETTE) {
  64937. uniforms.push("vInverseScreenSize");
  64938. uniforms.push("vignetteSettings1");
  64939. uniforms.push("vignetteSettings2");
  64940. }
  64941. if (defines.COLORCURVES) {
  64942. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  64943. }
  64944. };
  64945. /**
  64946. * Prepare the list of samplers associated with the Image Processing effects.
  64947. * @param samplersList The list of uniforms used in the effect
  64948. * @param defines the list of defines currently in use
  64949. */
  64950. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  64951. if (defines.COLORGRADING) {
  64952. samplersList.push("txColorTransform");
  64953. }
  64954. };
  64955. /**
  64956. * Prepare the list of defines associated to the shader.
  64957. * @param defines the list of defines to complete
  64958. * @param forPostProcess Define if we are currently in post process mode or not
  64959. */
  64960. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  64961. if (forPostProcess === void 0) { forPostProcess = false; }
  64962. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  64963. defines.VIGNETTE = false;
  64964. defines.TONEMAPPING = false;
  64965. defines.TONEMAPPING_ACES = false;
  64966. defines.CONTRAST = false;
  64967. defines.EXPOSURE = false;
  64968. defines.COLORCURVES = false;
  64969. defines.COLORGRADING = false;
  64970. defines.COLORGRADING3D = false;
  64971. defines.IMAGEPROCESSING = false;
  64972. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  64973. return;
  64974. }
  64975. defines.VIGNETTE = this.vignetteEnabled;
  64976. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  64977. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  64978. defines.TONEMAPPING = this.toneMappingEnabled;
  64979. switch (this._toneMappingType) {
  64980. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  64981. defines.TONEMAPPING_ACES = true;
  64982. break;
  64983. default:
  64984. defines.TONEMAPPING_ACES = false;
  64985. break;
  64986. }
  64987. defines.CONTRAST = (this.contrast !== 1.0);
  64988. defines.EXPOSURE = (this.exposure !== 1.0);
  64989. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  64990. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  64991. if (defines.COLORGRADING) {
  64992. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  64993. }
  64994. else {
  64995. defines.COLORGRADING3D = false;
  64996. }
  64997. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  64998. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  64999. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  65000. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  65001. };
  65002. /**
  65003. * Returns true if all the image processing information are ready.
  65004. * @returns True if ready, otherwise, false
  65005. */
  65006. ImageProcessingConfiguration.prototype.isReady = function () {
  65007. // Color Grading texure can not be none blocking.
  65008. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  65009. };
  65010. /**
  65011. * Binds the image processing to the shader.
  65012. * @param effect The effect to bind to
  65013. * @param aspectRatio Define the current aspect ratio of the effect
  65014. */
  65015. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  65016. if (aspectRatio === void 0) { aspectRatio = 1; }
  65017. // Color Curves
  65018. if (this._colorCurvesEnabled && this.colorCurves) {
  65019. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  65020. }
  65021. // Vignette
  65022. if (this._vignetteEnabled) {
  65023. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  65024. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  65025. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  65026. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  65027. var vignetteScaleX = vignetteScaleY * aspectRatio;
  65028. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  65029. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  65030. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  65031. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  65032. var vignettePower = -2.0 * this.vignetteWeight;
  65033. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  65034. }
  65035. // Exposure
  65036. effect.setFloat("exposureLinear", this.exposure);
  65037. // Contrast
  65038. effect.setFloat("contrast", this.contrast);
  65039. // Color transform settings
  65040. if (this.colorGradingTexture) {
  65041. effect.setTexture("txColorTransform", this.colorGradingTexture);
  65042. var textureSize = this.colorGradingTexture.getSize().height;
  65043. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  65044. 0.5 / textureSize, // textureOffset
  65045. textureSize, // textureSize
  65046. this.colorGradingTexture.level // weight
  65047. );
  65048. }
  65049. };
  65050. /**
  65051. * Clones the current image processing instance.
  65052. * @return The cloned image processing
  65053. */
  65054. ImageProcessingConfiguration.prototype.clone = function () {
  65055. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  65056. };
  65057. /**
  65058. * Serializes the current image processing instance to a json representation.
  65059. * @return a JSON representation
  65060. */
  65061. ImageProcessingConfiguration.prototype.serialize = function () {
  65062. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  65063. };
  65064. /**
  65065. * Parses the image processing from a json representation.
  65066. * @param source the JSON source to parse
  65067. * @return The parsed image processing
  65068. */
  65069. ImageProcessingConfiguration.Parse = function (source) {
  65070. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  65071. };
  65072. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  65073. /**
  65074. * Used to apply the vignette as a mix with the pixel color.
  65075. */
  65076. get: function () {
  65077. return this._VIGNETTEMODE_MULTIPLY;
  65078. },
  65079. enumerable: true,
  65080. configurable: true
  65081. });
  65082. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  65083. /**
  65084. * Used to apply the vignette as a replacement of the pixel color.
  65085. */
  65086. get: function () {
  65087. return this._VIGNETTEMODE_OPAQUE;
  65088. },
  65089. enumerable: true,
  65090. configurable: true
  65091. });
  65092. /**
  65093. * Default tone mapping applied in BabylonJS.
  65094. */
  65095. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  65096. /**
  65097. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  65098. * to other engines rendering to increase portability.
  65099. */
  65100. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  65101. // Static constants associated to the image processing.
  65102. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  65103. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  65104. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65105. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  65106. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  65107. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65109. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  65110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  65112. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  65113. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65114. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65115. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  65116. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65118. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  65119. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65121. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  65122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65124. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  65125. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65126. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65127. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  65128. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65129. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65130. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  65131. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65133. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  65134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65136. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  65137. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65138. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65139. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  65140. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65141. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65142. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  65143. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65145. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  65146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  65148. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  65149. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65150. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65151. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  65152. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65153. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65154. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  65155. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65156. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65157. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  65158. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65160. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  65161. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65162. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65163. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  65164. return ImageProcessingConfiguration;
  65165. }());
  65166. // References the dependencies.
  65167. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  65168. /***/ }),
  65169. /***/ "./Materials/index.ts":
  65170. /*!****************************!*\
  65171. !*** ./Materials/index.ts ***!
  65172. \****************************/
  65173. /*! exports provided: ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, BackgroundMaterial, PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  65174. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65175. "use strict";
  65176. __webpack_require__.r(__webpack_exports__);
  65177. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  65178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  65179. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  65180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  65181. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  65182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  65183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  65184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  65185. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  65186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  65187. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  65188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  65189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  65190. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  65191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  65192. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  65193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  65194. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  65195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  65196. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  65197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  65198. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  65199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterialDefines"]; });
  65200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  65201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  65202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  65203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  65204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  65205. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  65206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  65207. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  65208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  65209. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  65210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  65211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  65212. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  65213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  65214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  65215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["EquiRectangularCubeTexture"]; });
  65216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  65217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  65218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  65219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  65220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  65221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  65222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  65223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  65224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  65225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  65226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  65227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  65228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  65229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  65230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  65231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  65232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  65233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  65234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  65235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  65236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  65237. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  65238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  65239. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  65240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  65241. /***/ }),
  65242. /***/ "./Materials/material.ts":
  65243. /*!*******************************!*\
  65244. !*** ./Materials/material.ts ***!
  65245. \*******************************/
  65246. /*! exports provided: Material */
  65247. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65248. "use strict";
  65249. __webpack_require__.r(__webpack_exports__);
  65250. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  65251. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  65252. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  65253. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  65254. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  65255. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  65256. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  65257. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  65258. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  65259. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  65260. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  65261. /**
  65262. * Base class for the main features of a material in Babylon.js
  65263. */
  65264. var Material = /** @class */ (function () {
  65265. /**
  65266. * Creates a material instance
  65267. * @param name defines the name of the material
  65268. * @param scene defines the scene to reference
  65269. * @param doNotAdd specifies if the material should be added to the scene
  65270. */
  65271. function Material(name, scene, doNotAdd) {
  65272. /**
  65273. * Gets or sets user defined metadata
  65274. */
  65275. this.metadata = null;
  65276. /**
  65277. * For internal use only. Please do not use.
  65278. */
  65279. this.reservedDataStore = null;
  65280. /**
  65281. * Specifies if the ready state should be checked on each call
  65282. */
  65283. this.checkReadyOnEveryCall = false;
  65284. /**
  65285. * Specifies if the ready state should be checked once
  65286. */
  65287. this.checkReadyOnlyOnce = false;
  65288. /**
  65289. * The state of the material
  65290. */
  65291. this.state = "";
  65292. /**
  65293. * The alpha value of the material
  65294. */
  65295. this._alpha = 1.0;
  65296. /**
  65297. * Specifies if back face culling is enabled
  65298. */
  65299. this._backFaceCulling = true;
  65300. /**
  65301. * Specifies if the material should be serialized
  65302. */
  65303. this.doNotSerialize = false;
  65304. /**
  65305. * @hidden
  65306. */
  65307. this._storeEffectOnSubMeshes = false;
  65308. /**
  65309. * An event triggered when the material is disposed
  65310. */
  65311. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  65312. /**
  65313. * Stores the value of the alpha mode
  65314. */
  65315. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  65316. /**
  65317. * Stores the state of the need depth pre-pass value
  65318. */
  65319. this._needDepthPrePass = false;
  65320. /**
  65321. * Specifies if depth writing should be disabled
  65322. */
  65323. this.disableDepthWrite = false;
  65324. /**
  65325. * Specifies if depth writing should be forced
  65326. */
  65327. this.forceDepthWrite = false;
  65328. /**
  65329. * Specifies if there should be a separate pass for culling
  65330. */
  65331. this.separateCullingPass = false;
  65332. /**
  65333. * Stores the state specifing if fog should be enabled
  65334. */
  65335. this._fogEnabled = true;
  65336. /**
  65337. * Stores the size of points
  65338. */
  65339. this.pointSize = 1.0;
  65340. /**
  65341. * Stores the z offset value
  65342. */
  65343. this.zOffset = 0;
  65344. /**
  65345. * @hidden
  65346. * Specifies if the material was previously ready
  65347. */
  65348. this._wasPreviouslyReady = false;
  65349. /**
  65350. * Stores the fill mode state
  65351. */
  65352. this._fillMode = Material.TriangleFillMode;
  65353. /** @hidden */
  65354. this._indexInSceneMaterialArray = -1;
  65355. this.name = name;
  65356. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  65357. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  65358. this.uniqueId = this._scene.getUniqueId();
  65359. if (this._scene.useRightHandedSystem) {
  65360. this.sideOrientation = Material.ClockWiseSideOrientation;
  65361. }
  65362. else {
  65363. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  65364. }
  65365. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  65366. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  65367. if (!doNotAdd) {
  65368. this._scene.addMaterial(this);
  65369. }
  65370. if (this._scene.useMaterialMeshMap) {
  65371. this.meshMap = {};
  65372. }
  65373. }
  65374. Object.defineProperty(Material.prototype, "alpha", {
  65375. /**
  65376. * Gets the alpha value of the material
  65377. */
  65378. get: function () {
  65379. return this._alpha;
  65380. },
  65381. /**
  65382. * Sets the alpha value of the material
  65383. */
  65384. set: function (value) {
  65385. if (this._alpha === value) {
  65386. return;
  65387. }
  65388. this._alpha = value;
  65389. this.markAsDirty(Material.MiscDirtyFlag);
  65390. },
  65391. enumerable: true,
  65392. configurable: true
  65393. });
  65394. Object.defineProperty(Material.prototype, "backFaceCulling", {
  65395. /**
  65396. * Gets the back-face culling state
  65397. */
  65398. get: function () {
  65399. return this._backFaceCulling;
  65400. },
  65401. /**
  65402. * Sets the back-face culling state
  65403. */
  65404. set: function (value) {
  65405. if (this._backFaceCulling === value) {
  65406. return;
  65407. }
  65408. this._backFaceCulling = value;
  65409. this.markAsDirty(Material.TextureDirtyFlag);
  65410. },
  65411. enumerable: true,
  65412. configurable: true
  65413. });
  65414. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  65415. /**
  65416. * Gets a boolean indicating that current material needs to register RTT
  65417. */
  65418. get: function () {
  65419. return false;
  65420. },
  65421. enumerable: true,
  65422. configurable: true
  65423. });
  65424. Object.defineProperty(Material.prototype, "onDispose", {
  65425. /**
  65426. * Called during a dispose event
  65427. */
  65428. set: function (callback) {
  65429. if (this._onDisposeObserver) {
  65430. this.onDisposeObservable.remove(this._onDisposeObserver);
  65431. }
  65432. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  65433. },
  65434. enumerable: true,
  65435. configurable: true
  65436. });
  65437. Object.defineProperty(Material.prototype, "onBindObservable", {
  65438. /**
  65439. * An event triggered when the material is bound
  65440. */
  65441. get: function () {
  65442. if (!this._onBindObservable) {
  65443. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  65444. }
  65445. return this._onBindObservable;
  65446. },
  65447. enumerable: true,
  65448. configurable: true
  65449. });
  65450. Object.defineProperty(Material.prototype, "onBind", {
  65451. /**
  65452. * Called during a bind event
  65453. */
  65454. set: function (callback) {
  65455. if (this._onBindObserver) {
  65456. this.onBindObservable.remove(this._onBindObserver);
  65457. }
  65458. this._onBindObserver = this.onBindObservable.add(callback);
  65459. },
  65460. enumerable: true,
  65461. configurable: true
  65462. });
  65463. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  65464. /**
  65465. * An event triggered when the material is unbound
  65466. */
  65467. get: function () {
  65468. if (!this._onUnBindObservable) {
  65469. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  65470. }
  65471. return this._onUnBindObservable;
  65472. },
  65473. enumerable: true,
  65474. configurable: true
  65475. });
  65476. Object.defineProperty(Material.prototype, "alphaMode", {
  65477. /**
  65478. * Gets the value of the alpha mode
  65479. */
  65480. get: function () {
  65481. return this._alphaMode;
  65482. },
  65483. /**
  65484. * Sets the value of the alpha mode.
  65485. *
  65486. * | Value | Type | Description |
  65487. * | --- | --- | --- |
  65488. * | 0 | ALPHA_DISABLE | |
  65489. * | 1 | ALPHA_ADD | |
  65490. * | 2 | ALPHA_COMBINE | |
  65491. * | 3 | ALPHA_SUBTRACT | |
  65492. * | 4 | ALPHA_MULTIPLY | |
  65493. * | 5 | ALPHA_MAXIMIZED | |
  65494. * | 6 | ALPHA_ONEONE | |
  65495. * | 7 | ALPHA_PREMULTIPLIED | |
  65496. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  65497. * | 9 | ALPHA_INTERPOLATE | |
  65498. * | 10 | ALPHA_SCREENMODE | |
  65499. *
  65500. */
  65501. set: function (value) {
  65502. if (this._alphaMode === value) {
  65503. return;
  65504. }
  65505. this._alphaMode = value;
  65506. this.markAsDirty(Material.TextureDirtyFlag);
  65507. },
  65508. enumerable: true,
  65509. configurable: true
  65510. });
  65511. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  65512. /**
  65513. * Gets the depth pre-pass value
  65514. */
  65515. get: function () {
  65516. return this._needDepthPrePass;
  65517. },
  65518. /**
  65519. * Sets the need depth pre-pass value
  65520. */
  65521. set: function (value) {
  65522. if (this._needDepthPrePass === value) {
  65523. return;
  65524. }
  65525. this._needDepthPrePass = value;
  65526. if (this._needDepthPrePass) {
  65527. this.checkReadyOnEveryCall = true;
  65528. }
  65529. },
  65530. enumerable: true,
  65531. configurable: true
  65532. });
  65533. Object.defineProperty(Material.prototype, "fogEnabled", {
  65534. /**
  65535. * Gets the value of the fog enabled state
  65536. */
  65537. get: function () {
  65538. return this._fogEnabled;
  65539. },
  65540. /**
  65541. * Sets the state for enabling fog
  65542. */
  65543. set: function (value) {
  65544. if (this._fogEnabled === value) {
  65545. return;
  65546. }
  65547. this._fogEnabled = value;
  65548. this.markAsDirty(Material.MiscDirtyFlag);
  65549. },
  65550. enumerable: true,
  65551. configurable: true
  65552. });
  65553. Object.defineProperty(Material.prototype, "wireframe", {
  65554. /**
  65555. * Gets a value specifying if wireframe mode is enabled
  65556. */
  65557. get: function () {
  65558. switch (this._fillMode) {
  65559. case Material.WireFrameFillMode:
  65560. case Material.LineListDrawMode:
  65561. case Material.LineLoopDrawMode:
  65562. case Material.LineStripDrawMode:
  65563. return true;
  65564. }
  65565. return this._scene.forceWireframe;
  65566. },
  65567. /**
  65568. * Sets the state of wireframe mode
  65569. */
  65570. set: function (value) {
  65571. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  65572. },
  65573. enumerable: true,
  65574. configurable: true
  65575. });
  65576. Object.defineProperty(Material.prototype, "pointsCloud", {
  65577. /**
  65578. * Gets the value specifying if point clouds are enabled
  65579. */
  65580. get: function () {
  65581. switch (this._fillMode) {
  65582. case Material.PointFillMode:
  65583. case Material.PointListDrawMode:
  65584. return true;
  65585. }
  65586. return this._scene.forcePointsCloud;
  65587. },
  65588. /**
  65589. * Sets the state of point cloud mode
  65590. */
  65591. set: function (value) {
  65592. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  65593. },
  65594. enumerable: true,
  65595. configurable: true
  65596. });
  65597. Object.defineProperty(Material.prototype, "fillMode", {
  65598. /**
  65599. * Gets the material fill mode
  65600. */
  65601. get: function () {
  65602. return this._fillMode;
  65603. },
  65604. /**
  65605. * Sets the material fill mode
  65606. */
  65607. set: function (value) {
  65608. if (this._fillMode === value) {
  65609. return;
  65610. }
  65611. this._fillMode = value;
  65612. this.markAsDirty(Material.MiscDirtyFlag);
  65613. },
  65614. enumerable: true,
  65615. configurable: true
  65616. });
  65617. /**
  65618. * Returns a string representation of the current material
  65619. * @param fullDetails defines a boolean indicating which levels of logging is desired
  65620. * @returns a string with material information
  65621. */
  65622. Material.prototype.toString = function (fullDetails) {
  65623. var ret = "Name: " + this.name;
  65624. if (fullDetails) {
  65625. }
  65626. return ret;
  65627. };
  65628. /**
  65629. * Gets the class name of the material
  65630. * @returns a string with the class name of the material
  65631. */
  65632. Material.prototype.getClassName = function () {
  65633. return "Material";
  65634. };
  65635. Object.defineProperty(Material.prototype, "isFrozen", {
  65636. /**
  65637. * Specifies if updates for the material been locked
  65638. */
  65639. get: function () {
  65640. return this.checkReadyOnlyOnce;
  65641. },
  65642. enumerable: true,
  65643. configurable: true
  65644. });
  65645. /**
  65646. * Locks updates for the material
  65647. */
  65648. Material.prototype.freeze = function () {
  65649. this.checkReadyOnlyOnce = true;
  65650. };
  65651. /**
  65652. * Unlocks updates for the material
  65653. */
  65654. Material.prototype.unfreeze = function () {
  65655. this.checkReadyOnlyOnce = false;
  65656. };
  65657. /**
  65658. * Specifies if the material is ready to be used
  65659. * @param mesh defines the mesh to check
  65660. * @param useInstances specifies if instances should be used
  65661. * @returns a boolean indicating if the material is ready to be used
  65662. */
  65663. Material.prototype.isReady = function (mesh, useInstances) {
  65664. return true;
  65665. };
  65666. /**
  65667. * Specifies that the submesh is ready to be used
  65668. * @param mesh defines the mesh to check
  65669. * @param subMesh defines which submesh to check
  65670. * @param useInstances specifies that instances should be used
  65671. * @returns a boolean indicating that the submesh is ready or not
  65672. */
  65673. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  65674. return false;
  65675. };
  65676. /**
  65677. * Returns the material effect
  65678. * @returns the effect associated with the material
  65679. */
  65680. Material.prototype.getEffect = function () {
  65681. return this._effect;
  65682. };
  65683. /**
  65684. * Returns the current scene
  65685. * @returns a Scene
  65686. */
  65687. Material.prototype.getScene = function () {
  65688. return this._scene;
  65689. };
  65690. /**
  65691. * Specifies if the material will require alpha blending
  65692. * @returns a boolean specifying if alpha blending is needed
  65693. */
  65694. Material.prototype.needAlphaBlending = function () {
  65695. return (this.alpha < 1.0);
  65696. };
  65697. /**
  65698. * Specifies if the mesh will require alpha blending
  65699. * @param mesh defines the mesh to check
  65700. * @returns a boolean specifying if alpha blending is needed for the mesh
  65701. */
  65702. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  65703. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  65704. };
  65705. /**
  65706. * Specifies if this material should be rendered in alpha test mode
  65707. * @returns a boolean specifying if an alpha test is needed.
  65708. */
  65709. Material.prototype.needAlphaTesting = function () {
  65710. return false;
  65711. };
  65712. /**
  65713. * Gets the texture used for the alpha test
  65714. * @returns the texture to use for alpha testing
  65715. */
  65716. Material.prototype.getAlphaTestTexture = function () {
  65717. return null;
  65718. };
  65719. /**
  65720. * Marks the material to indicate that it needs to be re-calculated
  65721. */
  65722. Material.prototype.markDirty = function () {
  65723. this._wasPreviouslyReady = false;
  65724. };
  65725. /** @hidden */
  65726. Material.prototype._preBind = function (effect, overrideOrientation) {
  65727. if (overrideOrientation === void 0) { overrideOrientation = null; }
  65728. var engine = this._scene.getEngine();
  65729. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  65730. var reverse = orientation === Material.ClockWiseSideOrientation;
  65731. engine.enableEffect(effect ? effect : this._effect);
  65732. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  65733. return reverse;
  65734. };
  65735. /**
  65736. * Binds the material to the mesh
  65737. * @param world defines the world transformation matrix
  65738. * @param mesh defines the mesh to bind the material to
  65739. */
  65740. Material.prototype.bind = function (world, mesh) {
  65741. };
  65742. /**
  65743. * Binds the submesh to the material
  65744. * @param world defines the world transformation matrix
  65745. * @param mesh defines the mesh containing the submesh
  65746. * @param subMesh defines the submesh to bind the material to
  65747. */
  65748. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  65749. };
  65750. /**
  65751. * Binds the world matrix to the material
  65752. * @param world defines the world transformation matrix
  65753. */
  65754. Material.prototype.bindOnlyWorldMatrix = function (world) {
  65755. };
  65756. /**
  65757. * Binds the scene's uniform buffer to the effect.
  65758. * @param effect defines the effect to bind to the scene uniform buffer
  65759. * @param sceneUbo defines the uniform buffer storing scene data
  65760. */
  65761. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  65762. sceneUbo.bindToEffect(effect, "Scene");
  65763. };
  65764. /**
  65765. * Binds the view matrix to the effect
  65766. * @param effect defines the effect to bind the view matrix to
  65767. */
  65768. Material.prototype.bindView = function (effect) {
  65769. if (!this._useUBO) {
  65770. effect.setMatrix("view", this.getScene().getViewMatrix());
  65771. }
  65772. else {
  65773. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  65774. }
  65775. };
  65776. /**
  65777. * Binds the view projection matrix to the effect
  65778. * @param effect defines the effect to bind the view projection matrix to
  65779. */
  65780. Material.prototype.bindViewProjection = function (effect) {
  65781. if (!this._useUBO) {
  65782. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  65783. }
  65784. else {
  65785. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  65786. }
  65787. };
  65788. /**
  65789. * Specifies if material alpha testing should be turned on for the mesh
  65790. * @param mesh defines the mesh to check
  65791. */
  65792. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  65793. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  65794. };
  65795. /**
  65796. * Processes to execute after binding the material to a mesh
  65797. * @param mesh defines the rendered mesh
  65798. */
  65799. Material.prototype._afterBind = function (mesh) {
  65800. this._scene._cachedMaterial = this;
  65801. if (mesh) {
  65802. this._scene._cachedVisibility = mesh.visibility;
  65803. }
  65804. else {
  65805. this._scene._cachedVisibility = 1;
  65806. }
  65807. if (this._onBindObservable && mesh) {
  65808. this._onBindObservable.notifyObservers(mesh);
  65809. }
  65810. if (this.disableDepthWrite) {
  65811. var engine = this._scene.getEngine();
  65812. this._cachedDepthWriteState = engine.getDepthWrite();
  65813. engine.setDepthWrite(false);
  65814. }
  65815. };
  65816. /**
  65817. * Unbinds the material from the mesh
  65818. */
  65819. Material.prototype.unbind = function () {
  65820. if (this._onUnBindObservable) {
  65821. this._onUnBindObservable.notifyObservers(this);
  65822. }
  65823. if (this.disableDepthWrite) {
  65824. var engine = this._scene.getEngine();
  65825. engine.setDepthWrite(this._cachedDepthWriteState);
  65826. }
  65827. };
  65828. /**
  65829. * Gets the active textures from the material
  65830. * @returns an array of textures
  65831. */
  65832. Material.prototype.getActiveTextures = function () {
  65833. return [];
  65834. };
  65835. /**
  65836. * Specifies if the material uses a texture
  65837. * @param texture defines the texture to check against the material
  65838. * @returns a boolean specifying if the material uses the texture
  65839. */
  65840. Material.prototype.hasTexture = function (texture) {
  65841. return false;
  65842. };
  65843. /**
  65844. * Makes a duplicate of the material, and gives it a new name
  65845. * @param name defines the new name for the duplicated material
  65846. * @returns the cloned material
  65847. */
  65848. Material.prototype.clone = function (name) {
  65849. return null;
  65850. };
  65851. /**
  65852. * Gets the meshes bound to the material
  65853. * @returns an array of meshes bound to the material
  65854. */
  65855. Material.prototype.getBindedMeshes = function () {
  65856. var _this = this;
  65857. if (this.meshMap) {
  65858. var result = new Array();
  65859. for (var meshId in this.meshMap) {
  65860. var mesh = this.meshMap[meshId];
  65861. if (mesh) {
  65862. result.push(mesh);
  65863. }
  65864. }
  65865. return result;
  65866. }
  65867. else {
  65868. var meshes = this._scene.meshes;
  65869. return meshes.filter(function (mesh) { return mesh.material === _this; });
  65870. }
  65871. };
  65872. /**
  65873. * Force shader compilation
  65874. * @param mesh defines the mesh associated with this material
  65875. * @param onCompiled defines a function to execute once the material is compiled
  65876. * @param options defines the options to configure the compilation
  65877. */
  65878. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  65879. var _this = this;
  65880. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  65881. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  65882. var scene = this.getScene();
  65883. var checkReady = function () {
  65884. if (!_this._scene || !_this._scene.getEngine()) {
  65885. return;
  65886. }
  65887. if (subMesh._materialDefines) {
  65888. subMesh._materialDefines._renderId = -1;
  65889. }
  65890. var clipPlaneState = scene.clipPlane;
  65891. if (localOptions.clipPlane) {
  65892. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  65893. }
  65894. if (_this._storeEffectOnSubMeshes) {
  65895. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  65896. if (onCompiled) {
  65897. onCompiled(_this);
  65898. }
  65899. }
  65900. else {
  65901. setTimeout(checkReady, 16);
  65902. }
  65903. }
  65904. else {
  65905. if (_this.isReady()) {
  65906. if (onCompiled) {
  65907. onCompiled(_this);
  65908. }
  65909. }
  65910. else {
  65911. setTimeout(checkReady, 16);
  65912. }
  65913. }
  65914. if (localOptions.clipPlane) {
  65915. scene.clipPlane = clipPlaneState;
  65916. }
  65917. };
  65918. checkReady();
  65919. };
  65920. /**
  65921. * Force shader compilation
  65922. * @param mesh defines the mesh that will use this material
  65923. * @param options defines additional options for compiling the shaders
  65924. * @returns a promise that resolves when the compilation completes
  65925. */
  65926. Material.prototype.forceCompilationAsync = function (mesh, options) {
  65927. var _this = this;
  65928. return new Promise(function (resolve) {
  65929. _this.forceCompilation(mesh, function () {
  65930. resolve();
  65931. }, options);
  65932. });
  65933. };
  65934. /**
  65935. * Marks a define in the material to indicate that it needs to be re-computed
  65936. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  65937. */
  65938. Material.prototype.markAsDirty = function (flag) {
  65939. if (this.getScene().blockMaterialDirtyMechanism) {
  65940. return;
  65941. }
  65942. Material._DirtyCallbackArray.length = 0;
  65943. if (flag & Material.TextureDirtyFlag) {
  65944. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  65945. }
  65946. if (flag & Material.LightDirtyFlag) {
  65947. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  65948. }
  65949. if (flag & Material.FresnelDirtyFlag) {
  65950. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  65951. }
  65952. if (flag & Material.AttributesDirtyFlag) {
  65953. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  65954. }
  65955. if (flag & Material.MiscDirtyFlag) {
  65956. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  65957. }
  65958. if (Material._DirtyCallbackArray.length) {
  65959. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  65960. }
  65961. this.getScene().resetCachedMaterial();
  65962. };
  65963. /**
  65964. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  65965. * @param func defines a function which checks material defines against the submeshes
  65966. */
  65967. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  65968. if (this.getScene().blockMaterialDirtyMechanism) {
  65969. return;
  65970. }
  65971. var meshes = this.getScene().meshes;
  65972. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  65973. var mesh = meshes_1[_i];
  65974. if (!mesh.subMeshes) {
  65975. continue;
  65976. }
  65977. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  65978. var subMesh = _b[_a];
  65979. if (subMesh.getMaterial() !== this) {
  65980. continue;
  65981. }
  65982. if (!subMesh._materialDefines) {
  65983. continue;
  65984. }
  65985. func(subMesh._materialDefines);
  65986. }
  65987. }
  65988. };
  65989. /**
  65990. * Indicates that image processing needs to be re-calculated for all submeshes
  65991. */
  65992. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  65993. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  65994. };
  65995. /**
  65996. * Indicates that textures need to be re-calculated for all submeshes
  65997. */
  65998. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  65999. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  66000. };
  66001. /**
  66002. * Indicates that fresnel needs to be re-calculated for all submeshes
  66003. */
  66004. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  66005. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  66006. };
  66007. /**
  66008. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  66009. */
  66010. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  66011. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  66012. };
  66013. /**
  66014. * Indicates that lights need to be re-calculated for all submeshes
  66015. */
  66016. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  66017. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  66018. };
  66019. /**
  66020. * Indicates that attributes need to be re-calculated for all submeshes
  66021. */
  66022. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  66023. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  66024. };
  66025. /**
  66026. * Indicates that misc needs to be re-calculated for all submeshes
  66027. */
  66028. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  66029. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  66030. };
  66031. /**
  66032. * Indicates that textures and misc need to be re-calculated for all submeshes
  66033. */
  66034. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  66035. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  66036. };
  66037. /**
  66038. * Disposes the material
  66039. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  66040. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  66041. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  66042. */
  66043. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  66044. var scene = this.getScene();
  66045. // Animations
  66046. scene.stopAnimation(this);
  66047. scene.freeProcessedMaterials();
  66048. // Remove from scene
  66049. scene.removeMaterial(this);
  66050. if (notBoundToMesh !== true) {
  66051. // Remove from meshes
  66052. if (this.meshMap) {
  66053. for (var meshId in this.meshMap) {
  66054. var mesh = this.meshMap[meshId];
  66055. if (mesh) {
  66056. mesh.material = null; // will set the entry in the map to undefined
  66057. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  66058. }
  66059. }
  66060. }
  66061. else {
  66062. var meshes = scene.meshes;
  66063. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  66064. var mesh = meshes_2[_i];
  66065. if (mesh.material === this) {
  66066. mesh.material = null;
  66067. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  66068. }
  66069. }
  66070. }
  66071. }
  66072. this._uniformBuffer.dispose();
  66073. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  66074. if (forceDisposeEffect && this._effect) {
  66075. if (!this._storeEffectOnSubMeshes) {
  66076. this._effect.dispose();
  66077. }
  66078. this._effect = null;
  66079. }
  66080. // Callback
  66081. this.onDisposeObservable.notifyObservers(this);
  66082. this.onDisposeObservable.clear();
  66083. if (this._onBindObservable) {
  66084. this._onBindObservable.clear();
  66085. }
  66086. if (this._onUnBindObservable) {
  66087. this._onUnBindObservable.clear();
  66088. }
  66089. };
  66090. /** @hidden */
  66091. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  66092. if (mesh.geometry) {
  66093. var geometry = (mesh.geometry);
  66094. if (this._storeEffectOnSubMeshes) {
  66095. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  66096. var subMesh = _a[_i];
  66097. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  66098. if (forceDisposeEffect && subMesh._materialEffect) {
  66099. subMesh._materialEffect.dispose();
  66100. }
  66101. }
  66102. }
  66103. else {
  66104. geometry._releaseVertexArrayObject(this._effect);
  66105. }
  66106. }
  66107. };
  66108. /**
  66109. * Serializes this material
  66110. * @returns the serialized material object
  66111. */
  66112. Material.prototype.serialize = function () {
  66113. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  66114. };
  66115. /**
  66116. * Creates a material from parsed material data
  66117. * @param parsedMaterial defines parsed material data
  66118. * @param scene defines the hosting scene
  66119. * @param rootUrl defines the root URL to use to load textures
  66120. * @returns a new material
  66121. */
  66122. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  66123. if (!parsedMaterial.customType) {
  66124. parsedMaterial.customType = "BABYLON.StandardMaterial";
  66125. }
  66126. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  66127. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  66128. if (!BABYLON.LegacyPBRMaterial) {
  66129. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library.");
  66130. return null;
  66131. }
  66132. }
  66133. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  66134. return materialType.Parse(parsedMaterial, scene, rootUrl);
  66135. };
  66136. /**
  66137. * Returns the triangle fill mode
  66138. */
  66139. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  66140. /**
  66141. * Returns the wireframe mode
  66142. */
  66143. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  66144. /**
  66145. * Returns the point fill mode
  66146. */
  66147. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  66148. /**
  66149. * Returns the point list draw mode
  66150. */
  66151. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  66152. /**
  66153. * Returns the line list draw mode
  66154. */
  66155. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  66156. /**
  66157. * Returns the line loop draw mode
  66158. */
  66159. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  66160. /**
  66161. * Returns the line strip draw mode
  66162. */
  66163. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  66164. /**
  66165. * Returns the triangle strip draw mode
  66166. */
  66167. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  66168. /**
  66169. * Returns the triangle fan draw mode
  66170. */
  66171. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  66172. /**
  66173. * Stores the clock-wise side orientation
  66174. */
  66175. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  66176. /**
  66177. * Stores the counter clock-wise side orientation
  66178. */
  66179. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  66180. /**
  66181. * The dirty texture flag value
  66182. */
  66183. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  66184. /**
  66185. * The dirty light flag value
  66186. */
  66187. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  66188. /**
  66189. * The dirty fresnel flag value
  66190. */
  66191. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  66192. /**
  66193. * The dirty attribute flag value
  66194. */
  66195. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  66196. /**
  66197. * The dirty misc flag value
  66198. */
  66199. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  66200. /**
  66201. * The all dirty flag value
  66202. */
  66203. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  66204. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  66205. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  66206. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  66207. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  66208. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  66209. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  66210. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  66211. Material._FresnelDirtyCallBack(defines);
  66212. Material._MiscDirtyCallBack(defines);
  66213. };
  66214. Material._TextureAndMiscDirtyCallBack = function (defines) {
  66215. Material._TextureDirtyCallBack(defines);
  66216. Material._MiscDirtyCallBack(defines);
  66217. };
  66218. Material._DirtyCallbackArray = [];
  66219. Material._RunDirtyCallBacks = function (defines) {
  66220. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  66221. var cb = _a[_i];
  66222. cb(defines);
  66223. }
  66224. };
  66225. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66226. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66227. ], Material.prototype, "id", void 0);
  66228. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66230. ], Material.prototype, "uniqueId", void 0);
  66231. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66232. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66233. ], Material.prototype, "name", void 0);
  66234. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66235. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66236. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  66237. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66238. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66239. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  66240. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66241. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66242. ], Material.prototype, "state", void 0);
  66243. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66244. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  66245. ], Material.prototype, "_alpha", void 0);
  66246. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66247. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  66248. ], Material.prototype, "_backFaceCulling", void 0);
  66249. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66250. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66251. ], Material.prototype, "sideOrientation", void 0);
  66252. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66253. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  66254. ], Material.prototype, "_alphaMode", void 0);
  66255. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66256. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66257. ], Material.prototype, "_needDepthPrePass", void 0);
  66258. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66259. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66260. ], Material.prototype, "disableDepthWrite", void 0);
  66261. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66262. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66263. ], Material.prototype, "forceDepthWrite", void 0);
  66264. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66265. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66266. ], Material.prototype, "separateCullingPass", void 0);
  66267. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66268. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  66269. ], Material.prototype, "_fogEnabled", void 0);
  66270. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66271. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66272. ], Material.prototype, "pointSize", void 0);
  66273. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66274. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66275. ], Material.prototype, "zOffset", void 0);
  66276. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66277. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66278. ], Material.prototype, "wireframe", null);
  66279. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66280. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66281. ], Material.prototype, "pointsCloud", null);
  66282. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66283. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66284. ], Material.prototype, "fillMode", null);
  66285. return Material;
  66286. }());
  66287. /***/ }),
  66288. /***/ "./Materials/materialDefines.ts":
  66289. /*!**************************************!*\
  66290. !*** ./Materials/materialDefines.ts ***!
  66291. \**************************************/
  66292. /*! exports provided: MaterialDefines */
  66293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66294. "use strict";
  66295. __webpack_require__.r(__webpack_exports__);
  66296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  66297. /**
  66298. * Manages the defines for the Material
  66299. */
  66300. var MaterialDefines = /** @class */ (function () {
  66301. function MaterialDefines() {
  66302. this._isDirty = true;
  66303. /** @hidden */
  66304. this._areLightsDirty = true;
  66305. /** @hidden */
  66306. this._areAttributesDirty = true;
  66307. /** @hidden */
  66308. this._areTexturesDirty = true;
  66309. /** @hidden */
  66310. this._areFresnelDirty = true;
  66311. /** @hidden */
  66312. this._areMiscDirty = true;
  66313. /** @hidden */
  66314. this._areImageProcessingDirty = true;
  66315. /** @hidden */
  66316. this._normals = false;
  66317. /** @hidden */
  66318. this._uvs = false;
  66319. /** @hidden */
  66320. this._needNormals = false;
  66321. /** @hidden */
  66322. this._needUVs = false;
  66323. }
  66324. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  66325. /**
  66326. * Specifies if the material needs to be re-calculated
  66327. */
  66328. get: function () {
  66329. return this._isDirty;
  66330. },
  66331. enumerable: true,
  66332. configurable: true
  66333. });
  66334. /**
  66335. * Marks the material to indicate that it has been re-calculated
  66336. */
  66337. MaterialDefines.prototype.markAsProcessed = function () {
  66338. this._isDirty = false;
  66339. this._areAttributesDirty = false;
  66340. this._areTexturesDirty = false;
  66341. this._areFresnelDirty = false;
  66342. this._areLightsDirty = false;
  66343. this._areMiscDirty = false;
  66344. this._areImageProcessingDirty = false;
  66345. };
  66346. /**
  66347. * Marks the material to indicate that it needs to be re-calculated
  66348. */
  66349. MaterialDefines.prototype.markAsUnprocessed = function () {
  66350. this._isDirty = true;
  66351. };
  66352. /**
  66353. * Marks the material to indicate all of its defines need to be re-calculated
  66354. */
  66355. MaterialDefines.prototype.markAllAsDirty = function () {
  66356. this._areTexturesDirty = true;
  66357. this._areAttributesDirty = true;
  66358. this._areLightsDirty = true;
  66359. this._areFresnelDirty = true;
  66360. this._areMiscDirty = true;
  66361. this._areImageProcessingDirty = true;
  66362. this._isDirty = true;
  66363. };
  66364. /**
  66365. * Marks the material to indicate that image processing needs to be re-calculated
  66366. */
  66367. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  66368. this._areImageProcessingDirty = true;
  66369. this._isDirty = true;
  66370. };
  66371. /**
  66372. * Marks the material to indicate the lights need to be re-calculated
  66373. */
  66374. MaterialDefines.prototype.markAsLightDirty = function () {
  66375. this._areLightsDirty = true;
  66376. this._isDirty = true;
  66377. };
  66378. /**
  66379. * Marks the attribute state as changed
  66380. */
  66381. MaterialDefines.prototype.markAsAttributesDirty = function () {
  66382. this._areAttributesDirty = true;
  66383. this._isDirty = true;
  66384. };
  66385. /**
  66386. * Marks the texture state as changed
  66387. */
  66388. MaterialDefines.prototype.markAsTexturesDirty = function () {
  66389. this._areTexturesDirty = true;
  66390. this._isDirty = true;
  66391. };
  66392. /**
  66393. * Marks the fresnel state as changed
  66394. */
  66395. MaterialDefines.prototype.markAsFresnelDirty = function () {
  66396. this._areFresnelDirty = true;
  66397. this._isDirty = true;
  66398. };
  66399. /**
  66400. * Marks the misc state as changed
  66401. */
  66402. MaterialDefines.prototype.markAsMiscDirty = function () {
  66403. this._areMiscDirty = true;
  66404. this._isDirty = true;
  66405. };
  66406. /**
  66407. * Rebuilds the material defines
  66408. */
  66409. MaterialDefines.prototype.rebuild = function () {
  66410. if (this._keys) {
  66411. delete this._keys;
  66412. }
  66413. this._keys = [];
  66414. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  66415. var key = _a[_i];
  66416. if (key[0] === "_") {
  66417. continue;
  66418. }
  66419. this._keys.push(key);
  66420. }
  66421. };
  66422. /**
  66423. * Specifies if two material defines are equal
  66424. * @param other - A material define instance to compare to
  66425. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  66426. */
  66427. MaterialDefines.prototype.isEqual = function (other) {
  66428. if (this._keys.length !== other._keys.length) {
  66429. return false;
  66430. }
  66431. for (var index = 0; index < this._keys.length; index++) {
  66432. var prop = this._keys[index];
  66433. if (this[prop] !== other[prop]) {
  66434. return false;
  66435. }
  66436. }
  66437. return true;
  66438. };
  66439. /**
  66440. * Clones this instance's defines to another instance
  66441. * @param other - material defines to clone values to
  66442. */
  66443. MaterialDefines.prototype.cloneTo = function (other) {
  66444. if (this._keys.length !== other._keys.length) {
  66445. other._keys = this._keys.slice(0);
  66446. }
  66447. for (var index = 0; index < this._keys.length; index++) {
  66448. var prop = this._keys[index];
  66449. other[prop] = this[prop];
  66450. }
  66451. };
  66452. /**
  66453. * Resets the material define values
  66454. */
  66455. MaterialDefines.prototype.reset = function () {
  66456. for (var index = 0; index < this._keys.length; index++) {
  66457. var prop = this._keys[index];
  66458. var type = typeof this[prop];
  66459. switch (type) {
  66460. case "number":
  66461. this[prop] = 0;
  66462. break;
  66463. case "string":
  66464. this[prop] = "";
  66465. break;
  66466. default:
  66467. this[prop] = false;
  66468. break;
  66469. }
  66470. }
  66471. };
  66472. /**
  66473. * Converts the material define values to a string
  66474. * @returns - String of material define information
  66475. */
  66476. MaterialDefines.prototype.toString = function () {
  66477. var result = "";
  66478. for (var index = 0; index < this._keys.length; index++) {
  66479. var prop = this._keys[index];
  66480. var value = this[prop];
  66481. var type = typeof value;
  66482. switch (type) {
  66483. case "number":
  66484. case "string":
  66485. result += "#define " + prop + " " + value + "\n";
  66486. break;
  66487. default:
  66488. if (value) {
  66489. result += "#define " + prop + "\n";
  66490. }
  66491. break;
  66492. }
  66493. }
  66494. return result;
  66495. };
  66496. return MaterialDefines;
  66497. }());
  66498. /***/ }),
  66499. /***/ "./Materials/materialFlags.ts":
  66500. /*!************************************!*\
  66501. !*** ./Materials/materialFlags.ts ***!
  66502. \************************************/
  66503. /*! exports provided: MaterialFlags */
  66504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66505. "use strict";
  66506. __webpack_require__.r(__webpack_exports__);
  66507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  66508. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  66509. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  66510. /**
  66511. * This groups all the flags used to control the materials channel.
  66512. */
  66513. var MaterialFlags = /** @class */ (function () {
  66514. function MaterialFlags() {
  66515. }
  66516. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  66517. /**
  66518. * Are diffuse textures enabled in the application.
  66519. */
  66520. get: function () {
  66521. return this._DiffuseTextureEnabled;
  66522. },
  66523. set: function (value) {
  66524. if (this._DiffuseTextureEnabled === value) {
  66525. return;
  66526. }
  66527. this._DiffuseTextureEnabled = value;
  66528. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66529. },
  66530. enumerable: true,
  66531. configurable: true
  66532. });
  66533. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  66534. /**
  66535. * Are ambient textures enabled in the application.
  66536. */
  66537. get: function () {
  66538. return this._AmbientTextureEnabled;
  66539. },
  66540. set: function (value) {
  66541. if (this._AmbientTextureEnabled === value) {
  66542. return;
  66543. }
  66544. this._AmbientTextureEnabled = value;
  66545. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66546. },
  66547. enumerable: true,
  66548. configurable: true
  66549. });
  66550. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  66551. /**
  66552. * Are opacity textures enabled in the application.
  66553. */
  66554. get: function () {
  66555. return this._OpacityTextureEnabled;
  66556. },
  66557. set: function (value) {
  66558. if (this._OpacityTextureEnabled === value) {
  66559. return;
  66560. }
  66561. this._OpacityTextureEnabled = value;
  66562. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66563. },
  66564. enumerable: true,
  66565. configurable: true
  66566. });
  66567. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  66568. /**
  66569. * Are reflection textures enabled in the application.
  66570. */
  66571. get: function () {
  66572. return this._ReflectionTextureEnabled;
  66573. },
  66574. set: function (value) {
  66575. if (this._ReflectionTextureEnabled === value) {
  66576. return;
  66577. }
  66578. this._ReflectionTextureEnabled = value;
  66579. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66580. },
  66581. enumerable: true,
  66582. configurable: true
  66583. });
  66584. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  66585. /**
  66586. * Are emissive textures enabled in the application.
  66587. */
  66588. get: function () {
  66589. return this._EmissiveTextureEnabled;
  66590. },
  66591. set: function (value) {
  66592. if (this._EmissiveTextureEnabled === value) {
  66593. return;
  66594. }
  66595. this._EmissiveTextureEnabled = value;
  66596. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66597. },
  66598. enumerable: true,
  66599. configurable: true
  66600. });
  66601. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  66602. /**
  66603. * Are specular textures enabled in the application.
  66604. */
  66605. get: function () {
  66606. return this._SpecularTextureEnabled;
  66607. },
  66608. set: function (value) {
  66609. if (this._SpecularTextureEnabled === value) {
  66610. return;
  66611. }
  66612. this._SpecularTextureEnabled = value;
  66613. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66614. },
  66615. enumerable: true,
  66616. configurable: true
  66617. });
  66618. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  66619. /**
  66620. * Are bump textures enabled in the application.
  66621. */
  66622. get: function () {
  66623. return this._BumpTextureEnabled;
  66624. },
  66625. set: function (value) {
  66626. if (this._BumpTextureEnabled === value) {
  66627. return;
  66628. }
  66629. this._BumpTextureEnabled = value;
  66630. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66631. },
  66632. enumerable: true,
  66633. configurable: true
  66634. });
  66635. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  66636. /**
  66637. * Are lightmap textures enabled in the application.
  66638. */
  66639. get: function () {
  66640. return this._LightmapTextureEnabled;
  66641. },
  66642. set: function (value) {
  66643. if (this._LightmapTextureEnabled === value) {
  66644. return;
  66645. }
  66646. this._LightmapTextureEnabled = value;
  66647. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66648. },
  66649. enumerable: true,
  66650. configurable: true
  66651. });
  66652. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  66653. /**
  66654. * Are refraction textures enabled in the application.
  66655. */
  66656. get: function () {
  66657. return this._RefractionTextureEnabled;
  66658. },
  66659. set: function (value) {
  66660. if (this._RefractionTextureEnabled === value) {
  66661. return;
  66662. }
  66663. this._RefractionTextureEnabled = value;
  66664. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66665. },
  66666. enumerable: true,
  66667. configurable: true
  66668. });
  66669. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  66670. /**
  66671. * Are color grading textures enabled in the application.
  66672. */
  66673. get: function () {
  66674. return this._ColorGradingTextureEnabled;
  66675. },
  66676. set: function (value) {
  66677. if (this._ColorGradingTextureEnabled === value) {
  66678. return;
  66679. }
  66680. this._ColorGradingTextureEnabled = value;
  66681. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66682. },
  66683. enumerable: true,
  66684. configurable: true
  66685. });
  66686. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  66687. /**
  66688. * Are fresnels enabled in the application.
  66689. */
  66690. get: function () {
  66691. return this._FresnelEnabled;
  66692. },
  66693. set: function (value) {
  66694. if (this._FresnelEnabled === value) {
  66695. return;
  66696. }
  66697. this._FresnelEnabled = value;
  66698. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  66699. },
  66700. enumerable: true,
  66701. configurable: true
  66702. });
  66703. Object.defineProperty(MaterialFlags, "ClearCoatTextureEnabled", {
  66704. /**
  66705. * Are clear coat textures enabled in the application.
  66706. */
  66707. get: function () {
  66708. return this._ClearCoatTextureEnabled;
  66709. },
  66710. set: function (value) {
  66711. if (this._ClearCoatTextureEnabled === value) {
  66712. return;
  66713. }
  66714. this._ClearCoatTextureEnabled = value;
  66715. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66716. },
  66717. enumerable: true,
  66718. configurable: true
  66719. });
  66720. Object.defineProperty(MaterialFlags, "ClearCoatBumpTextureEnabled", {
  66721. /**
  66722. * Are clear coat bump textures enabled in the application.
  66723. */
  66724. get: function () {
  66725. return this._ClearCoatBumpTextureEnabled;
  66726. },
  66727. set: function (value) {
  66728. if (this._ClearCoatBumpTextureEnabled === value) {
  66729. return;
  66730. }
  66731. this._ClearCoatBumpTextureEnabled = value;
  66732. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66733. },
  66734. enumerable: true,
  66735. configurable: true
  66736. });
  66737. Object.defineProperty(MaterialFlags, "ClearCoatTintTextureEnabled", {
  66738. /**
  66739. * Are clear coat tint textures enabled in the application.
  66740. */
  66741. get: function () {
  66742. return this._ClearCoatTintTextureEnabled;
  66743. },
  66744. set: function (value) {
  66745. if (this._ClearCoatTintTextureEnabled === value) {
  66746. return;
  66747. }
  66748. this._ClearCoatTintTextureEnabled = value;
  66749. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66750. },
  66751. enumerable: true,
  66752. configurable: true
  66753. });
  66754. Object.defineProperty(MaterialFlags, "SheenTextureEnabled", {
  66755. /**
  66756. * Are sheen textures enabled in the application.
  66757. */
  66758. get: function () {
  66759. return this._SheenTextureEnabled;
  66760. },
  66761. set: function (value) {
  66762. if (this._SheenTextureEnabled === value) {
  66763. return;
  66764. }
  66765. this._SheenTextureEnabled = value;
  66766. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66767. },
  66768. enumerable: true,
  66769. configurable: true
  66770. });
  66771. Object.defineProperty(MaterialFlags, "AnisotropicTextureEnabled", {
  66772. /**
  66773. * Are anisotropic textures enabled in the application.
  66774. */
  66775. get: function () {
  66776. return this._AnisotropicTextureEnabled;
  66777. },
  66778. set: function (value) {
  66779. if (this._AnisotropicTextureEnabled === value) {
  66780. return;
  66781. }
  66782. this._AnisotropicTextureEnabled = value;
  66783. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66784. },
  66785. enumerable: true,
  66786. configurable: true
  66787. });
  66788. Object.defineProperty(MaterialFlags, "ThicknessTextureEnabled", {
  66789. /**
  66790. * Are thickness textures enabled in the application.
  66791. */
  66792. get: function () {
  66793. return this._ThicknessTextureEnabled;
  66794. },
  66795. set: function (value) {
  66796. if (this._ThicknessTextureEnabled === value) {
  66797. return;
  66798. }
  66799. this._ThicknessTextureEnabled = value;
  66800. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66801. },
  66802. enumerable: true,
  66803. configurable: true
  66804. });
  66805. // Flags used to enable or disable a type of texture for all Standard Materials
  66806. MaterialFlags._DiffuseTextureEnabled = true;
  66807. MaterialFlags._AmbientTextureEnabled = true;
  66808. MaterialFlags._OpacityTextureEnabled = true;
  66809. MaterialFlags._ReflectionTextureEnabled = true;
  66810. MaterialFlags._EmissiveTextureEnabled = true;
  66811. MaterialFlags._SpecularTextureEnabled = true;
  66812. MaterialFlags._BumpTextureEnabled = true;
  66813. MaterialFlags._LightmapTextureEnabled = true;
  66814. MaterialFlags._RefractionTextureEnabled = true;
  66815. MaterialFlags._ColorGradingTextureEnabled = true;
  66816. MaterialFlags._FresnelEnabled = true;
  66817. MaterialFlags._ClearCoatTextureEnabled = true;
  66818. MaterialFlags._ClearCoatBumpTextureEnabled = true;
  66819. MaterialFlags._ClearCoatTintTextureEnabled = true;
  66820. MaterialFlags._SheenTextureEnabled = true;
  66821. MaterialFlags._AnisotropicTextureEnabled = true;
  66822. MaterialFlags._ThicknessTextureEnabled = true;
  66823. return MaterialFlags;
  66824. }());
  66825. /***/ }),
  66826. /***/ "./Materials/materialHelper.ts":
  66827. /*!*************************************!*\
  66828. !*** ./Materials/materialHelper.ts ***!
  66829. \*************************************/
  66830. /*! exports provided: MaterialHelper */
  66831. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66832. "use strict";
  66833. __webpack_require__.r(__webpack_exports__);
  66834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  66835. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  66836. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  66837. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  66838. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  66839. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  66840. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  66841. /**
  66842. * "Static Class" containing the most commonly used helper while dealing with material for
  66843. * rendering purpose.
  66844. *
  66845. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66846. *
  66847. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66848. */
  66849. var MaterialHelper = /** @class */ (function () {
  66850. function MaterialHelper() {
  66851. }
  66852. /**
  66853. * Bind the current view position to an effect.
  66854. * @param effect The effect to be bound
  66855. * @param scene The scene the eyes position is used from
  66856. */
  66857. MaterialHelper.BindEyePosition = function (effect, scene) {
  66858. if (scene._forcedViewPosition) {
  66859. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  66860. return;
  66861. }
  66862. var globalPosition = scene.activeCamera.globalPosition;
  66863. if (!globalPosition) {
  66864. // Use WebVRFreecamera's device position as global position is not it's actual position in babylon space
  66865. globalPosition = scene.activeCamera.devicePosition;
  66866. }
  66867. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : globalPosition);
  66868. };
  66869. /**
  66870. * Helps preparing the defines values about the UVs in used in the effect.
  66871. * UVs are shared as much as we can accross channels in the shaders.
  66872. * @param texture The texture we are preparing the UVs for
  66873. * @param defines The defines to update
  66874. * @param key The channel key "diffuse", "specular"... used in the shader
  66875. */
  66876. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  66877. defines._needUVs = true;
  66878. defines[key] = true;
  66879. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  66880. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  66881. if (texture.coordinatesIndex === 0) {
  66882. defines["MAINUV1"] = true;
  66883. }
  66884. else {
  66885. defines["MAINUV2"] = true;
  66886. }
  66887. }
  66888. else {
  66889. defines[key + "DIRECTUV"] = 0;
  66890. }
  66891. };
  66892. /**
  66893. * Binds a texture matrix value to its corrsponding uniform
  66894. * @param texture The texture to bind the matrix for
  66895. * @param uniformBuffer The uniform buffer receivin the data
  66896. * @param key The channel key "diffuse", "specular"... used in the shader
  66897. */
  66898. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  66899. var matrix = texture.getTextureMatrix();
  66900. if (!matrix.isIdentityAs3x2()) {
  66901. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  66902. }
  66903. };
  66904. /**
  66905. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66906. * @param mesh defines the current mesh
  66907. * @param scene defines the current scene
  66908. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66909. * @param pointsCloud defines if point cloud rendering has to be turned on
  66910. * @param fogEnabled defines if fog has to be turned on
  66911. * @param alphaTest defines if alpha testing has to be turned on
  66912. * @param defines defines the current list of defines
  66913. */
  66914. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  66915. if (defines._areMiscDirty) {
  66916. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  66917. defines["POINTSIZE"] = pointsCloud;
  66918. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  66919. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  66920. defines["ALPHATEST"] = alphaTest;
  66921. }
  66922. };
  66923. /**
  66924. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66925. * @param scene defines the current scene
  66926. * @param engine defines the current engine
  66927. * @param defines specifies the list of active defines
  66928. * @param useInstances defines if instances have to be turned on
  66929. * @param useClipPlane defines if clip plane have to be turned on
  66930. */
  66931. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  66932. if (useClipPlane === void 0) { useClipPlane = null; }
  66933. var changed = false;
  66934. var useClipPlane1 = false;
  66935. var useClipPlane2 = false;
  66936. var useClipPlane3 = false;
  66937. var useClipPlane4 = false;
  66938. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  66939. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  66940. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  66941. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  66942. if (defines["CLIPPLANE"] !== useClipPlane1) {
  66943. defines["CLIPPLANE"] = useClipPlane1;
  66944. changed = true;
  66945. }
  66946. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  66947. defines["CLIPPLANE2"] = useClipPlane2;
  66948. changed = true;
  66949. }
  66950. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  66951. defines["CLIPPLANE3"] = useClipPlane3;
  66952. changed = true;
  66953. }
  66954. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  66955. defines["CLIPPLANE4"] = useClipPlane4;
  66956. changed = true;
  66957. }
  66958. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  66959. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  66960. changed = true;
  66961. }
  66962. if (defines["INSTANCES"] !== useInstances) {
  66963. defines["INSTANCES"] = useInstances;
  66964. changed = true;
  66965. }
  66966. if (changed) {
  66967. defines.markAsUnprocessed();
  66968. }
  66969. };
  66970. /**
  66971. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66972. * @param mesh The mesh containing the geometry data we will draw
  66973. * @param defines The defines to update
  66974. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66975. * @param useBones Precise whether bones should be used or not (override mesh info)
  66976. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66977. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66978. * @returns false if defines are considered not dirty and have not been checked
  66979. */
  66980. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  66981. if (useMorphTargets === void 0) { useMorphTargets = false; }
  66982. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  66983. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  66984. return false;
  66985. }
  66986. defines._normals = defines._needNormals;
  66987. defines._uvs = defines._needUVs;
  66988. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  66989. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  66990. defines["TANGENT"] = true;
  66991. }
  66992. if (defines._needUVs) {
  66993. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  66994. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  66995. }
  66996. else {
  66997. defines["UV1"] = false;
  66998. defines["UV2"] = false;
  66999. }
  67000. if (useVertexColor) {
  67001. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  67002. defines["VERTEXCOLOR"] = hasVertexColors;
  67003. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  67004. }
  67005. if (useBones) {
  67006. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  67007. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  67008. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  67009. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  67010. defines["BONETEXTURE"] = true;
  67011. }
  67012. else {
  67013. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  67014. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  67015. }
  67016. }
  67017. else {
  67018. defines["NUM_BONE_INFLUENCERS"] = 0;
  67019. defines["BonesPerMesh"] = 0;
  67020. }
  67021. }
  67022. if (useMorphTargets) {
  67023. var manager = mesh.morphTargetManager;
  67024. if (manager) {
  67025. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  67026. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  67027. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  67028. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  67029. }
  67030. else {
  67031. defines["MORPHTARGETS_TANGENT"] = false;
  67032. defines["MORPHTARGETS_NORMAL"] = false;
  67033. defines["MORPHTARGETS"] = false;
  67034. defines["NUM_MORPH_INFLUENCERS"] = 0;
  67035. }
  67036. }
  67037. return true;
  67038. };
  67039. /**
  67040. * Prepares the defines related to multiview
  67041. * @param scene The scene we are intending to draw
  67042. * @param defines The defines to update
  67043. */
  67044. MaterialHelper.PrepareDefinesForMultiview = function (scene, defines) {
  67045. if (scene.activeCamera) {
  67046. var previousMultiview = defines.MULTIVIEW;
  67047. defines.MULTIVIEW = (scene.activeCamera.outputRenderTarget !== null && scene.activeCamera.outputRenderTarget.getViewCount() > 1);
  67048. if (defines.MULTIVIEW != previousMultiview) {
  67049. defines.markAsUnprocessed();
  67050. }
  67051. }
  67052. };
  67053. /**
  67054. * Prepares the defines related to the light information passed in parameter
  67055. * @param scene The scene we are intending to draw
  67056. * @param mesh The mesh the effect is compiling for
  67057. * @param defines The defines to update
  67058. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  67059. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  67060. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  67061. * @returns true if normals will be required for the rest of the effect
  67062. */
  67063. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  67064. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  67065. if (disableLighting === void 0) { disableLighting = false; }
  67066. if (!defines._areLightsDirty) {
  67067. return defines._needNormals;
  67068. }
  67069. var lightIndex = 0;
  67070. var needNormals = false;
  67071. var needRebuild = false;
  67072. var lightmapMode = false;
  67073. var shadowEnabled = false;
  67074. var specularEnabled = false;
  67075. if (scene.lightsEnabled && !disableLighting) {
  67076. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  67077. var light = _a[_i];
  67078. needNormals = true;
  67079. if (defines["LIGHT" + lightIndex] === undefined) {
  67080. needRebuild = true;
  67081. }
  67082. defines["LIGHT" + lightIndex] = true;
  67083. defines["SPOTLIGHT" + lightIndex] = false;
  67084. defines["HEMILIGHT" + lightIndex] = false;
  67085. defines["POINTLIGHT" + lightIndex] = false;
  67086. defines["DIRLIGHT" + lightIndex] = false;
  67087. light.prepareLightSpecificDefines(defines, lightIndex);
  67088. // FallOff.
  67089. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  67090. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  67091. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  67092. switch (light.falloffType) {
  67093. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  67094. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  67095. break;
  67096. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  67097. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  67098. break;
  67099. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  67100. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  67101. break;
  67102. }
  67103. // Specular
  67104. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  67105. specularEnabled = true;
  67106. }
  67107. // Shadows
  67108. defines["SHADOW" + lightIndex] = false;
  67109. defines["SHADOWPCF" + lightIndex] = false;
  67110. defines["SHADOWPCSS" + lightIndex] = false;
  67111. defines["SHADOWPOISSON" + lightIndex] = false;
  67112. defines["SHADOWESM" + lightIndex] = false;
  67113. defines["SHADOWCUBE" + lightIndex] = false;
  67114. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  67115. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  67116. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  67117. var shadowGenerator = light.getShadowGenerator();
  67118. if (shadowGenerator) {
  67119. var shadowMap = shadowGenerator.getShadowMap();
  67120. if (shadowMap) {
  67121. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  67122. shadowEnabled = true;
  67123. shadowGenerator.prepareDefines(defines, lightIndex);
  67124. }
  67125. }
  67126. }
  67127. }
  67128. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  67129. lightmapMode = true;
  67130. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  67131. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  67132. }
  67133. else {
  67134. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  67135. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  67136. }
  67137. lightIndex++;
  67138. if (lightIndex === maxSimultaneousLights) {
  67139. break;
  67140. }
  67141. }
  67142. }
  67143. defines["SPECULARTERM"] = specularEnabled;
  67144. defines["SHADOWS"] = shadowEnabled;
  67145. // Resetting all other lights if any
  67146. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  67147. if (defines["LIGHT" + index] !== undefined) {
  67148. defines["LIGHT" + index] = false;
  67149. defines["HEMILIGHT" + index] = false;
  67150. defines["POINTLIGHT" + index] = false;
  67151. defines["DIRLIGHT" + index] = false;
  67152. defines["SPOTLIGHT" + index] = false;
  67153. defines["SHADOW" + index] = false;
  67154. defines["SHADOWPCF" + index] = false;
  67155. defines["SHADOWPCSS" + index] = false;
  67156. defines["SHADOWPOISSON" + index] = false;
  67157. defines["SHADOWESM" + index] = false;
  67158. defines["SHADOWCUBE" + index] = false;
  67159. defines["SHADOWLOWQUALITY" + index] = false;
  67160. defines["SHADOWMEDIUMQUALITY" + index] = false;
  67161. }
  67162. }
  67163. var caps = scene.getEngine().getCaps();
  67164. if (defines["SHADOWFLOAT"] === undefined) {
  67165. needRebuild = true;
  67166. }
  67167. defines["SHADOWFLOAT"] = shadowEnabled &&
  67168. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  67169. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  67170. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  67171. if (needRebuild) {
  67172. defines.rebuild();
  67173. }
  67174. return needNormals;
  67175. };
  67176. /**
  67177. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  67178. * that won t be acctive due to defines being turned off.
  67179. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  67180. * @param samplersList The samplers list
  67181. * @param defines The defines helping in the list generation
  67182. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  67183. */
  67184. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  67185. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  67186. var uniformsList;
  67187. var uniformBuffersList = null;
  67188. if (uniformsListOrOptions.uniformsNames) {
  67189. var options = uniformsListOrOptions;
  67190. uniformsList = options.uniformsNames;
  67191. uniformBuffersList = options.uniformBuffersNames;
  67192. samplersList = options.samplers;
  67193. defines = options.defines;
  67194. maxSimultaneousLights = options.maxSimultaneousLights;
  67195. }
  67196. else {
  67197. uniformsList = uniformsListOrOptions;
  67198. if (!samplersList) {
  67199. samplersList = [];
  67200. }
  67201. }
  67202. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  67203. if (!defines["LIGHT" + lightIndex]) {
  67204. break;
  67205. }
  67206. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  67207. if (uniformBuffersList) {
  67208. uniformBuffersList.push("Light" + lightIndex);
  67209. }
  67210. samplersList.push("shadowSampler" + lightIndex);
  67211. samplersList.push("depthSampler" + lightIndex);
  67212. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  67213. samplersList.push("projectionLightSampler" + lightIndex);
  67214. uniformsList.push("textureProjectionMatrix" + lightIndex);
  67215. }
  67216. }
  67217. if (defines["NUM_MORPH_INFLUENCERS"]) {
  67218. uniformsList.push("morphTargetInfluences");
  67219. }
  67220. };
  67221. /**
  67222. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  67223. * @param defines The defines to update while falling back
  67224. * @param fallbacks The authorized effect fallbacks
  67225. * @param maxSimultaneousLights The maximum number of lights allowed
  67226. * @param rank the current rank of the Effect
  67227. * @returns The newly affected rank
  67228. */
  67229. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  67230. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  67231. if (rank === void 0) { rank = 0; }
  67232. var lightFallbackRank = 0;
  67233. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  67234. if (!defines["LIGHT" + lightIndex]) {
  67235. break;
  67236. }
  67237. if (lightIndex > 0) {
  67238. lightFallbackRank = rank + lightIndex;
  67239. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  67240. }
  67241. if (!defines["SHADOWS"]) {
  67242. if (defines["SHADOW" + lightIndex]) {
  67243. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  67244. }
  67245. if (defines["SHADOWPCF" + lightIndex]) {
  67246. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  67247. }
  67248. if (defines["SHADOWPCSS" + lightIndex]) {
  67249. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  67250. }
  67251. if (defines["SHADOWPOISSON" + lightIndex]) {
  67252. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  67253. }
  67254. if (defines["SHADOWESM" + lightIndex]) {
  67255. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  67256. }
  67257. }
  67258. }
  67259. return lightFallbackRank++;
  67260. };
  67261. /**
  67262. * Prepares the list of attributes required for morph targets according to the effect defines.
  67263. * @param attribs The current list of supported attribs
  67264. * @param mesh The mesh to prepare the morph targets attributes for
  67265. * @param defines The current Defines of the effect
  67266. */
  67267. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  67268. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  67269. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  67270. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  67271. var manager = mesh.morphTargetManager;
  67272. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  67273. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  67274. for (var index = 0; index < influencers; index++) {
  67275. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  67276. if (normal) {
  67277. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  67278. }
  67279. if (tangent) {
  67280. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  67281. }
  67282. if (attribs.length > maxAttributesCount) {
  67283. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  67284. }
  67285. }
  67286. }
  67287. };
  67288. /**
  67289. * Prepares the list of attributes required for bones according to the effect defines.
  67290. * @param attribs The current list of supported attribs
  67291. * @param mesh The mesh to prepare the bones attributes for
  67292. * @param defines The current Defines of the effect
  67293. * @param fallbacks The current efffect fallback strategy
  67294. */
  67295. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  67296. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  67297. fallbacks.addCPUSkinningFallback(0, mesh);
  67298. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  67299. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  67300. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  67301. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  67302. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  67303. }
  67304. }
  67305. };
  67306. /**
  67307. * Prepares the list of attributes required for instances according to the effect defines.
  67308. * @param attribs The current list of supported attribs
  67309. * @param defines The current Defines of the effect
  67310. */
  67311. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  67312. if (defines["INSTANCES"]) {
  67313. attribs.push("world0");
  67314. attribs.push("world1");
  67315. attribs.push("world2");
  67316. attribs.push("world3");
  67317. }
  67318. };
  67319. /**
  67320. * Binds the light shadow information to the effect for the given mesh.
  67321. * @param light The light containing the generator
  67322. * @param scene The scene the lights belongs to
  67323. * @param mesh The mesh we are binding the information to render
  67324. * @param lightIndex The light index in the effect used to render the mesh
  67325. * @param effect The effect we are binding the data to
  67326. */
  67327. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  67328. if (light.shadowEnabled && mesh.receiveShadows) {
  67329. var shadowGenerator = light.getShadowGenerator();
  67330. if (shadowGenerator) {
  67331. shadowGenerator.bindShadowLight(lightIndex, effect);
  67332. }
  67333. }
  67334. };
  67335. /**
  67336. * Binds the light information to the effect.
  67337. * @param light The light containing the generator
  67338. * @param effect The effect we are binding the data to
  67339. * @param lightIndex The light index in the effect used to render
  67340. */
  67341. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  67342. light.transferToEffect(effect, lightIndex + "");
  67343. };
  67344. /**
  67345. * Binds the lights information from the scene to the effect for the given mesh.
  67346. * @param scene The scene the lights belongs to
  67347. * @param mesh The mesh we are binding the information to render
  67348. * @param effect The effect we are binding the data to
  67349. * @param defines The generated defines for the effect
  67350. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  67351. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  67352. */
  67353. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  67354. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  67355. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  67356. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  67357. for (var i = 0; i < len; i++) {
  67358. var light = mesh._lightSources[i];
  67359. var iAsString = i.toString();
  67360. var scaledIntensity = light.getScaledIntensity();
  67361. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  67362. MaterialHelper.BindLightProperties(light, effect, i);
  67363. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  67364. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  67365. if (defines["SPECULARTERM"]) {
  67366. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  67367. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  67368. }
  67369. // Shadows
  67370. if (scene.shadowsEnabled) {
  67371. this.BindLightShadow(light, mesh, iAsString, effect);
  67372. }
  67373. light._uniformBuffer.update();
  67374. }
  67375. };
  67376. /**
  67377. * Binds the fog information from the scene to the effect for the given mesh.
  67378. * @param scene The scene the lights belongs to
  67379. * @param mesh The mesh we are binding the information to render
  67380. * @param effect The effect we are binding the data to
  67381. * @param linearSpace Defines if the fog effect is applied in linear space
  67382. */
  67383. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  67384. if (linearSpace === void 0) { linearSpace = false; }
  67385. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  67386. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  67387. // Convert fog color to linear space if used in a linear space computed shader.
  67388. if (linearSpace) {
  67389. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  67390. effect.setColor3("vFogColor", this._tempFogColor);
  67391. }
  67392. else {
  67393. effect.setColor3("vFogColor", scene.fogColor);
  67394. }
  67395. }
  67396. };
  67397. /**
  67398. * Binds the bones information from the mesh to the effect.
  67399. * @param mesh The mesh we are binding the information to render
  67400. * @param effect The effect we are binding the data to
  67401. */
  67402. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  67403. if (!effect || !mesh) {
  67404. return;
  67405. }
  67406. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  67407. mesh.computeBonesUsingShaders = false;
  67408. }
  67409. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  67410. var skeleton = mesh.skeleton;
  67411. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  67412. var boneTexture = skeleton.getTransformMatrixTexture();
  67413. effect.setTexture("boneSampler", boneTexture);
  67414. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  67415. }
  67416. else {
  67417. var matrices = skeleton.getTransformMatrices(mesh);
  67418. if (matrices) {
  67419. effect.setMatrices("mBones", matrices);
  67420. }
  67421. }
  67422. }
  67423. };
  67424. /**
  67425. * Binds the morph targets information from the mesh to the effect.
  67426. * @param abstractMesh The mesh we are binding the information to render
  67427. * @param effect The effect we are binding the data to
  67428. */
  67429. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  67430. var manager = abstractMesh.morphTargetManager;
  67431. if (!abstractMesh || !manager) {
  67432. return;
  67433. }
  67434. effect.setFloatArray("morphTargetInfluences", manager.influences);
  67435. };
  67436. /**
  67437. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  67438. * @param defines The generated defines used in the effect
  67439. * @param effect The effect we are binding the data to
  67440. * @param scene The scene we are willing to render with logarithmic scale for
  67441. */
  67442. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  67443. if (defines["LOGARITHMICDEPTH"]) {
  67444. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  67445. }
  67446. };
  67447. /**
  67448. * Binds the clip plane information from the scene to the effect.
  67449. * @param scene The scene the clip plane information are extracted from
  67450. * @param effect The effect we are binding the data to
  67451. */
  67452. MaterialHelper.BindClipPlane = function (effect, scene) {
  67453. if (scene.clipPlane) {
  67454. var clipPlane = scene.clipPlane;
  67455. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  67456. }
  67457. if (scene.clipPlane2) {
  67458. var clipPlane = scene.clipPlane2;
  67459. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  67460. }
  67461. if (scene.clipPlane3) {
  67462. var clipPlane = scene.clipPlane3;
  67463. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  67464. }
  67465. if (scene.clipPlane4) {
  67466. var clipPlane = scene.clipPlane4;
  67467. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  67468. }
  67469. };
  67470. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  67471. return MaterialHelper;
  67472. }());
  67473. /***/ }),
  67474. /***/ "./Materials/multiMaterial.ts":
  67475. /*!************************************!*\
  67476. !*** ./Materials/multiMaterial.ts ***!
  67477. \************************************/
  67478. /*! exports provided: MultiMaterial */
  67479. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67480. "use strict";
  67481. __webpack_require__.r(__webpack_exports__);
  67482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  67483. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  67484. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  67485. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  67486. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  67487. /**
  67488. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67489. * separate meshes. This can be use to improve performances.
  67490. * @see http://doc.babylonjs.com/how_to/multi_materials
  67491. */
  67492. var MultiMaterial = /** @class */ (function (_super) {
  67493. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  67494. /**
  67495. * Instantiates a new Multi Material
  67496. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67497. * separate meshes. This can be use to improve performances.
  67498. * @see http://doc.babylonjs.com/how_to/multi_materials
  67499. * @param name Define the name in the scene
  67500. * @param scene Define the scene the material belongs to
  67501. */
  67502. function MultiMaterial(name, scene) {
  67503. var _this = _super.call(this, name, scene, true) || this;
  67504. scene.multiMaterials.push(_this);
  67505. _this.subMaterials = new Array();
  67506. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  67507. return _this;
  67508. }
  67509. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  67510. /**
  67511. * Gets or Sets the list of Materials used within the multi material.
  67512. * They need to be ordered according to the submeshes order in the associated mesh
  67513. */
  67514. get: function () {
  67515. return this._subMaterials;
  67516. },
  67517. set: function (value) {
  67518. this._subMaterials = value;
  67519. this._hookArray(value);
  67520. },
  67521. enumerable: true,
  67522. configurable: true
  67523. });
  67524. /**
  67525. * Function used to align with Node.getChildren()
  67526. * @returns the list of Materials used within the multi material
  67527. */
  67528. MultiMaterial.prototype.getChildren = function () {
  67529. return this.subMaterials;
  67530. };
  67531. MultiMaterial.prototype._hookArray = function (array) {
  67532. var _this = this;
  67533. var oldPush = array.push;
  67534. array.push = function () {
  67535. var items = [];
  67536. for (var _i = 0; _i < arguments.length; _i++) {
  67537. items[_i] = arguments[_i];
  67538. }
  67539. var result = oldPush.apply(array, items);
  67540. _this._markAllSubMeshesAsTexturesDirty();
  67541. return result;
  67542. };
  67543. var oldSplice = array.splice;
  67544. array.splice = function (index, deleteCount) {
  67545. var deleted = oldSplice.apply(array, [index, deleteCount]);
  67546. _this._markAllSubMeshesAsTexturesDirty();
  67547. return deleted;
  67548. };
  67549. };
  67550. /**
  67551. * Get one of the submaterial by its index in the submaterials array
  67552. * @param index The index to look the sub material at
  67553. * @returns The Material if the index has been defined
  67554. */
  67555. MultiMaterial.prototype.getSubMaterial = function (index) {
  67556. if (index < 0 || index >= this.subMaterials.length) {
  67557. return this.getScene().defaultMaterial;
  67558. }
  67559. return this.subMaterials[index];
  67560. };
  67561. /**
  67562. * Get the list of active textures for the whole sub materials list.
  67563. * @returns All the textures that will be used during the rendering
  67564. */
  67565. MultiMaterial.prototype.getActiveTextures = function () {
  67566. var _a;
  67567. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  67568. if (subMaterial) {
  67569. return subMaterial.getActiveTextures();
  67570. }
  67571. else {
  67572. return [];
  67573. }
  67574. }));
  67575. };
  67576. /**
  67577. * Gets the current class name of the material e.g. "MultiMaterial"
  67578. * Mainly use in serialization.
  67579. * @returns the class name
  67580. */
  67581. MultiMaterial.prototype.getClassName = function () {
  67582. return "MultiMaterial";
  67583. };
  67584. /**
  67585. * Checks if the material is ready to render the requested sub mesh
  67586. * @param mesh Define the mesh the submesh belongs to
  67587. * @param subMesh Define the sub mesh to look readyness for
  67588. * @param useInstances Define whether or not the material is used with instances
  67589. * @returns true if ready, otherwise false
  67590. */
  67591. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  67592. for (var index = 0; index < this.subMaterials.length; index++) {
  67593. var subMaterial = this.subMaterials[index];
  67594. if (subMaterial) {
  67595. if (subMaterial._storeEffectOnSubMeshes) {
  67596. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  67597. return false;
  67598. }
  67599. continue;
  67600. }
  67601. if (!subMaterial.isReady(mesh)) {
  67602. return false;
  67603. }
  67604. }
  67605. }
  67606. return true;
  67607. };
  67608. /**
  67609. * Clones the current material and its related sub materials
  67610. * @param name Define the name of the newly cloned material
  67611. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67612. * @returns the cloned material
  67613. */
  67614. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  67615. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  67616. for (var index = 0; index < this.subMaterials.length; index++) {
  67617. var subMaterial = null;
  67618. var current = this.subMaterials[index];
  67619. if (cloneChildren && current) {
  67620. subMaterial = current.clone(name + "-" + current.name);
  67621. }
  67622. else {
  67623. subMaterial = this.subMaterials[index];
  67624. }
  67625. newMultiMaterial.subMaterials.push(subMaterial);
  67626. }
  67627. return newMultiMaterial;
  67628. };
  67629. /**
  67630. * Serializes the materials into a JSON representation.
  67631. * @returns the JSON representation
  67632. */
  67633. MultiMaterial.prototype.serialize = function () {
  67634. var serializationObject = {};
  67635. serializationObject.name = this.name;
  67636. serializationObject.id = this.id;
  67637. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  67638. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  67639. }
  67640. serializationObject.materials = [];
  67641. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  67642. var subMat = this.subMaterials[matIndex];
  67643. if (subMat) {
  67644. serializationObject.materials.push(subMat.id);
  67645. }
  67646. else {
  67647. serializationObject.materials.push(null);
  67648. }
  67649. }
  67650. return serializationObject;
  67651. };
  67652. /**
  67653. * Dispose the material and release its associated resources
  67654. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  67655. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  67656. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  67657. */
  67658. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  67659. var scene = this.getScene();
  67660. if (!scene) {
  67661. return;
  67662. }
  67663. if (forceDisposeChildren) {
  67664. for (var index = 0; index < this.subMaterials.length; index++) {
  67665. var subMaterial = this.subMaterials[index];
  67666. if (subMaterial) {
  67667. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  67668. }
  67669. }
  67670. }
  67671. var index = scene.multiMaterials.indexOf(this);
  67672. if (index >= 0) {
  67673. scene.multiMaterials.splice(index, 1);
  67674. }
  67675. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  67676. };
  67677. /**
  67678. * Creates a MultiMaterial from parsed MultiMaterial data.
  67679. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67680. * @param scene defines the hosting scene
  67681. * @returns a new MultiMaterial
  67682. */
  67683. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  67684. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  67685. multiMaterial.id = parsedMultiMaterial.id;
  67686. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  67687. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  67688. }
  67689. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  67690. var subMatId = parsedMultiMaterial.materials[matIndex];
  67691. if (subMatId) {
  67692. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  67693. }
  67694. else {
  67695. multiMaterial.subMaterials.push(null);
  67696. }
  67697. }
  67698. return multiMaterial;
  67699. };
  67700. return MultiMaterial;
  67701. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  67702. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  67703. /***/ }),
  67704. /***/ "./Materials/pushMaterial.ts":
  67705. /*!***********************************!*\
  67706. !*** ./Materials/pushMaterial.ts ***!
  67707. \***********************************/
  67708. /*! exports provided: PushMaterial */
  67709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67710. "use strict";
  67711. __webpack_require__.r(__webpack_exports__);
  67712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  67713. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  67714. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  67715. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  67716. /**
  67717. * Base class of materials working in push mode in babylon JS
  67718. * @hidden
  67719. */
  67720. var PushMaterial = /** @class */ (function (_super) {
  67721. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  67722. function PushMaterial(name, scene) {
  67723. var _this = _super.call(this, name, scene) || this;
  67724. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  67725. /**
  67726. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  67727. * This means that the material can keep using a previous shader while a new one is being compiled.
  67728. * This is mostly used when shader parallel compilation is supported (true by default)
  67729. */
  67730. _this.allowShaderHotSwapping = true;
  67731. _this._storeEffectOnSubMeshes = true;
  67732. return _this;
  67733. }
  67734. PushMaterial.prototype.getEffect = function () {
  67735. return this._activeEffect;
  67736. };
  67737. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  67738. if (!mesh) {
  67739. return false;
  67740. }
  67741. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  67742. return true;
  67743. }
  67744. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  67745. };
  67746. /**
  67747. * Binds the given world matrix to the active effect
  67748. *
  67749. * @param world the matrix to bind
  67750. */
  67751. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  67752. this._activeEffect.setMatrix("world", world);
  67753. };
  67754. /**
  67755. * Binds the given normal matrix to the active effect
  67756. *
  67757. * @param normalMatrix the matrix to bind
  67758. */
  67759. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  67760. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  67761. };
  67762. PushMaterial.prototype.bind = function (world, mesh) {
  67763. if (!mesh) {
  67764. return;
  67765. }
  67766. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  67767. };
  67768. PushMaterial.prototype._afterBind = function (mesh, effect) {
  67769. if (effect === void 0) { effect = null; }
  67770. _super.prototype._afterBind.call(this, mesh);
  67771. this.getScene()._cachedEffect = effect;
  67772. };
  67773. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  67774. if (visibility === void 0) { visibility = 1; }
  67775. return scene.isCachedMaterialInvalid(this, effect, visibility);
  67776. };
  67777. return PushMaterial;
  67778. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  67779. /***/ }),
  67780. /***/ "./Materials/shaderMaterial.ts":
  67781. /*!*************************************!*\
  67782. !*** ./Materials/shaderMaterial.ts ***!
  67783. \*************************************/
  67784. /*! exports provided: ShaderMaterial */
  67785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67786. "use strict";
  67787. __webpack_require__.r(__webpack_exports__);
  67788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  67789. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  67790. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  67791. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  67792. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  67793. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  67794. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  67795. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  67796. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  67797. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  67798. /**
  67799. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  67800. *
  67801. * This returned material effects how the mesh will look based on the code in the shaders.
  67802. *
  67803. * @see http://doc.babylonjs.com/how_to/shader_material
  67804. */
  67805. var ShaderMaterial = /** @class */ (function (_super) {
  67806. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  67807. /**
  67808. * Instantiate a new shader material.
  67809. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  67810. * This returned material effects how the mesh will look based on the code in the shaders.
  67811. * @see http://doc.babylonjs.com/how_to/shader_material
  67812. * @param name Define the name of the material in the scene
  67813. * @param scene Define the scene the material belongs to
  67814. * @param shaderPath Defines the route to the shader code in one of three ways:
  67815. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  67816. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  67817. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  67818. * @param options Define the options used to create the shader
  67819. */
  67820. function ShaderMaterial(name, scene, shaderPath, options) {
  67821. if (options === void 0) { options = {}; }
  67822. var _this = _super.call(this, name, scene) || this;
  67823. _this._textures = {};
  67824. _this._textureArrays = {};
  67825. _this._floats = {};
  67826. _this._ints = {};
  67827. _this._floatsArrays = {};
  67828. _this._colors3 = {};
  67829. _this._colors3Arrays = {};
  67830. _this._colors4 = {};
  67831. _this._vectors2 = {};
  67832. _this._vectors3 = {};
  67833. _this._vectors4 = {};
  67834. _this._matrices = {};
  67835. _this._matrices3x3 = {};
  67836. _this._matrices2x2 = {};
  67837. _this._vectors2Arrays = {};
  67838. _this._vectors3Arrays = {};
  67839. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  67840. _this._shaderPath = shaderPath;
  67841. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  67842. return _this;
  67843. }
  67844. Object.defineProperty(ShaderMaterial.prototype, "options", {
  67845. /**
  67846. * Gets the options used to compile the shader.
  67847. * They can be modified to trigger a new compilation
  67848. */
  67849. get: function () {
  67850. return this._options;
  67851. },
  67852. enumerable: true,
  67853. configurable: true
  67854. });
  67855. /**
  67856. * Gets the current class name of the material e.g. "ShaderMaterial"
  67857. * Mainly use in serialization.
  67858. * @returns the class name
  67859. */
  67860. ShaderMaterial.prototype.getClassName = function () {
  67861. return "ShaderMaterial";
  67862. };
  67863. /**
  67864. * Specifies if the material will require alpha blending
  67865. * @returns a boolean specifying if alpha blending is needed
  67866. */
  67867. ShaderMaterial.prototype.needAlphaBlending = function () {
  67868. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  67869. };
  67870. /**
  67871. * Specifies if this material should be rendered in alpha test mode
  67872. * @returns a boolean specifying if an alpha test is needed.
  67873. */
  67874. ShaderMaterial.prototype.needAlphaTesting = function () {
  67875. return this._options.needAlphaTesting;
  67876. };
  67877. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  67878. if (this._options.uniforms.indexOf(uniformName) === -1) {
  67879. this._options.uniforms.push(uniformName);
  67880. }
  67881. };
  67882. /**
  67883. * Set a texture in the shader.
  67884. * @param name Define the name of the uniform samplers as defined in the shader
  67885. * @param texture Define the texture to bind to this sampler
  67886. * @return the material itself allowing "fluent" like uniform updates
  67887. */
  67888. ShaderMaterial.prototype.setTexture = function (name, texture) {
  67889. if (this._options.samplers.indexOf(name) === -1) {
  67890. this._options.samplers.push(name);
  67891. }
  67892. this._textures[name] = texture;
  67893. return this;
  67894. };
  67895. /**
  67896. * Set a texture array in the shader.
  67897. * @param name Define the name of the uniform sampler array as defined in the shader
  67898. * @param textures Define the list of textures to bind to this sampler
  67899. * @return the material itself allowing "fluent" like uniform updates
  67900. */
  67901. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  67902. if (this._options.samplers.indexOf(name) === -1) {
  67903. this._options.samplers.push(name);
  67904. }
  67905. this._checkUniform(name);
  67906. this._textureArrays[name] = textures;
  67907. return this;
  67908. };
  67909. /**
  67910. * Set a float in the shader.
  67911. * @param name Define the name of the uniform as defined in the shader
  67912. * @param value Define the value to give to the uniform
  67913. * @return the material itself allowing "fluent" like uniform updates
  67914. */
  67915. ShaderMaterial.prototype.setFloat = function (name, value) {
  67916. this._checkUniform(name);
  67917. this._floats[name] = value;
  67918. return this;
  67919. };
  67920. /**
  67921. * Set a int in the shader.
  67922. * @param name Define the name of the uniform as defined in the shader
  67923. * @param value Define the value to give to the uniform
  67924. * @return the material itself allowing "fluent" like uniform updates
  67925. */
  67926. ShaderMaterial.prototype.setInt = function (name, value) {
  67927. this._checkUniform(name);
  67928. this._ints[name] = value;
  67929. return this;
  67930. };
  67931. /**
  67932. * Set an array of floats in the shader.
  67933. * @param name Define the name of the uniform as defined in the shader
  67934. * @param value Define the value to give to the uniform
  67935. * @return the material itself allowing "fluent" like uniform updates
  67936. */
  67937. ShaderMaterial.prototype.setFloats = function (name, value) {
  67938. this._checkUniform(name);
  67939. this._floatsArrays[name] = value;
  67940. return this;
  67941. };
  67942. /**
  67943. * Set a vec3 in the shader from a Color3.
  67944. * @param name Define the name of the uniform as defined in the shader
  67945. * @param value Define the value to give to the uniform
  67946. * @return the material itself allowing "fluent" like uniform updates
  67947. */
  67948. ShaderMaterial.prototype.setColor3 = function (name, value) {
  67949. this._checkUniform(name);
  67950. this._colors3[name] = value;
  67951. return this;
  67952. };
  67953. /**
  67954. * Set a vec3 array in the shader from a Color3 array.
  67955. * @param name Define the name of the uniform as defined in the shader
  67956. * @param value Define the value to give to the uniform
  67957. * @return the material itself allowing "fluent" like uniform updates
  67958. */
  67959. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  67960. this._checkUniform(name);
  67961. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  67962. color.toArray(arr, arr.length);
  67963. return arr;
  67964. }, []);
  67965. return this;
  67966. };
  67967. /**
  67968. * Set a vec4 in the shader from a Color4.
  67969. * @param name Define the name of the uniform as defined in the shader
  67970. * @param value Define the value to give to the uniform
  67971. * @return the material itself allowing "fluent" like uniform updates
  67972. */
  67973. ShaderMaterial.prototype.setColor4 = function (name, value) {
  67974. this._checkUniform(name);
  67975. this._colors4[name] = value;
  67976. return this;
  67977. };
  67978. /**
  67979. * Set a vec2 in the shader from a Vector2.
  67980. * @param name Define the name of the uniform as defined in the shader
  67981. * @param value Define the value to give to the uniform
  67982. * @return the material itself allowing "fluent" like uniform updates
  67983. */
  67984. ShaderMaterial.prototype.setVector2 = function (name, value) {
  67985. this._checkUniform(name);
  67986. this._vectors2[name] = value;
  67987. return this;
  67988. };
  67989. /**
  67990. * Set a vec3 in the shader from a Vector3.
  67991. * @param name Define the name of the uniform as defined in the shader
  67992. * @param value Define the value to give to the uniform
  67993. * @return the material itself allowing "fluent" like uniform updates
  67994. */
  67995. ShaderMaterial.prototype.setVector3 = function (name, value) {
  67996. this._checkUniform(name);
  67997. this._vectors3[name] = value;
  67998. return this;
  67999. };
  68000. /**
  68001. * Set a vec4 in the shader from a Vector4.
  68002. * @param name Define the name of the uniform as defined in the shader
  68003. * @param value Define the value to give to the uniform
  68004. * @return the material itself allowing "fluent" like uniform updates
  68005. */
  68006. ShaderMaterial.prototype.setVector4 = function (name, value) {
  68007. this._checkUniform(name);
  68008. this._vectors4[name] = value;
  68009. return this;
  68010. };
  68011. /**
  68012. * Set a mat4 in the shader from a Matrix.
  68013. * @param name Define the name of the uniform as defined in the shader
  68014. * @param value Define the value to give to the uniform
  68015. * @return the material itself allowing "fluent" like uniform updates
  68016. */
  68017. ShaderMaterial.prototype.setMatrix = function (name, value) {
  68018. this._checkUniform(name);
  68019. this._matrices[name] = value;
  68020. return this;
  68021. };
  68022. /**
  68023. * Set a mat3 in the shader from a Float32Array.
  68024. * @param name Define the name of the uniform as defined in the shader
  68025. * @param value Define the value to give to the uniform
  68026. * @return the material itself allowing "fluent" like uniform updates
  68027. */
  68028. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  68029. this._checkUniform(name);
  68030. this._matrices3x3[name] = value;
  68031. return this;
  68032. };
  68033. /**
  68034. * Set a mat2 in the shader from a Float32Array.
  68035. * @param name Define the name of the uniform as defined in the shader
  68036. * @param value Define the value to give to the uniform
  68037. * @return the material itself allowing "fluent" like uniform updates
  68038. */
  68039. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  68040. this._checkUniform(name);
  68041. this._matrices2x2[name] = value;
  68042. return this;
  68043. };
  68044. /**
  68045. * Set a vec2 array in the shader from a number array.
  68046. * @param name Define the name of the uniform as defined in the shader
  68047. * @param value Define the value to give to the uniform
  68048. * @return the material itself allowing "fluent" like uniform updates
  68049. */
  68050. ShaderMaterial.prototype.setArray2 = function (name, value) {
  68051. this._checkUniform(name);
  68052. this._vectors2Arrays[name] = value;
  68053. return this;
  68054. };
  68055. /**
  68056. * Set a vec3 array in the shader from a number array.
  68057. * @param name Define the name of the uniform as defined in the shader
  68058. * @param value Define the value to give to the uniform
  68059. * @return the material itself allowing "fluent" like uniform updates
  68060. */
  68061. ShaderMaterial.prototype.setArray3 = function (name, value) {
  68062. this._checkUniform(name);
  68063. this._vectors3Arrays[name] = value;
  68064. return this;
  68065. };
  68066. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  68067. if (!mesh) {
  68068. return true;
  68069. }
  68070. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  68071. return false;
  68072. }
  68073. return false;
  68074. };
  68075. /**
  68076. * Specifies that the submesh is ready to be used
  68077. * @param mesh defines the mesh to check
  68078. * @param subMesh defines which submesh to check
  68079. * @param useInstances specifies that instances should be used
  68080. * @returns a boolean indicating that the submesh is ready or not
  68081. */
  68082. ShaderMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  68083. return this.isReady(mesh, useInstances);
  68084. };
  68085. /**
  68086. * Checks if the material is ready to render the requested mesh
  68087. * @param mesh Define the mesh to render
  68088. * @param useInstances Define whether or not the material is used with instances
  68089. * @returns true if ready, otherwise false
  68090. */
  68091. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  68092. var scene = this.getScene();
  68093. var engine = scene.getEngine();
  68094. if (!this.checkReadyOnEveryCall) {
  68095. if (this._renderId === scene.getRenderId()) {
  68096. if (this._checkCache(mesh, useInstances)) {
  68097. return true;
  68098. }
  68099. }
  68100. }
  68101. // Instances
  68102. var defines = [];
  68103. var attribs = [];
  68104. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  68105. for (var index = 0; index < this._options.defines.length; index++) {
  68106. defines.push(this._options.defines[index]);
  68107. }
  68108. for (var index = 0; index < this._options.attributes.length; index++) {
  68109. attribs.push(this._options.attributes[index]);
  68110. }
  68111. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  68112. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  68113. defines.push("#define VERTEXCOLOR");
  68114. }
  68115. if (useInstances) {
  68116. defines.push("#define INSTANCES");
  68117. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  68118. }
  68119. // Bones
  68120. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  68121. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  68122. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  68123. if (mesh.numBoneInfluencers > 4) {
  68124. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  68125. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  68126. }
  68127. var skeleton = mesh.skeleton;
  68128. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  68129. fallbacks.addCPUSkinningFallback(0, mesh);
  68130. if (skeleton.isUsingTextureForMatrices) {
  68131. defines.push("#define BONETEXTURE");
  68132. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  68133. this._options.uniforms.push("boneTextureWidth");
  68134. }
  68135. if (this._options.samplers.indexOf("boneSampler") === -1) {
  68136. this._options.samplers.push("boneSampler");
  68137. }
  68138. }
  68139. else {
  68140. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  68141. if (this._options.uniforms.indexOf("mBones") === -1) {
  68142. this._options.uniforms.push("mBones");
  68143. }
  68144. }
  68145. }
  68146. else {
  68147. defines.push("#define NUM_BONE_INFLUENCERS 0");
  68148. }
  68149. // Textures
  68150. for (var name in this._textures) {
  68151. if (!this._textures[name].isReady()) {
  68152. return false;
  68153. }
  68154. }
  68155. // Alpha test
  68156. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  68157. defines.push("#define ALPHATEST");
  68158. }
  68159. var previousEffect = this._effect;
  68160. var join = defines.join("\n");
  68161. this._effect = engine.createEffect(this._shaderPath, {
  68162. attributes: attribs,
  68163. uniformsNames: this._options.uniforms,
  68164. uniformBuffersNames: this._options.uniformBuffers,
  68165. samplers: this._options.samplers,
  68166. defines: join,
  68167. fallbacks: fallbacks,
  68168. onCompiled: this.onCompiled,
  68169. onError: this.onError
  68170. }, engine);
  68171. if (!this._effect.isReady()) {
  68172. return false;
  68173. }
  68174. if (previousEffect !== this._effect) {
  68175. scene.resetCachedMaterial();
  68176. }
  68177. this._renderId = scene.getRenderId();
  68178. return true;
  68179. };
  68180. /**
  68181. * Binds the world matrix to the material
  68182. * @param world defines the world transformation matrix
  68183. */
  68184. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  68185. var scene = this.getScene();
  68186. if (!this._effect) {
  68187. return;
  68188. }
  68189. if (this._options.uniforms.indexOf("world") !== -1) {
  68190. this._effect.setMatrix("world", world);
  68191. }
  68192. if (this._options.uniforms.indexOf("worldView") !== -1) {
  68193. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  68194. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  68195. }
  68196. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  68197. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  68198. }
  68199. };
  68200. /**
  68201. * Binds the material to the mesh
  68202. * @param world defines the world transformation matrix
  68203. * @param mesh defines the mesh to bind the material to
  68204. */
  68205. ShaderMaterial.prototype.bind = function (world, mesh) {
  68206. // Std values
  68207. this.bindOnlyWorldMatrix(world);
  68208. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  68209. if (this._options.uniforms.indexOf("view") !== -1) {
  68210. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  68211. }
  68212. if (this._options.uniforms.indexOf("projection") !== -1) {
  68213. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  68214. }
  68215. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  68216. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  68217. }
  68218. // Bones
  68219. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  68220. var name;
  68221. // Texture
  68222. for (name in this._textures) {
  68223. this._effect.setTexture(name, this._textures[name]);
  68224. }
  68225. // Texture arrays
  68226. for (name in this._textureArrays) {
  68227. this._effect.setTextureArray(name, this._textureArrays[name]);
  68228. }
  68229. // Int
  68230. for (name in this._ints) {
  68231. this._effect.setInt(name, this._ints[name]);
  68232. }
  68233. // Float
  68234. for (name in this._floats) {
  68235. this._effect.setFloat(name, this._floats[name]);
  68236. }
  68237. // Floats
  68238. for (name in this._floatsArrays) {
  68239. this._effect.setArray(name, this._floatsArrays[name]);
  68240. }
  68241. // Color3
  68242. for (name in this._colors3) {
  68243. this._effect.setColor3(name, this._colors3[name]);
  68244. }
  68245. for (name in this._colors3Arrays) {
  68246. this._effect.setArray3(name, this._colors3Arrays[name]);
  68247. }
  68248. // Color4
  68249. for (name in this._colors4) {
  68250. var color = this._colors4[name];
  68251. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  68252. }
  68253. // Vector2
  68254. for (name in this._vectors2) {
  68255. this._effect.setVector2(name, this._vectors2[name]);
  68256. }
  68257. // Vector3
  68258. for (name in this._vectors3) {
  68259. this._effect.setVector3(name, this._vectors3[name]);
  68260. }
  68261. // Vector4
  68262. for (name in this._vectors4) {
  68263. this._effect.setVector4(name, this._vectors4[name]);
  68264. }
  68265. // Matrix
  68266. for (name in this._matrices) {
  68267. this._effect.setMatrix(name, this._matrices[name]);
  68268. }
  68269. // Matrix 3x3
  68270. for (name in this._matrices3x3) {
  68271. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  68272. }
  68273. // Matrix 2x2
  68274. for (name in this._matrices2x2) {
  68275. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  68276. }
  68277. // Vector2Array
  68278. for (name in this._vectors2Arrays) {
  68279. this._effect.setArray2(name, this._vectors2Arrays[name]);
  68280. }
  68281. // Vector3Array
  68282. for (name in this._vectors3Arrays) {
  68283. this._effect.setArray3(name, this._vectors3Arrays[name]);
  68284. }
  68285. }
  68286. this._afterBind(mesh);
  68287. };
  68288. /**
  68289. * Gets the active textures from the material
  68290. * @returns an array of textures
  68291. */
  68292. ShaderMaterial.prototype.getActiveTextures = function () {
  68293. var activeTextures = _super.prototype.getActiveTextures.call(this);
  68294. for (var name in this._textures) {
  68295. activeTextures.push(this._textures[name]);
  68296. }
  68297. for (var name in this._textureArrays) {
  68298. var array = this._textureArrays[name];
  68299. for (var index = 0; index < array.length; index++) {
  68300. activeTextures.push(array[index]);
  68301. }
  68302. }
  68303. return activeTextures;
  68304. };
  68305. /**
  68306. * Specifies if the material uses a texture
  68307. * @param texture defines the texture to check against the material
  68308. * @returns a boolean specifying if the material uses the texture
  68309. */
  68310. ShaderMaterial.prototype.hasTexture = function (texture) {
  68311. if (_super.prototype.hasTexture.call(this, texture)) {
  68312. return true;
  68313. }
  68314. for (var name in this._textures) {
  68315. if (this._textures[name] === texture) {
  68316. return true;
  68317. }
  68318. }
  68319. for (var name in this._textureArrays) {
  68320. var array = this._textureArrays[name];
  68321. for (var index = 0; index < array.length; index++) {
  68322. if (array[index] === texture) {
  68323. return true;
  68324. }
  68325. }
  68326. }
  68327. return false;
  68328. };
  68329. /**
  68330. * Makes a duplicate of the material, and gives it a new name
  68331. * @param name defines the new name for the duplicated material
  68332. * @returns the cloned material
  68333. */
  68334. ShaderMaterial.prototype.clone = function (name) {
  68335. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  68336. return newShaderMaterial;
  68337. };
  68338. /**
  68339. * Disposes the material
  68340. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  68341. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  68342. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  68343. */
  68344. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  68345. if (forceDisposeTextures) {
  68346. var name;
  68347. for (name in this._textures) {
  68348. this._textures[name].dispose();
  68349. }
  68350. for (name in this._textureArrays) {
  68351. var array = this._textureArrays[name];
  68352. for (var index = 0; index < array.length; index++) {
  68353. array[index].dispose();
  68354. }
  68355. }
  68356. }
  68357. this._textures = {};
  68358. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  68359. };
  68360. /**
  68361. * Serializes this material in a JSON representation
  68362. * @returns the serialized material object
  68363. */
  68364. ShaderMaterial.prototype.serialize = function () {
  68365. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  68366. serializationObject.customType = "ShaderMaterial";
  68367. serializationObject.options = this._options;
  68368. serializationObject.shaderPath = this._shaderPath;
  68369. var name;
  68370. // Texture
  68371. serializationObject.textures = {};
  68372. for (name in this._textures) {
  68373. serializationObject.textures[name] = this._textures[name].serialize();
  68374. }
  68375. // Texture arrays
  68376. serializationObject.textureArrays = {};
  68377. for (name in this._textureArrays) {
  68378. serializationObject.textureArrays[name] = [];
  68379. var array = this._textureArrays[name];
  68380. for (var index = 0; index < array.length; index++) {
  68381. serializationObject.textureArrays[name].push(array[index].serialize());
  68382. }
  68383. }
  68384. // Float
  68385. serializationObject.floats = {};
  68386. for (name in this._floats) {
  68387. serializationObject.floats[name] = this._floats[name];
  68388. }
  68389. // Float s
  68390. serializationObject.FloatArrays = {};
  68391. for (name in this._floatsArrays) {
  68392. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  68393. }
  68394. // Color3
  68395. serializationObject.colors3 = {};
  68396. for (name in this._colors3) {
  68397. serializationObject.colors3[name] = this._colors3[name].asArray();
  68398. }
  68399. // Color3 array
  68400. serializationObject.colors3Arrays = {};
  68401. for (name in this._colors3Arrays) {
  68402. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  68403. }
  68404. // Color4
  68405. serializationObject.colors4 = {};
  68406. for (name in this._colors4) {
  68407. serializationObject.colors4[name] = this._colors4[name].asArray();
  68408. }
  68409. // Vector2
  68410. serializationObject.vectors2 = {};
  68411. for (name in this._vectors2) {
  68412. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  68413. }
  68414. // Vector3
  68415. serializationObject.vectors3 = {};
  68416. for (name in this._vectors3) {
  68417. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  68418. }
  68419. // Vector4
  68420. serializationObject.vectors4 = {};
  68421. for (name in this._vectors4) {
  68422. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  68423. }
  68424. // Matrix
  68425. serializationObject.matrices = {};
  68426. for (name in this._matrices) {
  68427. serializationObject.matrices[name] = this._matrices[name].asArray();
  68428. }
  68429. // Matrix 3x3
  68430. serializationObject.matrices3x3 = {};
  68431. for (name in this._matrices3x3) {
  68432. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  68433. }
  68434. // Matrix 2x2
  68435. serializationObject.matrices2x2 = {};
  68436. for (name in this._matrices2x2) {
  68437. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  68438. }
  68439. // Vector2Array
  68440. serializationObject.vectors2Arrays = {};
  68441. for (name in this._vectors2Arrays) {
  68442. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  68443. }
  68444. // Vector3Array
  68445. serializationObject.vectors3Arrays = {};
  68446. for (name in this._vectors3Arrays) {
  68447. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  68448. }
  68449. return serializationObject;
  68450. };
  68451. /**
  68452. * Creates a shader material from parsed shader material data
  68453. * @param source defines the JSON represnetation of the material
  68454. * @param scene defines the hosting scene
  68455. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68456. * @returns a new material
  68457. */
  68458. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  68459. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  68460. var name;
  68461. // Texture
  68462. for (name in source.textures) {
  68463. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  68464. }
  68465. // Texture arrays
  68466. for (name in source.textureArrays) {
  68467. var array = source.textureArrays[name];
  68468. var textureArray = new Array();
  68469. for (var index = 0; index < array.length; index++) {
  68470. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  68471. }
  68472. material.setTextureArray(name, textureArray);
  68473. }
  68474. // Float
  68475. for (name in source.floats) {
  68476. material.setFloat(name, source.floats[name]);
  68477. }
  68478. // Float s
  68479. for (name in source.floatsArrays) {
  68480. material.setFloats(name, source.floatsArrays[name]);
  68481. }
  68482. // Color3
  68483. for (name in source.colors3) {
  68484. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  68485. }
  68486. // Color3 arrays
  68487. for (name in source.colors3Arrays) {
  68488. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  68489. if (i % 3 === 0) {
  68490. arr.push([num]);
  68491. }
  68492. else {
  68493. arr[arr.length - 1].push(num);
  68494. }
  68495. return arr;
  68496. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  68497. material.setColor3Array(name, colors);
  68498. }
  68499. // Color4
  68500. for (name in source.colors4) {
  68501. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  68502. }
  68503. // Vector2
  68504. for (name in source.vectors2) {
  68505. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  68506. }
  68507. // Vector3
  68508. for (name in source.vectors3) {
  68509. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  68510. }
  68511. // Vector4
  68512. for (name in source.vectors4) {
  68513. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  68514. }
  68515. // Matrix
  68516. for (name in source.matrices) {
  68517. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  68518. }
  68519. // Matrix 3x3
  68520. for (name in source.matrices3x3) {
  68521. material.setMatrix3x3(name, source.matrices3x3[name]);
  68522. }
  68523. // Matrix 2x2
  68524. for (name in source.matrices2x2) {
  68525. material.setMatrix2x2(name, source.matrices2x2[name]);
  68526. }
  68527. // Vector2Array
  68528. for (name in source.vectors2Arrays) {
  68529. material.setArray2(name, source.vectors2Arrays[name]);
  68530. }
  68531. // Vector3Array
  68532. for (name in source.vectors3Arrays) {
  68533. material.setArray3(name, source.vectors3Arrays[name]);
  68534. }
  68535. return material;
  68536. };
  68537. return ShaderMaterial;
  68538. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  68539. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  68540. /***/ }),
  68541. /***/ "./Materials/standardMaterial.ts":
  68542. /*!***************************************!*\
  68543. !*** ./Materials/standardMaterial.ts ***!
  68544. \***************************************/
  68545. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  68546. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  68547. "use strict";
  68548. __webpack_require__.r(__webpack_exports__);
  68549. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  68550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  68551. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  68552. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  68553. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  68554. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  68555. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  68556. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  68557. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  68558. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  68559. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  68560. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  68561. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  68562. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  68563. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  68564. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  68565. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  68566. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  68567. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  68568. /** @hidden */
  68569. var StandardMaterialDefines = /** @class */ (function (_super) {
  68570. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  68571. function StandardMaterialDefines() {
  68572. var _this = _super.call(this) || this;
  68573. _this.MAINUV1 = false;
  68574. _this.MAINUV2 = false;
  68575. _this.DIFFUSE = false;
  68576. _this.DIFFUSEDIRECTUV = 0;
  68577. _this.AMBIENT = false;
  68578. _this.AMBIENTDIRECTUV = 0;
  68579. _this.OPACITY = false;
  68580. _this.OPACITYDIRECTUV = 0;
  68581. _this.OPACITYRGB = false;
  68582. _this.REFLECTION = false;
  68583. _this.EMISSIVE = false;
  68584. _this.EMISSIVEDIRECTUV = 0;
  68585. _this.SPECULAR = false;
  68586. _this.SPECULARDIRECTUV = 0;
  68587. _this.BUMP = false;
  68588. _this.BUMPDIRECTUV = 0;
  68589. _this.PARALLAX = false;
  68590. _this.PARALLAXOCCLUSION = false;
  68591. _this.SPECULAROVERALPHA = false;
  68592. _this.CLIPPLANE = false;
  68593. _this.CLIPPLANE2 = false;
  68594. _this.CLIPPLANE3 = false;
  68595. _this.CLIPPLANE4 = false;
  68596. _this.ALPHATEST = false;
  68597. _this.DEPTHPREPASS = false;
  68598. _this.ALPHAFROMDIFFUSE = false;
  68599. _this.POINTSIZE = false;
  68600. _this.FOG = false;
  68601. _this.SPECULARTERM = false;
  68602. _this.DIFFUSEFRESNEL = false;
  68603. _this.OPACITYFRESNEL = false;
  68604. _this.REFLECTIONFRESNEL = false;
  68605. _this.REFRACTIONFRESNEL = false;
  68606. _this.EMISSIVEFRESNEL = false;
  68607. _this.FRESNEL = false;
  68608. _this.NORMAL = false;
  68609. _this.UV1 = false;
  68610. _this.UV2 = false;
  68611. _this.VERTEXCOLOR = false;
  68612. _this.VERTEXALPHA = false;
  68613. _this.NUM_BONE_INFLUENCERS = 0;
  68614. _this.BonesPerMesh = 0;
  68615. _this.BONETEXTURE = false;
  68616. _this.INSTANCES = false;
  68617. _this.GLOSSINESS = false;
  68618. _this.ROUGHNESS = false;
  68619. _this.EMISSIVEASILLUMINATION = false;
  68620. _this.LINKEMISSIVEWITHDIFFUSE = false;
  68621. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  68622. _this.LIGHTMAP = false;
  68623. _this.LIGHTMAPDIRECTUV = 0;
  68624. _this.OBJECTSPACE_NORMALMAP = false;
  68625. _this.USELIGHTMAPASSHADOWMAP = false;
  68626. _this.REFLECTIONMAP_3D = false;
  68627. _this.REFLECTIONMAP_SPHERICAL = false;
  68628. _this.REFLECTIONMAP_PLANAR = false;
  68629. _this.REFLECTIONMAP_CUBIC = false;
  68630. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  68631. _this.REFLECTIONMAP_PROJECTION = false;
  68632. _this.REFLECTIONMAP_SKYBOX = false;
  68633. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  68634. _this.REFLECTIONMAP_EXPLICIT = false;
  68635. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  68636. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  68637. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  68638. _this.INVERTCUBICMAP = false;
  68639. _this.LOGARITHMICDEPTH = false;
  68640. _this.REFRACTION = false;
  68641. _this.REFRACTIONMAP_3D = false;
  68642. _this.REFLECTIONOVERALPHA = false;
  68643. _this.TWOSIDEDLIGHTING = false;
  68644. _this.SHADOWFLOAT = false;
  68645. _this.MORPHTARGETS = false;
  68646. _this.MORPHTARGETS_NORMAL = false;
  68647. _this.MORPHTARGETS_TANGENT = false;
  68648. _this.NUM_MORPH_INFLUENCERS = 0;
  68649. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  68650. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  68651. _this.IMAGEPROCESSING = false;
  68652. _this.VIGNETTE = false;
  68653. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  68654. _this.VIGNETTEBLENDMODEOPAQUE = false;
  68655. _this.TONEMAPPING = false;
  68656. _this.TONEMAPPING_ACES = false;
  68657. _this.CONTRAST = false;
  68658. _this.COLORCURVES = false;
  68659. _this.COLORGRADING = false;
  68660. _this.COLORGRADING3D = false;
  68661. _this.SAMPLER3DGREENDEPTH = false;
  68662. _this.SAMPLER3DBGRMAP = false;
  68663. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  68664. _this.MULTIVIEW = false;
  68665. /**
  68666. * If the reflection texture on this material is in linear color space
  68667. * @hidden
  68668. */
  68669. _this.IS_REFLECTION_LINEAR = false;
  68670. /**
  68671. * If the refraction texture on this material is in linear color space
  68672. * @hidden
  68673. */
  68674. _this.IS_REFRACTION_LINEAR = false;
  68675. _this.EXPOSURE = false;
  68676. _this.rebuild();
  68677. return _this;
  68678. }
  68679. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  68680. var modes = [
  68681. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  68682. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  68683. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  68684. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  68685. ];
  68686. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  68687. var mode = modes_1[_i];
  68688. this[mode] = (mode === modeToEnable);
  68689. }
  68690. };
  68691. return StandardMaterialDefines;
  68692. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  68693. /**
  68694. * This is the default material used in Babylon. It is the best trade off between quality
  68695. * and performances.
  68696. * @see http://doc.babylonjs.com/babylon101/materials
  68697. */
  68698. var StandardMaterial = /** @class */ (function (_super) {
  68699. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  68700. /**
  68701. * Instantiates a new standard material.
  68702. * This is the default material used in Babylon. It is the best trade off between quality
  68703. * and performances.
  68704. * @see http://doc.babylonjs.com/babylon101/materials
  68705. * @param name Define the name of the material in the scene
  68706. * @param scene Define the scene the material belong to
  68707. */
  68708. function StandardMaterial(name, scene) {
  68709. var _this = _super.call(this, name, scene) || this;
  68710. /**
  68711. * The color of the material lit by the environmental background lighting.
  68712. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  68713. */
  68714. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  68715. /**
  68716. * The basic color of the material as viewed under a light.
  68717. */
  68718. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  68719. /**
  68720. * Define how the color and intensity of the highlight given by the light in the material.
  68721. */
  68722. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  68723. /**
  68724. * Define the color of the material as if self lit.
  68725. * This will be mixed in the final result even in the absence of light.
  68726. */
  68727. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  68728. /**
  68729. * Defines how sharp are the highlights in the material.
  68730. * The bigger the value the sharper giving a more glossy feeling to the result.
  68731. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  68732. */
  68733. _this.specularPower = 64;
  68734. _this._useAlphaFromDiffuseTexture = false;
  68735. _this._useEmissiveAsIllumination = false;
  68736. _this._linkEmissiveWithDiffuse = false;
  68737. _this._useSpecularOverAlpha = false;
  68738. _this._useReflectionOverAlpha = false;
  68739. _this._disableLighting = false;
  68740. _this._useObjectSpaceNormalMap = false;
  68741. _this._useParallax = false;
  68742. _this._useParallaxOcclusion = false;
  68743. /**
  68744. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  68745. */
  68746. _this.parallaxScaleBias = 0.05;
  68747. _this._roughness = 0;
  68748. /**
  68749. * In case of refraction, define the value of the indice of refraction.
  68750. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  68751. */
  68752. _this.indexOfRefraction = 0.98;
  68753. /**
  68754. * Invert the refraction texture alongside the y axis.
  68755. * It can be useful with procedural textures or probe for instance.
  68756. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  68757. */
  68758. _this.invertRefractionY = true;
  68759. /**
  68760. * Defines the alpha limits in alpha test mode.
  68761. */
  68762. _this.alphaCutOff = 0.4;
  68763. _this._useLightmapAsShadowmap = false;
  68764. _this._useReflectionFresnelFromSpecular = false;
  68765. _this._useGlossinessFromSpecularMapAlpha = false;
  68766. _this._maxSimultaneousLights = 4;
  68767. _this._invertNormalMapX = false;
  68768. _this._invertNormalMapY = false;
  68769. _this._twoSidedLighting = false;
  68770. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  68771. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  68772. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  68773. // Setup the default processing configuration to the scene.
  68774. _this._attachImageProcessingConfiguration(null);
  68775. _this.getRenderTargetTextures = function () {
  68776. _this._renderTargets.reset();
  68777. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  68778. _this._renderTargets.push(_this._reflectionTexture);
  68779. }
  68780. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  68781. _this._renderTargets.push(_this._refractionTexture);
  68782. }
  68783. return _this._renderTargets;
  68784. };
  68785. return _this;
  68786. }
  68787. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  68788. /**
  68789. * Gets the image processing configuration used either in this material.
  68790. */
  68791. get: function () {
  68792. return this._imageProcessingConfiguration;
  68793. },
  68794. /**
  68795. * Sets the Default image processing configuration used either in the this material.
  68796. *
  68797. * If sets to null, the scene one is in use.
  68798. */
  68799. set: function (value) {
  68800. this._attachImageProcessingConfiguration(value);
  68801. // Ensure the effect will be rebuilt.
  68802. this._markAllSubMeshesAsTexturesDirty();
  68803. },
  68804. enumerable: true,
  68805. configurable: true
  68806. });
  68807. /**
  68808. * Attaches a new image processing configuration to the Standard Material.
  68809. * @param configuration
  68810. */
  68811. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  68812. var _this = this;
  68813. if (configuration === this._imageProcessingConfiguration) {
  68814. return;
  68815. }
  68816. // Detaches observer.
  68817. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  68818. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  68819. }
  68820. // Pick the scene configuration if needed.
  68821. if (!configuration) {
  68822. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  68823. }
  68824. else {
  68825. this._imageProcessingConfiguration = configuration;
  68826. }
  68827. // Attaches observer.
  68828. if (this._imageProcessingConfiguration) {
  68829. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  68830. _this._markAllSubMeshesAsImageProcessingDirty();
  68831. });
  68832. }
  68833. };
  68834. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  68835. /**
  68836. * Gets wether the color curves effect is enabled.
  68837. */
  68838. get: function () {
  68839. return this.imageProcessingConfiguration.colorCurvesEnabled;
  68840. },
  68841. /**
  68842. * Sets wether the color curves effect is enabled.
  68843. */
  68844. set: function (value) {
  68845. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  68846. },
  68847. enumerable: true,
  68848. configurable: true
  68849. });
  68850. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  68851. /**
  68852. * Gets wether the color grading effect is enabled.
  68853. */
  68854. get: function () {
  68855. return this.imageProcessingConfiguration.colorGradingEnabled;
  68856. },
  68857. /**
  68858. * Gets wether the color grading effect is enabled.
  68859. */
  68860. set: function (value) {
  68861. this.imageProcessingConfiguration.colorGradingEnabled = value;
  68862. },
  68863. enumerable: true,
  68864. configurable: true
  68865. });
  68866. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  68867. /**
  68868. * Gets wether tonemapping is enabled or not.
  68869. */
  68870. get: function () {
  68871. return this._imageProcessingConfiguration.toneMappingEnabled;
  68872. },
  68873. /**
  68874. * Sets wether tonemapping is enabled or not
  68875. */
  68876. set: function (value) {
  68877. this._imageProcessingConfiguration.toneMappingEnabled = value;
  68878. },
  68879. enumerable: true,
  68880. configurable: true
  68881. });
  68882. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  68883. /**
  68884. * The camera exposure used on this material.
  68885. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  68886. * This corresponds to a photographic exposure.
  68887. */
  68888. get: function () {
  68889. return this._imageProcessingConfiguration.exposure;
  68890. },
  68891. /**
  68892. * The camera exposure used on this material.
  68893. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  68894. * This corresponds to a photographic exposure.
  68895. */
  68896. set: function (value) {
  68897. this._imageProcessingConfiguration.exposure = value;
  68898. },
  68899. enumerable: true,
  68900. configurable: true
  68901. });
  68902. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  68903. /**
  68904. * Gets The camera contrast used on this material.
  68905. */
  68906. get: function () {
  68907. return this._imageProcessingConfiguration.contrast;
  68908. },
  68909. /**
  68910. * Sets The camera contrast used on this material.
  68911. */
  68912. set: function (value) {
  68913. this._imageProcessingConfiguration.contrast = value;
  68914. },
  68915. enumerable: true,
  68916. configurable: true
  68917. });
  68918. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  68919. /**
  68920. * Gets the Color Grading 2D Lookup Texture.
  68921. */
  68922. get: function () {
  68923. return this._imageProcessingConfiguration.colorGradingTexture;
  68924. },
  68925. /**
  68926. * Sets the Color Grading 2D Lookup Texture.
  68927. */
  68928. set: function (value) {
  68929. this._imageProcessingConfiguration.colorGradingTexture = value;
  68930. },
  68931. enumerable: true,
  68932. configurable: true
  68933. });
  68934. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  68935. /**
  68936. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  68937. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  68938. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  68939. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  68940. */
  68941. get: function () {
  68942. return this._imageProcessingConfiguration.colorCurves;
  68943. },
  68944. /**
  68945. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  68946. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  68947. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  68948. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  68949. */
  68950. set: function (value) {
  68951. this._imageProcessingConfiguration.colorCurves = value;
  68952. },
  68953. enumerable: true,
  68954. configurable: true
  68955. });
  68956. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  68957. /**
  68958. * Gets a boolean indicating that current material needs to register RTT
  68959. */
  68960. get: function () {
  68961. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  68962. return true;
  68963. }
  68964. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  68965. return true;
  68966. }
  68967. return false;
  68968. },
  68969. enumerable: true,
  68970. configurable: true
  68971. });
  68972. /**
  68973. * Gets the current class name of the material e.g. "StandardMaterial"
  68974. * Mainly use in serialization.
  68975. * @returns the class name
  68976. */
  68977. StandardMaterial.prototype.getClassName = function () {
  68978. return "StandardMaterial";
  68979. };
  68980. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  68981. /**
  68982. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  68983. * You can try switching to logarithmic depth.
  68984. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  68985. */
  68986. get: function () {
  68987. return this._useLogarithmicDepth;
  68988. },
  68989. set: function (value) {
  68990. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  68991. this._markAllSubMeshesAsMiscDirty();
  68992. },
  68993. enumerable: true,
  68994. configurable: true
  68995. });
  68996. /**
  68997. * Specifies if the material will require alpha blending
  68998. * @returns a boolean specifying if alpha blending is needed
  68999. */
  69000. StandardMaterial.prototype.needAlphaBlending = function () {
  69001. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  69002. };
  69003. /**
  69004. * Specifies if this material should be rendered in alpha test mode
  69005. * @returns a boolean specifying if an alpha test is needed.
  69006. */
  69007. StandardMaterial.prototype.needAlphaTesting = function () {
  69008. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  69009. };
  69010. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  69011. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  69012. };
  69013. /**
  69014. * Get the texture used for alpha test purpose.
  69015. * @returns the diffuse texture in case of the standard material.
  69016. */
  69017. StandardMaterial.prototype.getAlphaTestTexture = function () {
  69018. return this._diffuseTexture;
  69019. };
  69020. /**
  69021. * Get if the submesh is ready to be used and all its information available.
  69022. * Child classes can use it to update shaders
  69023. * @param mesh defines the mesh to check
  69024. * @param subMesh defines which submesh to check
  69025. * @param useInstances specifies that instances should be used
  69026. * @returns a boolean indicating that the submesh is ready or not
  69027. */
  69028. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  69029. if (useInstances === void 0) { useInstances = false; }
  69030. if (subMesh.effect && this.isFrozen) {
  69031. if (this._wasPreviouslyReady) {
  69032. return true;
  69033. }
  69034. }
  69035. if (!subMesh._materialDefines) {
  69036. subMesh._materialDefines = new StandardMaterialDefines();
  69037. }
  69038. var scene = this.getScene();
  69039. var defines = subMesh._materialDefines;
  69040. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  69041. if (defines._renderId === scene.getRenderId()) {
  69042. return true;
  69043. }
  69044. }
  69045. var engine = scene.getEngine();
  69046. // Lights
  69047. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  69048. // Multiview
  69049. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  69050. // Textures
  69051. if (defines._areTexturesDirty) {
  69052. defines._needUVs = false;
  69053. defines.MAINUV1 = false;
  69054. defines.MAINUV2 = false;
  69055. if (scene.texturesEnabled) {
  69056. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  69057. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  69058. return false;
  69059. }
  69060. else {
  69061. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  69062. }
  69063. }
  69064. else {
  69065. defines.DIFFUSE = false;
  69066. }
  69067. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  69068. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  69069. return false;
  69070. }
  69071. else {
  69072. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  69073. }
  69074. }
  69075. else {
  69076. defines.AMBIENT = false;
  69077. }
  69078. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  69079. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  69080. return false;
  69081. }
  69082. else {
  69083. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  69084. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  69085. }
  69086. }
  69087. else {
  69088. defines.OPACITY = false;
  69089. }
  69090. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  69091. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  69092. return false;
  69093. }
  69094. else {
  69095. defines._needNormals = true;
  69096. defines.REFLECTION = true;
  69097. defines.ROUGHNESS = (this._roughness > 0);
  69098. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  69099. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  69100. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  69101. switch (this._reflectionTexture.coordinatesMode) {
  69102. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  69103. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  69104. break;
  69105. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  69106. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  69107. break;
  69108. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  69109. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  69110. break;
  69111. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  69112. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  69113. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  69114. break;
  69115. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  69116. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  69117. break;
  69118. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  69119. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  69120. break;
  69121. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  69122. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  69123. break;
  69124. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  69125. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  69126. break;
  69127. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  69128. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  69129. default:
  69130. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  69131. break;
  69132. }
  69133. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  69134. }
  69135. }
  69136. else {
  69137. defines.REFLECTION = false;
  69138. }
  69139. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  69140. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  69141. return false;
  69142. }
  69143. else {
  69144. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  69145. }
  69146. }
  69147. else {
  69148. defines.EMISSIVE = false;
  69149. }
  69150. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  69151. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  69152. return false;
  69153. }
  69154. else {
  69155. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  69156. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  69157. }
  69158. }
  69159. else {
  69160. defines.LIGHTMAP = false;
  69161. }
  69162. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  69163. if (!this._specularTexture.isReadyOrNotBlocking()) {
  69164. return false;
  69165. }
  69166. else {
  69167. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  69168. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  69169. }
  69170. }
  69171. else {
  69172. defines.SPECULAR = false;
  69173. }
  69174. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  69175. // Bump texure can not be not blocking.
  69176. if (!this._bumpTexture.isReady()) {
  69177. return false;
  69178. }
  69179. else {
  69180. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  69181. defines.PARALLAX = this._useParallax;
  69182. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  69183. }
  69184. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  69185. }
  69186. else {
  69187. defines.BUMP = false;
  69188. }
  69189. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  69190. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  69191. return false;
  69192. }
  69193. else {
  69194. defines._needUVs = true;
  69195. defines.REFRACTION = true;
  69196. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  69197. }
  69198. }
  69199. else {
  69200. defines.REFRACTION = false;
  69201. }
  69202. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  69203. }
  69204. else {
  69205. defines.DIFFUSE = false;
  69206. defines.AMBIENT = false;
  69207. defines.OPACITY = false;
  69208. defines.REFLECTION = false;
  69209. defines.EMISSIVE = false;
  69210. defines.LIGHTMAP = false;
  69211. defines.BUMP = false;
  69212. defines.REFRACTION = false;
  69213. }
  69214. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  69215. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  69216. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  69217. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  69218. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  69219. }
  69220. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  69221. if (!this._imageProcessingConfiguration.isReady()) {
  69222. return false;
  69223. }
  69224. this._imageProcessingConfiguration.prepareDefines(defines);
  69225. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  69226. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  69227. }
  69228. if (defines._areFresnelDirty) {
  69229. if (StandardMaterial.FresnelEnabled) {
  69230. // Fresnel
  69231. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  69232. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  69233. this._reflectionFresnelParameters) {
  69234. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  69235. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  69236. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  69237. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  69238. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  69239. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  69240. defines._needNormals = true;
  69241. defines.FRESNEL = true;
  69242. }
  69243. }
  69244. else {
  69245. defines.FRESNEL = false;
  69246. }
  69247. }
  69248. // Misc.
  69249. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  69250. // Attribs
  69251. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  69252. // Values that need to be evaluated on every frame
  69253. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  69254. // Get correct effect
  69255. if (defines.isDirty) {
  69256. defines.markAsProcessed();
  69257. // Fallbacks
  69258. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  69259. if (defines.REFLECTION) {
  69260. fallbacks.addFallback(0, "REFLECTION");
  69261. }
  69262. if (defines.SPECULAR) {
  69263. fallbacks.addFallback(0, "SPECULAR");
  69264. }
  69265. if (defines.BUMP) {
  69266. fallbacks.addFallback(0, "BUMP");
  69267. }
  69268. if (defines.PARALLAX) {
  69269. fallbacks.addFallback(1, "PARALLAX");
  69270. }
  69271. if (defines.PARALLAXOCCLUSION) {
  69272. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  69273. }
  69274. if (defines.SPECULAROVERALPHA) {
  69275. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  69276. }
  69277. if (defines.FOG) {
  69278. fallbacks.addFallback(1, "FOG");
  69279. }
  69280. if (defines.POINTSIZE) {
  69281. fallbacks.addFallback(0, "POINTSIZE");
  69282. }
  69283. if (defines.LOGARITHMICDEPTH) {
  69284. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  69285. }
  69286. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  69287. if (defines.SPECULARTERM) {
  69288. fallbacks.addFallback(0, "SPECULARTERM");
  69289. }
  69290. if (defines.DIFFUSEFRESNEL) {
  69291. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  69292. }
  69293. if (defines.OPACITYFRESNEL) {
  69294. fallbacks.addFallback(2, "OPACITYFRESNEL");
  69295. }
  69296. if (defines.REFLECTIONFRESNEL) {
  69297. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  69298. }
  69299. if (defines.EMISSIVEFRESNEL) {
  69300. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  69301. }
  69302. if (defines.FRESNEL) {
  69303. fallbacks.addFallback(4, "FRESNEL");
  69304. }
  69305. if (defines.MULTIVIEW) {
  69306. fallbacks.addFallback(0, "MULTIVIEW");
  69307. }
  69308. //Attributes
  69309. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  69310. if (defines.NORMAL) {
  69311. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  69312. }
  69313. if (defines.UV1) {
  69314. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  69315. }
  69316. if (defines.UV2) {
  69317. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  69318. }
  69319. if (defines.VERTEXCOLOR) {
  69320. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  69321. }
  69322. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  69323. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  69324. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  69325. var shaderName = "default";
  69326. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor", "visibility",
  69327. "vFogInfos", "vFogColor", "pointSize",
  69328. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  69329. "mBones",
  69330. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  69331. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  69332. "vReflectionPosition", "vReflectionSize",
  69333. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  69334. ];
  69335. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  69336. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  69337. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  69338. var uniformBuffers = ["Material", "Scene"];
  69339. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  69340. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  69341. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  69342. }
  69343. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  69344. uniformsNames: uniforms,
  69345. uniformBuffersNames: uniformBuffers,
  69346. samplers: samplers,
  69347. defines: defines,
  69348. maxSimultaneousLights: this._maxSimultaneousLights
  69349. });
  69350. if (this.customShaderNameResolve) {
  69351. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  69352. }
  69353. var join = defines.toString();
  69354. var previousEffect = subMesh.effect;
  69355. var effect = scene.getEngine().createEffect(shaderName, {
  69356. attributes: attribs,
  69357. uniformsNames: uniforms,
  69358. uniformBuffersNames: uniformBuffers,
  69359. samplers: samplers,
  69360. defines: join,
  69361. fallbacks: fallbacks,
  69362. onCompiled: this.onCompiled,
  69363. onError: this.onError,
  69364. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  69365. }, engine);
  69366. if (effect) {
  69367. // Use previous effect while new one is compiling
  69368. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  69369. effect = previousEffect;
  69370. defines.markAsUnprocessed();
  69371. }
  69372. else {
  69373. scene.resetCachedMaterial();
  69374. subMesh.setEffect(effect, defines);
  69375. this.buildUniformLayout();
  69376. }
  69377. }
  69378. }
  69379. if (!subMesh.effect || !subMesh.effect.isReady()) {
  69380. return false;
  69381. }
  69382. defines._renderId = scene.getRenderId();
  69383. this._wasPreviouslyReady = true;
  69384. return true;
  69385. };
  69386. /**
  69387. * Builds the material UBO layouts.
  69388. * Used internally during the effect preparation.
  69389. */
  69390. StandardMaterial.prototype.buildUniformLayout = function () {
  69391. // Order is important !
  69392. var ubo = this._uniformBuffer;
  69393. ubo.addUniform("diffuseLeftColor", 4);
  69394. ubo.addUniform("diffuseRightColor", 4);
  69395. ubo.addUniform("opacityParts", 4);
  69396. ubo.addUniform("reflectionLeftColor", 4);
  69397. ubo.addUniform("reflectionRightColor", 4);
  69398. ubo.addUniform("refractionLeftColor", 4);
  69399. ubo.addUniform("refractionRightColor", 4);
  69400. ubo.addUniform("emissiveLeftColor", 4);
  69401. ubo.addUniform("emissiveRightColor", 4);
  69402. ubo.addUniform("vDiffuseInfos", 2);
  69403. ubo.addUniform("vAmbientInfos", 2);
  69404. ubo.addUniform("vOpacityInfos", 2);
  69405. ubo.addUniform("vReflectionInfos", 2);
  69406. ubo.addUniform("vReflectionPosition", 3);
  69407. ubo.addUniform("vReflectionSize", 3);
  69408. ubo.addUniform("vEmissiveInfos", 2);
  69409. ubo.addUniform("vLightmapInfos", 2);
  69410. ubo.addUniform("vSpecularInfos", 2);
  69411. ubo.addUniform("vBumpInfos", 3);
  69412. ubo.addUniform("diffuseMatrix", 16);
  69413. ubo.addUniform("ambientMatrix", 16);
  69414. ubo.addUniform("opacityMatrix", 16);
  69415. ubo.addUniform("reflectionMatrix", 16);
  69416. ubo.addUniform("emissiveMatrix", 16);
  69417. ubo.addUniform("lightmapMatrix", 16);
  69418. ubo.addUniform("specularMatrix", 16);
  69419. ubo.addUniform("bumpMatrix", 16);
  69420. ubo.addUniform("vTangentSpaceParams", 2);
  69421. ubo.addUniform("pointSize", 1);
  69422. ubo.addUniform("refractionMatrix", 16);
  69423. ubo.addUniform("vRefractionInfos", 4);
  69424. ubo.addUniform("vSpecularColor", 4);
  69425. ubo.addUniform("vEmissiveColor", 3);
  69426. ubo.addUniform("visibility", 1);
  69427. ubo.addUniform("vDiffuseColor", 4);
  69428. ubo.create();
  69429. };
  69430. /**
  69431. * Unbinds the material from the mesh
  69432. */
  69433. StandardMaterial.prototype.unbind = function () {
  69434. if (this._activeEffect) {
  69435. var needFlag = false;
  69436. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  69437. this._activeEffect.setTexture("reflection2DSampler", null);
  69438. needFlag = true;
  69439. }
  69440. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  69441. this._activeEffect.setTexture("refraction2DSampler", null);
  69442. needFlag = true;
  69443. }
  69444. if (needFlag) {
  69445. this._markAllSubMeshesAsTexturesDirty();
  69446. }
  69447. }
  69448. _super.prototype.unbind.call(this);
  69449. };
  69450. /**
  69451. * Binds the submesh to this material by preparing the effect and shader to draw
  69452. * @param world defines the world transformation matrix
  69453. * @param mesh defines the mesh containing the submesh
  69454. * @param subMesh defines the submesh to bind the material to
  69455. */
  69456. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  69457. var scene = this.getScene();
  69458. var defines = subMesh._materialDefines;
  69459. if (!defines) {
  69460. return;
  69461. }
  69462. var effect = subMesh.effect;
  69463. if (!effect) {
  69464. return;
  69465. }
  69466. this._activeEffect = effect;
  69467. // Matrices
  69468. if (!defines.INSTANCES) {
  69469. this.bindOnlyWorldMatrix(world);
  69470. }
  69471. // Normal Matrix
  69472. if (defines.OBJECTSPACE_NORMALMAP) {
  69473. world.toNormalMatrix(this._normalMatrix);
  69474. this.bindOnlyNormalMatrix(this._normalMatrix);
  69475. }
  69476. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  69477. // Bones
  69478. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  69479. var ubo = this._uniformBuffer;
  69480. if (mustRebind) {
  69481. ubo.bindToEffect(effect, "Material");
  69482. this.bindViewProjection(effect);
  69483. if (!ubo.useUbo || !this.isFrozen || !ubo.isSync) {
  69484. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  69485. // Fresnel
  69486. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  69487. ubo.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  69488. ubo.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  69489. }
  69490. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  69491. ubo.updateColor4("opacityParts", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](this.opacityFresnelParameters.leftColor.toLuminance(), this.opacityFresnelParameters.rightColor.toLuminance(), this.opacityFresnelParameters.bias), this.opacityFresnelParameters.power);
  69492. }
  69493. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  69494. ubo.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  69495. ubo.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  69496. }
  69497. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  69498. ubo.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  69499. ubo.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  69500. }
  69501. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  69502. ubo.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  69503. ubo.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  69504. }
  69505. }
  69506. // Textures
  69507. if (scene.texturesEnabled) {
  69508. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  69509. ubo.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  69510. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, ubo, "diffuse");
  69511. if (this._diffuseTexture.hasAlpha) {
  69512. effect.setFloat("alphaCutOff", this.alphaCutOff);
  69513. }
  69514. }
  69515. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  69516. ubo.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  69517. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, ubo, "ambient");
  69518. }
  69519. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  69520. ubo.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  69521. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, ubo, "opacity");
  69522. }
  69523. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  69524. ubo.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  69525. ubo.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  69526. if (this._reflectionTexture.boundingBoxSize) {
  69527. var cubeTexture = this._reflectionTexture;
  69528. ubo.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  69529. ubo.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  69530. }
  69531. }
  69532. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  69533. ubo.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  69534. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, ubo, "emissive");
  69535. }
  69536. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  69537. ubo.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  69538. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, ubo, "lightmap");
  69539. }
  69540. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  69541. ubo.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  69542. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, ubo, "specular");
  69543. }
  69544. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  69545. ubo.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  69546. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, ubo, "bump");
  69547. if (scene._mirroredCameraPosition) {
  69548. ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  69549. }
  69550. else {
  69551. ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  69552. }
  69553. }
  69554. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  69555. var depth = 1.0;
  69556. if (!this._refractionTexture.isCube) {
  69557. ubo.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  69558. if (this._refractionTexture.depth) {
  69559. depth = this._refractionTexture.depth;
  69560. }
  69561. }
  69562. ubo.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  69563. }
  69564. }
  69565. // Point size
  69566. if (this.pointsCloud) {
  69567. ubo.updateFloat("pointSize", this.pointSize);
  69568. }
  69569. if (defines.SPECULARTERM) {
  69570. ubo.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  69571. }
  69572. ubo.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  69573. // Visibility
  69574. ubo.updateFloat("visibility", mesh.visibility);
  69575. // Diffuse
  69576. ubo.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha);
  69577. }
  69578. // Textures
  69579. if (scene.texturesEnabled) {
  69580. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  69581. effect.setTexture("diffuseSampler", this._diffuseTexture);
  69582. }
  69583. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  69584. effect.setTexture("ambientSampler", this._ambientTexture);
  69585. }
  69586. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  69587. effect.setTexture("opacitySampler", this._opacityTexture);
  69588. }
  69589. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  69590. if (this._reflectionTexture.isCube) {
  69591. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  69592. }
  69593. else {
  69594. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  69595. }
  69596. }
  69597. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  69598. effect.setTexture("emissiveSampler", this._emissiveTexture);
  69599. }
  69600. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  69601. effect.setTexture("lightmapSampler", this._lightmapTexture);
  69602. }
  69603. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  69604. effect.setTexture("specularSampler", this._specularTexture);
  69605. }
  69606. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  69607. effect.setTexture("bumpSampler", this._bumpTexture);
  69608. }
  69609. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  69610. var depth = 1.0;
  69611. if (this._refractionTexture.isCube) {
  69612. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  69613. }
  69614. else {
  69615. effect.setTexture("refraction2DSampler", this._refractionTexture);
  69616. }
  69617. }
  69618. }
  69619. // Clip plane
  69620. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  69621. // Colors
  69622. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  69623. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  69624. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  69625. }
  69626. if (mustRebind || !this.isFrozen) {
  69627. // Lights
  69628. if (scene.lightsEnabled && !this._disableLighting) {
  69629. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  69630. }
  69631. // View
  69632. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  69633. this.bindView(effect);
  69634. }
  69635. // Fog
  69636. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  69637. // Morph targets
  69638. if (defines.NUM_MORPH_INFLUENCERS) {
  69639. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  69640. }
  69641. // Log. depth
  69642. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  69643. // image processing
  69644. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  69645. this._imageProcessingConfiguration.bind(this._activeEffect);
  69646. }
  69647. }
  69648. ubo.update();
  69649. this._afterBind(mesh, this._activeEffect);
  69650. };
  69651. /**
  69652. * Get the list of animatables in the material.
  69653. * @returns the list of animatables object used in the material
  69654. */
  69655. StandardMaterial.prototype.getAnimatables = function () {
  69656. var results = [];
  69657. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  69658. results.push(this._diffuseTexture);
  69659. }
  69660. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  69661. results.push(this._ambientTexture);
  69662. }
  69663. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  69664. results.push(this._opacityTexture);
  69665. }
  69666. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  69667. results.push(this._reflectionTexture);
  69668. }
  69669. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  69670. results.push(this._emissiveTexture);
  69671. }
  69672. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  69673. results.push(this._specularTexture);
  69674. }
  69675. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  69676. results.push(this._bumpTexture);
  69677. }
  69678. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  69679. results.push(this._lightmapTexture);
  69680. }
  69681. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  69682. results.push(this._refractionTexture);
  69683. }
  69684. return results;
  69685. };
  69686. /**
  69687. * Gets the active textures from the material
  69688. * @returns an array of textures
  69689. */
  69690. StandardMaterial.prototype.getActiveTextures = function () {
  69691. var activeTextures = _super.prototype.getActiveTextures.call(this);
  69692. if (this._diffuseTexture) {
  69693. activeTextures.push(this._diffuseTexture);
  69694. }
  69695. if (this._ambientTexture) {
  69696. activeTextures.push(this._ambientTexture);
  69697. }
  69698. if (this._opacityTexture) {
  69699. activeTextures.push(this._opacityTexture);
  69700. }
  69701. if (this._reflectionTexture) {
  69702. activeTextures.push(this._reflectionTexture);
  69703. }
  69704. if (this._emissiveTexture) {
  69705. activeTextures.push(this._emissiveTexture);
  69706. }
  69707. if (this._specularTexture) {
  69708. activeTextures.push(this._specularTexture);
  69709. }
  69710. if (this._bumpTexture) {
  69711. activeTextures.push(this._bumpTexture);
  69712. }
  69713. if (this._lightmapTexture) {
  69714. activeTextures.push(this._lightmapTexture);
  69715. }
  69716. if (this._refractionTexture) {
  69717. activeTextures.push(this._refractionTexture);
  69718. }
  69719. return activeTextures;
  69720. };
  69721. /**
  69722. * Specifies if the material uses a texture
  69723. * @param texture defines the texture to check against the material
  69724. * @returns a boolean specifying if the material uses the texture
  69725. */
  69726. StandardMaterial.prototype.hasTexture = function (texture) {
  69727. if (_super.prototype.hasTexture.call(this, texture)) {
  69728. return true;
  69729. }
  69730. if (this._diffuseTexture === texture) {
  69731. return true;
  69732. }
  69733. if (this._ambientTexture === texture) {
  69734. return true;
  69735. }
  69736. if (this._opacityTexture === texture) {
  69737. return true;
  69738. }
  69739. if (this._reflectionTexture === texture) {
  69740. return true;
  69741. }
  69742. if (this._emissiveTexture === texture) {
  69743. return true;
  69744. }
  69745. if (this._specularTexture === texture) {
  69746. return true;
  69747. }
  69748. if (this._bumpTexture === texture) {
  69749. return true;
  69750. }
  69751. if (this._lightmapTexture === texture) {
  69752. return true;
  69753. }
  69754. if (this._refractionTexture === texture) {
  69755. return true;
  69756. }
  69757. return false;
  69758. };
  69759. /**
  69760. * Disposes the material
  69761. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  69762. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  69763. */
  69764. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  69765. if (forceDisposeTextures) {
  69766. if (this._diffuseTexture) {
  69767. this._diffuseTexture.dispose();
  69768. }
  69769. if (this._ambientTexture) {
  69770. this._ambientTexture.dispose();
  69771. }
  69772. if (this._opacityTexture) {
  69773. this._opacityTexture.dispose();
  69774. }
  69775. if (this._reflectionTexture) {
  69776. this._reflectionTexture.dispose();
  69777. }
  69778. if (this._emissiveTexture) {
  69779. this._emissiveTexture.dispose();
  69780. }
  69781. if (this._specularTexture) {
  69782. this._specularTexture.dispose();
  69783. }
  69784. if (this._bumpTexture) {
  69785. this._bumpTexture.dispose();
  69786. }
  69787. if (this._lightmapTexture) {
  69788. this._lightmapTexture.dispose();
  69789. }
  69790. if (this._refractionTexture) {
  69791. this._refractionTexture.dispose();
  69792. }
  69793. }
  69794. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  69795. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  69796. }
  69797. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  69798. };
  69799. /**
  69800. * Makes a duplicate of the material, and gives it a new name
  69801. * @param name defines the new name for the duplicated material
  69802. * @returns the cloned material
  69803. */
  69804. StandardMaterial.prototype.clone = function (name) {
  69805. var _this = this;
  69806. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  69807. result.name = name;
  69808. result.id = name;
  69809. return result;
  69810. };
  69811. /**
  69812. * Serializes this material in a JSON representation
  69813. * @returns the serialized material object
  69814. */
  69815. StandardMaterial.prototype.serialize = function () {
  69816. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  69817. };
  69818. /**
  69819. * Creates a standard material from parsed material data
  69820. * @param source defines the JSON representation of the material
  69821. * @param scene defines the hosting scene
  69822. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69823. * @returns a new standard material
  69824. */
  69825. StandardMaterial.Parse = function (source, scene, rootUrl) {
  69826. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  69827. };
  69828. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  69829. // Flags used to enable or disable a type of texture for all Standard Materials
  69830. /**
  69831. * Are diffuse textures enabled in the application.
  69832. */
  69833. get: function () {
  69834. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  69835. },
  69836. set: function (value) {
  69837. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  69838. },
  69839. enumerable: true,
  69840. configurable: true
  69841. });
  69842. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  69843. /**
  69844. * Are ambient textures enabled in the application.
  69845. */
  69846. get: function () {
  69847. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  69848. },
  69849. set: function (value) {
  69850. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  69851. },
  69852. enumerable: true,
  69853. configurable: true
  69854. });
  69855. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  69856. /**
  69857. * Are opacity textures enabled in the application.
  69858. */
  69859. get: function () {
  69860. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  69861. },
  69862. set: function (value) {
  69863. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  69864. },
  69865. enumerable: true,
  69866. configurable: true
  69867. });
  69868. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  69869. /**
  69870. * Are reflection textures enabled in the application.
  69871. */
  69872. get: function () {
  69873. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  69874. },
  69875. set: function (value) {
  69876. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  69877. },
  69878. enumerable: true,
  69879. configurable: true
  69880. });
  69881. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  69882. /**
  69883. * Are emissive textures enabled in the application.
  69884. */
  69885. get: function () {
  69886. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  69887. },
  69888. set: function (value) {
  69889. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  69890. },
  69891. enumerable: true,
  69892. configurable: true
  69893. });
  69894. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  69895. /**
  69896. * Are specular textures enabled in the application.
  69897. */
  69898. get: function () {
  69899. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  69900. },
  69901. set: function (value) {
  69902. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  69903. },
  69904. enumerable: true,
  69905. configurable: true
  69906. });
  69907. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  69908. /**
  69909. * Are bump textures enabled in the application.
  69910. */
  69911. get: function () {
  69912. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  69913. },
  69914. set: function (value) {
  69915. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  69916. },
  69917. enumerable: true,
  69918. configurable: true
  69919. });
  69920. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  69921. /**
  69922. * Are lightmap textures enabled in the application.
  69923. */
  69924. get: function () {
  69925. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  69926. },
  69927. set: function (value) {
  69928. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  69929. },
  69930. enumerable: true,
  69931. configurable: true
  69932. });
  69933. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  69934. /**
  69935. * Are refraction textures enabled in the application.
  69936. */
  69937. get: function () {
  69938. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  69939. },
  69940. set: function (value) {
  69941. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  69942. },
  69943. enumerable: true,
  69944. configurable: true
  69945. });
  69946. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  69947. /**
  69948. * Are color grading textures enabled in the application.
  69949. */
  69950. get: function () {
  69951. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  69952. },
  69953. set: function (value) {
  69954. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  69955. },
  69956. enumerable: true,
  69957. configurable: true
  69958. });
  69959. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  69960. /**
  69961. * Are fresnels enabled in the application.
  69962. */
  69963. get: function () {
  69964. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  69965. },
  69966. set: function (value) {
  69967. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  69968. },
  69969. enumerable: true,
  69970. configurable: true
  69971. });
  69972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  69974. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  69975. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  69977. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  69978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  69980. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  69981. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69983. ], StandardMaterial.prototype, "ambientTexture", void 0);
  69984. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69985. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  69986. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  69987. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69988. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  69989. ], StandardMaterial.prototype, "opacityTexture", void 0);
  69990. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  69992. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  69993. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69994. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69995. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  69996. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69997. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  69998. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  69999. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70000. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70001. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  70002. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70003. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  70004. ], StandardMaterial.prototype, "_specularTexture", void 0);
  70005. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70006. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70007. ], StandardMaterial.prototype, "specularTexture", void 0);
  70008. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70009. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  70010. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  70011. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70012. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70013. ], StandardMaterial.prototype, "bumpTexture", void 0);
  70014. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70015. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  70016. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  70017. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70018. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70019. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  70020. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70021. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  70022. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  70023. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70024. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70025. ], StandardMaterial.prototype, "refractionTexture", void 0);
  70026. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70027. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  70028. ], StandardMaterial.prototype, "ambientColor", void 0);
  70029. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70030. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  70031. ], StandardMaterial.prototype, "diffuseColor", void 0);
  70032. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70033. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  70034. ], StandardMaterial.prototype, "specularColor", void 0);
  70035. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  70037. ], StandardMaterial.prototype, "emissiveColor", void 0);
  70038. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70040. ], StandardMaterial.prototype, "specularPower", void 0);
  70041. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  70043. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  70044. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70046. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  70047. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  70049. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  70050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70052. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  70053. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70054. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  70055. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  70056. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70057. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70058. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  70059. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70060. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  70061. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  70062. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70063. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70064. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  70065. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70066. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  70067. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  70068. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70069. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70070. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  70071. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70072. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  70073. ], StandardMaterial.prototype, "_disableLighting", void 0);
  70074. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70075. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  70076. ], StandardMaterial.prototype, "disableLighting", void 0);
  70077. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70078. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  70079. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  70080. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70081. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70082. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  70083. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70084. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  70085. ], StandardMaterial.prototype, "_useParallax", void 0);
  70086. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70087. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70088. ], StandardMaterial.prototype, "useParallax", void 0);
  70089. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70090. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  70091. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  70092. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70093. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70094. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  70095. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70097. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  70098. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  70100. ], StandardMaterial.prototype, "_roughness", void 0);
  70101. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70102. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70103. ], StandardMaterial.prototype, "roughness", void 0);
  70104. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70105. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70106. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  70107. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70109. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  70110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70112. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  70113. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70114. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  70115. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  70116. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70118. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  70119. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  70121. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  70122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  70124. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  70125. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70126. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  70127. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  70128. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70129. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  70130. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  70131. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  70133. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  70134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  70136. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  70137. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70138. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  70139. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  70140. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70141. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  70142. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  70143. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  70145. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  70146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  70148. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  70149. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70150. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  70151. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  70152. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70153. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  70154. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  70155. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70156. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  70157. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  70158. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70160. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  70161. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70162. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  70163. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  70164. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70165. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  70166. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  70167. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70168. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  70169. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  70170. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70171. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70172. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  70173. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70174. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  70175. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  70176. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70177. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70178. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  70179. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70180. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  70181. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  70182. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70183. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70184. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  70185. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70186. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70187. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  70188. return StandardMaterial;
  70189. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  70190. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  70191. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  70192. return new StandardMaterial("default material", scene);
  70193. };
  70194. /***/ }),
  70195. /***/ "./Materials/uniformBuffer.ts":
  70196. /*!************************************!*\
  70197. !*** ./Materials/uniformBuffer.ts ***!
  70198. \************************************/
  70199. /*! exports provided: UniformBuffer */
  70200. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  70201. "use strict";
  70202. __webpack_require__.r(__webpack_exports__);
  70203. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  70204. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  70205. /**
  70206. * Uniform buffer objects.
  70207. *
  70208. * Handles blocks of uniform on the GPU.
  70209. *
  70210. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  70211. *
  70212. * For more information, please refer to :
  70213. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  70214. */
  70215. var UniformBuffer = /** @class */ (function () {
  70216. /**
  70217. * Instantiates a new Uniform buffer objects.
  70218. *
  70219. * Handles blocks of uniform on the GPU.
  70220. *
  70221. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  70222. *
  70223. * For more information, please refer to :
  70224. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  70225. * @param engine Define the engine the buffer is associated with
  70226. * @param data Define the data contained in the buffer
  70227. * @param dynamic Define if the buffer is updatable
  70228. */
  70229. function UniformBuffer(engine, data, dynamic) {
  70230. this._engine = engine;
  70231. this._noUBO = !engine.supportsUniformBuffers;
  70232. this._dynamic = dynamic;
  70233. this._data = data || [];
  70234. this._uniformLocations = {};
  70235. this._uniformSizes = {};
  70236. this._uniformLocationPointer = 0;
  70237. this._needSync = false;
  70238. if (this._noUBO) {
  70239. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  70240. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  70241. this.updateFloat = this._updateFloatForEffect;
  70242. this.updateFloat2 = this._updateFloat2ForEffect;
  70243. this.updateFloat3 = this._updateFloat3ForEffect;
  70244. this.updateFloat4 = this._updateFloat4ForEffect;
  70245. this.updateMatrix = this._updateMatrixForEffect;
  70246. this.updateVector3 = this._updateVector3ForEffect;
  70247. this.updateVector4 = this._updateVector4ForEffect;
  70248. this.updateColor3 = this._updateColor3ForEffect;
  70249. this.updateColor4 = this._updateColor4ForEffect;
  70250. }
  70251. else {
  70252. this._engine._uniformBuffers.push(this);
  70253. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  70254. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  70255. this.updateFloat = this._updateFloatForUniform;
  70256. this.updateFloat2 = this._updateFloat2ForUniform;
  70257. this.updateFloat3 = this._updateFloat3ForUniform;
  70258. this.updateFloat4 = this._updateFloat4ForUniform;
  70259. this.updateMatrix = this._updateMatrixForUniform;
  70260. this.updateVector3 = this._updateVector3ForUniform;
  70261. this.updateVector4 = this._updateVector4ForUniform;
  70262. this.updateColor3 = this._updateColor3ForUniform;
  70263. this.updateColor4 = this._updateColor4ForUniform;
  70264. }
  70265. }
  70266. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  70267. /**
  70268. * Indicates if the buffer is using the WebGL2 UBO implementation,
  70269. * or just falling back on setUniformXXX calls.
  70270. */
  70271. get: function () {
  70272. return !this._noUBO;
  70273. },
  70274. enumerable: true,
  70275. configurable: true
  70276. });
  70277. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  70278. /**
  70279. * Indicates if the WebGL underlying uniform buffer is in sync
  70280. * with the javascript cache data.
  70281. */
  70282. get: function () {
  70283. return !this._needSync;
  70284. },
  70285. enumerable: true,
  70286. configurable: true
  70287. });
  70288. /**
  70289. * Indicates if the WebGL underlying uniform buffer is dynamic.
  70290. * Also, a dynamic UniformBuffer will disable cache verification and always
  70291. * update the underlying WebGL uniform buffer to the GPU.
  70292. * @returns if Dynamic, otherwise false
  70293. */
  70294. UniformBuffer.prototype.isDynamic = function () {
  70295. return this._dynamic !== undefined;
  70296. };
  70297. /**
  70298. * The data cache on JS side.
  70299. * @returns the underlying data as a float array
  70300. */
  70301. UniformBuffer.prototype.getData = function () {
  70302. return this._bufferData;
  70303. };
  70304. /**
  70305. * The underlying WebGL Uniform buffer.
  70306. * @returns the webgl buffer
  70307. */
  70308. UniformBuffer.prototype.getBuffer = function () {
  70309. return this._buffer;
  70310. };
  70311. /**
  70312. * std140 layout specifies how to align data within an UBO structure.
  70313. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  70314. * for specs.
  70315. */
  70316. UniformBuffer.prototype._fillAlignment = function (size) {
  70317. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  70318. // and 4x4 matrices
  70319. // TODO : change if other types are used
  70320. var alignment;
  70321. if (size <= 2) {
  70322. alignment = size;
  70323. }
  70324. else {
  70325. alignment = 4;
  70326. }
  70327. if ((this._uniformLocationPointer % alignment) !== 0) {
  70328. var oldPointer = this._uniformLocationPointer;
  70329. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  70330. var diff = this._uniformLocationPointer - oldPointer;
  70331. for (var i = 0; i < diff; i++) {
  70332. this._data.push(0);
  70333. }
  70334. }
  70335. };
  70336. /**
  70337. * Adds an uniform in the buffer.
  70338. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  70339. * for the layout to be correct !
  70340. * @param name Name of the uniform, as used in the uniform block in the shader.
  70341. * @param size Data size, or data directly.
  70342. */
  70343. UniformBuffer.prototype.addUniform = function (name, size) {
  70344. if (this._noUBO) {
  70345. return;
  70346. }
  70347. if (this._uniformLocations[name] !== undefined) {
  70348. // Already existing uniform
  70349. return;
  70350. }
  70351. // This function must be called in the order of the shader layout !
  70352. // size can be the size of the uniform, or data directly
  70353. var data;
  70354. if (size instanceof Array) {
  70355. data = size;
  70356. size = data.length;
  70357. }
  70358. else {
  70359. size = size;
  70360. data = [];
  70361. // Fill with zeros
  70362. for (var i = 0; i < size; i++) {
  70363. data.push(0);
  70364. }
  70365. }
  70366. this._fillAlignment(size);
  70367. this._uniformSizes[name] = size;
  70368. this._uniformLocations[name] = this._uniformLocationPointer;
  70369. this._uniformLocationPointer += size;
  70370. for (var i = 0; i < size; i++) {
  70371. this._data.push(data[i]);
  70372. }
  70373. this._needSync = true;
  70374. };
  70375. /**
  70376. * Adds a Matrix 4x4 to the uniform buffer.
  70377. * @param name Name of the uniform, as used in the uniform block in the shader.
  70378. * @param mat A 4x4 matrix.
  70379. */
  70380. UniformBuffer.prototype.addMatrix = function (name, mat) {
  70381. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  70382. };
  70383. /**
  70384. * Adds a vec2 to the uniform buffer.
  70385. * @param name Name of the uniform, as used in the uniform block in the shader.
  70386. * @param x Define the x component value of the vec2
  70387. * @param y Define the y component value of the vec2
  70388. */
  70389. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  70390. var temp = [x, y];
  70391. this.addUniform(name, temp);
  70392. };
  70393. /**
  70394. * Adds a vec3 to the uniform buffer.
  70395. * @param name Name of the uniform, as used in the uniform block in the shader.
  70396. * @param x Define the x component value of the vec3
  70397. * @param y Define the y component value of the vec3
  70398. * @param z Define the z component value of the vec3
  70399. */
  70400. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  70401. var temp = [x, y, z];
  70402. this.addUniform(name, temp);
  70403. };
  70404. /**
  70405. * Adds a vec3 to the uniform buffer.
  70406. * @param name Name of the uniform, as used in the uniform block in the shader.
  70407. * @param color Define the vec3 from a Color
  70408. */
  70409. UniformBuffer.prototype.addColor3 = function (name, color) {
  70410. var temp = new Array();
  70411. color.toArray(temp);
  70412. this.addUniform(name, temp);
  70413. };
  70414. /**
  70415. * Adds a vec4 to the uniform buffer.
  70416. * @param name Name of the uniform, as used in the uniform block in the shader.
  70417. * @param color Define the rgb components from a Color
  70418. * @param alpha Define the a component of the vec4
  70419. */
  70420. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  70421. var temp = new Array();
  70422. color.toArray(temp);
  70423. temp.push(alpha);
  70424. this.addUniform(name, temp);
  70425. };
  70426. /**
  70427. * Adds a vec3 to the uniform buffer.
  70428. * @param name Name of the uniform, as used in the uniform block in the shader.
  70429. * @param vector Define the vec3 components from a Vector
  70430. */
  70431. UniformBuffer.prototype.addVector3 = function (name, vector) {
  70432. var temp = new Array();
  70433. vector.toArray(temp);
  70434. this.addUniform(name, temp);
  70435. };
  70436. /**
  70437. * Adds a Matrix 3x3 to the uniform buffer.
  70438. * @param name Name of the uniform, as used in the uniform block in the shader.
  70439. */
  70440. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  70441. this.addUniform(name, 12);
  70442. };
  70443. /**
  70444. * Adds a Matrix 2x2 to the uniform buffer.
  70445. * @param name Name of the uniform, as used in the uniform block in the shader.
  70446. */
  70447. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  70448. this.addUniform(name, 8);
  70449. };
  70450. /**
  70451. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  70452. */
  70453. UniformBuffer.prototype.create = function () {
  70454. if (this._noUBO) {
  70455. return;
  70456. }
  70457. if (this._buffer) {
  70458. return; // nothing to do
  70459. }
  70460. // See spec, alignment must be filled as a vec4
  70461. this._fillAlignment(4);
  70462. this._bufferData = new Float32Array(this._data);
  70463. this._rebuild();
  70464. this._needSync = true;
  70465. };
  70466. /** @hidden */
  70467. UniformBuffer.prototype._rebuild = function () {
  70468. if (this._noUBO) {
  70469. return;
  70470. }
  70471. if (this._dynamic) {
  70472. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  70473. }
  70474. else {
  70475. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  70476. }
  70477. };
  70478. /**
  70479. * Updates the WebGL Uniform Buffer on the GPU.
  70480. * If the `dynamic` flag is set to true, no cache comparison is done.
  70481. * Otherwise, the buffer will be updated only if the cache differs.
  70482. */
  70483. UniformBuffer.prototype.update = function () {
  70484. if (!this._buffer) {
  70485. this.create();
  70486. return;
  70487. }
  70488. if (!this._dynamic && !this._needSync) {
  70489. return;
  70490. }
  70491. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  70492. this._needSync = false;
  70493. };
  70494. /**
  70495. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  70496. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  70497. * @param data Define the flattened data
  70498. * @param size Define the size of the data.
  70499. */
  70500. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  70501. var location = this._uniformLocations[uniformName];
  70502. if (location === undefined) {
  70503. if (this._buffer) {
  70504. // Cannot add an uniform if the buffer is already created
  70505. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  70506. return;
  70507. }
  70508. this.addUniform(uniformName, size);
  70509. location = this._uniformLocations[uniformName];
  70510. }
  70511. if (!this._buffer) {
  70512. this.create();
  70513. }
  70514. if (!this._dynamic) {
  70515. // Cache for static uniform buffers
  70516. var changed = false;
  70517. for (var i = 0; i < size; i++) {
  70518. if (this._bufferData[location + i] !== data[i]) {
  70519. changed = true;
  70520. this._bufferData[location + i] = data[i];
  70521. }
  70522. }
  70523. this._needSync = this._needSync || changed;
  70524. }
  70525. else {
  70526. // No cache for dynamic
  70527. for (var i = 0; i < size; i++) {
  70528. this._bufferData[location + i] = data[i];
  70529. }
  70530. }
  70531. };
  70532. // Update methods
  70533. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  70534. // To match std140, matrix must be realigned
  70535. for (var i = 0; i < 3; i++) {
  70536. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  70537. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  70538. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  70539. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  70540. }
  70541. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  70542. };
  70543. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  70544. this._currentEffect.setMatrix3x3(name, matrix);
  70545. };
  70546. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  70547. this._currentEffect.setMatrix2x2(name, matrix);
  70548. };
  70549. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  70550. // To match std140, matrix must be realigned
  70551. for (var i = 0; i < 2; i++) {
  70552. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  70553. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  70554. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  70555. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  70556. }
  70557. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  70558. };
  70559. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  70560. this._currentEffect.setFloat(name, x);
  70561. };
  70562. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  70563. UniformBuffer._tempBuffer[0] = x;
  70564. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  70565. };
  70566. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  70567. if (suffix === void 0) { suffix = ""; }
  70568. this._currentEffect.setFloat2(name + suffix, x, y);
  70569. };
  70570. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  70571. UniformBuffer._tempBuffer[0] = x;
  70572. UniformBuffer._tempBuffer[1] = y;
  70573. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  70574. };
  70575. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  70576. if (suffix === void 0) { suffix = ""; }
  70577. this._currentEffect.setFloat3(name + suffix, x, y, z);
  70578. };
  70579. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  70580. UniformBuffer._tempBuffer[0] = x;
  70581. UniformBuffer._tempBuffer[1] = y;
  70582. UniformBuffer._tempBuffer[2] = z;
  70583. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  70584. };
  70585. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  70586. if (suffix === void 0) { suffix = ""; }
  70587. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  70588. };
  70589. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  70590. UniformBuffer._tempBuffer[0] = x;
  70591. UniformBuffer._tempBuffer[1] = y;
  70592. UniformBuffer._tempBuffer[2] = z;
  70593. UniformBuffer._tempBuffer[3] = w;
  70594. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  70595. };
  70596. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  70597. this._currentEffect.setMatrix(name, mat);
  70598. };
  70599. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  70600. this.updateUniform(name, mat.toArray(), 16);
  70601. };
  70602. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  70603. this._currentEffect.setVector3(name, vector);
  70604. };
  70605. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  70606. vector.toArray(UniformBuffer._tempBuffer);
  70607. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  70608. };
  70609. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  70610. this._currentEffect.setVector4(name, vector);
  70611. };
  70612. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  70613. vector.toArray(UniformBuffer._tempBuffer);
  70614. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  70615. };
  70616. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  70617. if (suffix === void 0) { suffix = ""; }
  70618. this._currentEffect.setColor3(name + suffix, color);
  70619. };
  70620. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  70621. color.toArray(UniformBuffer._tempBuffer);
  70622. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  70623. };
  70624. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  70625. if (suffix === void 0) { suffix = ""; }
  70626. this._currentEffect.setColor4(name + suffix, color, alpha);
  70627. };
  70628. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  70629. color.toArray(UniformBuffer._tempBuffer);
  70630. UniformBuffer._tempBuffer[3] = alpha;
  70631. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  70632. };
  70633. /**
  70634. * Sets a sampler uniform on the effect.
  70635. * @param name Define the name of the sampler.
  70636. * @param texture Define the texture to set in the sampler
  70637. */
  70638. UniformBuffer.prototype.setTexture = function (name, texture) {
  70639. this._currentEffect.setTexture(name, texture);
  70640. };
  70641. /**
  70642. * Directly updates the value of the uniform in the cache AND on the GPU.
  70643. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  70644. * @param data Define the flattened data
  70645. */
  70646. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  70647. this.updateUniform(uniformName, data, data.length);
  70648. this.update();
  70649. };
  70650. /**
  70651. * Binds this uniform buffer to an effect.
  70652. * @param effect Define the effect to bind the buffer to
  70653. * @param name Name of the uniform block in the shader.
  70654. */
  70655. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  70656. this._currentEffect = effect;
  70657. if (this._noUBO || !this._buffer) {
  70658. return;
  70659. }
  70660. effect.bindUniformBuffer(this._buffer, name);
  70661. };
  70662. /**
  70663. * Disposes the uniform buffer.
  70664. */
  70665. UniformBuffer.prototype.dispose = function () {
  70666. if (this._noUBO) {
  70667. return;
  70668. }
  70669. var uniformBuffers = this._engine._uniformBuffers;
  70670. var index = uniformBuffers.indexOf(this);
  70671. if (index !== -1) {
  70672. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  70673. uniformBuffers.pop();
  70674. }
  70675. if (!this._buffer) {
  70676. return;
  70677. }
  70678. if (this._engine._releaseBuffer(this._buffer)) {
  70679. this._buffer = null;
  70680. }
  70681. };
  70682. // Pool for avoiding memory leaks
  70683. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  70684. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  70685. return UniformBuffer;
  70686. }());
  70687. /***/ }),
  70688. /***/ "./Maths/index.ts":
  70689. /*!************************!*\
  70690. !*** ./Maths/index.ts ***!
  70691. \************************/
  70692. /*! exports provided: Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics */
  70693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  70694. "use strict";
  70695. __webpack_require__.r(__webpack_exports__);
  70696. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  70697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  70698. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  70699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  70700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  70701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  70702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  70703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  70704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  70705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  70706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  70707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  70708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  70709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  70710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  70711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  70712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  70713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  70714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  70715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  70716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  70717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  70718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  70719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  70720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  70721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  70722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  70723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  70724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  70725. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  70726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  70727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  70728. /***/ }),
  70729. /***/ "./Maths/math.scalar.ts":
  70730. /*!******************************!*\
  70731. !*** ./Maths/math.scalar.ts ***!
  70732. \******************************/
  70733. /*! exports provided: Scalar */
  70734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  70735. "use strict";
  70736. __webpack_require__.r(__webpack_exports__);
  70737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  70738. /**
  70739. * Scalar computation library
  70740. */
  70741. var Scalar = /** @class */ (function () {
  70742. function Scalar() {
  70743. }
  70744. /**
  70745. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70746. * @param a number
  70747. * @param b number
  70748. * @param epsilon (default = 1.401298E-45)
  70749. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70750. */
  70751. Scalar.WithinEpsilon = function (a, b, epsilon) {
  70752. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  70753. var num = a - b;
  70754. return -epsilon <= num && num <= epsilon;
  70755. };
  70756. /**
  70757. * Returns a string : the upper case translation of the number i to hexadecimal.
  70758. * @param i number
  70759. * @returns the upper case translation of the number i to hexadecimal.
  70760. */
  70761. Scalar.ToHex = function (i) {
  70762. var str = i.toString(16);
  70763. if (i <= 15) {
  70764. return ("0" + str).toUpperCase();
  70765. }
  70766. return str.toUpperCase();
  70767. };
  70768. /**
  70769. * Returns -1 if value is negative and +1 is value is positive.
  70770. * @param value the value
  70771. * @returns the value itself if it's equal to zero.
  70772. */
  70773. Scalar.Sign = function (value) {
  70774. value = +value; // convert to a number
  70775. if (value === 0 || isNaN(value)) {
  70776. return value;
  70777. }
  70778. return value > 0 ? 1 : -1;
  70779. };
  70780. /**
  70781. * Returns the value itself if it's between min and max.
  70782. * Returns min if the value is lower than min.
  70783. * Returns max if the value is greater than max.
  70784. * @param value the value to clmap
  70785. * @param min the min value to clamp to (default: 0)
  70786. * @param max the max value to clamp to (default: 1)
  70787. * @returns the clamped value
  70788. */
  70789. Scalar.Clamp = function (value, min, max) {
  70790. if (min === void 0) { min = 0; }
  70791. if (max === void 0) { max = 1; }
  70792. return Math.min(max, Math.max(min, value));
  70793. };
  70794. /**
  70795. * the log2 of value.
  70796. * @param value the value to compute log2 of
  70797. * @returns the log2 of value.
  70798. */
  70799. Scalar.Log2 = function (value) {
  70800. return Math.log(value) * Math.LOG2E;
  70801. };
  70802. /**
  70803. * Loops the value, so that it is never larger than length and never smaller than 0.
  70804. *
  70805. * This is similar to the modulo operator but it works with floating point numbers.
  70806. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  70807. * With t = 5 and length = 2.5, the result would be 0.0.
  70808. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  70809. * @param value the value
  70810. * @param length the length
  70811. * @returns the looped value
  70812. */
  70813. Scalar.Repeat = function (value, length) {
  70814. return value - Math.floor(value / length) * length;
  70815. };
  70816. /**
  70817. * Normalize the value between 0.0 and 1.0 using min and max values
  70818. * @param value value to normalize
  70819. * @param min max to normalize between
  70820. * @param max min to normalize between
  70821. * @returns the normalized value
  70822. */
  70823. Scalar.Normalize = function (value, min, max) {
  70824. return (value - min) / (max - min);
  70825. };
  70826. /**
  70827. * Denormalize the value from 0.0 and 1.0 using min and max values
  70828. * @param normalized value to denormalize
  70829. * @param min max to denormalize between
  70830. * @param max min to denormalize between
  70831. * @returns the denormalized value
  70832. */
  70833. Scalar.Denormalize = function (normalized, min, max) {
  70834. return (normalized * (max - min) + min);
  70835. };
  70836. /**
  70837. * Calculates the shortest difference between two given angles given in degrees.
  70838. * @param current current angle in degrees
  70839. * @param target target angle in degrees
  70840. * @returns the delta
  70841. */
  70842. Scalar.DeltaAngle = function (current, target) {
  70843. var num = Scalar.Repeat(target - current, 360.0);
  70844. if (num > 180.0) {
  70845. num -= 360.0;
  70846. }
  70847. return num;
  70848. };
  70849. /**
  70850. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  70851. * @param tx value
  70852. * @param length length
  70853. * @returns The returned value will move back and forth between 0 and length
  70854. */
  70855. Scalar.PingPong = function (tx, length) {
  70856. var t = Scalar.Repeat(tx, length * 2.0);
  70857. return length - Math.abs(t - length);
  70858. };
  70859. /**
  70860. * Interpolates between min and max with smoothing at the limits.
  70861. *
  70862. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  70863. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  70864. * @param from from
  70865. * @param to to
  70866. * @param tx value
  70867. * @returns the smooth stepped value
  70868. */
  70869. Scalar.SmoothStep = function (from, to, tx) {
  70870. var t = Scalar.Clamp(tx);
  70871. t = -2.0 * t * t * t + 3.0 * t * t;
  70872. return to * t + from * (1.0 - t);
  70873. };
  70874. /**
  70875. * Moves a value current towards target.
  70876. *
  70877. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  70878. * Negative values of maxDelta pushes the value away from target.
  70879. * @param current current value
  70880. * @param target target value
  70881. * @param maxDelta max distance to move
  70882. * @returns resulting value
  70883. */
  70884. Scalar.MoveTowards = function (current, target, maxDelta) {
  70885. var result = 0;
  70886. if (Math.abs(target - current) <= maxDelta) {
  70887. result = target;
  70888. }
  70889. else {
  70890. result = current + Scalar.Sign(target - current) * maxDelta;
  70891. }
  70892. return result;
  70893. };
  70894. /**
  70895. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70896. *
  70897. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  70898. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  70899. * @param current current value
  70900. * @param target target value
  70901. * @param maxDelta max distance to move
  70902. * @returns resulting angle
  70903. */
  70904. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  70905. var num = Scalar.DeltaAngle(current, target);
  70906. var result = 0;
  70907. if (-maxDelta < num && num < maxDelta) {
  70908. result = target;
  70909. }
  70910. else {
  70911. target = current + num;
  70912. result = Scalar.MoveTowards(current, target, maxDelta);
  70913. }
  70914. return result;
  70915. };
  70916. /**
  70917. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  70918. * @param start start value
  70919. * @param end target value
  70920. * @param amount amount to lerp between
  70921. * @returns the lerped value
  70922. */
  70923. Scalar.Lerp = function (start, end, amount) {
  70924. return start + ((end - start) * amount);
  70925. };
  70926. /**
  70927. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70928. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  70929. * @param start start value
  70930. * @param end target value
  70931. * @param amount amount to lerp between
  70932. * @returns the lerped value
  70933. */
  70934. Scalar.LerpAngle = function (start, end, amount) {
  70935. var num = Scalar.Repeat(end - start, 360.0);
  70936. if (num > 180.0) {
  70937. num -= 360.0;
  70938. }
  70939. return start + num * Scalar.Clamp(amount);
  70940. };
  70941. /**
  70942. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  70943. * @param a start value
  70944. * @param b target value
  70945. * @param value value between a and b
  70946. * @returns the inverseLerp value
  70947. */
  70948. Scalar.InverseLerp = function (a, b, value) {
  70949. var result = 0;
  70950. if (a != b) {
  70951. result = Scalar.Clamp((value - a) / (b - a));
  70952. }
  70953. else {
  70954. result = 0.0;
  70955. }
  70956. return result;
  70957. };
  70958. /**
  70959. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  70960. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  70961. * @param value1 spline value
  70962. * @param tangent1 spline value
  70963. * @param value2 spline value
  70964. * @param tangent2 spline value
  70965. * @param amount input value
  70966. * @returns hermite result
  70967. */
  70968. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  70969. var squared = amount * amount;
  70970. var cubed = amount * squared;
  70971. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  70972. var part2 = (-2.0 * cubed) + (3.0 * squared);
  70973. var part3 = (cubed - (2.0 * squared)) + amount;
  70974. var part4 = cubed - squared;
  70975. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  70976. };
  70977. /**
  70978. * Returns a random float number between and min and max values
  70979. * @param min min value of random
  70980. * @param max max value of random
  70981. * @returns random value
  70982. */
  70983. Scalar.RandomRange = function (min, max) {
  70984. if (min === max) {
  70985. return min;
  70986. }
  70987. return ((Math.random() * (max - min)) + min);
  70988. };
  70989. /**
  70990. * This function returns percentage of a number in a given range.
  70991. *
  70992. * RangeToPercent(40,20,60) will return 0.5 (50%)
  70993. * RangeToPercent(34,0,100) will return 0.34 (34%)
  70994. * @param number to convert to percentage
  70995. * @param min min range
  70996. * @param max max range
  70997. * @returns the percentage
  70998. */
  70999. Scalar.RangeToPercent = function (number, min, max) {
  71000. return ((number - min) / (max - min));
  71001. };
  71002. /**
  71003. * This function returns number that corresponds to the percentage in a given range.
  71004. *
  71005. * PercentToRange(0.34,0,100) will return 34.
  71006. * @param percent to convert to number
  71007. * @param min min range
  71008. * @param max max range
  71009. * @returns the number
  71010. */
  71011. Scalar.PercentToRange = function (percent, min, max) {
  71012. return ((max - min) * percent + min);
  71013. };
  71014. /**
  71015. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  71016. * @param angle The angle to normalize in radian.
  71017. * @return The converted angle.
  71018. */
  71019. Scalar.NormalizeRadians = function (angle) {
  71020. // More precise but slower version kept for reference.
  71021. // angle = angle % Tools.TwoPi;
  71022. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  71023. //if (angle > Math.PI) {
  71024. // angle -= Tools.TwoPi;
  71025. //}
  71026. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  71027. return angle;
  71028. };
  71029. /**
  71030. * Two pi constants convenient for computation.
  71031. */
  71032. Scalar.TwoPi = Math.PI * 2;
  71033. return Scalar;
  71034. }());
  71035. /***/ }),
  71036. /***/ "./Maths/math.ts":
  71037. /*!***********************!*\
  71038. !*** ./Maths/math.ts ***!
  71039. \***********************/
  71040. /*! exports provided: ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp */
  71041. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  71042. "use strict";
  71043. __webpack_require__.r(__webpack_exports__);
  71044. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  71045. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  71046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  71047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  71048. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  71049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  71050. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  71051. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  71052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  71053. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  71054. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  71055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  71056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  71057. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  71058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  71059. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  71060. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  71061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  71062. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  71063. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  71064. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  71065. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  71066. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  71067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  71068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  71069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  71070. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  71071. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  71072. /**
  71073. * Constant used to convert a value to gamma space
  71074. * @ignorenaming
  71075. */
  71076. var ToGammaSpace = 1 / 2.2;
  71077. /**
  71078. * Constant used to convert a value to linear space
  71079. * @ignorenaming
  71080. */
  71081. var ToLinearSpace = 2.2;
  71082. /**
  71083. * Constant used to define the minimal number value in Babylon.js
  71084. * @ignorenaming
  71085. */
  71086. var Epsilon = 0.001;
  71087. /**
  71088. * Class used to hold a RBG color
  71089. */
  71090. var Color3 = /** @class */ (function () {
  71091. /**
  71092. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  71093. * @param r defines the red component (between 0 and 1, default is 0)
  71094. * @param g defines the green component (between 0 and 1, default is 0)
  71095. * @param b defines the blue component (between 0 and 1, default is 0)
  71096. */
  71097. function Color3(
  71098. /**
  71099. * Defines the red component (between 0 and 1, default is 0)
  71100. */
  71101. r,
  71102. /**
  71103. * Defines the green component (between 0 and 1, default is 0)
  71104. */
  71105. g,
  71106. /**
  71107. * Defines the blue component (between 0 and 1, default is 0)
  71108. */
  71109. b) {
  71110. if (r === void 0) { r = 0; }
  71111. if (g === void 0) { g = 0; }
  71112. if (b === void 0) { b = 0; }
  71113. this.r = r;
  71114. this.g = g;
  71115. this.b = b;
  71116. }
  71117. /**
  71118. * Creates a string with the Color3 current values
  71119. * @returns the string representation of the Color3 object
  71120. */
  71121. Color3.prototype.toString = function () {
  71122. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  71123. };
  71124. /**
  71125. * Returns the string "Color3"
  71126. * @returns "Color3"
  71127. */
  71128. Color3.prototype.getClassName = function () {
  71129. return "Color3";
  71130. };
  71131. /**
  71132. * Compute the Color3 hash code
  71133. * @returns an unique number that can be used to hash Color3 objects
  71134. */
  71135. Color3.prototype.getHashCode = function () {
  71136. var hash = this.r || 0;
  71137. hash = (hash * 397) ^ (this.g || 0);
  71138. hash = (hash * 397) ^ (this.b || 0);
  71139. return hash;
  71140. };
  71141. // Operators
  71142. /**
  71143. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  71144. * @param array defines the array where to store the r,g,b components
  71145. * @param index defines an optional index in the target array to define where to start storing values
  71146. * @returns the current Color3 object
  71147. */
  71148. Color3.prototype.toArray = function (array, index) {
  71149. if (index === void 0) { index = 0; }
  71150. array[index] = this.r;
  71151. array[index + 1] = this.g;
  71152. array[index + 2] = this.b;
  71153. return this;
  71154. };
  71155. /**
  71156. * Returns a new Color4 object from the current Color3 and the given alpha
  71157. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  71158. * @returns a new Color4 object
  71159. */
  71160. Color3.prototype.toColor4 = function (alpha) {
  71161. if (alpha === void 0) { alpha = 1; }
  71162. return new Color4(this.r, this.g, this.b, alpha);
  71163. };
  71164. /**
  71165. * Returns a new array populated with 3 numeric elements : red, green and blue values
  71166. * @returns the new array
  71167. */
  71168. Color3.prototype.asArray = function () {
  71169. var result = new Array();
  71170. this.toArray(result, 0);
  71171. return result;
  71172. };
  71173. /**
  71174. * Returns the luminance value
  71175. * @returns a float value
  71176. */
  71177. Color3.prototype.toLuminance = function () {
  71178. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  71179. };
  71180. /**
  71181. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  71182. * @param otherColor defines the second operand
  71183. * @returns the new Color3 object
  71184. */
  71185. Color3.prototype.multiply = function (otherColor) {
  71186. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  71187. };
  71188. /**
  71189. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  71190. * @param otherColor defines the second operand
  71191. * @param result defines the Color3 object where to store the result
  71192. * @returns the current Color3
  71193. */
  71194. Color3.prototype.multiplyToRef = function (otherColor, result) {
  71195. result.r = this.r * otherColor.r;
  71196. result.g = this.g * otherColor.g;
  71197. result.b = this.b * otherColor.b;
  71198. return this;
  71199. };
  71200. /**
  71201. * Determines equality between Color3 objects
  71202. * @param otherColor defines the second operand
  71203. * @returns true if the rgb values are equal to the given ones
  71204. */
  71205. Color3.prototype.equals = function (otherColor) {
  71206. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  71207. };
  71208. /**
  71209. * Determines equality between the current Color3 object and a set of r,b,g values
  71210. * @param r defines the red component to check
  71211. * @param g defines the green component to check
  71212. * @param b defines the blue component to check
  71213. * @returns true if the rgb values are equal to the given ones
  71214. */
  71215. Color3.prototype.equalsFloats = function (r, g, b) {
  71216. return this.r === r && this.g === g && this.b === b;
  71217. };
  71218. /**
  71219. * Multiplies in place each rgb value by scale
  71220. * @param scale defines the scaling factor
  71221. * @returns the updated Color3
  71222. */
  71223. Color3.prototype.scale = function (scale) {
  71224. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  71225. };
  71226. /**
  71227. * Multiplies the rgb values by scale and stores the result into "result"
  71228. * @param scale defines the scaling factor
  71229. * @param result defines the Color3 object where to store the result
  71230. * @returns the unmodified current Color3
  71231. */
  71232. Color3.prototype.scaleToRef = function (scale, result) {
  71233. result.r = this.r * scale;
  71234. result.g = this.g * scale;
  71235. result.b = this.b * scale;
  71236. return this;
  71237. };
  71238. /**
  71239. * Scale the current Color3 values by a factor and add the result to a given Color3
  71240. * @param scale defines the scale factor
  71241. * @param result defines color to store the result into
  71242. * @returns the unmodified current Color3
  71243. */
  71244. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  71245. result.r += this.r * scale;
  71246. result.g += this.g * scale;
  71247. result.b += this.b * scale;
  71248. return this;
  71249. };
  71250. /**
  71251. * Clamps the rgb values by the min and max values and stores the result into "result"
  71252. * @param min defines minimum clamping value (default is 0)
  71253. * @param max defines maximum clamping value (default is 1)
  71254. * @param result defines color to store the result into
  71255. * @returns the original Color3
  71256. */
  71257. Color3.prototype.clampToRef = function (min, max, result) {
  71258. if (min === void 0) { min = 0; }
  71259. if (max === void 0) { max = 1; }
  71260. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  71261. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  71262. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  71263. return this;
  71264. };
  71265. /**
  71266. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  71267. * @param otherColor defines the second operand
  71268. * @returns the new Color3
  71269. */
  71270. Color3.prototype.add = function (otherColor) {
  71271. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  71272. };
  71273. /**
  71274. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  71275. * @param otherColor defines the second operand
  71276. * @param result defines Color3 object to store the result into
  71277. * @returns the unmodified current Color3
  71278. */
  71279. Color3.prototype.addToRef = function (otherColor, result) {
  71280. result.r = this.r + otherColor.r;
  71281. result.g = this.g + otherColor.g;
  71282. result.b = this.b + otherColor.b;
  71283. return this;
  71284. };
  71285. /**
  71286. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  71287. * @param otherColor defines the second operand
  71288. * @returns the new Color3
  71289. */
  71290. Color3.prototype.subtract = function (otherColor) {
  71291. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  71292. };
  71293. /**
  71294. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  71295. * @param otherColor defines the second operand
  71296. * @param result defines Color3 object to store the result into
  71297. * @returns the unmodified current Color3
  71298. */
  71299. Color3.prototype.subtractToRef = function (otherColor, result) {
  71300. result.r = this.r - otherColor.r;
  71301. result.g = this.g - otherColor.g;
  71302. result.b = this.b - otherColor.b;
  71303. return this;
  71304. };
  71305. /**
  71306. * Copy the current object
  71307. * @returns a new Color3 copied the current one
  71308. */
  71309. Color3.prototype.clone = function () {
  71310. return new Color3(this.r, this.g, this.b);
  71311. };
  71312. /**
  71313. * Copies the rgb values from the source in the current Color3
  71314. * @param source defines the source Color3 object
  71315. * @returns the updated Color3 object
  71316. */
  71317. Color3.prototype.copyFrom = function (source) {
  71318. this.r = source.r;
  71319. this.g = source.g;
  71320. this.b = source.b;
  71321. return this;
  71322. };
  71323. /**
  71324. * Updates the Color3 rgb values from the given floats
  71325. * @param r defines the red component to read from
  71326. * @param g defines the green component to read from
  71327. * @param b defines the blue component to read from
  71328. * @returns the current Color3 object
  71329. */
  71330. Color3.prototype.copyFromFloats = function (r, g, b) {
  71331. this.r = r;
  71332. this.g = g;
  71333. this.b = b;
  71334. return this;
  71335. };
  71336. /**
  71337. * Updates the Color3 rgb values from the given floats
  71338. * @param r defines the red component to read from
  71339. * @param g defines the green component to read from
  71340. * @param b defines the blue component to read from
  71341. * @returns the current Color3 object
  71342. */
  71343. Color3.prototype.set = function (r, g, b) {
  71344. return this.copyFromFloats(r, g, b);
  71345. };
  71346. /**
  71347. * Compute the Color3 hexadecimal code as a string
  71348. * @returns a string containing the hexadecimal representation of the Color3 object
  71349. */
  71350. Color3.prototype.toHexString = function () {
  71351. var intR = (this.r * 255) | 0;
  71352. var intG = (this.g * 255) | 0;
  71353. var intB = (this.b * 255) | 0;
  71354. return "#" + _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].ToHex(intR) + _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].ToHex(intG) + _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].ToHex(intB);
  71355. };
  71356. /**
  71357. * Computes a new Color3 converted from the current one to linear space
  71358. * @returns a new Color3 object
  71359. */
  71360. Color3.prototype.toLinearSpace = function () {
  71361. var convertedColor = new Color3();
  71362. this.toLinearSpaceToRef(convertedColor);
  71363. return convertedColor;
  71364. };
  71365. /**
  71366. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  71367. * @param convertedColor defines the Color3 object where to store the linear space version
  71368. * @returns the unmodified Color3
  71369. */
  71370. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  71371. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  71372. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  71373. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  71374. return this;
  71375. };
  71376. /**
  71377. * Computes a new Color3 converted from the current one to gamma space
  71378. * @returns a new Color3 object
  71379. */
  71380. Color3.prototype.toGammaSpace = function () {
  71381. var convertedColor = new Color3();
  71382. this.toGammaSpaceToRef(convertedColor);
  71383. return convertedColor;
  71384. };
  71385. /**
  71386. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  71387. * @param convertedColor defines the Color3 object where to store the gamma space version
  71388. * @returns the unmodified Color3
  71389. */
  71390. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  71391. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  71392. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  71393. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  71394. return this;
  71395. };
  71396. /**
  71397. * Creates a new Color3 from the string containing valid hexadecimal values
  71398. * @param hex defines a string containing valid hexadecimal values
  71399. * @returns a new Color3 object
  71400. */
  71401. Color3.FromHexString = function (hex) {
  71402. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  71403. return new Color3(0, 0, 0);
  71404. }
  71405. var r = parseInt(hex.substring(1, 3), 16);
  71406. var g = parseInt(hex.substring(3, 5), 16);
  71407. var b = parseInt(hex.substring(5, 7), 16);
  71408. return Color3.FromInts(r, g, b);
  71409. };
  71410. /**
  71411. * Creates a new Vector3 from the starting index of the given array
  71412. * @param array defines the source array
  71413. * @param offset defines an offset in the source array
  71414. * @returns a new Color3 object
  71415. */
  71416. Color3.FromArray = function (array, offset) {
  71417. if (offset === void 0) { offset = 0; }
  71418. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  71419. };
  71420. /**
  71421. * Creates a new Color3 from integer values (< 256)
  71422. * @param r defines the red component to read from (value between 0 and 255)
  71423. * @param g defines the green component to read from (value between 0 and 255)
  71424. * @param b defines the blue component to read from (value between 0 and 255)
  71425. * @returns a new Color3 object
  71426. */
  71427. Color3.FromInts = function (r, g, b) {
  71428. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  71429. };
  71430. /**
  71431. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  71432. * @param start defines the start Color3 value
  71433. * @param end defines the end Color3 value
  71434. * @param amount defines the gradient value between start and end
  71435. * @returns a new Color3 object
  71436. */
  71437. Color3.Lerp = function (start, end, amount) {
  71438. var result = new Color3(0.0, 0.0, 0.0);
  71439. Color3.LerpToRef(start, end, amount, result);
  71440. return result;
  71441. };
  71442. /**
  71443. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  71444. * @param left defines the start value
  71445. * @param right defines the end value
  71446. * @param amount defines the gradient factor
  71447. * @param result defines the Color3 object where to store the result
  71448. */
  71449. Color3.LerpToRef = function (left, right, amount, result) {
  71450. result.r = left.r + ((right.r - left.r) * amount);
  71451. result.g = left.g + ((right.g - left.g) * amount);
  71452. result.b = left.b + ((right.b - left.b) * amount);
  71453. };
  71454. /**
  71455. * Returns a Color3 value containing a red color
  71456. * @returns a new Color3 object
  71457. */
  71458. Color3.Red = function () { return new Color3(1, 0, 0); };
  71459. /**
  71460. * Returns a Color3 value containing a green color
  71461. * @returns a new Color3 object
  71462. */
  71463. Color3.Green = function () { return new Color3(0, 1, 0); };
  71464. /**
  71465. * Returns a Color3 value containing a blue color
  71466. * @returns a new Color3 object
  71467. */
  71468. Color3.Blue = function () { return new Color3(0, 0, 1); };
  71469. /**
  71470. * Returns a Color3 value containing a black color
  71471. * @returns a new Color3 object
  71472. */
  71473. Color3.Black = function () { return new Color3(0, 0, 0); };
  71474. Object.defineProperty(Color3, "BlackReadOnly", {
  71475. /**
  71476. * Gets a Color3 value containing a black color that must not be updated
  71477. */
  71478. get: function () {
  71479. return Color3._BlackReadOnly;
  71480. },
  71481. enumerable: true,
  71482. configurable: true
  71483. });
  71484. /**
  71485. * Returns a Color3 value containing a white color
  71486. * @returns a new Color3 object
  71487. */
  71488. Color3.White = function () { return new Color3(1, 1, 1); };
  71489. /**
  71490. * Returns a Color3 value containing a purple color
  71491. * @returns a new Color3 object
  71492. */
  71493. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  71494. /**
  71495. * Returns a Color3 value containing a magenta color
  71496. * @returns a new Color3 object
  71497. */
  71498. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  71499. /**
  71500. * Returns a Color3 value containing a yellow color
  71501. * @returns a new Color3 object
  71502. */
  71503. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  71504. /**
  71505. * Returns a Color3 value containing a gray color
  71506. * @returns a new Color3 object
  71507. */
  71508. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  71509. /**
  71510. * Returns a Color3 value containing a teal color
  71511. * @returns a new Color3 object
  71512. */
  71513. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  71514. /**
  71515. * Returns a Color3 value containing a random color
  71516. * @returns a new Color3 object
  71517. */
  71518. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  71519. // Statics
  71520. Color3._BlackReadOnly = Color3.Black();
  71521. return Color3;
  71522. }());
  71523. /**
  71524. * Class used to hold a RBGA color
  71525. */
  71526. var Color4 = /** @class */ (function () {
  71527. /**
  71528. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  71529. * @param r defines the red component (between 0 and 1, default is 0)
  71530. * @param g defines the green component (between 0 and 1, default is 0)
  71531. * @param b defines the blue component (between 0 and 1, default is 0)
  71532. * @param a defines the alpha component (between 0 and 1, default is 1)
  71533. */
  71534. function Color4(
  71535. /**
  71536. * Defines the red component (between 0 and 1, default is 0)
  71537. */
  71538. r,
  71539. /**
  71540. * Defines the green component (between 0 and 1, default is 0)
  71541. */
  71542. g,
  71543. /**
  71544. * Defines the blue component (between 0 and 1, default is 0)
  71545. */
  71546. b,
  71547. /**
  71548. * Defines the alpha component (between 0 and 1, default is 1)
  71549. */
  71550. a) {
  71551. if (r === void 0) { r = 0; }
  71552. if (g === void 0) { g = 0; }
  71553. if (b === void 0) { b = 0; }
  71554. if (a === void 0) { a = 1; }
  71555. this.r = r;
  71556. this.g = g;
  71557. this.b = b;
  71558. this.a = a;
  71559. }
  71560. // Operators
  71561. /**
  71562. * Adds in place the given Color4 values to the current Color4 object
  71563. * @param right defines the second operand
  71564. * @returns the current updated Color4 object
  71565. */
  71566. Color4.prototype.addInPlace = function (right) {
  71567. this.r += right.r;
  71568. this.g += right.g;
  71569. this.b += right.b;
  71570. this.a += right.a;
  71571. return this;
  71572. };
  71573. /**
  71574. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  71575. * @returns the new array
  71576. */
  71577. Color4.prototype.asArray = function () {
  71578. var result = new Array();
  71579. this.toArray(result, 0);
  71580. return result;
  71581. };
  71582. /**
  71583. * Stores from the starting index in the given array the Color4 successive values
  71584. * @param array defines the array where to store the r,g,b components
  71585. * @param index defines an optional index in the target array to define where to start storing values
  71586. * @returns the current Color4 object
  71587. */
  71588. Color4.prototype.toArray = function (array, index) {
  71589. if (index === void 0) { index = 0; }
  71590. array[index] = this.r;
  71591. array[index + 1] = this.g;
  71592. array[index + 2] = this.b;
  71593. array[index + 3] = this.a;
  71594. return this;
  71595. };
  71596. /**
  71597. * Determines equality between Color4 objects
  71598. * @param otherColor defines the second operand
  71599. * @returns true if the rgba values are equal to the given ones
  71600. */
  71601. Color4.prototype.equals = function (otherColor) {
  71602. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  71603. };
  71604. /**
  71605. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  71606. * @param right defines the second operand
  71607. * @returns a new Color4 object
  71608. */
  71609. Color4.prototype.add = function (right) {
  71610. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  71611. };
  71612. /**
  71613. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  71614. * @param right defines the second operand
  71615. * @returns a new Color4 object
  71616. */
  71617. Color4.prototype.subtract = function (right) {
  71618. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  71619. };
  71620. /**
  71621. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  71622. * @param right defines the second operand
  71623. * @param result defines the Color4 object where to store the result
  71624. * @returns the current Color4 object
  71625. */
  71626. Color4.prototype.subtractToRef = function (right, result) {
  71627. result.r = this.r - right.r;
  71628. result.g = this.g - right.g;
  71629. result.b = this.b - right.b;
  71630. result.a = this.a - right.a;
  71631. return this;
  71632. };
  71633. /**
  71634. * Creates a new Color4 with the current Color4 values multiplied by scale
  71635. * @param scale defines the scaling factor to apply
  71636. * @returns a new Color4 object
  71637. */
  71638. Color4.prototype.scale = function (scale) {
  71639. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  71640. };
  71641. /**
  71642. * Multiplies the current Color4 values by scale and stores the result in "result"
  71643. * @param scale defines the scaling factor to apply
  71644. * @param result defines the Color4 object where to store the result
  71645. * @returns the current unmodified Color4
  71646. */
  71647. Color4.prototype.scaleToRef = function (scale, result) {
  71648. result.r = this.r * scale;
  71649. result.g = this.g * scale;
  71650. result.b = this.b * scale;
  71651. result.a = this.a * scale;
  71652. return this;
  71653. };
  71654. /**
  71655. * Scale the current Color4 values by a factor and add the result to a given Color4
  71656. * @param scale defines the scale factor
  71657. * @param result defines the Color4 object where to store the result
  71658. * @returns the unmodified current Color4
  71659. */
  71660. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  71661. result.r += this.r * scale;
  71662. result.g += this.g * scale;
  71663. result.b += this.b * scale;
  71664. result.a += this.a * scale;
  71665. return this;
  71666. };
  71667. /**
  71668. * Clamps the rgb values by the min and max values and stores the result into "result"
  71669. * @param min defines minimum clamping value (default is 0)
  71670. * @param max defines maximum clamping value (default is 1)
  71671. * @param result defines color to store the result into.
  71672. * @returns the cuurent Color4
  71673. */
  71674. Color4.prototype.clampToRef = function (min, max, result) {
  71675. if (min === void 0) { min = 0; }
  71676. if (max === void 0) { max = 1; }
  71677. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  71678. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  71679. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  71680. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  71681. return this;
  71682. };
  71683. /**
  71684. * Multipy an Color4 value by another and return a new Color4 object
  71685. * @param color defines the Color4 value to multiply by
  71686. * @returns a new Color4 object
  71687. */
  71688. Color4.prototype.multiply = function (color) {
  71689. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  71690. };
  71691. /**
  71692. * Multipy a Color4 value by another and push the result in a reference value
  71693. * @param color defines the Color4 value to multiply by
  71694. * @param result defines the Color4 to fill the result in
  71695. * @returns the result Color4
  71696. */
  71697. Color4.prototype.multiplyToRef = function (color, result) {
  71698. result.r = this.r * color.r;
  71699. result.g = this.g * color.g;
  71700. result.b = this.b * color.b;
  71701. result.a = this.a * color.a;
  71702. return result;
  71703. };
  71704. /**
  71705. * Creates a string with the Color4 current values
  71706. * @returns the string representation of the Color4 object
  71707. */
  71708. Color4.prototype.toString = function () {
  71709. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  71710. };
  71711. /**
  71712. * Returns the string "Color4"
  71713. * @returns "Color4"
  71714. */
  71715. Color4.prototype.getClassName = function () {
  71716. return "Color4";
  71717. };
  71718. /**
  71719. * Compute the Color4 hash code
  71720. * @returns an unique number that can be used to hash Color4 objects
  71721. */
  71722. Color4.prototype.getHashCode = function () {
  71723. var hash = this.r || 0;
  71724. hash = (hash * 397) ^ (this.g || 0);
  71725. hash = (hash * 397) ^ (this.b || 0);
  71726. hash = (hash * 397) ^ (this.a || 0);
  71727. return hash;
  71728. };
  71729. /**
  71730. * Creates a new Color4 copied from the current one
  71731. * @returns a new Color4 object
  71732. */
  71733. Color4.prototype.clone = function () {
  71734. return new Color4(this.r, this.g, this.b, this.a);
  71735. };
  71736. /**
  71737. * Copies the given Color4 values into the current one
  71738. * @param source defines the source Color4 object
  71739. * @returns the current updated Color4 object
  71740. */
  71741. Color4.prototype.copyFrom = function (source) {
  71742. this.r = source.r;
  71743. this.g = source.g;
  71744. this.b = source.b;
  71745. this.a = source.a;
  71746. return this;
  71747. };
  71748. /**
  71749. * Copies the given float values into the current one
  71750. * @param r defines the red component to read from
  71751. * @param g defines the green component to read from
  71752. * @param b defines the blue component to read from
  71753. * @param a defines the alpha component to read from
  71754. * @returns the current updated Color4 object
  71755. */
  71756. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  71757. this.r = r;
  71758. this.g = g;
  71759. this.b = b;
  71760. this.a = a;
  71761. return this;
  71762. };
  71763. /**
  71764. * Copies the given float values into the current one
  71765. * @param r defines the red component to read from
  71766. * @param g defines the green component to read from
  71767. * @param b defines the blue component to read from
  71768. * @param a defines the alpha component to read from
  71769. * @returns the current updated Color4 object
  71770. */
  71771. Color4.prototype.set = function (r, g, b, a) {
  71772. return this.copyFromFloats(r, g, b, a);
  71773. };
  71774. /**
  71775. * Compute the Color4 hexadecimal code as a string
  71776. * @returns a string containing the hexadecimal representation of the Color4 object
  71777. */
  71778. Color4.prototype.toHexString = function () {
  71779. var intR = (this.r * 255) | 0;
  71780. var intG = (this.g * 255) | 0;
  71781. var intB = (this.b * 255) | 0;
  71782. var intA = (this.a * 255) | 0;
  71783. return "#" + _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].ToHex(intR) + _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].ToHex(intG) + _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].ToHex(intB) + _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].ToHex(intA);
  71784. };
  71785. /**
  71786. * Computes a new Color4 converted from the current one to linear space
  71787. * @returns a new Color4 object
  71788. */
  71789. Color4.prototype.toLinearSpace = function () {
  71790. var convertedColor = new Color4();
  71791. this.toLinearSpaceToRef(convertedColor);
  71792. return convertedColor;
  71793. };
  71794. /**
  71795. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  71796. * @param convertedColor defines the Color4 object where to store the linear space version
  71797. * @returns the unmodified Color4
  71798. */
  71799. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  71800. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  71801. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  71802. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  71803. convertedColor.a = this.a;
  71804. return this;
  71805. };
  71806. /**
  71807. * Computes a new Color4 converted from the current one to gamma space
  71808. * @returns a new Color4 object
  71809. */
  71810. Color4.prototype.toGammaSpace = function () {
  71811. var convertedColor = new Color4();
  71812. this.toGammaSpaceToRef(convertedColor);
  71813. return convertedColor;
  71814. };
  71815. /**
  71816. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  71817. * @param convertedColor defines the Color4 object where to store the gamma space version
  71818. * @returns the unmodified Color4
  71819. */
  71820. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  71821. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  71822. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  71823. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  71824. convertedColor.a = this.a;
  71825. return this;
  71826. };
  71827. // Statics
  71828. /**
  71829. * Creates a new Color4 from the string containing valid hexadecimal values
  71830. * @param hex defines a string containing valid hexadecimal values
  71831. * @returns a new Color4 object
  71832. */
  71833. Color4.FromHexString = function (hex) {
  71834. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  71835. return new Color4(0.0, 0.0, 0.0, 0.0);
  71836. }
  71837. var r = parseInt(hex.substring(1, 3), 16);
  71838. var g = parseInt(hex.substring(3, 5), 16);
  71839. var b = parseInt(hex.substring(5, 7), 16);
  71840. var a = parseInt(hex.substring(7, 9), 16);
  71841. return Color4.FromInts(r, g, b, a);
  71842. };
  71843. /**
  71844. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71845. * @param left defines the start value
  71846. * @param right defines the end value
  71847. * @param amount defines the gradient factor
  71848. * @returns a new Color4 object
  71849. */
  71850. Color4.Lerp = function (left, right, amount) {
  71851. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  71852. Color4.LerpToRef(left, right, amount, result);
  71853. return result;
  71854. };
  71855. /**
  71856. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71857. * @param left defines the start value
  71858. * @param right defines the end value
  71859. * @param amount defines the gradient factor
  71860. * @param result defines the Color4 object where to store data
  71861. */
  71862. Color4.LerpToRef = function (left, right, amount, result) {
  71863. result.r = left.r + (right.r - left.r) * amount;
  71864. result.g = left.g + (right.g - left.g) * amount;
  71865. result.b = left.b + (right.b - left.b) * amount;
  71866. result.a = left.a + (right.a - left.a) * amount;
  71867. };
  71868. /**
  71869. * Creates a new Color4 from a Color3 and an alpha value
  71870. * @param color3 defines the source Color3 to read from
  71871. * @param alpha defines the alpha component (1.0 by default)
  71872. * @returns a new Color4 object
  71873. */
  71874. Color4.FromColor3 = function (color3, alpha) {
  71875. if (alpha === void 0) { alpha = 1.0; }
  71876. return new Color4(color3.r, color3.g, color3.b, alpha);
  71877. };
  71878. /**
  71879. * Creates a new Color4 from the starting index element of the given array
  71880. * @param array defines the source array to read from
  71881. * @param offset defines the offset in the source array
  71882. * @returns a new Color4 object
  71883. */
  71884. Color4.FromArray = function (array, offset) {
  71885. if (offset === void 0) { offset = 0; }
  71886. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  71887. };
  71888. /**
  71889. * Creates a new Color3 from integer values (< 256)
  71890. * @param r defines the red component to read from (value between 0 and 255)
  71891. * @param g defines the green component to read from (value between 0 and 255)
  71892. * @param b defines the blue component to read from (value between 0 and 255)
  71893. * @param a defines the alpha component to read from (value between 0 and 255)
  71894. * @returns a new Color3 object
  71895. */
  71896. Color4.FromInts = function (r, g, b, a) {
  71897. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  71898. };
  71899. /**
  71900. * Check the content of a given array and convert it to an array containing RGBA data
  71901. * If the original array was already containing count * 4 values then it is returned directly
  71902. * @param colors defines the array to check
  71903. * @param count defines the number of RGBA data to expect
  71904. * @returns an array containing count * 4 values (RGBA)
  71905. */
  71906. Color4.CheckColors4 = function (colors, count) {
  71907. // Check if color3 was used
  71908. if (colors.length === count * 3) {
  71909. var colors4 = [];
  71910. for (var index = 0; index < colors.length; index += 3) {
  71911. var newIndex = (index / 3) * 4;
  71912. colors4[newIndex] = colors[index];
  71913. colors4[newIndex + 1] = colors[index + 1];
  71914. colors4[newIndex + 2] = colors[index + 2];
  71915. colors4[newIndex + 3] = 1.0;
  71916. }
  71917. return colors4;
  71918. }
  71919. return colors;
  71920. };
  71921. return Color4;
  71922. }());
  71923. /**
  71924. * Class representing a vector containing 2 coordinates
  71925. */
  71926. var Vector2 = /** @class */ (function () {
  71927. /**
  71928. * Creates a new Vector2 from the given x and y coordinates
  71929. * @param x defines the first coordinate
  71930. * @param y defines the second coordinate
  71931. */
  71932. function Vector2(
  71933. /** defines the first coordinate */
  71934. x,
  71935. /** defines the second coordinate */
  71936. y) {
  71937. if (x === void 0) { x = 0; }
  71938. if (y === void 0) { y = 0; }
  71939. this.x = x;
  71940. this.y = y;
  71941. }
  71942. /**
  71943. * Gets a string with the Vector2 coordinates
  71944. * @returns a string with the Vector2 coordinates
  71945. */
  71946. Vector2.prototype.toString = function () {
  71947. return "{X: " + this.x + " Y:" + this.y + "}";
  71948. };
  71949. /**
  71950. * Gets class name
  71951. * @returns the string "Vector2"
  71952. */
  71953. Vector2.prototype.getClassName = function () {
  71954. return "Vector2";
  71955. };
  71956. /**
  71957. * Gets current vector hash code
  71958. * @returns the Vector2 hash code as a number
  71959. */
  71960. Vector2.prototype.getHashCode = function () {
  71961. var hash = this.x || 0;
  71962. hash = (hash * 397) ^ (this.y || 0);
  71963. return hash;
  71964. };
  71965. // Operators
  71966. /**
  71967. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  71968. * @param array defines the source array
  71969. * @param index defines the offset in source array
  71970. * @returns the current Vector2
  71971. */
  71972. Vector2.prototype.toArray = function (array, index) {
  71973. if (index === void 0) { index = 0; }
  71974. array[index] = this.x;
  71975. array[index + 1] = this.y;
  71976. return this;
  71977. };
  71978. /**
  71979. * Copy the current vector to an array
  71980. * @returns a new array with 2 elements: the Vector2 coordinates.
  71981. */
  71982. Vector2.prototype.asArray = function () {
  71983. var result = new Array();
  71984. this.toArray(result, 0);
  71985. return result;
  71986. };
  71987. /**
  71988. * Sets the Vector2 coordinates with the given Vector2 coordinates
  71989. * @param source defines the source Vector2
  71990. * @returns the current updated Vector2
  71991. */
  71992. Vector2.prototype.copyFrom = function (source) {
  71993. this.x = source.x;
  71994. this.y = source.y;
  71995. return this;
  71996. };
  71997. /**
  71998. * Sets the Vector2 coordinates with the given floats
  71999. * @param x defines the first coordinate
  72000. * @param y defines the second coordinate
  72001. * @returns the current updated Vector2
  72002. */
  72003. Vector2.prototype.copyFromFloats = function (x, y) {
  72004. this.x = x;
  72005. this.y = y;
  72006. return this;
  72007. };
  72008. /**
  72009. * Sets the Vector2 coordinates with the given floats
  72010. * @param x defines the first coordinate
  72011. * @param y defines the second coordinate
  72012. * @returns the current updated Vector2
  72013. */
  72014. Vector2.prototype.set = function (x, y) {
  72015. return this.copyFromFloats(x, y);
  72016. };
  72017. /**
  72018. * Add another vector with the current one
  72019. * @param otherVector defines the other vector
  72020. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  72021. */
  72022. Vector2.prototype.add = function (otherVector) {
  72023. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  72024. };
  72025. /**
  72026. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  72027. * @param otherVector defines the other vector
  72028. * @param result defines the target vector
  72029. * @returns the unmodified current Vector2
  72030. */
  72031. Vector2.prototype.addToRef = function (otherVector, result) {
  72032. result.x = this.x + otherVector.x;
  72033. result.y = this.y + otherVector.y;
  72034. return this;
  72035. };
  72036. /**
  72037. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  72038. * @param otherVector defines the other vector
  72039. * @returns the current updated Vector2
  72040. */
  72041. Vector2.prototype.addInPlace = function (otherVector) {
  72042. this.x += otherVector.x;
  72043. this.y += otherVector.y;
  72044. return this;
  72045. };
  72046. /**
  72047. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  72048. * @param otherVector defines the other vector
  72049. * @returns a new Vector2
  72050. */
  72051. Vector2.prototype.addVector3 = function (otherVector) {
  72052. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  72053. };
  72054. /**
  72055. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  72056. * @param otherVector defines the other vector
  72057. * @returns a new Vector2
  72058. */
  72059. Vector2.prototype.subtract = function (otherVector) {
  72060. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  72061. };
  72062. /**
  72063. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  72064. * @param otherVector defines the other vector
  72065. * @param result defines the target vector
  72066. * @returns the unmodified current Vector2
  72067. */
  72068. Vector2.prototype.subtractToRef = function (otherVector, result) {
  72069. result.x = this.x - otherVector.x;
  72070. result.y = this.y - otherVector.y;
  72071. return this;
  72072. };
  72073. /**
  72074. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  72075. * @param otherVector defines the other vector
  72076. * @returns the current updated Vector2
  72077. */
  72078. Vector2.prototype.subtractInPlace = function (otherVector) {
  72079. this.x -= otherVector.x;
  72080. this.y -= otherVector.y;
  72081. return this;
  72082. };
  72083. /**
  72084. * Multiplies in place the current Vector2 coordinates by the given ones
  72085. * @param otherVector defines the other vector
  72086. * @returns the current updated Vector2
  72087. */
  72088. Vector2.prototype.multiplyInPlace = function (otherVector) {
  72089. this.x *= otherVector.x;
  72090. this.y *= otherVector.y;
  72091. return this;
  72092. };
  72093. /**
  72094. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  72095. * @param otherVector defines the other vector
  72096. * @returns a new Vector2
  72097. */
  72098. Vector2.prototype.multiply = function (otherVector) {
  72099. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  72100. };
  72101. /**
  72102. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  72103. * @param otherVector defines the other vector
  72104. * @param result defines the target vector
  72105. * @returns the unmodified current Vector2
  72106. */
  72107. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  72108. result.x = this.x * otherVector.x;
  72109. result.y = this.y * otherVector.y;
  72110. return this;
  72111. };
  72112. /**
  72113. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  72114. * @param x defines the first coordinate
  72115. * @param y defines the second coordinate
  72116. * @returns a new Vector2
  72117. */
  72118. Vector2.prototype.multiplyByFloats = function (x, y) {
  72119. return new Vector2(this.x * x, this.y * y);
  72120. };
  72121. /**
  72122. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  72123. * @param otherVector defines the other vector
  72124. * @returns a new Vector2
  72125. */
  72126. Vector2.prototype.divide = function (otherVector) {
  72127. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  72128. };
  72129. /**
  72130. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  72131. * @param otherVector defines the other vector
  72132. * @param result defines the target vector
  72133. * @returns the unmodified current Vector2
  72134. */
  72135. Vector2.prototype.divideToRef = function (otherVector, result) {
  72136. result.x = this.x / otherVector.x;
  72137. result.y = this.y / otherVector.y;
  72138. return this;
  72139. };
  72140. /**
  72141. * Divides the current Vector2 coordinates by the given ones
  72142. * @param otherVector defines the other vector
  72143. * @returns the current updated Vector2
  72144. */
  72145. Vector2.prototype.divideInPlace = function (otherVector) {
  72146. return this.divideToRef(otherVector, this);
  72147. };
  72148. /**
  72149. * Gets a new Vector2 with current Vector2 negated coordinates
  72150. * @returns a new Vector2
  72151. */
  72152. Vector2.prototype.negate = function () {
  72153. return new Vector2(-this.x, -this.y);
  72154. };
  72155. /**
  72156. * Multiply the Vector2 coordinates by scale
  72157. * @param scale defines the scaling factor
  72158. * @returns the current updated Vector2
  72159. */
  72160. Vector2.prototype.scaleInPlace = function (scale) {
  72161. this.x *= scale;
  72162. this.y *= scale;
  72163. return this;
  72164. };
  72165. /**
  72166. * Returns a new Vector2 scaled by "scale" from the current Vector2
  72167. * @param scale defines the scaling factor
  72168. * @returns a new Vector2
  72169. */
  72170. Vector2.prototype.scale = function (scale) {
  72171. var result = new Vector2(0, 0);
  72172. this.scaleToRef(scale, result);
  72173. return result;
  72174. };
  72175. /**
  72176. * Scale the current Vector2 values by a factor to a given Vector2
  72177. * @param scale defines the scale factor
  72178. * @param result defines the Vector2 object where to store the result
  72179. * @returns the unmodified current Vector2
  72180. */
  72181. Vector2.prototype.scaleToRef = function (scale, result) {
  72182. result.x = this.x * scale;
  72183. result.y = this.y * scale;
  72184. return this;
  72185. };
  72186. /**
  72187. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  72188. * @param scale defines the scale factor
  72189. * @param result defines the Vector2 object where to store the result
  72190. * @returns the unmodified current Vector2
  72191. */
  72192. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  72193. result.x += this.x * scale;
  72194. result.y += this.y * scale;
  72195. return this;
  72196. };
  72197. /**
  72198. * Gets a boolean if two vectors are equals
  72199. * @param otherVector defines the other vector
  72200. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  72201. */
  72202. Vector2.prototype.equals = function (otherVector) {
  72203. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  72204. };
  72205. /**
  72206. * Gets a boolean if two vectors are equals (using an epsilon value)
  72207. * @param otherVector defines the other vector
  72208. * @param epsilon defines the minimal distance to consider equality
  72209. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  72210. */
  72211. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  72212. if (epsilon === void 0) { epsilon = Epsilon; }
  72213. return otherVector && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon) && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon);
  72214. };
  72215. /**
  72216. * Gets a new Vector2 from current Vector2 floored values
  72217. * @returns a new Vector2
  72218. */
  72219. Vector2.prototype.floor = function () {
  72220. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  72221. };
  72222. /**
  72223. * Gets a new Vector2 from current Vector2 floored values
  72224. * @returns a new Vector2
  72225. */
  72226. Vector2.prototype.fract = function () {
  72227. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  72228. };
  72229. // Properties
  72230. /**
  72231. * Gets the length of the vector
  72232. * @returns the vector length (float)
  72233. */
  72234. Vector2.prototype.length = function () {
  72235. return Math.sqrt(this.x * this.x + this.y * this.y);
  72236. };
  72237. /**
  72238. * Gets the vector squared length
  72239. * @returns the vector squared length (float)
  72240. */
  72241. Vector2.prototype.lengthSquared = function () {
  72242. return (this.x * this.x + this.y * this.y);
  72243. };
  72244. // Methods
  72245. /**
  72246. * Normalize the vector
  72247. * @returns the current updated Vector2
  72248. */
  72249. Vector2.prototype.normalize = function () {
  72250. var len = this.length();
  72251. if (len === 0) {
  72252. return this;
  72253. }
  72254. var num = 1.0 / len;
  72255. this.x *= num;
  72256. this.y *= num;
  72257. return this;
  72258. };
  72259. /**
  72260. * Gets a new Vector2 copied from the Vector2
  72261. * @returns a new Vector2
  72262. */
  72263. Vector2.prototype.clone = function () {
  72264. return new Vector2(this.x, this.y);
  72265. };
  72266. // Statics
  72267. /**
  72268. * Gets a new Vector2(0, 0)
  72269. * @returns a new Vector2
  72270. */
  72271. Vector2.Zero = function () {
  72272. return new Vector2(0, 0);
  72273. };
  72274. /**
  72275. * Gets a new Vector2(1, 1)
  72276. * @returns a new Vector2
  72277. */
  72278. Vector2.One = function () {
  72279. return new Vector2(1, 1);
  72280. };
  72281. /**
  72282. * Gets a new Vector2 set from the given index element of the given array
  72283. * @param array defines the data source
  72284. * @param offset defines the offset in the data source
  72285. * @returns a new Vector2
  72286. */
  72287. Vector2.FromArray = function (array, offset) {
  72288. if (offset === void 0) { offset = 0; }
  72289. return new Vector2(array[offset], array[offset + 1]);
  72290. };
  72291. /**
  72292. * Sets "result" from the given index element of the given array
  72293. * @param array defines the data source
  72294. * @param offset defines the offset in the data source
  72295. * @param result defines the target vector
  72296. */
  72297. Vector2.FromArrayToRef = function (array, offset, result) {
  72298. result.x = array[offset];
  72299. result.y = array[offset + 1];
  72300. };
  72301. /**
  72302. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  72303. * @param value1 defines 1st point of control
  72304. * @param value2 defines 2nd point of control
  72305. * @param value3 defines 3rd point of control
  72306. * @param value4 defines 4th point of control
  72307. * @param amount defines the interpolation factor
  72308. * @returns a new Vector2
  72309. */
  72310. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  72311. var squared = amount * amount;
  72312. var cubed = amount * squared;
  72313. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  72314. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  72315. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  72316. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  72317. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  72318. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  72319. return new Vector2(x, y);
  72320. };
  72321. /**
  72322. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  72323. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  72324. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  72325. * @param value defines the value to clamp
  72326. * @param min defines the lower limit
  72327. * @param max defines the upper limit
  72328. * @returns a new Vector2
  72329. */
  72330. Vector2.Clamp = function (value, min, max) {
  72331. var x = value.x;
  72332. x = (x > max.x) ? max.x : x;
  72333. x = (x < min.x) ? min.x : x;
  72334. var y = value.y;
  72335. y = (y > max.y) ? max.y : y;
  72336. y = (y < min.y) ? min.y : y;
  72337. return new Vector2(x, y);
  72338. };
  72339. /**
  72340. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  72341. * @param value1 defines the 1st control point
  72342. * @param tangent1 defines the outgoing tangent
  72343. * @param value2 defines the 2nd control point
  72344. * @param tangent2 defines the incoming tangent
  72345. * @param amount defines the interpolation factor
  72346. * @returns a new Vector2
  72347. */
  72348. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  72349. var squared = amount * amount;
  72350. var cubed = amount * squared;
  72351. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  72352. var part2 = (-2.0 * cubed) + (3.0 * squared);
  72353. var part3 = (cubed - (2.0 * squared)) + amount;
  72354. var part4 = cubed - squared;
  72355. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  72356. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  72357. return new Vector2(x, y);
  72358. };
  72359. /**
  72360. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  72361. * @param start defines the start vector
  72362. * @param end defines the end vector
  72363. * @param amount defines the interpolation factor
  72364. * @returns a new Vector2
  72365. */
  72366. Vector2.Lerp = function (start, end, amount) {
  72367. var x = start.x + ((end.x - start.x) * amount);
  72368. var y = start.y + ((end.y - start.y) * amount);
  72369. return new Vector2(x, y);
  72370. };
  72371. /**
  72372. * Gets the dot product of the vector "left" and the vector "right"
  72373. * @param left defines first vector
  72374. * @param right defines second vector
  72375. * @returns the dot product (float)
  72376. */
  72377. Vector2.Dot = function (left, right) {
  72378. return left.x * right.x + left.y * right.y;
  72379. };
  72380. /**
  72381. * Returns a new Vector2 equal to the normalized given vector
  72382. * @param vector defines the vector to normalize
  72383. * @returns a new Vector2
  72384. */
  72385. Vector2.Normalize = function (vector) {
  72386. var newVector = vector.clone();
  72387. newVector.normalize();
  72388. return newVector;
  72389. };
  72390. /**
  72391. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  72392. * @param left defines 1st vector
  72393. * @param right defines 2nd vector
  72394. * @returns a new Vector2
  72395. */
  72396. Vector2.Minimize = function (left, right) {
  72397. var x = (left.x < right.x) ? left.x : right.x;
  72398. var y = (left.y < right.y) ? left.y : right.y;
  72399. return new Vector2(x, y);
  72400. };
  72401. /**
  72402. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  72403. * @param left defines 1st vector
  72404. * @param right defines 2nd vector
  72405. * @returns a new Vector2
  72406. */
  72407. Vector2.Maximize = function (left, right) {
  72408. var x = (left.x > right.x) ? left.x : right.x;
  72409. var y = (left.y > right.y) ? left.y : right.y;
  72410. return new Vector2(x, y);
  72411. };
  72412. /**
  72413. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  72414. * @param vector defines the vector to transform
  72415. * @param transformation defines the matrix to apply
  72416. * @returns a new Vector2
  72417. */
  72418. Vector2.Transform = function (vector, transformation) {
  72419. var r = Vector2.Zero();
  72420. Vector2.TransformToRef(vector, transformation, r);
  72421. return r;
  72422. };
  72423. /**
  72424. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  72425. * @param vector defines the vector to transform
  72426. * @param transformation defines the matrix to apply
  72427. * @param result defines the target vector
  72428. */
  72429. Vector2.TransformToRef = function (vector, transformation, result) {
  72430. var m = transformation.m;
  72431. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  72432. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  72433. result.x = x;
  72434. result.y = y;
  72435. };
  72436. /**
  72437. * Determines if a given vector is included in a triangle
  72438. * @param p defines the vector to test
  72439. * @param p0 defines 1st triangle point
  72440. * @param p1 defines 2nd triangle point
  72441. * @param p2 defines 3rd triangle point
  72442. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  72443. */
  72444. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  72445. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  72446. var sign = a < 0 ? -1 : 1;
  72447. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  72448. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  72449. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  72450. };
  72451. /**
  72452. * Gets the distance between the vectors "value1" and "value2"
  72453. * @param value1 defines first vector
  72454. * @param value2 defines second vector
  72455. * @returns the distance between vectors
  72456. */
  72457. Vector2.Distance = function (value1, value2) {
  72458. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  72459. };
  72460. /**
  72461. * Returns the squared distance between the vectors "value1" and "value2"
  72462. * @param value1 defines first vector
  72463. * @param value2 defines second vector
  72464. * @returns the squared distance between vectors
  72465. */
  72466. Vector2.DistanceSquared = function (value1, value2) {
  72467. var x = value1.x - value2.x;
  72468. var y = value1.y - value2.y;
  72469. return (x * x) + (y * y);
  72470. };
  72471. /**
  72472. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  72473. * @param value1 defines first vector
  72474. * @param value2 defines second vector
  72475. * @returns a new Vector2
  72476. */
  72477. Vector2.Center = function (value1, value2) {
  72478. var center = value1.add(value2);
  72479. center.scaleInPlace(0.5);
  72480. return center;
  72481. };
  72482. /**
  72483. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  72484. * @param p defines the middle point
  72485. * @param segA defines one point of the segment
  72486. * @param segB defines the other point of the segment
  72487. * @returns the shortest distance
  72488. */
  72489. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  72490. var l2 = Vector2.DistanceSquared(segA, segB);
  72491. if (l2 === 0.0) {
  72492. return Vector2.Distance(p, segA);
  72493. }
  72494. var v = segB.subtract(segA);
  72495. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  72496. var proj = segA.add(v.multiplyByFloats(t, t));
  72497. return Vector2.Distance(p, proj);
  72498. };
  72499. return Vector2;
  72500. }());
  72501. /**
  72502. * Classed used to store (x,y,z) vector representation
  72503. * A Vector3 is the main object used in 3D geometry
  72504. * It can represent etiher the coordinates of a point the space, either a direction
  72505. * Reminder: js uses a left handed forward facing system
  72506. */
  72507. var Vector3 = /** @class */ (function () {
  72508. /**
  72509. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  72510. * @param x defines the first coordinates (on X axis)
  72511. * @param y defines the second coordinates (on Y axis)
  72512. * @param z defines the third coordinates (on Z axis)
  72513. */
  72514. function Vector3(
  72515. /**
  72516. * Defines the first coordinates (on X axis)
  72517. */
  72518. x,
  72519. /**
  72520. * Defines the second coordinates (on Y axis)
  72521. */
  72522. y,
  72523. /**
  72524. * Defines the third coordinates (on Z axis)
  72525. */
  72526. z) {
  72527. if (x === void 0) { x = 0; }
  72528. if (y === void 0) { y = 0; }
  72529. if (z === void 0) { z = 0; }
  72530. this.x = x;
  72531. this.y = y;
  72532. this.z = z;
  72533. }
  72534. /**
  72535. * Creates a string representation of the Vector3
  72536. * @returns a string with the Vector3 coordinates.
  72537. */
  72538. Vector3.prototype.toString = function () {
  72539. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  72540. };
  72541. /**
  72542. * Gets the class name
  72543. * @returns the string "Vector3"
  72544. */
  72545. Vector3.prototype.getClassName = function () {
  72546. return "Vector3";
  72547. };
  72548. /**
  72549. * Creates the Vector3 hash code
  72550. * @returns a number which tends to be unique between Vector3 instances
  72551. */
  72552. Vector3.prototype.getHashCode = function () {
  72553. var hash = this.x || 0;
  72554. hash = (hash * 397) ^ (this.y || 0);
  72555. hash = (hash * 397) ^ (this.z || 0);
  72556. return hash;
  72557. };
  72558. // Operators
  72559. /**
  72560. * Creates an array containing three elements : the coordinates of the Vector3
  72561. * @returns a new array of numbers
  72562. */
  72563. Vector3.prototype.asArray = function () {
  72564. var result = [];
  72565. this.toArray(result, 0);
  72566. return result;
  72567. };
  72568. /**
  72569. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  72570. * @param array defines the destination array
  72571. * @param index defines the offset in the destination array
  72572. * @returns the current Vector3
  72573. */
  72574. Vector3.prototype.toArray = function (array, index) {
  72575. if (index === void 0) { index = 0; }
  72576. array[index] = this.x;
  72577. array[index + 1] = this.y;
  72578. array[index + 2] = this.z;
  72579. return this;
  72580. };
  72581. /**
  72582. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  72583. * @returns a new Quaternion object, computed from the Vector3 coordinates
  72584. */
  72585. Vector3.prototype.toQuaternion = function () {
  72586. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  72587. };
  72588. /**
  72589. * Adds the given vector to the current Vector3
  72590. * @param otherVector defines the second operand
  72591. * @returns the current updated Vector3
  72592. */
  72593. Vector3.prototype.addInPlace = function (otherVector) {
  72594. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  72595. };
  72596. /**
  72597. * Adds the given coordinates to the current Vector3
  72598. * @param x defines the x coordinate of the operand
  72599. * @param y defines the y coordinate of the operand
  72600. * @param z defines the z coordinate of the operand
  72601. * @returns the current updated Vector3
  72602. */
  72603. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  72604. this.x += x;
  72605. this.y += y;
  72606. this.z += z;
  72607. return this;
  72608. };
  72609. /**
  72610. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  72611. * @param otherVector defines the second operand
  72612. * @returns the resulting Vector3
  72613. */
  72614. Vector3.prototype.add = function (otherVector) {
  72615. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  72616. };
  72617. /**
  72618. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  72619. * @param otherVector defines the second operand
  72620. * @param result defines the Vector3 object where to store the result
  72621. * @returns the current Vector3
  72622. */
  72623. Vector3.prototype.addToRef = function (otherVector, result) {
  72624. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  72625. };
  72626. /**
  72627. * Subtract the given vector from the current Vector3
  72628. * @param otherVector defines the second operand
  72629. * @returns the current updated Vector3
  72630. */
  72631. Vector3.prototype.subtractInPlace = function (otherVector) {
  72632. this.x -= otherVector.x;
  72633. this.y -= otherVector.y;
  72634. this.z -= otherVector.z;
  72635. return this;
  72636. };
  72637. /**
  72638. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  72639. * @param otherVector defines the second operand
  72640. * @returns the resulting Vector3
  72641. */
  72642. Vector3.prototype.subtract = function (otherVector) {
  72643. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  72644. };
  72645. /**
  72646. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  72647. * @param otherVector defines the second operand
  72648. * @param result defines the Vector3 object where to store the result
  72649. * @returns the current Vector3
  72650. */
  72651. Vector3.prototype.subtractToRef = function (otherVector, result) {
  72652. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  72653. };
  72654. /**
  72655. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  72656. * @param x defines the x coordinate of the operand
  72657. * @param y defines the y coordinate of the operand
  72658. * @param z defines the z coordinate of the operand
  72659. * @returns the resulting Vector3
  72660. */
  72661. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  72662. return new Vector3(this.x - x, this.y - y, this.z - z);
  72663. };
  72664. /**
  72665. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  72666. * @param x defines the x coordinate of the operand
  72667. * @param y defines the y coordinate of the operand
  72668. * @param z defines the z coordinate of the operand
  72669. * @param result defines the Vector3 object where to store the result
  72670. * @returns the current Vector3
  72671. */
  72672. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  72673. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  72674. };
  72675. /**
  72676. * Gets a new Vector3 set with the current Vector3 negated coordinates
  72677. * @returns a new Vector3
  72678. */
  72679. Vector3.prototype.negate = function () {
  72680. return new Vector3(-this.x, -this.y, -this.z);
  72681. };
  72682. /**
  72683. * Multiplies the Vector3 coordinates by the float "scale"
  72684. * @param scale defines the multiplier factor
  72685. * @returns the current updated Vector3
  72686. */
  72687. Vector3.prototype.scaleInPlace = function (scale) {
  72688. this.x *= scale;
  72689. this.y *= scale;
  72690. this.z *= scale;
  72691. return this;
  72692. };
  72693. /**
  72694. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  72695. * @param scale defines the multiplier factor
  72696. * @returns a new Vector3
  72697. */
  72698. Vector3.prototype.scale = function (scale) {
  72699. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  72700. };
  72701. /**
  72702. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  72703. * @param scale defines the multiplier factor
  72704. * @param result defines the Vector3 object where to store the result
  72705. * @returns the current Vector3
  72706. */
  72707. Vector3.prototype.scaleToRef = function (scale, result) {
  72708. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  72709. };
  72710. /**
  72711. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  72712. * @param scale defines the scale factor
  72713. * @param result defines the Vector3 object where to store the result
  72714. * @returns the unmodified current Vector3
  72715. */
  72716. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  72717. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  72718. };
  72719. /**
  72720. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  72721. * @param otherVector defines the second operand
  72722. * @returns true if both vectors are equals
  72723. */
  72724. Vector3.prototype.equals = function (otherVector) {
  72725. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  72726. };
  72727. /**
  72728. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  72729. * @param otherVector defines the second operand
  72730. * @param epsilon defines the minimal distance to define values as equals
  72731. * @returns true if both vectors are distant less than epsilon
  72732. */
  72733. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  72734. if (epsilon === void 0) { epsilon = Epsilon; }
  72735. return otherVector && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon) && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon) && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon);
  72736. };
  72737. /**
  72738. * Returns true if the current Vector3 coordinates equals the given floats
  72739. * @param x defines the x coordinate of the operand
  72740. * @param y defines the y coordinate of the operand
  72741. * @param z defines the z coordinate of the operand
  72742. * @returns true if both vectors are equals
  72743. */
  72744. Vector3.prototype.equalsToFloats = function (x, y, z) {
  72745. return this.x === x && this.y === y && this.z === z;
  72746. };
  72747. /**
  72748. * Multiplies the current Vector3 coordinates by the given ones
  72749. * @param otherVector defines the second operand
  72750. * @returns the current updated Vector3
  72751. */
  72752. Vector3.prototype.multiplyInPlace = function (otherVector) {
  72753. this.x *= otherVector.x;
  72754. this.y *= otherVector.y;
  72755. this.z *= otherVector.z;
  72756. return this;
  72757. };
  72758. /**
  72759. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  72760. * @param otherVector defines the second operand
  72761. * @returns the new Vector3
  72762. */
  72763. Vector3.prototype.multiply = function (otherVector) {
  72764. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  72765. };
  72766. /**
  72767. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  72768. * @param otherVector defines the second operand
  72769. * @param result defines the Vector3 object where to store the result
  72770. * @returns the current Vector3
  72771. */
  72772. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  72773. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  72774. };
  72775. /**
  72776. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  72777. * @param x defines the x coordinate of the operand
  72778. * @param y defines the y coordinate of the operand
  72779. * @param z defines the z coordinate of the operand
  72780. * @returns the new Vector3
  72781. */
  72782. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  72783. return new Vector3(this.x * x, this.y * y, this.z * z);
  72784. };
  72785. /**
  72786. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  72787. * @param otherVector defines the second operand
  72788. * @returns the new Vector3
  72789. */
  72790. Vector3.prototype.divide = function (otherVector) {
  72791. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  72792. };
  72793. /**
  72794. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  72795. * @param otherVector defines the second operand
  72796. * @param result defines the Vector3 object where to store the result
  72797. * @returns the current Vector3
  72798. */
  72799. Vector3.prototype.divideToRef = function (otherVector, result) {
  72800. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  72801. };
  72802. /**
  72803. * Divides the current Vector3 coordinates by the given ones.
  72804. * @param otherVector defines the second operand
  72805. * @returns the current updated Vector3
  72806. */
  72807. Vector3.prototype.divideInPlace = function (otherVector) {
  72808. return this.divideToRef(otherVector, this);
  72809. };
  72810. /**
  72811. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  72812. * @param other defines the second operand
  72813. * @returns the current updated Vector3
  72814. */
  72815. Vector3.prototype.minimizeInPlace = function (other) {
  72816. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  72817. };
  72818. /**
  72819. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  72820. * @param other defines the second operand
  72821. * @returns the current updated Vector3
  72822. */
  72823. Vector3.prototype.maximizeInPlace = function (other) {
  72824. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  72825. };
  72826. /**
  72827. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  72828. * @param x defines the x coordinate of the operand
  72829. * @param y defines the y coordinate of the operand
  72830. * @param z defines the z coordinate of the operand
  72831. * @returns the current updated Vector3
  72832. */
  72833. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  72834. if (x < this.x) {
  72835. this.x = x;
  72836. }
  72837. if (y < this.y) {
  72838. this.y = y;
  72839. }
  72840. if (z < this.z) {
  72841. this.z = z;
  72842. }
  72843. return this;
  72844. };
  72845. /**
  72846. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  72847. * @param x defines the x coordinate of the operand
  72848. * @param y defines the y coordinate of the operand
  72849. * @param z defines the z coordinate of the operand
  72850. * @returns the current updated Vector3
  72851. */
  72852. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  72853. if (x > this.x) {
  72854. this.x = x;
  72855. }
  72856. if (y > this.y) {
  72857. this.y = y;
  72858. }
  72859. if (z > this.z) {
  72860. this.z = z;
  72861. }
  72862. return this;
  72863. };
  72864. /**
  72865. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  72866. * Check if is non uniform within a certain amount of decimal places to account for this
  72867. * @param epsilon the amount the values can differ
  72868. * @returns if the the vector is non uniform to a certain number of decimal places
  72869. */
  72870. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  72871. var absX = Math.abs(this.x);
  72872. var absY = Math.abs(this.y);
  72873. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  72874. return true;
  72875. }
  72876. var absZ = Math.abs(this.z);
  72877. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  72878. return true;
  72879. }
  72880. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  72881. return true;
  72882. }
  72883. return false;
  72884. };
  72885. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  72886. /**
  72887. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  72888. */
  72889. get: function () {
  72890. var absX = Math.abs(this.x);
  72891. var absY = Math.abs(this.y);
  72892. if (absX !== absY) {
  72893. return true;
  72894. }
  72895. var absZ = Math.abs(this.z);
  72896. if (absX !== absZ) {
  72897. return true;
  72898. }
  72899. if (absY !== absZ) {
  72900. return true;
  72901. }
  72902. return false;
  72903. },
  72904. enumerable: true,
  72905. configurable: true
  72906. });
  72907. /**
  72908. * Gets a new Vector3 from current Vector3 floored values
  72909. * @returns a new Vector3
  72910. */
  72911. Vector3.prototype.floor = function () {
  72912. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  72913. };
  72914. /**
  72915. * Gets a new Vector3 from current Vector3 floored values
  72916. * @returns a new Vector3
  72917. */
  72918. Vector3.prototype.fract = function () {
  72919. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  72920. };
  72921. // Properties
  72922. /**
  72923. * Gets the length of the Vector3
  72924. * @returns the length of the Vecto3
  72925. */
  72926. Vector3.prototype.length = function () {
  72927. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  72928. };
  72929. /**
  72930. * Gets the squared length of the Vector3
  72931. * @returns squared length of the Vector3
  72932. */
  72933. Vector3.prototype.lengthSquared = function () {
  72934. return (this.x * this.x + this.y * this.y + this.z * this.z);
  72935. };
  72936. /**
  72937. * Normalize the current Vector3.
  72938. * Please note that this is an in place operation.
  72939. * @returns the current updated Vector3
  72940. */
  72941. Vector3.prototype.normalize = function () {
  72942. return this.normalizeFromLength(this.length());
  72943. };
  72944. /**
  72945. * Reorders the x y z properties of the vector in place
  72946. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  72947. * @returns the current updated vector
  72948. */
  72949. Vector3.prototype.reorderInPlace = function (order) {
  72950. var _this = this;
  72951. order = order.toLowerCase();
  72952. if (order === "xyz") {
  72953. return this;
  72954. }
  72955. MathTmp.Vector3[0].copyFrom(this);
  72956. ["x", "y", "z"].forEach(function (val, i) {
  72957. _this[val] = MathTmp.Vector3[0][order[i]];
  72958. });
  72959. return this;
  72960. };
  72961. /**
  72962. * Rotates the vector around 0,0,0 by a quaternion
  72963. * @param quaternion the rotation quaternion
  72964. * @param result vector to store the result
  72965. * @returns the resulting vector
  72966. */
  72967. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  72968. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  72969. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  72970. return result;
  72971. };
  72972. /**
  72973. * Rotates a vector around a given point
  72974. * @param quaternion the rotation quaternion
  72975. * @param point the point to rotate around
  72976. * @param result vector to store the result
  72977. * @returns the resulting vector
  72978. */
  72979. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  72980. this.subtractToRef(point, MathTmp.Vector3[0]);
  72981. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  72982. point.addToRef(MathTmp.Vector3[0], result);
  72983. return result;
  72984. };
  72985. /**
  72986. * Normalize the current Vector3 with the given input length.
  72987. * Please note that this is an in place operation.
  72988. * @param len the length of the vector
  72989. * @returns the current updated Vector3
  72990. */
  72991. Vector3.prototype.normalizeFromLength = function (len) {
  72992. if (len === 0 || len === 1.0) {
  72993. return this;
  72994. }
  72995. return this.scaleInPlace(1.0 / len);
  72996. };
  72997. /**
  72998. * Normalize the current Vector3 to a new vector
  72999. * @returns the new Vector3
  73000. */
  73001. Vector3.prototype.normalizeToNew = function () {
  73002. var normalized = new Vector3(0, 0, 0);
  73003. this.normalizeToRef(normalized);
  73004. return normalized;
  73005. };
  73006. /**
  73007. * Normalize the current Vector3 to the reference
  73008. * @param reference define the Vector3 to update
  73009. * @returns the updated Vector3
  73010. */
  73011. Vector3.prototype.normalizeToRef = function (reference) {
  73012. var len = this.length();
  73013. if (len === 0 || len === 1.0) {
  73014. return reference.copyFromFloats(this.x, this.y, this.z);
  73015. }
  73016. return this.scaleToRef(1.0 / len, reference);
  73017. };
  73018. /**
  73019. * Creates a new Vector3 copied from the current Vector3
  73020. * @returns the new Vector3
  73021. */
  73022. Vector3.prototype.clone = function () {
  73023. return new Vector3(this.x, this.y, this.z);
  73024. };
  73025. /**
  73026. * Copies the given vector coordinates to the current Vector3 ones
  73027. * @param source defines the source Vector3
  73028. * @returns the current updated Vector3
  73029. */
  73030. Vector3.prototype.copyFrom = function (source) {
  73031. return this.copyFromFloats(source.x, source.y, source.z);
  73032. };
  73033. /**
  73034. * Copies the given floats to the current Vector3 coordinates
  73035. * @param x defines the x coordinate of the operand
  73036. * @param y defines the y coordinate of the operand
  73037. * @param z defines the z coordinate of the operand
  73038. * @returns the current updated Vector3
  73039. */
  73040. Vector3.prototype.copyFromFloats = function (x, y, z) {
  73041. this.x = x;
  73042. this.y = y;
  73043. this.z = z;
  73044. return this;
  73045. };
  73046. /**
  73047. * Copies the given floats to the current Vector3 coordinates
  73048. * @param x defines the x coordinate of the operand
  73049. * @param y defines the y coordinate of the operand
  73050. * @param z defines the z coordinate of the operand
  73051. * @returns the current updated Vector3
  73052. */
  73053. Vector3.prototype.set = function (x, y, z) {
  73054. return this.copyFromFloats(x, y, z);
  73055. };
  73056. /**
  73057. * Copies the given float to the current Vector3 coordinates
  73058. * @param v defines the x, y and z coordinates of the operand
  73059. * @returns the current updated Vector3
  73060. */
  73061. Vector3.prototype.setAll = function (v) {
  73062. this.x = this.y = this.z = v;
  73063. return this;
  73064. };
  73065. // Statics
  73066. /**
  73067. * Get the clip factor between two vectors
  73068. * @param vector0 defines the first operand
  73069. * @param vector1 defines the second operand
  73070. * @param axis defines the axis to use
  73071. * @param size defines the size along the axis
  73072. * @returns the clip factor
  73073. */
  73074. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  73075. var d0 = Vector3.Dot(vector0, axis) - size;
  73076. var d1 = Vector3.Dot(vector1, axis) - size;
  73077. var s = d0 / (d0 - d1);
  73078. return s;
  73079. };
  73080. /**
  73081. * Get angle between two vectors
  73082. * @param vector0 angle between vector0 and vector1
  73083. * @param vector1 angle between vector0 and vector1
  73084. * @param normal direction of the normal
  73085. * @return the angle between vector0 and vector1
  73086. */
  73087. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  73088. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  73089. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  73090. var dot = Vector3.Dot(v0, v1);
  73091. var n = MathTmp.Vector3[3];
  73092. Vector3.CrossToRef(v0, v1, n);
  73093. if (Vector3.Dot(n, normal) > 0) {
  73094. return Math.acos(dot);
  73095. }
  73096. return -Math.acos(dot);
  73097. };
  73098. /**
  73099. * Returns a new Vector3 set from the index "offset" of the given array
  73100. * @param array defines the source array
  73101. * @param offset defines the offset in the source array
  73102. * @returns the new Vector3
  73103. */
  73104. Vector3.FromArray = function (array, offset) {
  73105. if (offset === void 0) { offset = 0; }
  73106. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  73107. };
  73108. /**
  73109. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  73110. * This function is deprecated. Use FromArray instead
  73111. * @param array defines the source array
  73112. * @param offset defines the offset in the source array
  73113. * @returns the new Vector3
  73114. */
  73115. Vector3.FromFloatArray = function (array, offset) {
  73116. return Vector3.FromArray(array, offset);
  73117. };
  73118. /**
  73119. * Sets the given vector "result" with the element values from the index "offset" of the given array
  73120. * @param array defines the source array
  73121. * @param offset defines the offset in the source array
  73122. * @param result defines the Vector3 where to store the result
  73123. */
  73124. Vector3.FromArrayToRef = function (array, offset, result) {
  73125. result.x = array[offset];
  73126. result.y = array[offset + 1];
  73127. result.z = array[offset + 2];
  73128. };
  73129. /**
  73130. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  73131. * This function is deprecated. Use FromArrayToRef instead.
  73132. * @param array defines the source array
  73133. * @param offset defines the offset in the source array
  73134. * @param result defines the Vector3 where to store the result
  73135. */
  73136. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  73137. return Vector3.FromArrayToRef(array, offset, result);
  73138. };
  73139. /**
  73140. * Sets the given vector "result" with the given floats.
  73141. * @param x defines the x coordinate of the source
  73142. * @param y defines the y coordinate of the source
  73143. * @param z defines the z coordinate of the source
  73144. * @param result defines the Vector3 where to store the result
  73145. */
  73146. Vector3.FromFloatsToRef = function (x, y, z, result) {
  73147. result.copyFromFloats(x, y, z);
  73148. };
  73149. /**
  73150. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  73151. * @returns a new empty Vector3
  73152. */
  73153. Vector3.Zero = function () {
  73154. return new Vector3(0.0, 0.0, 0.0);
  73155. };
  73156. /**
  73157. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  73158. * @returns a new unit Vector3
  73159. */
  73160. Vector3.One = function () {
  73161. return new Vector3(1.0, 1.0, 1.0);
  73162. };
  73163. /**
  73164. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  73165. * @returns a new up Vector3
  73166. */
  73167. Vector3.Up = function () {
  73168. return new Vector3(0.0, 1.0, 0.0);
  73169. };
  73170. Object.defineProperty(Vector3, "UpReadOnly", {
  73171. /**
  73172. * Gets a up Vector3 that must not be updated
  73173. */
  73174. get: function () {
  73175. return Vector3._UpReadOnly;
  73176. },
  73177. enumerable: true,
  73178. configurable: true
  73179. });
  73180. /**
  73181. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  73182. * @returns a new down Vector3
  73183. */
  73184. Vector3.Down = function () {
  73185. return new Vector3(0.0, -1.0, 0.0);
  73186. };
  73187. /**
  73188. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  73189. * @returns a new forward Vector3
  73190. */
  73191. Vector3.Forward = function () {
  73192. return new Vector3(0.0, 0.0, 1.0);
  73193. };
  73194. /**
  73195. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  73196. * @returns a new forward Vector3
  73197. */
  73198. Vector3.Backward = function () {
  73199. return new Vector3(0.0, 0.0, -1.0);
  73200. };
  73201. /**
  73202. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  73203. * @returns a new right Vector3
  73204. */
  73205. Vector3.Right = function () {
  73206. return new Vector3(1.0, 0.0, 0.0);
  73207. };
  73208. /**
  73209. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  73210. * @returns a new left Vector3
  73211. */
  73212. Vector3.Left = function () {
  73213. return new Vector3(-1.0, 0.0, 0.0);
  73214. };
  73215. /**
  73216. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  73217. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73218. * @param vector defines the Vector3 to transform
  73219. * @param transformation defines the transformation matrix
  73220. * @returns the transformed Vector3
  73221. */
  73222. Vector3.TransformCoordinates = function (vector, transformation) {
  73223. var result = Vector3.Zero();
  73224. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  73225. return result;
  73226. };
  73227. /**
  73228. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  73229. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73230. * @param vector defines the Vector3 to transform
  73231. * @param transformation defines the transformation matrix
  73232. * @param result defines the Vector3 where to store the result
  73233. */
  73234. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  73235. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  73236. };
  73237. /**
  73238. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  73239. * This method computes tranformed coordinates only, not transformed direction vectors
  73240. * @param x define the x coordinate of the source vector
  73241. * @param y define the y coordinate of the source vector
  73242. * @param z define the z coordinate of the source vector
  73243. * @param transformation defines the transformation matrix
  73244. * @param result defines the Vector3 where to store the result
  73245. */
  73246. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  73247. var m = transformation.m;
  73248. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  73249. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  73250. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  73251. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  73252. result.x = rx * rw;
  73253. result.y = ry * rw;
  73254. result.z = rz * rw;
  73255. };
  73256. /**
  73257. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  73258. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73259. * @param vector defines the Vector3 to transform
  73260. * @param transformation defines the transformation matrix
  73261. * @returns the new Vector3
  73262. */
  73263. Vector3.TransformNormal = function (vector, transformation) {
  73264. var result = Vector3.Zero();
  73265. Vector3.TransformNormalToRef(vector, transformation, result);
  73266. return result;
  73267. };
  73268. /**
  73269. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  73270. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73271. * @param vector defines the Vector3 to transform
  73272. * @param transformation defines the transformation matrix
  73273. * @param result defines the Vector3 where to store the result
  73274. */
  73275. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  73276. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  73277. };
  73278. /**
  73279. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  73280. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73281. * @param x define the x coordinate of the source vector
  73282. * @param y define the y coordinate of the source vector
  73283. * @param z define the z coordinate of the source vector
  73284. * @param transformation defines the transformation matrix
  73285. * @param result defines the Vector3 where to store the result
  73286. */
  73287. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  73288. var m = transformation.m;
  73289. result.x = x * m[0] + y * m[4] + z * m[8];
  73290. result.y = x * m[1] + y * m[5] + z * m[9];
  73291. result.z = x * m[2] + y * m[6] + z * m[10];
  73292. };
  73293. /**
  73294. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  73295. * @param value1 defines the first control point
  73296. * @param value2 defines the second control point
  73297. * @param value3 defines the third control point
  73298. * @param value4 defines the fourth control point
  73299. * @param amount defines the amount on the spline to use
  73300. * @returns the new Vector3
  73301. */
  73302. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  73303. var squared = amount * amount;
  73304. var cubed = amount * squared;
  73305. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  73306. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  73307. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  73308. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  73309. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  73310. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  73311. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  73312. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  73313. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  73314. return new Vector3(x, y, z);
  73315. };
  73316. /**
  73317. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  73318. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73319. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73320. * @param value defines the current value
  73321. * @param min defines the lower range value
  73322. * @param max defines the upper range value
  73323. * @returns the new Vector3
  73324. */
  73325. Vector3.Clamp = function (value, min, max) {
  73326. var v = new Vector3();
  73327. Vector3.ClampToRef(value, min, max, v);
  73328. return v;
  73329. };
  73330. /**
  73331. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  73332. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73333. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73334. * @param value defines the current value
  73335. * @param min defines the lower range value
  73336. * @param max defines the upper range value
  73337. * @param result defines the Vector3 where to store the result
  73338. */
  73339. Vector3.ClampToRef = function (value, min, max, result) {
  73340. var x = value.x;
  73341. x = (x > max.x) ? max.x : x;
  73342. x = (x < min.x) ? min.x : x;
  73343. var y = value.y;
  73344. y = (y > max.y) ? max.y : y;
  73345. y = (y < min.y) ? min.y : y;
  73346. var z = value.z;
  73347. z = (z > max.z) ? max.z : z;
  73348. z = (z < min.z) ? min.z : z;
  73349. result.copyFromFloats(x, y, z);
  73350. };
  73351. /**
  73352. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  73353. * @param value1 defines the first control point
  73354. * @param tangent1 defines the first tangent vector
  73355. * @param value2 defines the second control point
  73356. * @param tangent2 defines the second tangent vector
  73357. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  73358. * @returns the new Vector3
  73359. */
  73360. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  73361. var squared = amount * amount;
  73362. var cubed = amount * squared;
  73363. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  73364. var part2 = (-2.0 * cubed) + (3.0 * squared);
  73365. var part3 = (cubed - (2.0 * squared)) + amount;
  73366. var part4 = cubed - squared;
  73367. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  73368. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  73369. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  73370. return new Vector3(x, y, z);
  73371. };
  73372. /**
  73373. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  73374. * @param start defines the start value
  73375. * @param end defines the end value
  73376. * @param amount max defines amount between both (between 0 and 1)
  73377. * @returns the new Vector3
  73378. */
  73379. Vector3.Lerp = function (start, end, amount) {
  73380. var result = new Vector3(0, 0, 0);
  73381. Vector3.LerpToRef(start, end, amount, result);
  73382. return result;
  73383. };
  73384. /**
  73385. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  73386. * @param start defines the start value
  73387. * @param end defines the end value
  73388. * @param amount max defines amount between both (between 0 and 1)
  73389. * @param result defines the Vector3 where to store the result
  73390. */
  73391. Vector3.LerpToRef = function (start, end, amount, result) {
  73392. result.x = start.x + ((end.x - start.x) * amount);
  73393. result.y = start.y + ((end.y - start.y) * amount);
  73394. result.z = start.z + ((end.z - start.z) * amount);
  73395. };
  73396. /**
  73397. * Returns the dot product (float) between the vectors "left" and "right"
  73398. * @param left defines the left operand
  73399. * @param right defines the right operand
  73400. * @returns the dot product
  73401. */
  73402. Vector3.Dot = function (left, right) {
  73403. return (left.x * right.x + left.y * right.y + left.z * right.z);
  73404. };
  73405. /**
  73406. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  73407. * The cross product is then orthogonal to both "left" and "right"
  73408. * @param left defines the left operand
  73409. * @param right defines the right operand
  73410. * @returns the cross product
  73411. */
  73412. Vector3.Cross = function (left, right) {
  73413. var result = Vector3.Zero();
  73414. Vector3.CrossToRef(left, right, result);
  73415. return result;
  73416. };
  73417. /**
  73418. * Sets the given vector "result" with the cross product of "left" and "right"
  73419. * The cross product is then orthogonal to both "left" and "right"
  73420. * @param left defines the left operand
  73421. * @param right defines the right operand
  73422. * @param result defines the Vector3 where to store the result
  73423. */
  73424. Vector3.CrossToRef = function (left, right, result) {
  73425. var x = left.y * right.z - left.z * right.y;
  73426. var y = left.z * right.x - left.x * right.z;
  73427. var z = left.x * right.y - left.y * right.x;
  73428. result.copyFromFloats(x, y, z);
  73429. };
  73430. /**
  73431. * Returns a new Vector3 as the normalization of the given vector
  73432. * @param vector defines the Vector3 to normalize
  73433. * @returns the new Vector3
  73434. */
  73435. Vector3.Normalize = function (vector) {
  73436. var result = Vector3.Zero();
  73437. Vector3.NormalizeToRef(vector, result);
  73438. return result;
  73439. };
  73440. /**
  73441. * Sets the given vector "result" with the normalization of the given first vector
  73442. * @param vector defines the Vector3 to normalize
  73443. * @param result defines the Vector3 where to store the result
  73444. */
  73445. Vector3.NormalizeToRef = function (vector, result) {
  73446. vector.normalizeToRef(result);
  73447. };
  73448. /**
  73449. * Project a Vector3 onto screen space
  73450. * @param vector defines the Vector3 to project
  73451. * @param world defines the world matrix to use
  73452. * @param transform defines the transform (view x projection) matrix to use
  73453. * @param viewport defines the screen viewport to use
  73454. * @returns the new Vector3
  73455. */
  73456. Vector3.Project = function (vector, world, transform, viewport) {
  73457. var cw = viewport.width;
  73458. var ch = viewport.height;
  73459. var cx = viewport.x;
  73460. var cy = viewport.y;
  73461. var viewportMatrix = MathTmp.Matrix[1];
  73462. Matrix.FromValuesToRef(cw / 2.0, 0, 0, 0, 0, -ch / 2.0, 0, 0, 0, 0, 0.5, 0, cx + cw / 2.0, ch / 2.0 + cy, 0.5, 1, viewportMatrix);
  73463. var matrix = MathTmp.Matrix[0];
  73464. world.multiplyToRef(transform, matrix);
  73465. matrix.multiplyToRef(viewportMatrix, matrix);
  73466. return Vector3.TransformCoordinates(vector, matrix);
  73467. };
  73468. /** @hidden */
  73469. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  73470. Vector3.TransformCoordinatesToRef(source, matrix, result);
  73471. var m = matrix.m;
  73472. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  73473. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  73474. result.scaleInPlace(1.0 / num);
  73475. }
  73476. };
  73477. /**
  73478. * Unproject from screen space to object space
  73479. * @param source defines the screen space Vector3 to use
  73480. * @param viewportWidth defines the current width of the viewport
  73481. * @param viewportHeight defines the current height of the viewport
  73482. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73483. * @param transform defines the transform (view x projection) matrix to use
  73484. * @returns the new Vector3
  73485. */
  73486. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  73487. var matrix = MathTmp.Matrix[0];
  73488. world.multiplyToRef(transform, matrix);
  73489. matrix.invert();
  73490. source.x = source.x / viewportWidth * 2 - 1;
  73491. source.y = -(source.y / viewportHeight * 2 - 1);
  73492. var vector = new Vector3();
  73493. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  73494. return vector;
  73495. };
  73496. /**
  73497. * Unproject from screen space to object space
  73498. * @param source defines the screen space Vector3 to use
  73499. * @param viewportWidth defines the current width of the viewport
  73500. * @param viewportHeight defines the current height of the viewport
  73501. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73502. * @param view defines the view matrix to use
  73503. * @param projection defines the projection matrix to use
  73504. * @returns the new Vector3
  73505. */
  73506. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  73507. var result = Vector3.Zero();
  73508. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  73509. return result;
  73510. };
  73511. /**
  73512. * Unproject from screen space to object space
  73513. * @param source defines the screen space Vector3 to use
  73514. * @param viewportWidth defines the current width of the viewport
  73515. * @param viewportHeight defines the current height of the viewport
  73516. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73517. * @param view defines the view matrix to use
  73518. * @param projection defines the projection matrix to use
  73519. * @param result defines the Vector3 where to store the result
  73520. */
  73521. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  73522. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  73523. };
  73524. /**
  73525. * Unproject from screen space to object space
  73526. * @param sourceX defines the screen space x coordinate to use
  73527. * @param sourceY defines the screen space y coordinate to use
  73528. * @param sourceZ defines the screen space z coordinate to use
  73529. * @param viewportWidth defines the current width of the viewport
  73530. * @param viewportHeight defines the current height of the viewport
  73531. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73532. * @param view defines the view matrix to use
  73533. * @param projection defines the projection matrix to use
  73534. * @param result defines the Vector3 where to store the result
  73535. */
  73536. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  73537. var matrix = MathTmp.Matrix[0];
  73538. world.multiplyToRef(view, matrix);
  73539. matrix.multiplyToRef(projection, matrix);
  73540. matrix.invert();
  73541. var screenSource = MathTmp.Vector3[0];
  73542. screenSource.x = sourceX / viewportWidth * 2 - 1;
  73543. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  73544. screenSource.z = 2 * sourceZ - 1.0;
  73545. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  73546. };
  73547. /**
  73548. * Gets the minimal coordinate values between two Vector3
  73549. * @param left defines the first operand
  73550. * @param right defines the second operand
  73551. * @returns the new Vector3
  73552. */
  73553. Vector3.Minimize = function (left, right) {
  73554. var min = left.clone();
  73555. min.minimizeInPlace(right);
  73556. return min;
  73557. };
  73558. /**
  73559. * Gets the maximal coordinate values between two Vector3
  73560. * @param left defines the first operand
  73561. * @param right defines the second operand
  73562. * @returns the new Vector3
  73563. */
  73564. Vector3.Maximize = function (left, right) {
  73565. var max = left.clone();
  73566. max.maximizeInPlace(right);
  73567. return max;
  73568. };
  73569. /**
  73570. * Returns the distance between the vectors "value1" and "value2"
  73571. * @param value1 defines the first operand
  73572. * @param value2 defines the second operand
  73573. * @returns the distance
  73574. */
  73575. Vector3.Distance = function (value1, value2) {
  73576. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  73577. };
  73578. /**
  73579. * Returns the squared distance between the vectors "value1" and "value2"
  73580. * @param value1 defines the first operand
  73581. * @param value2 defines the second operand
  73582. * @returns the squared distance
  73583. */
  73584. Vector3.DistanceSquared = function (value1, value2) {
  73585. var x = value1.x - value2.x;
  73586. var y = value1.y - value2.y;
  73587. var z = value1.z - value2.z;
  73588. return (x * x) + (y * y) + (z * z);
  73589. };
  73590. /**
  73591. * Returns a new Vector3 located at the center between "value1" and "value2"
  73592. * @param value1 defines the first operand
  73593. * @param value2 defines the second operand
  73594. * @returns the new Vector3
  73595. */
  73596. Vector3.Center = function (value1, value2) {
  73597. var center = value1.add(value2);
  73598. center.scaleInPlace(0.5);
  73599. return center;
  73600. };
  73601. /**
  73602. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  73603. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  73604. * to something in order to rotate it from its local system to the given target system
  73605. * Note: axis1, axis2 and axis3 are normalized during this operation
  73606. * @param axis1 defines the first axis
  73607. * @param axis2 defines the second axis
  73608. * @param axis3 defines the third axis
  73609. * @returns a new Vector3
  73610. */
  73611. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  73612. var rotation = Vector3.Zero();
  73613. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  73614. return rotation;
  73615. };
  73616. /**
  73617. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  73618. * @param axis1 defines the first axis
  73619. * @param axis2 defines the second axis
  73620. * @param axis3 defines the third axis
  73621. * @param ref defines the Vector3 where to store the result
  73622. */
  73623. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  73624. var quat = MathTmp.Quaternion[0];
  73625. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  73626. quat.toEulerAnglesToRef(ref);
  73627. };
  73628. Vector3._UpReadOnly = Vector3.Up();
  73629. return Vector3;
  73630. }());
  73631. /**
  73632. * Vector4 class created for EulerAngle class conversion to Quaternion
  73633. */
  73634. var Vector4 = /** @class */ (function () {
  73635. /**
  73636. * Creates a Vector4 object from the given floats.
  73637. * @param x x value of the vector
  73638. * @param y y value of the vector
  73639. * @param z z value of the vector
  73640. * @param w w value of the vector
  73641. */
  73642. function Vector4(
  73643. /** x value of the vector */
  73644. x,
  73645. /** y value of the vector */
  73646. y,
  73647. /** z value of the vector */
  73648. z,
  73649. /** w value of the vector */
  73650. w) {
  73651. this.x = x;
  73652. this.y = y;
  73653. this.z = z;
  73654. this.w = w;
  73655. }
  73656. /**
  73657. * Returns the string with the Vector4 coordinates.
  73658. * @returns a string containing all the vector values
  73659. */
  73660. Vector4.prototype.toString = function () {
  73661. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  73662. };
  73663. /**
  73664. * Returns the string "Vector4".
  73665. * @returns "Vector4"
  73666. */
  73667. Vector4.prototype.getClassName = function () {
  73668. return "Vector4";
  73669. };
  73670. /**
  73671. * Returns the Vector4 hash code.
  73672. * @returns a unique hash code
  73673. */
  73674. Vector4.prototype.getHashCode = function () {
  73675. var hash = this.x || 0;
  73676. hash = (hash * 397) ^ (this.y || 0);
  73677. hash = (hash * 397) ^ (this.z || 0);
  73678. hash = (hash * 397) ^ (this.w || 0);
  73679. return hash;
  73680. };
  73681. // Operators
  73682. /**
  73683. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  73684. * @returns the resulting array
  73685. */
  73686. Vector4.prototype.asArray = function () {
  73687. var result = new Array();
  73688. this.toArray(result, 0);
  73689. return result;
  73690. };
  73691. /**
  73692. * Populates the given array from the given index with the Vector4 coordinates.
  73693. * @param array array to populate
  73694. * @param index index of the array to start at (default: 0)
  73695. * @returns the Vector4.
  73696. */
  73697. Vector4.prototype.toArray = function (array, index) {
  73698. if (index === undefined) {
  73699. index = 0;
  73700. }
  73701. array[index] = this.x;
  73702. array[index + 1] = this.y;
  73703. array[index + 2] = this.z;
  73704. array[index + 3] = this.w;
  73705. return this;
  73706. };
  73707. /**
  73708. * Adds the given vector to the current Vector4.
  73709. * @param otherVector the vector to add
  73710. * @returns the updated Vector4.
  73711. */
  73712. Vector4.prototype.addInPlace = function (otherVector) {
  73713. this.x += otherVector.x;
  73714. this.y += otherVector.y;
  73715. this.z += otherVector.z;
  73716. this.w += otherVector.w;
  73717. return this;
  73718. };
  73719. /**
  73720. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  73721. * @param otherVector the vector to add
  73722. * @returns the resulting vector
  73723. */
  73724. Vector4.prototype.add = function (otherVector) {
  73725. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  73726. };
  73727. /**
  73728. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  73729. * @param otherVector the vector to add
  73730. * @param result the vector to store the result
  73731. * @returns the current Vector4.
  73732. */
  73733. Vector4.prototype.addToRef = function (otherVector, result) {
  73734. result.x = this.x + otherVector.x;
  73735. result.y = this.y + otherVector.y;
  73736. result.z = this.z + otherVector.z;
  73737. result.w = this.w + otherVector.w;
  73738. return this;
  73739. };
  73740. /**
  73741. * Subtract in place the given vector from the current Vector4.
  73742. * @param otherVector the vector to subtract
  73743. * @returns the updated Vector4.
  73744. */
  73745. Vector4.prototype.subtractInPlace = function (otherVector) {
  73746. this.x -= otherVector.x;
  73747. this.y -= otherVector.y;
  73748. this.z -= otherVector.z;
  73749. this.w -= otherVector.w;
  73750. return this;
  73751. };
  73752. /**
  73753. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  73754. * @param otherVector the vector to add
  73755. * @returns the new vector with the result
  73756. */
  73757. Vector4.prototype.subtract = function (otherVector) {
  73758. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  73759. };
  73760. /**
  73761. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  73762. * @param otherVector the vector to subtract
  73763. * @param result the vector to store the result
  73764. * @returns the current Vector4.
  73765. */
  73766. Vector4.prototype.subtractToRef = function (otherVector, result) {
  73767. result.x = this.x - otherVector.x;
  73768. result.y = this.y - otherVector.y;
  73769. result.z = this.z - otherVector.z;
  73770. result.w = this.w - otherVector.w;
  73771. return this;
  73772. };
  73773. /**
  73774. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73775. */
  73776. /**
  73777. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73778. * @param x value to subtract
  73779. * @param y value to subtract
  73780. * @param z value to subtract
  73781. * @param w value to subtract
  73782. * @returns new vector containing the result
  73783. */
  73784. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  73785. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  73786. };
  73787. /**
  73788. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73789. * @param x value to subtract
  73790. * @param y value to subtract
  73791. * @param z value to subtract
  73792. * @param w value to subtract
  73793. * @param result the vector to store the result in
  73794. * @returns the current Vector4.
  73795. */
  73796. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  73797. result.x = this.x - x;
  73798. result.y = this.y - y;
  73799. result.z = this.z - z;
  73800. result.w = this.w - w;
  73801. return this;
  73802. };
  73803. /**
  73804. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  73805. * @returns a new vector with the negated values
  73806. */
  73807. Vector4.prototype.negate = function () {
  73808. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  73809. };
  73810. /**
  73811. * Multiplies the current Vector4 coordinates by scale (float).
  73812. * @param scale the number to scale with
  73813. * @returns the updated Vector4.
  73814. */
  73815. Vector4.prototype.scaleInPlace = function (scale) {
  73816. this.x *= scale;
  73817. this.y *= scale;
  73818. this.z *= scale;
  73819. this.w *= scale;
  73820. return this;
  73821. };
  73822. /**
  73823. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  73824. * @param scale the number to scale with
  73825. * @returns a new vector with the result
  73826. */
  73827. Vector4.prototype.scale = function (scale) {
  73828. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  73829. };
  73830. /**
  73831. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  73832. * @param scale the number to scale with
  73833. * @param result a vector to store the result in
  73834. * @returns the current Vector4.
  73835. */
  73836. Vector4.prototype.scaleToRef = function (scale, result) {
  73837. result.x = this.x * scale;
  73838. result.y = this.y * scale;
  73839. result.z = this.z * scale;
  73840. result.w = this.w * scale;
  73841. return this;
  73842. };
  73843. /**
  73844. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  73845. * @param scale defines the scale factor
  73846. * @param result defines the Vector4 object where to store the result
  73847. * @returns the unmodified current Vector4
  73848. */
  73849. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  73850. result.x += this.x * scale;
  73851. result.y += this.y * scale;
  73852. result.z += this.z * scale;
  73853. result.w += this.w * scale;
  73854. return this;
  73855. };
  73856. /**
  73857. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  73858. * @param otherVector the vector to compare against
  73859. * @returns true if they are equal
  73860. */
  73861. Vector4.prototype.equals = function (otherVector) {
  73862. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  73863. };
  73864. /**
  73865. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  73866. * @param otherVector vector to compare against
  73867. * @param epsilon (Default: very small number)
  73868. * @returns true if they are equal
  73869. */
  73870. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  73871. if (epsilon === void 0) { epsilon = Epsilon; }
  73872. return otherVector
  73873. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  73874. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  73875. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  73876. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  73877. };
  73878. /**
  73879. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  73880. * @param x x value to compare against
  73881. * @param y y value to compare against
  73882. * @param z z value to compare against
  73883. * @param w w value to compare against
  73884. * @returns true if equal
  73885. */
  73886. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  73887. return this.x === x && this.y === y && this.z === z && this.w === w;
  73888. };
  73889. /**
  73890. * Multiplies in place the current Vector4 by the given one.
  73891. * @param otherVector vector to multiple with
  73892. * @returns the updated Vector4.
  73893. */
  73894. Vector4.prototype.multiplyInPlace = function (otherVector) {
  73895. this.x *= otherVector.x;
  73896. this.y *= otherVector.y;
  73897. this.z *= otherVector.z;
  73898. this.w *= otherVector.w;
  73899. return this;
  73900. };
  73901. /**
  73902. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  73903. * @param otherVector vector to multiple with
  73904. * @returns resulting new vector
  73905. */
  73906. Vector4.prototype.multiply = function (otherVector) {
  73907. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  73908. };
  73909. /**
  73910. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  73911. * @param otherVector vector to multiple with
  73912. * @param result vector to store the result
  73913. * @returns the current Vector4.
  73914. */
  73915. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  73916. result.x = this.x * otherVector.x;
  73917. result.y = this.y * otherVector.y;
  73918. result.z = this.z * otherVector.z;
  73919. result.w = this.w * otherVector.w;
  73920. return this;
  73921. };
  73922. /**
  73923. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  73924. * @param x x value multiply with
  73925. * @param y y value multiply with
  73926. * @param z z value multiply with
  73927. * @param w w value multiply with
  73928. * @returns resulting new vector
  73929. */
  73930. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  73931. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  73932. };
  73933. /**
  73934. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  73935. * @param otherVector vector to devide with
  73936. * @returns resulting new vector
  73937. */
  73938. Vector4.prototype.divide = function (otherVector) {
  73939. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  73940. };
  73941. /**
  73942. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  73943. * @param otherVector vector to devide with
  73944. * @param result vector to store the result
  73945. * @returns the current Vector4.
  73946. */
  73947. Vector4.prototype.divideToRef = function (otherVector, result) {
  73948. result.x = this.x / otherVector.x;
  73949. result.y = this.y / otherVector.y;
  73950. result.z = this.z / otherVector.z;
  73951. result.w = this.w / otherVector.w;
  73952. return this;
  73953. };
  73954. /**
  73955. * Divides the current Vector3 coordinates by the given ones.
  73956. * @param otherVector vector to devide with
  73957. * @returns the updated Vector3.
  73958. */
  73959. Vector4.prototype.divideInPlace = function (otherVector) {
  73960. return this.divideToRef(otherVector, this);
  73961. };
  73962. /**
  73963. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  73964. * @param other defines the second operand
  73965. * @returns the current updated Vector4
  73966. */
  73967. Vector4.prototype.minimizeInPlace = function (other) {
  73968. if (other.x < this.x) {
  73969. this.x = other.x;
  73970. }
  73971. if (other.y < this.y) {
  73972. this.y = other.y;
  73973. }
  73974. if (other.z < this.z) {
  73975. this.z = other.z;
  73976. }
  73977. if (other.w < this.w) {
  73978. this.w = other.w;
  73979. }
  73980. return this;
  73981. };
  73982. /**
  73983. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  73984. * @param other defines the second operand
  73985. * @returns the current updated Vector4
  73986. */
  73987. Vector4.prototype.maximizeInPlace = function (other) {
  73988. if (other.x > this.x) {
  73989. this.x = other.x;
  73990. }
  73991. if (other.y > this.y) {
  73992. this.y = other.y;
  73993. }
  73994. if (other.z > this.z) {
  73995. this.z = other.z;
  73996. }
  73997. if (other.w > this.w) {
  73998. this.w = other.w;
  73999. }
  74000. return this;
  74001. };
  74002. /**
  74003. * Gets a new Vector4 from current Vector4 floored values
  74004. * @returns a new Vector4
  74005. */
  74006. Vector4.prototype.floor = function () {
  74007. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  74008. };
  74009. /**
  74010. * Gets a new Vector4 from current Vector3 floored values
  74011. * @returns a new Vector4
  74012. */
  74013. Vector4.prototype.fract = function () {
  74014. return new Vector4(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z), this.w - Math.floor(this.w));
  74015. };
  74016. // Properties
  74017. /**
  74018. * Returns the Vector4 length (float).
  74019. * @returns the length
  74020. */
  74021. Vector4.prototype.length = function () {
  74022. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  74023. };
  74024. /**
  74025. * Returns the Vector4 squared length (float).
  74026. * @returns the length squared
  74027. */
  74028. Vector4.prototype.lengthSquared = function () {
  74029. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  74030. };
  74031. // Methods
  74032. /**
  74033. * Normalizes in place the Vector4.
  74034. * @returns the updated Vector4.
  74035. */
  74036. Vector4.prototype.normalize = function () {
  74037. var len = this.length();
  74038. if (len === 0) {
  74039. return this;
  74040. }
  74041. return this.scaleInPlace(1.0 / len);
  74042. };
  74043. /**
  74044. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  74045. * @returns this converted to a new vector3
  74046. */
  74047. Vector4.prototype.toVector3 = function () {
  74048. return new Vector3(this.x, this.y, this.z);
  74049. };
  74050. /**
  74051. * Returns a new Vector4 copied from the current one.
  74052. * @returns the new cloned vector
  74053. */
  74054. Vector4.prototype.clone = function () {
  74055. return new Vector4(this.x, this.y, this.z, this.w);
  74056. };
  74057. /**
  74058. * Updates the current Vector4 with the given one coordinates.
  74059. * @param source the source vector to copy from
  74060. * @returns the updated Vector4.
  74061. */
  74062. Vector4.prototype.copyFrom = function (source) {
  74063. this.x = source.x;
  74064. this.y = source.y;
  74065. this.z = source.z;
  74066. this.w = source.w;
  74067. return this;
  74068. };
  74069. /**
  74070. * Updates the current Vector4 coordinates with the given floats.
  74071. * @param x float to copy from
  74072. * @param y float to copy from
  74073. * @param z float to copy from
  74074. * @param w float to copy from
  74075. * @returns the updated Vector4.
  74076. */
  74077. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  74078. this.x = x;
  74079. this.y = y;
  74080. this.z = z;
  74081. this.w = w;
  74082. return this;
  74083. };
  74084. /**
  74085. * Updates the current Vector4 coordinates with the given floats.
  74086. * @param x float to set from
  74087. * @param y float to set from
  74088. * @param z float to set from
  74089. * @param w float to set from
  74090. * @returns the updated Vector4.
  74091. */
  74092. Vector4.prototype.set = function (x, y, z, w) {
  74093. return this.copyFromFloats(x, y, z, w);
  74094. };
  74095. /**
  74096. * Copies the given float to the current Vector3 coordinates
  74097. * @param v defines the x, y, z and w coordinates of the operand
  74098. * @returns the current updated Vector3
  74099. */
  74100. Vector4.prototype.setAll = function (v) {
  74101. this.x = this.y = this.z = this.w = v;
  74102. return this;
  74103. };
  74104. // Statics
  74105. /**
  74106. * Returns a new Vector4 set from the starting index of the given array.
  74107. * @param array the array to pull values from
  74108. * @param offset the offset into the array to start at
  74109. * @returns the new vector
  74110. */
  74111. Vector4.FromArray = function (array, offset) {
  74112. if (!offset) {
  74113. offset = 0;
  74114. }
  74115. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  74116. };
  74117. /**
  74118. * Updates the given vector "result" from the starting index of the given array.
  74119. * @param array the array to pull values from
  74120. * @param offset the offset into the array to start at
  74121. * @param result the vector to store the result in
  74122. */
  74123. Vector4.FromArrayToRef = function (array, offset, result) {
  74124. result.x = array[offset];
  74125. result.y = array[offset + 1];
  74126. result.z = array[offset + 2];
  74127. result.w = array[offset + 3];
  74128. };
  74129. /**
  74130. * Updates the given vector "result" from the starting index of the given Float32Array.
  74131. * @param array the array to pull values from
  74132. * @param offset the offset into the array to start at
  74133. * @param result the vector to store the result in
  74134. */
  74135. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  74136. Vector4.FromArrayToRef(array, offset, result);
  74137. };
  74138. /**
  74139. * Updates the given vector "result" coordinates from the given floats.
  74140. * @param x float to set from
  74141. * @param y float to set from
  74142. * @param z float to set from
  74143. * @param w float to set from
  74144. * @param result the vector to the floats in
  74145. */
  74146. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  74147. result.x = x;
  74148. result.y = y;
  74149. result.z = z;
  74150. result.w = w;
  74151. };
  74152. /**
  74153. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  74154. * @returns the new vector
  74155. */
  74156. Vector4.Zero = function () {
  74157. return new Vector4(0.0, 0.0, 0.0, 0.0);
  74158. };
  74159. /**
  74160. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  74161. * @returns the new vector
  74162. */
  74163. Vector4.One = function () {
  74164. return new Vector4(1.0, 1.0, 1.0, 1.0);
  74165. };
  74166. /**
  74167. * Returns a new normalized Vector4 from the given one.
  74168. * @param vector the vector to normalize
  74169. * @returns the vector
  74170. */
  74171. Vector4.Normalize = function (vector) {
  74172. var result = Vector4.Zero();
  74173. Vector4.NormalizeToRef(vector, result);
  74174. return result;
  74175. };
  74176. /**
  74177. * Updates the given vector "result" from the normalization of the given one.
  74178. * @param vector the vector to normalize
  74179. * @param result the vector to store the result in
  74180. */
  74181. Vector4.NormalizeToRef = function (vector, result) {
  74182. result.copyFrom(vector);
  74183. result.normalize();
  74184. };
  74185. /**
  74186. * Returns a vector with the minimum values from the left and right vectors
  74187. * @param left left vector to minimize
  74188. * @param right right vector to minimize
  74189. * @returns a new vector with the minimum of the left and right vector values
  74190. */
  74191. Vector4.Minimize = function (left, right) {
  74192. var min = left.clone();
  74193. min.minimizeInPlace(right);
  74194. return min;
  74195. };
  74196. /**
  74197. * Returns a vector with the maximum values from the left and right vectors
  74198. * @param left left vector to maximize
  74199. * @param right right vector to maximize
  74200. * @returns a new vector with the maximum of the left and right vector values
  74201. */
  74202. Vector4.Maximize = function (left, right) {
  74203. var max = left.clone();
  74204. max.maximizeInPlace(right);
  74205. return max;
  74206. };
  74207. /**
  74208. * Returns the distance (float) between the vectors "value1" and "value2".
  74209. * @param value1 value to calulate the distance between
  74210. * @param value2 value to calulate the distance between
  74211. * @return the distance between the two vectors
  74212. */
  74213. Vector4.Distance = function (value1, value2) {
  74214. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  74215. };
  74216. /**
  74217. * Returns the squared distance (float) between the vectors "value1" and "value2".
  74218. * @param value1 value to calulate the distance between
  74219. * @param value2 value to calulate the distance between
  74220. * @return the distance between the two vectors squared
  74221. */
  74222. Vector4.DistanceSquared = function (value1, value2) {
  74223. var x = value1.x - value2.x;
  74224. var y = value1.y - value2.y;
  74225. var z = value1.z - value2.z;
  74226. var w = value1.w - value2.w;
  74227. return (x * x) + (y * y) + (z * z) + (w * w);
  74228. };
  74229. /**
  74230. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  74231. * @param value1 value to calulate the center between
  74232. * @param value2 value to calulate the center between
  74233. * @return the center between the two vectors
  74234. */
  74235. Vector4.Center = function (value1, value2) {
  74236. var center = value1.add(value2);
  74237. center.scaleInPlace(0.5);
  74238. return center;
  74239. };
  74240. /**
  74241. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  74242. * This methods computes transformed normalized direction vectors only.
  74243. * @param vector the vector to transform
  74244. * @param transformation the transformation matrix to apply
  74245. * @returns the new vector
  74246. */
  74247. Vector4.TransformNormal = function (vector, transformation) {
  74248. var result = Vector4.Zero();
  74249. Vector4.TransformNormalToRef(vector, transformation, result);
  74250. return result;
  74251. };
  74252. /**
  74253. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  74254. * This methods computes transformed normalized direction vectors only.
  74255. * @param vector the vector to transform
  74256. * @param transformation the transformation matrix to apply
  74257. * @param result the vector to store the result in
  74258. */
  74259. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  74260. var m = transformation.m;
  74261. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  74262. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  74263. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  74264. result.x = x;
  74265. result.y = y;
  74266. result.z = z;
  74267. result.w = vector.w;
  74268. };
  74269. /**
  74270. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  74271. * This methods computes transformed normalized direction vectors only.
  74272. * @param x value to transform
  74273. * @param y value to transform
  74274. * @param z value to transform
  74275. * @param w value to transform
  74276. * @param transformation the transformation matrix to apply
  74277. * @param result the vector to store the results in
  74278. */
  74279. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  74280. var m = transformation.m;
  74281. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  74282. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  74283. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  74284. result.w = w;
  74285. };
  74286. /**
  74287. * Creates a new Vector4 from a Vector3
  74288. * @param source defines the source data
  74289. * @param w defines the 4th component (default is 0)
  74290. * @returns a new Vector4
  74291. */
  74292. Vector4.FromVector3 = function (source, w) {
  74293. if (w === void 0) { w = 0; }
  74294. return new Vector4(source.x, source.y, source.z, w);
  74295. };
  74296. return Vector4;
  74297. }());
  74298. /**
  74299. * Size containing widht and height
  74300. */
  74301. var Size = /** @class */ (function () {
  74302. /**
  74303. * Creates a Size object from the given width and height (floats).
  74304. * @param width width of the new size
  74305. * @param height height of the new size
  74306. */
  74307. function Size(width, height) {
  74308. this.width = width;
  74309. this.height = height;
  74310. }
  74311. /**
  74312. * Returns a string with the Size width and height
  74313. * @returns a string with the Size width and height
  74314. */
  74315. Size.prototype.toString = function () {
  74316. return "{W: " + this.width + ", H: " + this.height + "}";
  74317. };
  74318. /**
  74319. * "Size"
  74320. * @returns the string "Size"
  74321. */
  74322. Size.prototype.getClassName = function () {
  74323. return "Size";
  74324. };
  74325. /**
  74326. * Returns the Size hash code.
  74327. * @returns a hash code for a unique width and height
  74328. */
  74329. Size.prototype.getHashCode = function () {
  74330. var hash = this.width || 0;
  74331. hash = (hash * 397) ^ (this.height || 0);
  74332. return hash;
  74333. };
  74334. /**
  74335. * Updates the current size from the given one.
  74336. * @param src the given size
  74337. */
  74338. Size.prototype.copyFrom = function (src) {
  74339. this.width = src.width;
  74340. this.height = src.height;
  74341. };
  74342. /**
  74343. * Updates in place the current Size from the given floats.
  74344. * @param width width of the new size
  74345. * @param height height of the new size
  74346. * @returns the updated Size.
  74347. */
  74348. Size.prototype.copyFromFloats = function (width, height) {
  74349. this.width = width;
  74350. this.height = height;
  74351. return this;
  74352. };
  74353. /**
  74354. * Updates in place the current Size from the given floats.
  74355. * @param width width to set
  74356. * @param height height to set
  74357. * @returns the updated Size.
  74358. */
  74359. Size.prototype.set = function (width, height) {
  74360. return this.copyFromFloats(width, height);
  74361. };
  74362. /**
  74363. * Multiplies the width and height by numbers
  74364. * @param w factor to multiple the width by
  74365. * @param h factor to multiple the height by
  74366. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  74367. */
  74368. Size.prototype.multiplyByFloats = function (w, h) {
  74369. return new Size(this.width * w, this.height * h);
  74370. };
  74371. /**
  74372. * Clones the size
  74373. * @returns a new Size copied from the given one.
  74374. */
  74375. Size.prototype.clone = function () {
  74376. return new Size(this.width, this.height);
  74377. };
  74378. /**
  74379. * True if the current Size and the given one width and height are strictly equal.
  74380. * @param other the other size to compare against
  74381. * @returns True if the current Size and the given one width and height are strictly equal.
  74382. */
  74383. Size.prototype.equals = function (other) {
  74384. if (!other) {
  74385. return false;
  74386. }
  74387. return (this.width === other.width) && (this.height === other.height);
  74388. };
  74389. Object.defineProperty(Size.prototype, "surface", {
  74390. /**
  74391. * The surface of the Size : width * height (float).
  74392. */
  74393. get: function () {
  74394. return this.width * this.height;
  74395. },
  74396. enumerable: true,
  74397. configurable: true
  74398. });
  74399. /**
  74400. * Create a new size of zero
  74401. * @returns a new Size set to (0.0, 0.0)
  74402. */
  74403. Size.Zero = function () {
  74404. return new Size(0.0, 0.0);
  74405. };
  74406. /**
  74407. * Sums the width and height of two sizes
  74408. * @param otherSize size to add to this size
  74409. * @returns a new Size set as the addition result of the current Size and the given one.
  74410. */
  74411. Size.prototype.add = function (otherSize) {
  74412. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  74413. return r;
  74414. };
  74415. /**
  74416. * Subtracts the width and height of two
  74417. * @param otherSize size to subtract to this size
  74418. * @returns a new Size set as the subtraction result of the given one from the current Size.
  74419. */
  74420. Size.prototype.subtract = function (otherSize) {
  74421. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  74422. return r;
  74423. };
  74424. /**
  74425. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  74426. * @param start starting size to lerp between
  74427. * @param end end size to lerp between
  74428. * @param amount amount to lerp between the start and end values
  74429. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  74430. */
  74431. Size.Lerp = function (start, end, amount) {
  74432. var w = start.width + ((end.width - start.width) * amount);
  74433. var h = start.height + ((end.height - start.height) * amount);
  74434. return new Size(w, h);
  74435. };
  74436. return Size;
  74437. }());
  74438. /**
  74439. * Class used to store quaternion data
  74440. * @see https://en.wikipedia.org/wiki/Quaternion
  74441. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  74442. */
  74443. var Quaternion = /** @class */ (function () {
  74444. /**
  74445. * Creates a new Quaternion from the given floats
  74446. * @param x defines the first component (0 by default)
  74447. * @param y defines the second component (0 by default)
  74448. * @param z defines the third component (0 by default)
  74449. * @param w defines the fourth component (1.0 by default)
  74450. */
  74451. function Quaternion(
  74452. /** defines the first component (0 by default) */
  74453. x,
  74454. /** defines the second component (0 by default) */
  74455. y,
  74456. /** defines the third component (0 by default) */
  74457. z,
  74458. /** defines the fourth component (1.0 by default) */
  74459. w) {
  74460. if (x === void 0) { x = 0.0; }
  74461. if (y === void 0) { y = 0.0; }
  74462. if (z === void 0) { z = 0.0; }
  74463. if (w === void 0) { w = 1.0; }
  74464. this.x = x;
  74465. this.y = y;
  74466. this.z = z;
  74467. this.w = w;
  74468. }
  74469. /**
  74470. * Gets a string representation for the current quaternion
  74471. * @returns a string with the Quaternion coordinates
  74472. */
  74473. Quaternion.prototype.toString = function () {
  74474. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  74475. };
  74476. /**
  74477. * Gets the class name of the quaternion
  74478. * @returns the string "Quaternion"
  74479. */
  74480. Quaternion.prototype.getClassName = function () {
  74481. return "Quaternion";
  74482. };
  74483. /**
  74484. * Gets a hash code for this quaternion
  74485. * @returns the quaternion hash code
  74486. */
  74487. Quaternion.prototype.getHashCode = function () {
  74488. var hash = this.x || 0;
  74489. hash = (hash * 397) ^ (this.y || 0);
  74490. hash = (hash * 397) ^ (this.z || 0);
  74491. hash = (hash * 397) ^ (this.w || 0);
  74492. return hash;
  74493. };
  74494. /**
  74495. * Copy the quaternion to an array
  74496. * @returns a new array populated with 4 elements from the quaternion coordinates
  74497. */
  74498. Quaternion.prototype.asArray = function () {
  74499. return [this.x, this.y, this.z, this.w];
  74500. };
  74501. /**
  74502. * Check if two quaternions are equals
  74503. * @param otherQuaternion defines the second operand
  74504. * @return true if the current quaternion and the given one coordinates are strictly equals
  74505. */
  74506. Quaternion.prototype.equals = function (otherQuaternion) {
  74507. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  74508. };
  74509. /**
  74510. * Clone the current quaternion
  74511. * @returns a new quaternion copied from the current one
  74512. */
  74513. Quaternion.prototype.clone = function () {
  74514. return new Quaternion(this.x, this.y, this.z, this.w);
  74515. };
  74516. /**
  74517. * Copy a quaternion to the current one
  74518. * @param other defines the other quaternion
  74519. * @returns the updated current quaternion
  74520. */
  74521. Quaternion.prototype.copyFrom = function (other) {
  74522. this.x = other.x;
  74523. this.y = other.y;
  74524. this.z = other.z;
  74525. this.w = other.w;
  74526. return this;
  74527. };
  74528. /**
  74529. * Updates the current quaternion with the given float coordinates
  74530. * @param x defines the x coordinate
  74531. * @param y defines the y coordinate
  74532. * @param z defines the z coordinate
  74533. * @param w defines the w coordinate
  74534. * @returns the updated current quaternion
  74535. */
  74536. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  74537. this.x = x;
  74538. this.y = y;
  74539. this.z = z;
  74540. this.w = w;
  74541. return this;
  74542. };
  74543. /**
  74544. * Updates the current quaternion from the given float coordinates
  74545. * @param x defines the x coordinate
  74546. * @param y defines the y coordinate
  74547. * @param z defines the z coordinate
  74548. * @param w defines the w coordinate
  74549. * @returns the updated current quaternion
  74550. */
  74551. Quaternion.prototype.set = function (x, y, z, w) {
  74552. return this.copyFromFloats(x, y, z, w);
  74553. };
  74554. /**
  74555. * Adds two quaternions
  74556. * @param other defines the second operand
  74557. * @returns a new quaternion as the addition result of the given one and the current quaternion
  74558. */
  74559. Quaternion.prototype.add = function (other) {
  74560. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  74561. };
  74562. /**
  74563. * Add a quaternion to the current one
  74564. * @param other defines the quaternion to add
  74565. * @returns the current quaternion
  74566. */
  74567. Quaternion.prototype.addInPlace = function (other) {
  74568. this.x += other.x;
  74569. this.y += other.y;
  74570. this.z += other.z;
  74571. this.w += other.w;
  74572. return this;
  74573. };
  74574. /**
  74575. * Subtract two quaternions
  74576. * @param other defines the second operand
  74577. * @returns a new quaternion as the subtraction result of the given one from the current one
  74578. */
  74579. Quaternion.prototype.subtract = function (other) {
  74580. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  74581. };
  74582. /**
  74583. * Multiplies the current quaternion by a scale factor
  74584. * @param value defines the scale factor
  74585. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  74586. */
  74587. Quaternion.prototype.scale = function (value) {
  74588. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  74589. };
  74590. /**
  74591. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  74592. * @param scale defines the scale factor
  74593. * @param result defines the Quaternion object where to store the result
  74594. * @returns the unmodified current quaternion
  74595. */
  74596. Quaternion.prototype.scaleToRef = function (scale, result) {
  74597. result.x = this.x * scale;
  74598. result.y = this.y * scale;
  74599. result.z = this.z * scale;
  74600. result.w = this.w * scale;
  74601. return this;
  74602. };
  74603. /**
  74604. * Multiplies in place the current quaternion by a scale factor
  74605. * @param value defines the scale factor
  74606. * @returns the current modified quaternion
  74607. */
  74608. Quaternion.prototype.scaleInPlace = function (value) {
  74609. this.x *= value;
  74610. this.y *= value;
  74611. this.z *= value;
  74612. this.w *= value;
  74613. return this;
  74614. };
  74615. /**
  74616. * Scale the current quaternion values by a factor and add the result to a given quaternion
  74617. * @param scale defines the scale factor
  74618. * @param result defines the Quaternion object where to store the result
  74619. * @returns the unmodified current quaternion
  74620. */
  74621. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  74622. result.x += this.x * scale;
  74623. result.y += this.y * scale;
  74624. result.z += this.z * scale;
  74625. result.w += this.w * scale;
  74626. return this;
  74627. };
  74628. /**
  74629. * Multiplies two quaternions
  74630. * @param q1 defines the second operand
  74631. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  74632. */
  74633. Quaternion.prototype.multiply = function (q1) {
  74634. var result = new Quaternion(0, 0, 0, 1.0);
  74635. this.multiplyToRef(q1, result);
  74636. return result;
  74637. };
  74638. /**
  74639. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  74640. * @param q1 defines the second operand
  74641. * @param result defines the target quaternion
  74642. * @returns the current quaternion
  74643. */
  74644. Quaternion.prototype.multiplyToRef = function (q1, result) {
  74645. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  74646. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  74647. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  74648. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  74649. result.copyFromFloats(x, y, z, w);
  74650. return this;
  74651. };
  74652. /**
  74653. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  74654. * @param q1 defines the second operand
  74655. * @returns the currentupdated quaternion
  74656. */
  74657. Quaternion.prototype.multiplyInPlace = function (q1) {
  74658. this.multiplyToRef(q1, this);
  74659. return this;
  74660. };
  74661. /**
  74662. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  74663. * @param ref defines the target quaternion
  74664. * @returns the current quaternion
  74665. */
  74666. Quaternion.prototype.conjugateToRef = function (ref) {
  74667. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  74668. return this;
  74669. };
  74670. /**
  74671. * Conjugates in place (1-q) the current quaternion
  74672. * @returns the current updated quaternion
  74673. */
  74674. Quaternion.prototype.conjugateInPlace = function () {
  74675. this.x *= -1;
  74676. this.y *= -1;
  74677. this.z *= -1;
  74678. return this;
  74679. };
  74680. /**
  74681. * Conjugates in place (1-q) the current quaternion
  74682. * @returns a new quaternion
  74683. */
  74684. Quaternion.prototype.conjugate = function () {
  74685. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  74686. return result;
  74687. };
  74688. /**
  74689. * Gets length of current quaternion
  74690. * @returns the quaternion length (float)
  74691. */
  74692. Quaternion.prototype.length = function () {
  74693. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  74694. };
  74695. /**
  74696. * Normalize in place the current quaternion
  74697. * @returns the current updated quaternion
  74698. */
  74699. Quaternion.prototype.normalize = function () {
  74700. var len = this.length();
  74701. if (len === 0) {
  74702. return this;
  74703. }
  74704. var inv = 1.0 / len;
  74705. this.x *= inv;
  74706. this.y *= inv;
  74707. this.z *= inv;
  74708. this.w *= inv;
  74709. return this;
  74710. };
  74711. /**
  74712. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  74713. * @param order is a reserved parameter and is ignore for now
  74714. * @returns a new Vector3 containing the Euler angles
  74715. */
  74716. Quaternion.prototype.toEulerAngles = function (order) {
  74717. if (order === void 0) { order = "YZX"; }
  74718. var result = Vector3.Zero();
  74719. this.toEulerAnglesToRef(result);
  74720. return result;
  74721. };
  74722. /**
  74723. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  74724. * @param result defines the vector which will be filled with the Euler angles
  74725. * @param order is a reserved parameter and is ignore for now
  74726. * @returns the current unchanged quaternion
  74727. */
  74728. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  74729. var qz = this.z;
  74730. var qx = this.x;
  74731. var qy = this.y;
  74732. var qw = this.w;
  74733. var sqw = qw * qw;
  74734. var sqz = qz * qz;
  74735. var sqx = qx * qx;
  74736. var sqy = qy * qy;
  74737. var zAxisY = qy * qz - qx * qw;
  74738. var limit = .4999999;
  74739. if (zAxisY < -limit) {
  74740. result.y = 2 * Math.atan2(qy, qw);
  74741. result.x = Math.PI / 2;
  74742. result.z = 0;
  74743. }
  74744. else if (zAxisY > limit) {
  74745. result.y = 2 * Math.atan2(qy, qw);
  74746. result.x = -Math.PI / 2;
  74747. result.z = 0;
  74748. }
  74749. else {
  74750. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  74751. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  74752. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  74753. }
  74754. return this;
  74755. };
  74756. /**
  74757. * Updates the given rotation matrix with the current quaternion values
  74758. * @param result defines the target matrix
  74759. * @returns the current unchanged quaternion
  74760. */
  74761. Quaternion.prototype.toRotationMatrix = function (result) {
  74762. Matrix.FromQuaternionToRef(this, result);
  74763. return this;
  74764. };
  74765. /**
  74766. * Updates the current quaternion from the given rotation matrix values
  74767. * @param matrix defines the source matrix
  74768. * @returns the current updated quaternion
  74769. */
  74770. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  74771. Quaternion.FromRotationMatrixToRef(matrix, this);
  74772. return this;
  74773. };
  74774. // Statics
  74775. /**
  74776. * Creates a new quaternion from a rotation matrix
  74777. * @param matrix defines the source matrix
  74778. * @returns a new quaternion created from the given rotation matrix values
  74779. */
  74780. Quaternion.FromRotationMatrix = function (matrix) {
  74781. var result = new Quaternion();
  74782. Quaternion.FromRotationMatrixToRef(matrix, result);
  74783. return result;
  74784. };
  74785. /**
  74786. * Updates the given quaternion with the given rotation matrix values
  74787. * @param matrix defines the source matrix
  74788. * @param result defines the target quaternion
  74789. */
  74790. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  74791. var data = matrix.m;
  74792. var m11 = data[0], m12 = data[4], m13 = data[8];
  74793. var m21 = data[1], m22 = data[5], m23 = data[9];
  74794. var m31 = data[2], m32 = data[6], m33 = data[10];
  74795. var trace = m11 + m22 + m33;
  74796. var s;
  74797. if (trace > 0) {
  74798. s = 0.5 / Math.sqrt(trace + 1.0);
  74799. result.w = 0.25 / s;
  74800. result.x = (m32 - m23) * s;
  74801. result.y = (m13 - m31) * s;
  74802. result.z = (m21 - m12) * s;
  74803. }
  74804. else if (m11 > m22 && m11 > m33) {
  74805. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  74806. result.w = (m32 - m23) / s;
  74807. result.x = 0.25 * s;
  74808. result.y = (m12 + m21) / s;
  74809. result.z = (m13 + m31) / s;
  74810. }
  74811. else if (m22 > m33) {
  74812. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  74813. result.w = (m13 - m31) / s;
  74814. result.x = (m12 + m21) / s;
  74815. result.y = 0.25 * s;
  74816. result.z = (m23 + m32) / s;
  74817. }
  74818. else {
  74819. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  74820. result.w = (m21 - m12) / s;
  74821. result.x = (m13 + m31) / s;
  74822. result.y = (m23 + m32) / s;
  74823. result.z = 0.25 * s;
  74824. }
  74825. };
  74826. /**
  74827. * Returns the dot product (float) between the quaternions "left" and "right"
  74828. * @param left defines the left operand
  74829. * @param right defines the right operand
  74830. * @returns the dot product
  74831. */
  74832. Quaternion.Dot = function (left, right) {
  74833. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  74834. };
  74835. /**
  74836. * Checks if the two quaternions are close to each other
  74837. * @param quat0 defines the first quaternion to check
  74838. * @param quat1 defines the second quaternion to check
  74839. * @returns true if the two quaternions are close to each other
  74840. */
  74841. Quaternion.AreClose = function (quat0, quat1) {
  74842. var dot = Quaternion.Dot(quat0, quat1);
  74843. return dot >= 0;
  74844. };
  74845. /**
  74846. * Creates an empty quaternion
  74847. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  74848. */
  74849. Quaternion.Zero = function () {
  74850. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  74851. };
  74852. /**
  74853. * Inverse a given quaternion
  74854. * @param q defines the source quaternion
  74855. * @returns a new quaternion as the inverted current quaternion
  74856. */
  74857. Quaternion.Inverse = function (q) {
  74858. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  74859. };
  74860. /**
  74861. * Inverse a given quaternion
  74862. * @param q defines the source quaternion
  74863. * @param result the quaternion the result will be stored in
  74864. * @returns the result quaternion
  74865. */
  74866. Quaternion.InverseToRef = function (q, result) {
  74867. result.set(-q.x, -q.y, -q.z, q.w);
  74868. return result;
  74869. };
  74870. /**
  74871. * Creates an identity quaternion
  74872. * @returns the identity quaternion
  74873. */
  74874. Quaternion.Identity = function () {
  74875. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  74876. };
  74877. /**
  74878. * Gets a boolean indicating if the given quaternion is identity
  74879. * @param quaternion defines the quaternion to check
  74880. * @returns true if the quaternion is identity
  74881. */
  74882. Quaternion.IsIdentity = function (quaternion) {
  74883. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  74884. };
  74885. /**
  74886. * Creates a quaternion from a rotation around an axis
  74887. * @param axis defines the axis to use
  74888. * @param angle defines the angle to use
  74889. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  74890. */
  74891. Quaternion.RotationAxis = function (axis, angle) {
  74892. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  74893. };
  74894. /**
  74895. * Creates a rotation around an axis and stores it into the given quaternion
  74896. * @param axis defines the axis to use
  74897. * @param angle defines the angle to use
  74898. * @param result defines the target quaternion
  74899. * @returns the target quaternion
  74900. */
  74901. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  74902. var sin = Math.sin(angle / 2);
  74903. axis.normalize();
  74904. result.w = Math.cos(angle / 2);
  74905. result.x = axis.x * sin;
  74906. result.y = axis.y * sin;
  74907. result.z = axis.z * sin;
  74908. return result;
  74909. };
  74910. /**
  74911. * Creates a new quaternion from data stored into an array
  74912. * @param array defines the data source
  74913. * @param offset defines the offset in the source array where the data starts
  74914. * @returns a new quaternion
  74915. */
  74916. Quaternion.FromArray = function (array, offset) {
  74917. if (!offset) {
  74918. offset = 0;
  74919. }
  74920. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  74921. };
  74922. /**
  74923. * Create a quaternion from Euler rotation angles
  74924. * @param x Pitch
  74925. * @param y Yaw
  74926. * @param z Roll
  74927. * @returns the new Quaternion
  74928. */
  74929. Quaternion.FromEulerAngles = function (x, y, z) {
  74930. var q = new Quaternion();
  74931. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  74932. return q;
  74933. };
  74934. /**
  74935. * Updates a quaternion from Euler rotation angles
  74936. * @param x Pitch
  74937. * @param y Yaw
  74938. * @param z Roll
  74939. * @param result the quaternion to store the result
  74940. * @returns the updated quaternion
  74941. */
  74942. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  74943. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  74944. return result;
  74945. };
  74946. /**
  74947. * Create a quaternion from Euler rotation vector
  74948. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74949. * @returns the new Quaternion
  74950. */
  74951. Quaternion.FromEulerVector = function (vec) {
  74952. var q = new Quaternion();
  74953. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  74954. return q;
  74955. };
  74956. /**
  74957. * Updates a quaternion from Euler rotation vector
  74958. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74959. * @param result the quaternion to store the result
  74960. * @returns the updated quaternion
  74961. */
  74962. Quaternion.FromEulerVectorToRef = function (vec, result) {
  74963. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  74964. return result;
  74965. };
  74966. /**
  74967. * Creates a new quaternion from the given Euler float angles (y, x, z)
  74968. * @param yaw defines the rotation around Y axis
  74969. * @param pitch defines the rotation around X axis
  74970. * @param roll defines the rotation around Z axis
  74971. * @returns the new quaternion
  74972. */
  74973. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  74974. var q = new Quaternion();
  74975. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  74976. return q;
  74977. };
  74978. /**
  74979. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  74980. * @param yaw defines the rotation around Y axis
  74981. * @param pitch defines the rotation around X axis
  74982. * @param roll defines the rotation around Z axis
  74983. * @param result defines the target quaternion
  74984. */
  74985. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  74986. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  74987. var halfRoll = roll * 0.5;
  74988. var halfPitch = pitch * 0.5;
  74989. var halfYaw = yaw * 0.5;
  74990. var sinRoll = Math.sin(halfRoll);
  74991. var cosRoll = Math.cos(halfRoll);
  74992. var sinPitch = Math.sin(halfPitch);
  74993. var cosPitch = Math.cos(halfPitch);
  74994. var sinYaw = Math.sin(halfYaw);
  74995. var cosYaw = Math.cos(halfYaw);
  74996. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  74997. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  74998. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  74999. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  75000. };
  75001. /**
  75002. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  75003. * @param alpha defines the rotation around first axis
  75004. * @param beta defines the rotation around second axis
  75005. * @param gamma defines the rotation around third axis
  75006. * @returns the new quaternion
  75007. */
  75008. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  75009. var result = new Quaternion();
  75010. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  75011. return result;
  75012. };
  75013. /**
  75014. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  75015. * @param alpha defines the rotation around first axis
  75016. * @param beta defines the rotation around second axis
  75017. * @param gamma defines the rotation around third axis
  75018. * @param result defines the target quaternion
  75019. */
  75020. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  75021. // Produces a quaternion from Euler angles in the z-x-z orientation
  75022. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  75023. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  75024. var halfBeta = beta * 0.5;
  75025. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  75026. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  75027. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  75028. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  75029. };
  75030. /**
  75031. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  75032. * @param axis1 defines the first axis
  75033. * @param axis2 defines the second axis
  75034. * @param axis3 defines the third axis
  75035. * @returns the new quaternion
  75036. */
  75037. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  75038. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  75039. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  75040. return quat;
  75041. };
  75042. /**
  75043. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  75044. * @param axis1 defines the first axis
  75045. * @param axis2 defines the second axis
  75046. * @param axis3 defines the third axis
  75047. * @param ref defines the target quaternion
  75048. */
  75049. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  75050. var rotMat = MathTmp.Matrix[0];
  75051. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  75052. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  75053. };
  75054. /**
  75055. * Interpolates between two quaternions
  75056. * @param left defines first quaternion
  75057. * @param right defines second quaternion
  75058. * @param amount defines the gradient to use
  75059. * @returns the new interpolated quaternion
  75060. */
  75061. Quaternion.Slerp = function (left, right, amount) {
  75062. var result = Quaternion.Identity();
  75063. Quaternion.SlerpToRef(left, right, amount, result);
  75064. return result;
  75065. };
  75066. /**
  75067. * Interpolates between two quaternions and stores it into a target quaternion
  75068. * @param left defines first quaternion
  75069. * @param right defines second quaternion
  75070. * @param amount defines the gradient to use
  75071. * @param result defines the target quaternion
  75072. */
  75073. Quaternion.SlerpToRef = function (left, right, amount, result) {
  75074. var num2;
  75075. var num3;
  75076. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  75077. var flag = false;
  75078. if (num4 < 0) {
  75079. flag = true;
  75080. num4 = -num4;
  75081. }
  75082. if (num4 > 0.999999) {
  75083. num3 = 1 - amount;
  75084. num2 = flag ? -amount : amount;
  75085. }
  75086. else {
  75087. var num5 = Math.acos(num4);
  75088. var num6 = (1.0 / Math.sin(num5));
  75089. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  75090. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  75091. }
  75092. result.x = (num3 * left.x) + (num2 * right.x);
  75093. result.y = (num3 * left.y) + (num2 * right.y);
  75094. result.z = (num3 * left.z) + (num2 * right.z);
  75095. result.w = (num3 * left.w) + (num2 * right.w);
  75096. };
  75097. /**
  75098. * Interpolate between two quaternions using Hermite interpolation
  75099. * @param value1 defines first quaternion
  75100. * @param tangent1 defines the incoming tangent
  75101. * @param value2 defines second quaternion
  75102. * @param tangent2 defines the outgoing tangent
  75103. * @param amount defines the target quaternion
  75104. * @returns the new interpolated quaternion
  75105. */
  75106. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  75107. var squared = amount * amount;
  75108. var cubed = amount * squared;
  75109. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  75110. var part2 = (-2.0 * cubed) + (3.0 * squared);
  75111. var part3 = (cubed - (2.0 * squared)) + amount;
  75112. var part4 = cubed - squared;
  75113. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  75114. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  75115. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  75116. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  75117. return new Quaternion(x, y, z, w);
  75118. };
  75119. return Quaternion;
  75120. }());
  75121. /**
  75122. * Class used to store matrix data (4x4)
  75123. */
  75124. var Matrix = /** @class */ (function () {
  75125. /**
  75126. * Creates an empty matrix (filled with zeros)
  75127. */
  75128. function Matrix() {
  75129. this._isIdentity = false;
  75130. this._isIdentityDirty = true;
  75131. this._isIdentity3x2 = true;
  75132. this._isIdentity3x2Dirty = true;
  75133. this._m = new Float32Array(16);
  75134. this._updateIdentityStatus(false);
  75135. }
  75136. Object.defineProperty(Matrix.prototype, "m", {
  75137. /**
  75138. * Gets the internal data of the matrix
  75139. */
  75140. get: function () { return this._m; },
  75141. enumerable: true,
  75142. configurable: true
  75143. });
  75144. /** @hidden */
  75145. Matrix.prototype._markAsUpdated = function () {
  75146. this.updateFlag = Matrix._updateFlagSeed++;
  75147. this._isIdentity = false;
  75148. this._isIdentity3x2 = false;
  75149. this._isIdentityDirty = true;
  75150. this._isIdentity3x2Dirty = true;
  75151. };
  75152. /** @hidden */
  75153. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  75154. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  75155. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  75156. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  75157. this.updateFlag = Matrix._updateFlagSeed++;
  75158. this._isIdentity = isIdentity;
  75159. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  75160. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  75161. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  75162. };
  75163. // Properties
  75164. /**
  75165. * Check if the current matrix is identity
  75166. * @returns true is the matrix is the identity matrix
  75167. */
  75168. Matrix.prototype.isIdentity = function () {
  75169. if (this._isIdentityDirty) {
  75170. this._isIdentityDirty = false;
  75171. var m = this._m;
  75172. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  75173. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  75174. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  75175. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  75176. }
  75177. return this._isIdentity;
  75178. };
  75179. /**
  75180. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  75181. * @returns true is the matrix is the identity matrix
  75182. */
  75183. Matrix.prototype.isIdentityAs3x2 = function () {
  75184. if (this._isIdentity3x2Dirty) {
  75185. this._isIdentity3x2Dirty = false;
  75186. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  75187. this._isIdentity3x2 = false;
  75188. }
  75189. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  75190. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  75191. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  75192. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  75193. this._isIdentity3x2 = false;
  75194. }
  75195. else {
  75196. this._isIdentity3x2 = true;
  75197. }
  75198. }
  75199. return this._isIdentity3x2;
  75200. };
  75201. /**
  75202. * Gets the determinant of the matrix
  75203. * @returns the matrix determinant
  75204. */
  75205. Matrix.prototype.determinant = function () {
  75206. if (this._isIdentity === true) {
  75207. return 1;
  75208. }
  75209. var m = this._m;
  75210. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  75211. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  75212. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  75213. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  75214. // https://en.wikipedia.org/wiki/Laplace_expansion
  75215. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  75216. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  75217. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  75218. // where
  75219. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  75220. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  75221. //
  75222. // Here we do that for the 1st row.
  75223. var det_22_33 = m22 * m33 - m32 * m23;
  75224. var det_21_33 = m21 * m33 - m31 * m23;
  75225. var det_21_32 = m21 * m32 - m31 * m22;
  75226. var det_20_33 = m20 * m33 - m30 * m23;
  75227. var det_20_32 = m20 * m32 - m22 * m30;
  75228. var det_20_31 = m20 * m31 - m30 * m21;
  75229. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  75230. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  75231. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  75232. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  75233. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  75234. };
  75235. // Methods
  75236. /**
  75237. * Returns the matrix as a Float32Array
  75238. * @returns the matrix underlying array
  75239. */
  75240. Matrix.prototype.toArray = function () {
  75241. return this._m;
  75242. };
  75243. /**
  75244. * Returns the matrix as a Float32Array
  75245. * @returns the matrix underlying array.
  75246. */
  75247. Matrix.prototype.asArray = function () {
  75248. return this._m;
  75249. };
  75250. /**
  75251. * Inverts the current matrix in place
  75252. * @returns the current inverted matrix
  75253. */
  75254. Matrix.prototype.invert = function () {
  75255. this.invertToRef(this);
  75256. return this;
  75257. };
  75258. /**
  75259. * Sets all the matrix elements to zero
  75260. * @returns the current matrix
  75261. */
  75262. Matrix.prototype.reset = function () {
  75263. Matrix.FromValuesToRef(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, this);
  75264. this._updateIdentityStatus(false);
  75265. return this;
  75266. };
  75267. /**
  75268. * Adds the current matrix with a second one
  75269. * @param other defines the matrix to add
  75270. * @returns a new matrix as the addition of the current matrix and the given one
  75271. */
  75272. Matrix.prototype.add = function (other) {
  75273. var result = new Matrix();
  75274. this.addToRef(other, result);
  75275. return result;
  75276. };
  75277. /**
  75278. * Sets the given matrix "result" to the addition of the current matrix and the given one
  75279. * @param other defines the matrix to add
  75280. * @param result defines the target matrix
  75281. * @returns the current matrix
  75282. */
  75283. Matrix.prototype.addToRef = function (other, result) {
  75284. var m = this._m;
  75285. var resultM = result._m;
  75286. var otherM = other.m;
  75287. for (var index = 0; index < 16; index++) {
  75288. resultM[index] = m[index] + otherM[index];
  75289. }
  75290. result._markAsUpdated();
  75291. return this;
  75292. };
  75293. /**
  75294. * Adds in place the given matrix to the current matrix
  75295. * @param other defines the second operand
  75296. * @returns the current updated matrix
  75297. */
  75298. Matrix.prototype.addToSelf = function (other) {
  75299. var m = this._m;
  75300. var otherM = other.m;
  75301. for (var index = 0; index < 16; index++) {
  75302. m[index] += otherM[index];
  75303. }
  75304. this._markAsUpdated();
  75305. return this;
  75306. };
  75307. /**
  75308. * Sets the given matrix to the current inverted Matrix
  75309. * @param other defines the target matrix
  75310. * @returns the unmodified current matrix
  75311. */
  75312. Matrix.prototype.invertToRef = function (other) {
  75313. if (this._isIdentity === true) {
  75314. Matrix.IdentityToRef(other);
  75315. return this;
  75316. }
  75317. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  75318. var m = this._m;
  75319. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  75320. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  75321. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  75322. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  75323. var det_22_33 = m22 * m33 - m32 * m23;
  75324. var det_21_33 = m21 * m33 - m31 * m23;
  75325. var det_21_32 = m21 * m32 - m31 * m22;
  75326. var det_20_33 = m20 * m33 - m30 * m23;
  75327. var det_20_32 = m20 * m32 - m22 * m30;
  75328. var det_20_31 = m20 * m31 - m30 * m21;
  75329. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  75330. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  75331. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  75332. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  75333. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  75334. if (det === 0) {
  75335. // not invertible
  75336. other.copyFrom(this);
  75337. return this;
  75338. }
  75339. var detInv = 1 / det;
  75340. var det_12_33 = m12 * m33 - m32 * m13;
  75341. var det_11_33 = m11 * m33 - m31 * m13;
  75342. var det_11_32 = m11 * m32 - m31 * m12;
  75343. var det_10_33 = m10 * m33 - m30 * m13;
  75344. var det_10_32 = m10 * m32 - m30 * m12;
  75345. var det_10_31 = m10 * m31 - m30 * m11;
  75346. var det_12_23 = m12 * m23 - m22 * m13;
  75347. var det_11_23 = m11 * m23 - m21 * m13;
  75348. var det_11_22 = m11 * m22 - m21 * m12;
  75349. var det_10_23 = m10 * m23 - m20 * m13;
  75350. var det_10_22 = m10 * m22 - m20 * m12;
  75351. var det_10_21 = m10 * m21 - m20 * m11;
  75352. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  75353. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  75354. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  75355. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  75356. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  75357. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  75358. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  75359. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  75360. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  75361. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  75362. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  75363. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  75364. Matrix.FromValuesToRef(cofact_00 * detInv, cofact_10 * detInv, cofact_20 * detInv, cofact_30 * detInv, cofact_01 * detInv, cofact_11 * detInv, cofact_21 * detInv, cofact_31 * detInv, cofact_02 * detInv, cofact_12 * detInv, cofact_22 * detInv, cofact_32 * detInv, cofact_03 * detInv, cofact_13 * detInv, cofact_23 * detInv, cofact_33 * detInv, other);
  75365. return this;
  75366. };
  75367. /**
  75368. * add a value at the specified position in the current Matrix
  75369. * @param index the index of the value within the matrix. between 0 and 15.
  75370. * @param value the value to be added
  75371. * @returns the current updated matrix
  75372. */
  75373. Matrix.prototype.addAtIndex = function (index, value) {
  75374. this._m[index] += value;
  75375. this._markAsUpdated();
  75376. return this;
  75377. };
  75378. /**
  75379. * mutiply the specified position in the current Matrix by a value
  75380. * @param index the index of the value within the matrix. between 0 and 15.
  75381. * @param value the value to be added
  75382. * @returns the current updated matrix
  75383. */
  75384. Matrix.prototype.multiplyAtIndex = function (index, value) {
  75385. this._m[index] *= value;
  75386. this._markAsUpdated();
  75387. return this;
  75388. };
  75389. /**
  75390. * Inserts the translation vector (using 3 floats) in the current matrix
  75391. * @param x defines the 1st component of the translation
  75392. * @param y defines the 2nd component of the translation
  75393. * @param z defines the 3rd component of the translation
  75394. * @returns the current updated matrix
  75395. */
  75396. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  75397. this._m[12] = x;
  75398. this._m[13] = y;
  75399. this._m[14] = z;
  75400. this._markAsUpdated();
  75401. return this;
  75402. };
  75403. /**
  75404. * Adds the translation vector (using 3 floats) in the current matrix
  75405. * @param x defines the 1st component of the translation
  75406. * @param y defines the 2nd component of the translation
  75407. * @param z defines the 3rd component of the translation
  75408. * @returns the current updated matrix
  75409. */
  75410. Matrix.prototype.addTranslationFromFloats = function (x, y, z) {
  75411. this._m[12] += x;
  75412. this._m[13] += y;
  75413. this._m[14] += z;
  75414. this._markAsUpdated();
  75415. return this;
  75416. };
  75417. /**
  75418. * Inserts the translation vector in the current matrix
  75419. * @param vector3 defines the translation to insert
  75420. * @returns the current updated matrix
  75421. */
  75422. Matrix.prototype.setTranslation = function (vector3) {
  75423. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  75424. };
  75425. /**
  75426. * Gets the translation value of the current matrix
  75427. * @returns a new Vector3 as the extracted translation from the matrix
  75428. */
  75429. Matrix.prototype.getTranslation = function () {
  75430. return new Vector3(this._m[12], this._m[13], this._m[14]);
  75431. };
  75432. /**
  75433. * Fill a Vector3 with the extracted translation from the matrix
  75434. * @param result defines the Vector3 where to store the translation
  75435. * @returns the current matrix
  75436. */
  75437. Matrix.prototype.getTranslationToRef = function (result) {
  75438. result.x = this._m[12];
  75439. result.y = this._m[13];
  75440. result.z = this._m[14];
  75441. return this;
  75442. };
  75443. /**
  75444. * Remove rotation and scaling part from the matrix
  75445. * @returns the updated matrix
  75446. */
  75447. Matrix.prototype.removeRotationAndScaling = function () {
  75448. var m = this.m;
  75449. Matrix.FromValuesToRef(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, m[12], m[13], m[14], m[15], this);
  75450. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  75451. return this;
  75452. };
  75453. /**
  75454. * Multiply two matrices
  75455. * @param other defines the second operand
  75456. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  75457. */
  75458. Matrix.prototype.multiply = function (other) {
  75459. var result = new Matrix();
  75460. this.multiplyToRef(other, result);
  75461. return result;
  75462. };
  75463. /**
  75464. * Copy the current matrix from the given one
  75465. * @param other defines the source matrix
  75466. * @returns the current updated matrix
  75467. */
  75468. Matrix.prototype.copyFrom = function (other) {
  75469. other.copyToArray(this._m);
  75470. var o = other;
  75471. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  75472. return this;
  75473. };
  75474. /**
  75475. * Populates the given array from the starting index with the current matrix values
  75476. * @param array defines the target array
  75477. * @param offset defines the offset in the target array where to start storing values
  75478. * @returns the current matrix
  75479. */
  75480. Matrix.prototype.copyToArray = function (array, offset) {
  75481. if (offset === void 0) { offset = 0; }
  75482. for (var index = 0; index < 16; index++) {
  75483. array[offset + index] = this._m[index];
  75484. }
  75485. return this;
  75486. };
  75487. /**
  75488. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  75489. * @param other defines the second operand
  75490. * @param result defines the matrix where to store the multiplication
  75491. * @returns the current matrix
  75492. */
  75493. Matrix.prototype.multiplyToRef = function (other, result) {
  75494. if (this._isIdentity) {
  75495. result.copyFrom(other);
  75496. return this;
  75497. }
  75498. if (other._isIdentity) {
  75499. result.copyFrom(this);
  75500. return this;
  75501. }
  75502. this.multiplyToArray(other, result._m, 0);
  75503. result._markAsUpdated();
  75504. return this;
  75505. };
  75506. /**
  75507. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  75508. * @param other defines the second operand
  75509. * @param result defines the array where to store the multiplication
  75510. * @param offset defines the offset in the target array where to start storing values
  75511. * @returns the current matrix
  75512. */
  75513. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  75514. var m = this._m;
  75515. var otherM = other.m;
  75516. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  75517. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  75518. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  75519. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  75520. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  75521. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  75522. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  75523. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  75524. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  75525. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  75526. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  75527. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  75528. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  75529. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  75530. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  75531. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  75532. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  75533. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  75534. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  75535. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  75536. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  75537. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  75538. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  75539. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  75540. return this;
  75541. };
  75542. /**
  75543. * Check equality between this matrix and a second one
  75544. * @param value defines the second matrix to compare
  75545. * @returns true is the current matrix and the given one values are strictly equal
  75546. */
  75547. Matrix.prototype.equals = function (value) {
  75548. var other = value;
  75549. if (!other) {
  75550. return false;
  75551. }
  75552. if (this._isIdentity || other._isIdentity) {
  75553. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  75554. return this._isIdentity && other._isIdentity;
  75555. }
  75556. }
  75557. var m = this.m;
  75558. var om = other.m;
  75559. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  75560. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  75561. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  75562. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  75563. };
  75564. /**
  75565. * Clone the current matrix
  75566. * @returns a new matrix from the current matrix
  75567. */
  75568. Matrix.prototype.clone = function () {
  75569. var matrix = new Matrix();
  75570. matrix.copyFrom(this);
  75571. return matrix;
  75572. };
  75573. /**
  75574. * Returns the name of the current matrix class
  75575. * @returns the string "Matrix"
  75576. */
  75577. Matrix.prototype.getClassName = function () {
  75578. return "Matrix";
  75579. };
  75580. /**
  75581. * Gets the hash code of the current matrix
  75582. * @returns the hash code
  75583. */
  75584. Matrix.prototype.getHashCode = function () {
  75585. var hash = this._m[0] || 0;
  75586. for (var i = 1; i < 16; i++) {
  75587. hash = (hash * 397) ^ (this._m[i] || 0);
  75588. }
  75589. return hash;
  75590. };
  75591. /**
  75592. * Decomposes the current Matrix into a translation, rotation and scaling components
  75593. * @param scale defines the scale vector3 given as a reference to update
  75594. * @param rotation defines the rotation quaternion given as a reference to update
  75595. * @param translation defines the translation vector3 given as a reference to update
  75596. * @returns true if operation was successful
  75597. */
  75598. Matrix.prototype.decompose = function (scale, rotation, translation) {
  75599. if (this._isIdentity) {
  75600. if (translation) {
  75601. translation.setAll(0);
  75602. }
  75603. if (scale) {
  75604. scale.setAll(1);
  75605. }
  75606. if (rotation) {
  75607. rotation.copyFromFloats(0, 0, 0, 1);
  75608. }
  75609. return true;
  75610. }
  75611. var m = this._m;
  75612. if (translation) {
  75613. translation.copyFromFloats(m[12], m[13], m[14]);
  75614. }
  75615. scale = scale || MathTmp.Vector3[0];
  75616. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  75617. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  75618. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  75619. if (this.determinant() <= 0) {
  75620. scale.y *= -1;
  75621. }
  75622. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  75623. if (rotation) {
  75624. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  75625. }
  75626. return false;
  75627. }
  75628. if (rotation) {
  75629. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  75630. Matrix.FromValuesToRef(m[0] * sx, m[1] * sx, m[2] * sx, 0.0, m[4] * sy, m[5] * sy, m[6] * sy, 0.0, m[8] * sz, m[9] * sz, m[10] * sz, 0.0, 0.0, 0.0, 0.0, 1.0, MathTmp.Matrix[0]);
  75631. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  75632. }
  75633. return true;
  75634. };
  75635. /**
  75636. * Gets specific row of the matrix
  75637. * @param index defines the number of the row to get
  75638. * @returns the index-th row of the current matrix as a new Vector4
  75639. */
  75640. Matrix.prototype.getRow = function (index) {
  75641. if (index < 0 || index > 3) {
  75642. return null;
  75643. }
  75644. var i = index * 4;
  75645. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  75646. };
  75647. /**
  75648. * Sets the index-th row of the current matrix to the vector4 values
  75649. * @param index defines the number of the row to set
  75650. * @param row defines the target vector4
  75651. * @returns the updated current matrix
  75652. */
  75653. Matrix.prototype.setRow = function (index, row) {
  75654. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  75655. };
  75656. /**
  75657. * Compute the transpose of the matrix
  75658. * @returns the new transposed matrix
  75659. */
  75660. Matrix.prototype.transpose = function () {
  75661. return Matrix.Transpose(this);
  75662. };
  75663. /**
  75664. * Compute the transpose of the matrix and store it in a given matrix
  75665. * @param result defines the target matrix
  75666. * @returns the current matrix
  75667. */
  75668. Matrix.prototype.transposeToRef = function (result) {
  75669. Matrix.TransposeToRef(this, result);
  75670. return this;
  75671. };
  75672. /**
  75673. * Sets the index-th row of the current matrix with the given 4 x float values
  75674. * @param index defines the row index
  75675. * @param x defines the x component to set
  75676. * @param y defines the y component to set
  75677. * @param z defines the z component to set
  75678. * @param w defines the w component to set
  75679. * @returns the updated current matrix
  75680. */
  75681. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  75682. if (index < 0 || index > 3) {
  75683. return this;
  75684. }
  75685. var i = index * 4;
  75686. this._m[i + 0] = x;
  75687. this._m[i + 1] = y;
  75688. this._m[i + 2] = z;
  75689. this._m[i + 3] = w;
  75690. this._markAsUpdated();
  75691. return this;
  75692. };
  75693. /**
  75694. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  75695. * @param scale defines the scale factor
  75696. * @returns a new matrix
  75697. */
  75698. Matrix.prototype.scale = function (scale) {
  75699. var result = new Matrix();
  75700. this.scaleToRef(scale, result);
  75701. return result;
  75702. };
  75703. /**
  75704. * Scale the current matrix values by a factor to a given result matrix
  75705. * @param scale defines the scale factor
  75706. * @param result defines the matrix to store the result
  75707. * @returns the current matrix
  75708. */
  75709. Matrix.prototype.scaleToRef = function (scale, result) {
  75710. for (var index = 0; index < 16; index++) {
  75711. result._m[index] = this._m[index] * scale;
  75712. }
  75713. result._markAsUpdated();
  75714. return this;
  75715. };
  75716. /**
  75717. * Scale the current matrix values by a factor and add the result to a given matrix
  75718. * @param scale defines the scale factor
  75719. * @param result defines the Matrix to store the result
  75720. * @returns the current matrix
  75721. */
  75722. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  75723. for (var index = 0; index < 16; index++) {
  75724. result._m[index] += this._m[index] * scale;
  75725. }
  75726. result._markAsUpdated();
  75727. return this;
  75728. };
  75729. /**
  75730. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  75731. * @param ref matrix to store the result
  75732. */
  75733. Matrix.prototype.toNormalMatrix = function (ref) {
  75734. var tmp = MathTmp.Matrix[0];
  75735. this.invertToRef(tmp);
  75736. tmp.transposeToRef(ref);
  75737. var m = ref._m;
  75738. Matrix.FromValuesToRef(m[0], m[1], m[2], 0.0, m[4], m[5], m[6], 0.0, m[8], m[9], m[10], 0.0, 0.0, 0.0, 0.0, 1.0, ref);
  75739. };
  75740. /**
  75741. * Gets only rotation part of the current matrix
  75742. * @returns a new matrix sets to the extracted rotation matrix from the current one
  75743. */
  75744. Matrix.prototype.getRotationMatrix = function () {
  75745. var result = new Matrix();
  75746. this.getRotationMatrixToRef(result);
  75747. return result;
  75748. };
  75749. /**
  75750. * Extracts the rotation matrix from the current one and sets it as the given "result"
  75751. * @param result defines the target matrix to store data to
  75752. * @returns the current matrix
  75753. */
  75754. Matrix.prototype.getRotationMatrixToRef = function (result) {
  75755. var scale = MathTmp.Vector3[0];
  75756. if (!this.decompose(scale)) {
  75757. Matrix.IdentityToRef(result);
  75758. return this;
  75759. }
  75760. var m = this._m;
  75761. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  75762. Matrix.FromValuesToRef(m[0] * sx, m[1] * sx, m[2] * sx, 0.0, m[4] * sy, m[5] * sy, m[6] * sy, 0.0, m[8] * sz, m[9] * sz, m[10] * sz, 0.0, 0.0, 0.0, 0.0, 1.0, result);
  75763. return this;
  75764. };
  75765. /**
  75766. * Toggles model matrix from being right handed to left handed in place and vice versa
  75767. */
  75768. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  75769. var m = this._m;
  75770. m[2] *= -1;
  75771. m[6] *= -1;
  75772. m[8] *= -1;
  75773. m[9] *= -1;
  75774. m[14] *= -1;
  75775. this._markAsUpdated();
  75776. };
  75777. /**
  75778. * Toggles projection matrix from being right handed to left handed in place and vice versa
  75779. */
  75780. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  75781. var m = this._m;
  75782. m[8] *= -1;
  75783. m[9] *= -1;
  75784. m[10] *= -1;
  75785. m[11] *= -1;
  75786. this._markAsUpdated();
  75787. };
  75788. // Statics
  75789. /**
  75790. * Creates a matrix from an array
  75791. * @param array defines the source array
  75792. * @param offset defines an offset in the source array
  75793. * @returns a new Matrix set from the starting index of the given array
  75794. */
  75795. Matrix.FromArray = function (array, offset) {
  75796. if (offset === void 0) { offset = 0; }
  75797. var result = new Matrix();
  75798. Matrix.FromArrayToRef(array, offset, result);
  75799. return result;
  75800. };
  75801. /**
  75802. * Copy the content of an array into a given matrix
  75803. * @param array defines the source array
  75804. * @param offset defines an offset in the source array
  75805. * @param result defines the target matrix
  75806. */
  75807. Matrix.FromArrayToRef = function (array, offset, result) {
  75808. for (var index = 0; index < 16; index++) {
  75809. result._m[index] = array[index + offset];
  75810. }
  75811. result._markAsUpdated();
  75812. };
  75813. /**
  75814. * Stores an array into a matrix after having multiplied each component by a given factor
  75815. * @param array defines the source array
  75816. * @param offset defines the offset in the source array
  75817. * @param scale defines the scaling factor
  75818. * @param result defines the target matrix
  75819. */
  75820. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  75821. for (var index = 0; index < 16; index++) {
  75822. result._m[index] = array[index + offset] * scale;
  75823. }
  75824. result._markAsUpdated();
  75825. };
  75826. Object.defineProperty(Matrix, "IdentityReadOnly", {
  75827. /**
  75828. * Gets an identity matrix that must not be updated
  75829. */
  75830. get: function () {
  75831. return Matrix._identityReadOnly;
  75832. },
  75833. enumerable: true,
  75834. configurable: true
  75835. });
  75836. /**
  75837. * Stores a list of values (16) inside a given matrix
  75838. * @param initialM11 defines 1st value of 1st row
  75839. * @param initialM12 defines 2nd value of 1st row
  75840. * @param initialM13 defines 3rd value of 1st row
  75841. * @param initialM14 defines 4th value of 1st row
  75842. * @param initialM21 defines 1st value of 2nd row
  75843. * @param initialM22 defines 2nd value of 2nd row
  75844. * @param initialM23 defines 3rd value of 2nd row
  75845. * @param initialM24 defines 4th value of 2nd row
  75846. * @param initialM31 defines 1st value of 3rd row
  75847. * @param initialM32 defines 2nd value of 3rd row
  75848. * @param initialM33 defines 3rd value of 3rd row
  75849. * @param initialM34 defines 4th value of 3rd row
  75850. * @param initialM41 defines 1st value of 4th row
  75851. * @param initialM42 defines 2nd value of 4th row
  75852. * @param initialM43 defines 3rd value of 4th row
  75853. * @param initialM44 defines 4th value of 4th row
  75854. * @param result defines the target matrix
  75855. */
  75856. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  75857. var m = result._m;
  75858. m[0] = initialM11;
  75859. m[1] = initialM12;
  75860. m[2] = initialM13;
  75861. m[3] = initialM14;
  75862. m[4] = initialM21;
  75863. m[5] = initialM22;
  75864. m[6] = initialM23;
  75865. m[7] = initialM24;
  75866. m[8] = initialM31;
  75867. m[9] = initialM32;
  75868. m[10] = initialM33;
  75869. m[11] = initialM34;
  75870. m[12] = initialM41;
  75871. m[13] = initialM42;
  75872. m[14] = initialM43;
  75873. m[15] = initialM44;
  75874. result._markAsUpdated();
  75875. };
  75876. /**
  75877. * Creates new matrix from a list of values (16)
  75878. * @param initialM11 defines 1st value of 1st row
  75879. * @param initialM12 defines 2nd value of 1st row
  75880. * @param initialM13 defines 3rd value of 1st row
  75881. * @param initialM14 defines 4th value of 1st row
  75882. * @param initialM21 defines 1st value of 2nd row
  75883. * @param initialM22 defines 2nd value of 2nd row
  75884. * @param initialM23 defines 3rd value of 2nd row
  75885. * @param initialM24 defines 4th value of 2nd row
  75886. * @param initialM31 defines 1st value of 3rd row
  75887. * @param initialM32 defines 2nd value of 3rd row
  75888. * @param initialM33 defines 3rd value of 3rd row
  75889. * @param initialM34 defines 4th value of 3rd row
  75890. * @param initialM41 defines 1st value of 4th row
  75891. * @param initialM42 defines 2nd value of 4th row
  75892. * @param initialM43 defines 3rd value of 4th row
  75893. * @param initialM44 defines 4th value of 4th row
  75894. * @returns the new matrix
  75895. */
  75896. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  75897. var result = new Matrix();
  75898. var m = result._m;
  75899. m[0] = initialM11;
  75900. m[1] = initialM12;
  75901. m[2] = initialM13;
  75902. m[3] = initialM14;
  75903. m[4] = initialM21;
  75904. m[5] = initialM22;
  75905. m[6] = initialM23;
  75906. m[7] = initialM24;
  75907. m[8] = initialM31;
  75908. m[9] = initialM32;
  75909. m[10] = initialM33;
  75910. m[11] = initialM34;
  75911. m[12] = initialM41;
  75912. m[13] = initialM42;
  75913. m[14] = initialM43;
  75914. m[15] = initialM44;
  75915. result._markAsUpdated();
  75916. return result;
  75917. };
  75918. /**
  75919. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  75920. * @param scale defines the scale vector3
  75921. * @param rotation defines the rotation quaternion
  75922. * @param translation defines the translation vector3
  75923. * @returns a new matrix
  75924. */
  75925. Matrix.Compose = function (scale, rotation, translation) {
  75926. var result = new Matrix();
  75927. Matrix.ComposeToRef(scale, rotation, translation, result);
  75928. return result;
  75929. };
  75930. /**
  75931. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  75932. * @param scale defines the scale vector3
  75933. * @param rotation defines the rotation quaternion
  75934. * @param translation defines the translation vector3
  75935. * @param result defines the target matrix
  75936. */
  75937. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  75938. var m = result._m;
  75939. var x = rotation.x, y = rotation.y, z = rotation.z, w = rotation.w;
  75940. var x2 = x + x, y2 = y + y, z2 = z + z;
  75941. var xx = x * x2, xy = x * y2, xz = x * z2;
  75942. var yy = y * y2, yz = y * z2, zz = z * z2;
  75943. var wx = w * x2, wy = w * y2, wz = w * z2;
  75944. var sx = scale.x, sy = scale.y, sz = scale.z;
  75945. m[0] = (1 - (yy + zz)) * sx;
  75946. m[1] = (xy + wz) * sx;
  75947. m[2] = (xz - wy) * sx;
  75948. m[3] = 0;
  75949. m[4] = (xy - wz) * sy;
  75950. m[5] = (1 - (xx + zz)) * sy;
  75951. m[6] = (yz + wx) * sy;
  75952. m[7] = 0;
  75953. m[8] = (xz + wy) * sz;
  75954. m[9] = (yz - wx) * sz;
  75955. m[10] = (1 - (xx + yy)) * sz;
  75956. m[11] = 0;
  75957. m[12] = translation.x;
  75958. m[13] = translation.y;
  75959. m[14] = translation.z;
  75960. m[15] = 1;
  75961. };
  75962. /**
  75963. * Creates a new identity matrix
  75964. * @returns a new identity matrix
  75965. */
  75966. Matrix.Identity = function () {
  75967. var identity = Matrix.FromValues(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
  75968. identity._updateIdentityStatus(true);
  75969. return identity;
  75970. };
  75971. /**
  75972. * Creates a new identity matrix and stores the result in a given matrix
  75973. * @param result defines the target matrix
  75974. */
  75975. Matrix.IdentityToRef = function (result) {
  75976. Matrix.FromValuesToRef(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, result);
  75977. result._updateIdentityStatus(true);
  75978. };
  75979. /**
  75980. * Creates a new zero matrix
  75981. * @returns a new zero matrix
  75982. */
  75983. Matrix.Zero = function () {
  75984. var zero = Matrix.FromValues(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  75985. zero._updateIdentityStatus(false);
  75986. return zero;
  75987. };
  75988. /**
  75989. * Creates a new rotation matrix for "angle" radians around the X axis
  75990. * @param angle defines the angle (in radians) to use
  75991. * @return the new matrix
  75992. */
  75993. Matrix.RotationX = function (angle) {
  75994. var result = new Matrix();
  75995. Matrix.RotationXToRef(angle, result);
  75996. return result;
  75997. };
  75998. /**
  75999. * Creates a new matrix as the invert of a given matrix
  76000. * @param source defines the source matrix
  76001. * @returns the new matrix
  76002. */
  76003. Matrix.Invert = function (source) {
  76004. var result = new Matrix();
  76005. source.invertToRef(result);
  76006. return result;
  76007. };
  76008. /**
  76009. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  76010. * @param angle defines the angle (in radians) to use
  76011. * @param result defines the target matrix
  76012. */
  76013. Matrix.RotationXToRef = function (angle, result) {
  76014. var s = Math.sin(angle);
  76015. var c = Math.cos(angle);
  76016. Matrix.FromValuesToRef(1.0, 0.0, 0.0, 0.0, 0.0, c, s, 0.0, 0.0, -s, c, 0.0, 0.0, 0.0, 0.0, 1.0, result);
  76017. result._updateIdentityStatus(c === 1 && s === 0);
  76018. };
  76019. /**
  76020. * Creates a new rotation matrix for "angle" radians around the Y axis
  76021. * @param angle defines the angle (in radians) to use
  76022. * @return the new matrix
  76023. */
  76024. Matrix.RotationY = function (angle) {
  76025. var result = new Matrix();
  76026. Matrix.RotationYToRef(angle, result);
  76027. return result;
  76028. };
  76029. /**
  76030. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  76031. * @param angle defines the angle (in radians) to use
  76032. * @param result defines the target matrix
  76033. */
  76034. Matrix.RotationYToRef = function (angle, result) {
  76035. var s = Math.sin(angle);
  76036. var c = Math.cos(angle);
  76037. Matrix.FromValuesToRef(c, 0.0, -s, 0.0, 0.0, 1.0, 0.0, 0.0, s, 0.0, c, 0.0, 0.0, 0.0, 0.0, 1.0, result);
  76038. result._updateIdentityStatus(c === 1 && s === 0);
  76039. };
  76040. /**
  76041. * Creates a new rotation matrix for "angle" radians around the Z axis
  76042. * @param angle defines the angle (in radians) to use
  76043. * @return the new matrix
  76044. */
  76045. Matrix.RotationZ = function (angle) {
  76046. var result = new Matrix();
  76047. Matrix.RotationZToRef(angle, result);
  76048. return result;
  76049. };
  76050. /**
  76051. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  76052. * @param angle defines the angle (in radians) to use
  76053. * @param result defines the target matrix
  76054. */
  76055. Matrix.RotationZToRef = function (angle, result) {
  76056. var s = Math.sin(angle);
  76057. var c = Math.cos(angle);
  76058. Matrix.FromValuesToRef(c, s, 0.0, 0.0, -s, c, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, result);
  76059. result._updateIdentityStatus(c === 1 && s === 0);
  76060. };
  76061. /**
  76062. * Creates a new rotation matrix for "angle" radians around the given axis
  76063. * @param axis defines the axis to use
  76064. * @param angle defines the angle (in radians) to use
  76065. * @return the new matrix
  76066. */
  76067. Matrix.RotationAxis = function (axis, angle) {
  76068. var result = new Matrix();
  76069. Matrix.RotationAxisToRef(axis, angle, result);
  76070. return result;
  76071. };
  76072. /**
  76073. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  76074. * @param axis defines the axis to use
  76075. * @param angle defines the angle (in radians) to use
  76076. * @param result defines the target matrix
  76077. */
  76078. Matrix.RotationAxisToRef = function (axis, angle, result) {
  76079. var s = Math.sin(-angle);
  76080. var c = Math.cos(-angle);
  76081. var c1 = 1 - c;
  76082. axis.normalize();
  76083. var m = result._m;
  76084. m[0] = (axis.x * axis.x) * c1 + c;
  76085. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  76086. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  76087. m[3] = 0.0;
  76088. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  76089. m[5] = (axis.y * axis.y) * c1 + c;
  76090. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  76091. m[7] = 0.0;
  76092. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  76093. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  76094. m[10] = (axis.z * axis.z) * c1 + c;
  76095. m[11] = 0.0;
  76096. m[12] = 0.0;
  76097. m[13] = 0.0;
  76098. m[14] = 0.0;
  76099. m[15] = 1.0;
  76100. result._markAsUpdated();
  76101. };
  76102. /**
  76103. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  76104. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  76105. * @param from defines the vector to align
  76106. * @param to defines the vector to align to
  76107. * @param result defines the target matrix
  76108. */
  76109. Matrix.RotationAlignToRef = function (from, to, result) {
  76110. var v = Vector3.Cross(to, from);
  76111. var c = Vector3.Dot(to, from);
  76112. var k = 1 / (1 + c);
  76113. var m = result._m;
  76114. m[0] = v.x * v.x * k + c;
  76115. m[1] = v.y * v.x * k - v.z;
  76116. m[2] = v.z * v.x * k + v.y;
  76117. m[3] = 0;
  76118. m[4] = v.x * v.y * k + v.z;
  76119. m[5] = v.y * v.y * k + c;
  76120. m[6] = v.z * v.y * k - v.x;
  76121. m[7] = 0;
  76122. m[8] = v.x * v.z * k - v.y;
  76123. m[9] = v.y * v.z * k + v.x;
  76124. m[10] = v.z * v.z * k + c;
  76125. m[11] = 0;
  76126. m[12] = 0;
  76127. m[13] = 0;
  76128. m[14] = 0;
  76129. m[15] = 1;
  76130. result._markAsUpdated();
  76131. };
  76132. /**
  76133. * Creates a rotation matrix
  76134. * @param yaw defines the yaw angle in radians (Y axis)
  76135. * @param pitch defines the pitch angle in radians (X axis)
  76136. * @param roll defines the roll angle in radians (X axis)
  76137. * @returns the new rotation matrix
  76138. */
  76139. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  76140. var result = new Matrix();
  76141. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  76142. return result;
  76143. };
  76144. /**
  76145. * Creates a rotation matrix and stores it in a given matrix
  76146. * @param yaw defines the yaw angle in radians (Y axis)
  76147. * @param pitch defines the pitch angle in radians (X axis)
  76148. * @param roll defines the roll angle in radians (X axis)
  76149. * @param result defines the target matrix
  76150. */
  76151. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  76152. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  76153. MathTmp.Quaternion[0].toRotationMatrix(result);
  76154. };
  76155. /**
  76156. * Creates a scaling matrix
  76157. * @param x defines the scale factor on X axis
  76158. * @param y defines the scale factor on Y axis
  76159. * @param z defines the scale factor on Z axis
  76160. * @returns the new matrix
  76161. */
  76162. Matrix.Scaling = function (x, y, z) {
  76163. var result = new Matrix();
  76164. Matrix.ScalingToRef(x, y, z, result);
  76165. return result;
  76166. };
  76167. /**
  76168. * Creates a scaling matrix and stores it in a given matrix
  76169. * @param x defines the scale factor on X axis
  76170. * @param y defines the scale factor on Y axis
  76171. * @param z defines the scale factor on Z axis
  76172. * @param result defines the target matrix
  76173. */
  76174. Matrix.ScalingToRef = function (x, y, z, result) {
  76175. Matrix.FromValuesToRef(x, 0.0, 0.0, 0.0, 0.0, y, 0.0, 0.0, 0.0, 0.0, z, 0.0, 0.0, 0.0, 0.0, 1.0, result);
  76176. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  76177. };
  76178. /**
  76179. * Creates a translation matrix
  76180. * @param x defines the translation on X axis
  76181. * @param y defines the translation on Y axis
  76182. * @param z defines the translationon Z axis
  76183. * @returns the new matrix
  76184. */
  76185. Matrix.Translation = function (x, y, z) {
  76186. var result = new Matrix();
  76187. Matrix.TranslationToRef(x, y, z, result);
  76188. return result;
  76189. };
  76190. /**
  76191. * Creates a translation matrix and stores it in a given matrix
  76192. * @param x defines the translation on X axis
  76193. * @param y defines the translation on Y axis
  76194. * @param z defines the translationon Z axis
  76195. * @param result defines the target matrix
  76196. */
  76197. Matrix.TranslationToRef = function (x, y, z, result) {
  76198. Matrix.FromValuesToRef(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, x, y, z, 1.0, result);
  76199. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  76200. };
  76201. /**
  76202. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  76203. * @param startValue defines the start value
  76204. * @param endValue defines the end value
  76205. * @param gradient defines the gradient factor
  76206. * @returns the new matrix
  76207. */
  76208. Matrix.Lerp = function (startValue, endValue, gradient) {
  76209. var result = new Matrix();
  76210. Matrix.LerpToRef(startValue, endValue, gradient, result);
  76211. return result;
  76212. };
  76213. /**
  76214. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  76215. * @param startValue defines the start value
  76216. * @param endValue defines the end value
  76217. * @param gradient defines the gradient factor
  76218. * @param result defines the Matrix object where to store data
  76219. */
  76220. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  76221. var resultM = result._m;
  76222. var startM = startValue.m;
  76223. var endM = endValue.m;
  76224. for (var index = 0; index < 16; index++) {
  76225. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  76226. }
  76227. result._markAsUpdated();
  76228. };
  76229. /**
  76230. * Builds a new matrix whose values are computed by:
  76231. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  76232. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  76233. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  76234. * @param startValue defines the first matrix
  76235. * @param endValue defines the second matrix
  76236. * @param gradient defines the gradient between the two matrices
  76237. * @returns the new matrix
  76238. */
  76239. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  76240. var result = new Matrix();
  76241. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  76242. return result;
  76243. };
  76244. /**
  76245. * Update a matrix to values which are computed by:
  76246. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  76247. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  76248. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  76249. * @param startValue defines the first matrix
  76250. * @param endValue defines the second matrix
  76251. * @param gradient defines the gradient between the two matrices
  76252. * @param result defines the target matrix
  76253. */
  76254. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  76255. var startScale = MathTmp.Vector3[0];
  76256. var startRotation = MathTmp.Quaternion[0];
  76257. var startTranslation = MathTmp.Vector3[1];
  76258. startValue.decompose(startScale, startRotation, startTranslation);
  76259. var endScale = MathTmp.Vector3[2];
  76260. var endRotation = MathTmp.Quaternion[1];
  76261. var endTranslation = MathTmp.Vector3[3];
  76262. endValue.decompose(endScale, endRotation, endTranslation);
  76263. var resultScale = MathTmp.Vector3[4];
  76264. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  76265. var resultRotation = MathTmp.Quaternion[2];
  76266. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  76267. var resultTranslation = MathTmp.Vector3[5];
  76268. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  76269. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  76270. };
  76271. /**
  76272. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  76273. * This function works in left handed mode
  76274. * @param eye defines the final position of the entity
  76275. * @param target defines where the entity should look at
  76276. * @param up defines the up vector for the entity
  76277. * @returns the new matrix
  76278. */
  76279. Matrix.LookAtLH = function (eye, target, up) {
  76280. var result = new Matrix();
  76281. Matrix.LookAtLHToRef(eye, target, up, result);
  76282. return result;
  76283. };
  76284. /**
  76285. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  76286. * This function works in left handed mode
  76287. * @param eye defines the final position of the entity
  76288. * @param target defines where the entity should look at
  76289. * @param up defines the up vector for the entity
  76290. * @param result defines the target matrix
  76291. */
  76292. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  76293. var xAxis = MathTmp.Vector3[0];
  76294. var yAxis = MathTmp.Vector3[1];
  76295. var zAxis = MathTmp.Vector3[2];
  76296. // Z axis
  76297. target.subtractToRef(eye, zAxis);
  76298. zAxis.normalize();
  76299. // X axis
  76300. Vector3.CrossToRef(up, zAxis, xAxis);
  76301. var xSquareLength = xAxis.lengthSquared();
  76302. if (xSquareLength === 0) {
  76303. xAxis.x = 1.0;
  76304. }
  76305. else {
  76306. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  76307. }
  76308. // Y axis
  76309. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  76310. yAxis.normalize();
  76311. // Eye angles
  76312. var ex = -Vector3.Dot(xAxis, eye);
  76313. var ey = -Vector3.Dot(yAxis, eye);
  76314. var ez = -Vector3.Dot(zAxis, eye);
  76315. Matrix.FromValuesToRef(xAxis.x, yAxis.x, zAxis.x, 0.0, xAxis.y, yAxis.y, zAxis.y, 0.0, xAxis.z, yAxis.z, zAxis.z, 0.0, ex, ey, ez, 1.0, result);
  76316. };
  76317. /**
  76318. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  76319. * This function works in right handed mode
  76320. * @param eye defines the final position of the entity
  76321. * @param target defines where the entity should look at
  76322. * @param up defines the up vector for the entity
  76323. * @returns the new matrix
  76324. */
  76325. Matrix.LookAtRH = function (eye, target, up) {
  76326. var result = new Matrix();
  76327. Matrix.LookAtRHToRef(eye, target, up, result);
  76328. return result;
  76329. };
  76330. /**
  76331. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  76332. * This function works in right handed mode
  76333. * @param eye defines the final position of the entity
  76334. * @param target defines where the entity should look at
  76335. * @param up defines the up vector for the entity
  76336. * @param result defines the target matrix
  76337. */
  76338. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  76339. var xAxis = MathTmp.Vector3[0];
  76340. var yAxis = MathTmp.Vector3[1];
  76341. var zAxis = MathTmp.Vector3[2];
  76342. // Z axis
  76343. eye.subtractToRef(target, zAxis);
  76344. zAxis.normalize();
  76345. // X axis
  76346. Vector3.CrossToRef(up, zAxis, xAxis);
  76347. var xSquareLength = xAxis.lengthSquared();
  76348. if (xSquareLength === 0) {
  76349. xAxis.x = 1.0;
  76350. }
  76351. else {
  76352. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  76353. }
  76354. // Y axis
  76355. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  76356. yAxis.normalize();
  76357. // Eye angles
  76358. var ex = -Vector3.Dot(xAxis, eye);
  76359. var ey = -Vector3.Dot(yAxis, eye);
  76360. var ez = -Vector3.Dot(zAxis, eye);
  76361. Matrix.FromValuesToRef(xAxis.x, yAxis.x, zAxis.x, 0.0, xAxis.y, yAxis.y, zAxis.y, 0.0, xAxis.z, yAxis.z, zAxis.z, 0.0, ex, ey, ez, 1.0, result);
  76362. };
  76363. /**
  76364. * Create a left-handed orthographic projection matrix
  76365. * @param width defines the viewport width
  76366. * @param height defines the viewport height
  76367. * @param znear defines the near clip plane
  76368. * @param zfar defines the far clip plane
  76369. * @returns a new matrix as a left-handed orthographic projection matrix
  76370. */
  76371. Matrix.OrthoLH = function (width, height, znear, zfar) {
  76372. var matrix = new Matrix();
  76373. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  76374. return matrix;
  76375. };
  76376. /**
  76377. * Store a left-handed orthographic projection to a given matrix
  76378. * @param width defines the viewport width
  76379. * @param height defines the viewport height
  76380. * @param znear defines the near clip plane
  76381. * @param zfar defines the far clip plane
  76382. * @param result defines the target matrix
  76383. */
  76384. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  76385. var n = znear;
  76386. var f = zfar;
  76387. var a = 2.0 / width;
  76388. var b = 2.0 / height;
  76389. var c = 2.0 / (f - n);
  76390. var d = -(f + n) / (f - n);
  76391. Matrix.FromValuesToRef(a, 0.0, 0.0, 0.0, 0.0, b, 0.0, 0.0, 0.0, 0.0, c, 0.0, 0.0, 0.0, d, 1.0, result);
  76392. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  76393. };
  76394. /**
  76395. * Create a left-handed orthographic projection matrix
  76396. * @param left defines the viewport left coordinate
  76397. * @param right defines the viewport right coordinate
  76398. * @param bottom defines the viewport bottom coordinate
  76399. * @param top defines the viewport top coordinate
  76400. * @param znear defines the near clip plane
  76401. * @param zfar defines the far clip plane
  76402. * @returns a new matrix as a left-handed orthographic projection matrix
  76403. */
  76404. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  76405. var matrix = new Matrix();
  76406. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  76407. return matrix;
  76408. };
  76409. /**
  76410. * Stores a left-handed orthographic projection into a given matrix
  76411. * @param left defines the viewport left coordinate
  76412. * @param right defines the viewport right coordinate
  76413. * @param bottom defines the viewport bottom coordinate
  76414. * @param top defines the viewport top coordinate
  76415. * @param znear defines the near clip plane
  76416. * @param zfar defines the far clip plane
  76417. * @param result defines the target matrix
  76418. */
  76419. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  76420. var n = znear;
  76421. var f = zfar;
  76422. var a = 2.0 / (right - left);
  76423. var b = 2.0 / (top - bottom);
  76424. var c = 2.0 / (f - n);
  76425. var d = -(f + n) / (f - n);
  76426. var i0 = (left + right) / (left - right);
  76427. var i1 = (top + bottom) / (bottom - top);
  76428. Matrix.FromValuesToRef(a, 0.0, 0.0, 0.0, 0.0, b, 0.0, 0.0, 0.0, 0.0, c, 0.0, i0, i1, d, 1.0, result);
  76429. result._markAsUpdated();
  76430. };
  76431. /**
  76432. * Creates a right-handed orthographic projection matrix
  76433. * @param left defines the viewport left coordinate
  76434. * @param right defines the viewport right coordinate
  76435. * @param bottom defines the viewport bottom coordinate
  76436. * @param top defines the viewport top coordinate
  76437. * @param znear defines the near clip plane
  76438. * @param zfar defines the far clip plane
  76439. * @returns a new matrix as a right-handed orthographic projection matrix
  76440. */
  76441. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  76442. var matrix = new Matrix();
  76443. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  76444. return matrix;
  76445. };
  76446. /**
  76447. * Stores a right-handed orthographic projection into a given matrix
  76448. * @param left defines the viewport left coordinate
  76449. * @param right defines the viewport right coordinate
  76450. * @param bottom defines the viewport bottom coordinate
  76451. * @param top defines the viewport top coordinate
  76452. * @param znear defines the near clip plane
  76453. * @param zfar defines the far clip plane
  76454. * @param result defines the target matrix
  76455. */
  76456. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  76457. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  76458. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  76459. };
  76460. /**
  76461. * Creates a left-handed perspective projection matrix
  76462. * @param width defines the viewport width
  76463. * @param height defines the viewport height
  76464. * @param znear defines the near clip plane
  76465. * @param zfar defines the far clip plane
  76466. * @returns a new matrix as a left-handed perspective projection matrix
  76467. */
  76468. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  76469. var matrix = new Matrix();
  76470. var n = znear;
  76471. var f = zfar;
  76472. var a = 2.0 * n / width;
  76473. var b = 2.0 * n / height;
  76474. var c = (f + n) / (f - n);
  76475. var d = -2.0 * f * n / (f - n);
  76476. Matrix.FromValuesToRef(a, 0.0, 0.0, 0.0, 0.0, b, 0.0, 0.0, 0.0, 0.0, c, 1.0, 0.0, 0.0, d, 0.0, matrix);
  76477. matrix._updateIdentityStatus(false);
  76478. return matrix;
  76479. };
  76480. /**
  76481. * Creates a left-handed perspective projection matrix
  76482. * @param fov defines the horizontal field of view
  76483. * @param aspect defines the aspect ratio
  76484. * @param znear defines the near clip plane
  76485. * @param zfar defines the far clip plane
  76486. * @returns a new matrix as a left-handed perspective projection matrix
  76487. */
  76488. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  76489. var matrix = new Matrix();
  76490. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  76491. return matrix;
  76492. };
  76493. /**
  76494. * Stores a left-handed perspective projection into a given matrix
  76495. * @param fov defines the horizontal field of view
  76496. * @param aspect defines the aspect ratio
  76497. * @param znear defines the near clip plane
  76498. * @param zfar defines the far clip plane
  76499. * @param result defines the target matrix
  76500. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  76501. */
  76502. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  76503. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  76504. var n = znear;
  76505. var f = zfar;
  76506. var t = 1.0 / (Math.tan(fov * 0.5));
  76507. var a = isVerticalFovFixed ? (t / aspect) : t;
  76508. var b = isVerticalFovFixed ? t : (t * aspect);
  76509. var c = (f + n) / (f - n);
  76510. var d = -2.0 * f * n / (f - n);
  76511. Matrix.FromValuesToRef(a, 0.0, 0.0, 0.0, 0.0, b, 0.0, 0.0, 0.0, 0.0, c, 1.0, 0.0, 0.0, d, 0.0, result);
  76512. result._updateIdentityStatus(false);
  76513. };
  76514. /**
  76515. * Creates a right-handed perspective projection matrix
  76516. * @param fov defines the horizontal field of view
  76517. * @param aspect defines the aspect ratio
  76518. * @param znear defines the near clip plane
  76519. * @param zfar defines the far clip plane
  76520. * @returns a new matrix as a right-handed perspective projection matrix
  76521. */
  76522. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  76523. var matrix = new Matrix();
  76524. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  76525. return matrix;
  76526. };
  76527. /**
  76528. * Stores a right-handed perspective projection into a given matrix
  76529. * @param fov defines the horizontal field of view
  76530. * @param aspect defines the aspect ratio
  76531. * @param znear defines the near clip plane
  76532. * @param zfar defines the far clip plane
  76533. * @param result defines the target matrix
  76534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  76535. */
  76536. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  76537. //alternatively this could be expressed as:
  76538. // m = PerspectiveFovLHToRef
  76539. // m[10] *= -1.0;
  76540. // m[11] *= -1.0;
  76541. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  76542. var n = znear;
  76543. var f = zfar;
  76544. var t = 1.0 / (Math.tan(fov * 0.5));
  76545. var a = isVerticalFovFixed ? (t / aspect) : t;
  76546. var b = isVerticalFovFixed ? t : (t * aspect);
  76547. var c = -(f + n) / (f - n);
  76548. var d = -2 * f * n / (f - n);
  76549. Matrix.FromValuesToRef(a, 0.0, 0.0, 0.0, 0.0, b, 0.0, 0.0, 0.0, 0.0, c, -1.0, 0.0, 0.0, d, 0.0, result);
  76550. result._updateIdentityStatus(false);
  76551. };
  76552. /**
  76553. * Stores a perspective projection for WebVR info a given matrix
  76554. * @param fov defines the field of view
  76555. * @param znear defines the near clip plane
  76556. * @param zfar defines the far clip plane
  76557. * @param result defines the target matrix
  76558. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  76559. */
  76560. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  76561. if (rightHanded === void 0) { rightHanded = false; }
  76562. var rightHandedFactor = rightHanded ? -1 : 1;
  76563. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  76564. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  76565. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  76566. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  76567. var xScale = 2.0 / (leftTan + rightTan);
  76568. var yScale = 2.0 / (upTan + downTan);
  76569. var m = result._m;
  76570. m[0] = xScale;
  76571. m[1] = m[2] = m[3] = m[4] = 0.0;
  76572. m[5] = yScale;
  76573. m[6] = m[7] = 0.0;
  76574. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  76575. m[9] = -((upTan - downTan) * yScale * 0.5);
  76576. m[10] = -zfar / (znear - zfar);
  76577. m[11] = 1.0 * rightHandedFactor;
  76578. m[12] = m[13] = m[15] = 0.0;
  76579. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  76580. result._markAsUpdated();
  76581. };
  76582. /**
  76583. * Computes a complete transformation matrix
  76584. * @param viewport defines the viewport to use
  76585. * @param world defines the world matrix
  76586. * @param view defines the view matrix
  76587. * @param projection defines the projection matrix
  76588. * @param zmin defines the near clip plane
  76589. * @param zmax defines the far clip plane
  76590. * @returns the transformation matrix
  76591. */
  76592. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  76593. var cw = viewport.width;
  76594. var ch = viewport.height;
  76595. var cx = viewport.x;
  76596. var cy = viewport.y;
  76597. var viewportMatrix = Matrix.FromValues(cw / 2.0, 0.0, 0.0, 0.0, 0.0, -ch / 2.0, 0.0, 0.0, 0.0, 0.0, zmax - zmin, 0.0, cx + cw / 2.0, ch / 2.0 + cy, zmin, 1.0);
  76598. var matrix = MathTmp.Matrix[0];
  76599. world.multiplyToRef(view, matrix);
  76600. matrix.multiplyToRef(projection, matrix);
  76601. return matrix.multiply(viewportMatrix);
  76602. };
  76603. /**
  76604. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  76605. * @param matrix defines the matrix to use
  76606. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  76607. */
  76608. Matrix.GetAsMatrix2x2 = function (matrix) {
  76609. var m = matrix.m;
  76610. return new Float32Array([m[0], m[1], m[4], m[5]]);
  76611. };
  76612. /**
  76613. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  76614. * @param matrix defines the matrix to use
  76615. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  76616. */
  76617. Matrix.GetAsMatrix3x3 = function (matrix) {
  76618. var m = matrix.m;
  76619. return new Float32Array([
  76620. m[0], m[1], m[2],
  76621. m[4], m[5], m[6],
  76622. m[8], m[9], m[10]
  76623. ]);
  76624. };
  76625. /**
  76626. * Compute the transpose of a given matrix
  76627. * @param matrix defines the matrix to transpose
  76628. * @returns the new matrix
  76629. */
  76630. Matrix.Transpose = function (matrix) {
  76631. var result = new Matrix();
  76632. Matrix.TransposeToRef(matrix, result);
  76633. return result;
  76634. };
  76635. /**
  76636. * Compute the transpose of a matrix and store it in a target matrix
  76637. * @param matrix defines the matrix to transpose
  76638. * @param result defines the target matrix
  76639. */
  76640. Matrix.TransposeToRef = function (matrix, result) {
  76641. var rm = result._m;
  76642. var mm = matrix.m;
  76643. rm[0] = mm[0];
  76644. rm[1] = mm[4];
  76645. rm[2] = mm[8];
  76646. rm[3] = mm[12];
  76647. rm[4] = mm[1];
  76648. rm[5] = mm[5];
  76649. rm[6] = mm[9];
  76650. rm[7] = mm[13];
  76651. rm[8] = mm[2];
  76652. rm[9] = mm[6];
  76653. rm[10] = mm[10];
  76654. rm[11] = mm[14];
  76655. rm[12] = mm[3];
  76656. rm[13] = mm[7];
  76657. rm[14] = mm[11];
  76658. rm[15] = mm[15];
  76659. // identity-ness does not change when transposing
  76660. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  76661. };
  76662. /**
  76663. * Computes a reflection matrix from a plane
  76664. * @param plane defines the reflection plane
  76665. * @returns a new matrix
  76666. */
  76667. Matrix.Reflection = function (plane) {
  76668. var matrix = new Matrix();
  76669. Matrix.ReflectionToRef(plane, matrix);
  76670. return matrix;
  76671. };
  76672. /**
  76673. * Computes a reflection matrix from a plane
  76674. * @param plane defines the reflection plane
  76675. * @param result defines the target matrix
  76676. */
  76677. Matrix.ReflectionToRef = function (plane, result) {
  76678. plane.normalize();
  76679. var x = plane.normal.x;
  76680. var y = plane.normal.y;
  76681. var z = plane.normal.z;
  76682. var temp = -2 * x;
  76683. var temp2 = -2 * y;
  76684. var temp3 = -2 * z;
  76685. Matrix.FromValuesToRef(temp * x + 1, temp2 * x, temp3 * x, 0.0, temp * y, temp2 * y + 1, temp3 * y, 0.0, temp * z, temp2 * z, temp3 * z + 1, 0.0, temp * plane.d, temp2 * plane.d, temp3 * plane.d, 1.0, result);
  76686. };
  76687. /**
  76688. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  76689. * @param xaxis defines the value of the 1st axis
  76690. * @param yaxis defines the value of the 2nd axis
  76691. * @param zaxis defines the value of the 3rd axis
  76692. * @param result defines the target matrix
  76693. */
  76694. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  76695. Matrix.FromValuesToRef(xaxis.x, xaxis.y, xaxis.z, 0.0, yaxis.x, yaxis.y, yaxis.z, 0.0, zaxis.x, zaxis.y, zaxis.z, 0.0, 0.0, 0.0, 0.0, 1.0, result);
  76696. };
  76697. /**
  76698. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  76699. * @param quat defines the quaternion to use
  76700. * @param result defines the target matrix
  76701. */
  76702. Matrix.FromQuaternionToRef = function (quat, result) {
  76703. var xx = quat.x * quat.x;
  76704. var yy = quat.y * quat.y;
  76705. var zz = quat.z * quat.z;
  76706. var xy = quat.x * quat.y;
  76707. var zw = quat.z * quat.w;
  76708. var zx = quat.z * quat.x;
  76709. var yw = quat.y * quat.w;
  76710. var yz = quat.y * quat.z;
  76711. var xw = quat.x * quat.w;
  76712. result._m[0] = 1.0 - (2.0 * (yy + zz));
  76713. result._m[1] = 2.0 * (xy + zw);
  76714. result._m[2] = 2.0 * (zx - yw);
  76715. result._m[3] = 0.0;
  76716. result._m[4] = 2.0 * (xy - zw);
  76717. result._m[5] = 1.0 - (2.0 * (zz + xx));
  76718. result._m[6] = 2.0 * (yz + xw);
  76719. result._m[7] = 0.0;
  76720. result._m[8] = 2.0 * (zx + yw);
  76721. result._m[9] = 2.0 * (yz - xw);
  76722. result._m[10] = 1.0 - (2.0 * (yy + xx));
  76723. result._m[11] = 0.0;
  76724. result._m[12] = 0.0;
  76725. result._m[13] = 0.0;
  76726. result._m[14] = 0.0;
  76727. result._m[15] = 1.0;
  76728. result._markAsUpdated();
  76729. };
  76730. Matrix._updateFlagSeed = 0;
  76731. Matrix._identityReadOnly = Matrix.Identity();
  76732. return Matrix;
  76733. }());
  76734. /**
  76735. * Represens a plane by the equation ax + by + cz + d = 0
  76736. */
  76737. var Plane = /** @class */ (function () {
  76738. /**
  76739. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  76740. * @param a a component of the plane
  76741. * @param b b component of the plane
  76742. * @param c c component of the plane
  76743. * @param d d component of the plane
  76744. */
  76745. function Plane(a, b, c, d) {
  76746. this.normal = new Vector3(a, b, c);
  76747. this.d = d;
  76748. }
  76749. /**
  76750. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  76751. */
  76752. Plane.prototype.asArray = function () {
  76753. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  76754. };
  76755. // Methods
  76756. /**
  76757. * @returns a new plane copied from the current Plane.
  76758. */
  76759. Plane.prototype.clone = function () {
  76760. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  76761. };
  76762. /**
  76763. * @returns the string "Plane".
  76764. */
  76765. Plane.prototype.getClassName = function () {
  76766. return "Plane";
  76767. };
  76768. /**
  76769. * @returns the Plane hash code.
  76770. */
  76771. Plane.prototype.getHashCode = function () {
  76772. var hash = this.normal.getHashCode();
  76773. hash = (hash * 397) ^ (this.d || 0);
  76774. return hash;
  76775. };
  76776. /**
  76777. * Normalize the current Plane in place.
  76778. * @returns the updated Plane.
  76779. */
  76780. Plane.prototype.normalize = function () {
  76781. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  76782. var magnitude = 0.0;
  76783. if (norm !== 0) {
  76784. magnitude = 1.0 / norm;
  76785. }
  76786. this.normal.x *= magnitude;
  76787. this.normal.y *= magnitude;
  76788. this.normal.z *= magnitude;
  76789. this.d *= magnitude;
  76790. return this;
  76791. };
  76792. /**
  76793. * Applies a transformation the plane and returns the result
  76794. * @param transformation the transformation matrix to be applied to the plane
  76795. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  76796. */
  76797. Plane.prototype.transform = function (transformation) {
  76798. var transposedMatrix = MathTmp.Matrix[0];
  76799. Matrix.TransposeToRef(transformation, transposedMatrix);
  76800. var m = transposedMatrix.m;
  76801. var x = this.normal.x;
  76802. var y = this.normal.y;
  76803. var z = this.normal.z;
  76804. var d = this.d;
  76805. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  76806. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  76807. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  76808. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  76809. return new Plane(normalX, normalY, normalZ, finalD);
  76810. };
  76811. /**
  76812. * Calcualtte the dot product between the point and the plane normal
  76813. * @param point point to calculate the dot product with
  76814. * @returns the dot product (float) of the point coordinates and the plane normal.
  76815. */
  76816. Plane.prototype.dotCoordinate = function (point) {
  76817. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  76818. };
  76819. /**
  76820. * Updates the current Plane from the plane defined by the three given points.
  76821. * @param point1 one of the points used to contruct the plane
  76822. * @param point2 one of the points used to contruct the plane
  76823. * @param point3 one of the points used to contruct the plane
  76824. * @returns the updated Plane.
  76825. */
  76826. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  76827. var x1 = point2.x - point1.x;
  76828. var y1 = point2.y - point1.y;
  76829. var z1 = point2.z - point1.z;
  76830. var x2 = point3.x - point1.x;
  76831. var y2 = point3.y - point1.y;
  76832. var z2 = point3.z - point1.z;
  76833. var yz = (y1 * z2) - (z1 * y2);
  76834. var xz = (z1 * x2) - (x1 * z2);
  76835. var xy = (x1 * y2) - (y1 * x2);
  76836. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  76837. var invPyth;
  76838. if (pyth !== 0) {
  76839. invPyth = 1.0 / pyth;
  76840. }
  76841. else {
  76842. invPyth = 0.0;
  76843. }
  76844. this.normal.x = yz * invPyth;
  76845. this.normal.y = xz * invPyth;
  76846. this.normal.z = xy * invPyth;
  76847. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  76848. return this;
  76849. };
  76850. /**
  76851. * Checks if the plane is facing a given direction
  76852. * @param direction the direction to check if the plane is facing
  76853. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  76854. * @returns True is the vector "direction" is the same side than the plane normal.
  76855. */
  76856. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  76857. var dot = Vector3.Dot(this.normal, direction);
  76858. return (dot <= epsilon);
  76859. };
  76860. /**
  76861. * Calculates the distance to a point
  76862. * @param point point to calculate distance to
  76863. * @returns the signed distance (float) from the given point to the Plane.
  76864. */
  76865. Plane.prototype.signedDistanceTo = function (point) {
  76866. return Vector3.Dot(point, this.normal) + this.d;
  76867. };
  76868. // Statics
  76869. /**
  76870. * Creates a plane from an array
  76871. * @param array the array to create a plane from
  76872. * @returns a new Plane from the given array.
  76873. */
  76874. Plane.FromArray = function (array) {
  76875. return new Plane(array[0], array[1], array[2], array[3]);
  76876. };
  76877. /**
  76878. * Creates a plane from three points
  76879. * @param point1 point used to create the plane
  76880. * @param point2 point used to create the plane
  76881. * @param point3 point used to create the plane
  76882. * @returns a new Plane defined by the three given points.
  76883. */
  76884. Plane.FromPoints = function (point1, point2, point3) {
  76885. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  76886. result.copyFromPoints(point1, point2, point3);
  76887. return result;
  76888. };
  76889. /**
  76890. * Creates a plane from an origin point and a normal
  76891. * @param origin origin of the plane to be constructed
  76892. * @param normal normal of the plane to be constructed
  76893. * @returns a new Plane the normal vector to this plane at the given origin point.
  76894. * Note : the vector "normal" is updated because normalized.
  76895. */
  76896. Plane.FromPositionAndNormal = function (origin, normal) {
  76897. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  76898. normal.normalize();
  76899. result.normal = normal;
  76900. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  76901. return result;
  76902. };
  76903. /**
  76904. * Calculates the distance from a plane and a point
  76905. * @param origin origin of the plane to be constructed
  76906. * @param normal normal of the plane to be constructed
  76907. * @param point point to calculate distance to
  76908. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  76909. */
  76910. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  76911. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  76912. return Vector3.Dot(point, normal) + d;
  76913. };
  76914. return Plane;
  76915. }());
  76916. /**
  76917. * Class used to represent a viewport on screen
  76918. */
  76919. var Viewport = /** @class */ (function () {
  76920. /**
  76921. * Creates a Viewport object located at (x, y) and sized (width, height)
  76922. * @param x defines viewport left coordinate
  76923. * @param y defines viewport top coordinate
  76924. * @param width defines the viewport width
  76925. * @param height defines the viewport height
  76926. */
  76927. function Viewport(
  76928. /** viewport left coordinate */
  76929. x,
  76930. /** viewport top coordinate */
  76931. y,
  76932. /**viewport width */
  76933. width,
  76934. /** viewport height */
  76935. height) {
  76936. this.x = x;
  76937. this.y = y;
  76938. this.width = width;
  76939. this.height = height;
  76940. }
  76941. /**
  76942. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  76943. * @param renderWidth defines the rendering width
  76944. * @param renderHeight defines the rendering height
  76945. * @returns a new Viewport
  76946. */
  76947. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  76948. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  76949. };
  76950. /**
  76951. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  76952. * @param renderWidth defines the rendering width
  76953. * @param renderHeight defines the rendering height
  76954. * @param ref defines the target viewport
  76955. * @returns the current viewport
  76956. */
  76957. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  76958. ref.x = this.x * renderWidth;
  76959. ref.y = this.y * renderHeight;
  76960. ref.width = this.width * renderWidth;
  76961. ref.height = this.height * renderHeight;
  76962. return this;
  76963. };
  76964. /**
  76965. * Returns a new Viewport copied from the current one
  76966. * @returns a new Viewport
  76967. */
  76968. Viewport.prototype.clone = function () {
  76969. return new Viewport(this.x, this.y, this.width, this.height);
  76970. };
  76971. return Viewport;
  76972. }());
  76973. /**
  76974. * Reprasents a camera frustum
  76975. */
  76976. var Frustum = /** @class */ (function () {
  76977. function Frustum() {
  76978. }
  76979. /**
  76980. * Gets the planes representing the frustum
  76981. * @param transform matrix to be applied to the returned planes
  76982. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  76983. */
  76984. Frustum.GetPlanes = function (transform) {
  76985. var frustumPlanes = [];
  76986. for (var index = 0; index < 6; index++) {
  76987. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  76988. }
  76989. Frustum.GetPlanesToRef(transform, frustumPlanes);
  76990. return frustumPlanes;
  76991. };
  76992. /**
  76993. * Gets the near frustum plane transformed by the transform matrix
  76994. * @param transform transformation matrix to be applied to the resulting frustum plane
  76995. * @param frustumPlane the resuling frustum plane
  76996. */
  76997. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  76998. var m = transform.m;
  76999. frustumPlane.normal.x = m[3] + m[2];
  77000. frustumPlane.normal.y = m[7] + m[6];
  77001. frustumPlane.normal.z = m[11] + m[10];
  77002. frustumPlane.d = m[15] + m[14];
  77003. frustumPlane.normalize();
  77004. };
  77005. /**
  77006. * Gets the far frustum plane transformed by the transform matrix
  77007. * @param transform transformation matrix to be applied to the resulting frustum plane
  77008. * @param frustumPlane the resuling frustum plane
  77009. */
  77010. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  77011. var m = transform.m;
  77012. frustumPlane.normal.x = m[3] - m[2];
  77013. frustumPlane.normal.y = m[7] - m[6];
  77014. frustumPlane.normal.z = m[11] - m[10];
  77015. frustumPlane.d = m[15] - m[14];
  77016. frustumPlane.normalize();
  77017. };
  77018. /**
  77019. * Gets the left frustum plane transformed by the transform matrix
  77020. * @param transform transformation matrix to be applied to the resulting frustum plane
  77021. * @param frustumPlane the resuling frustum plane
  77022. */
  77023. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  77024. var m = transform.m;
  77025. frustumPlane.normal.x = m[3] + m[0];
  77026. frustumPlane.normal.y = m[7] + m[4];
  77027. frustumPlane.normal.z = m[11] + m[8];
  77028. frustumPlane.d = m[15] + m[12];
  77029. frustumPlane.normalize();
  77030. };
  77031. /**
  77032. * Gets the right frustum plane transformed by the transform matrix
  77033. * @param transform transformation matrix to be applied to the resulting frustum plane
  77034. * @param frustumPlane the resuling frustum plane
  77035. */
  77036. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  77037. var m = transform.m;
  77038. frustumPlane.normal.x = m[3] - m[0];
  77039. frustumPlane.normal.y = m[7] - m[4];
  77040. frustumPlane.normal.z = m[11] - m[8];
  77041. frustumPlane.d = m[15] - m[12];
  77042. frustumPlane.normalize();
  77043. };
  77044. /**
  77045. * Gets the top frustum plane transformed by the transform matrix
  77046. * @param transform transformation matrix to be applied to the resulting frustum plane
  77047. * @param frustumPlane the resuling frustum plane
  77048. */
  77049. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  77050. var m = transform.m;
  77051. frustumPlane.normal.x = m[3] - m[1];
  77052. frustumPlane.normal.y = m[7] - m[5];
  77053. frustumPlane.normal.z = m[11] - m[9];
  77054. frustumPlane.d = m[15] - m[13];
  77055. frustumPlane.normalize();
  77056. };
  77057. /**
  77058. * Gets the bottom frustum plane transformed by the transform matrix
  77059. * @param transform transformation matrix to be applied to the resulting frustum plane
  77060. * @param frustumPlane the resuling frustum plane
  77061. */
  77062. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  77063. var m = transform.m;
  77064. frustumPlane.normal.x = m[3] + m[1];
  77065. frustumPlane.normal.y = m[7] + m[5];
  77066. frustumPlane.normal.z = m[11] + m[9];
  77067. frustumPlane.d = m[15] + m[13];
  77068. frustumPlane.normalize();
  77069. };
  77070. /**
  77071. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  77072. * @param transform transformation matrix to be applied to the resulting frustum planes
  77073. * @param frustumPlanes the resuling frustum planes
  77074. */
  77075. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  77076. // Near
  77077. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  77078. // Far
  77079. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  77080. // Left
  77081. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  77082. // Right
  77083. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  77084. // Top
  77085. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  77086. // Bottom
  77087. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  77088. };
  77089. return Frustum;
  77090. }());
  77091. /** Defines supported spaces */
  77092. var Space;
  77093. (function (Space) {
  77094. /** Local (object) space */
  77095. Space[Space["LOCAL"] = 0] = "LOCAL";
  77096. /** World space */
  77097. Space[Space["WORLD"] = 1] = "WORLD";
  77098. /** Bone space */
  77099. Space[Space["BONE"] = 2] = "BONE";
  77100. })(Space || (Space = {}));
  77101. /** Defines the 3 main axes */
  77102. var Axis = /** @class */ (function () {
  77103. function Axis() {
  77104. }
  77105. /** X axis */
  77106. Axis.X = new Vector3(1.0, 0.0, 0.0);
  77107. /** Y axis */
  77108. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  77109. /** Z axis */
  77110. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  77111. return Axis;
  77112. }());
  77113. /** Class used to represent a Bezier curve */
  77114. var BezierCurve = /** @class */ (function () {
  77115. function BezierCurve() {
  77116. }
  77117. /**
  77118. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77119. * @param t defines the time
  77120. * @param x1 defines the left coordinate on X axis
  77121. * @param y1 defines the left coordinate on Y axis
  77122. * @param x2 defines the right coordinate on X axis
  77123. * @param y2 defines the right coordinate on Y axis
  77124. * @returns the interpolated value
  77125. */
  77126. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  77127. // Extract X (which is equal to time here)
  77128. var f0 = 1 - 3 * x2 + 3 * x1;
  77129. var f1 = 3 * x2 - 6 * x1;
  77130. var f2 = 3 * x1;
  77131. var refinedT = t;
  77132. for (var i = 0; i < 5; i++) {
  77133. var refinedT2 = refinedT * refinedT;
  77134. var refinedT3 = refinedT2 * refinedT;
  77135. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  77136. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  77137. refinedT -= (x - t) * slope;
  77138. refinedT = Math.min(1, Math.max(0, refinedT));
  77139. }
  77140. // Resolve cubic bezier for the given x
  77141. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  77142. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  77143. Math.pow(refinedT, 3);
  77144. };
  77145. return BezierCurve;
  77146. }());
  77147. /**
  77148. * Defines potential orientation for back face culling
  77149. */
  77150. var Orientation;
  77151. (function (Orientation) {
  77152. /**
  77153. * Clockwise
  77154. */
  77155. Orientation[Orientation["CW"] = 0] = "CW";
  77156. /** Counter clockwise */
  77157. Orientation[Orientation["CCW"] = 1] = "CCW";
  77158. })(Orientation || (Orientation = {}));
  77159. /**
  77160. * Defines angle representation
  77161. */
  77162. var Angle = /** @class */ (function () {
  77163. /**
  77164. * Creates an Angle object of "radians" radians (float).
  77165. * @param radians the angle in radians
  77166. */
  77167. function Angle(radians) {
  77168. this._radians = radians;
  77169. if (this._radians < 0.0) {
  77170. this._radians += (2.0 * Math.PI);
  77171. }
  77172. }
  77173. /**
  77174. * Get value in degrees
  77175. * @returns the Angle value in degrees (float)
  77176. */
  77177. Angle.prototype.degrees = function () {
  77178. return this._radians * 180.0 / Math.PI;
  77179. };
  77180. /**
  77181. * Get value in radians
  77182. * @returns the Angle value in radians (float)
  77183. */
  77184. Angle.prototype.radians = function () {
  77185. return this._radians;
  77186. };
  77187. /**
  77188. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77189. * @param a defines first vector
  77190. * @param b defines second vector
  77191. * @returns a new Angle
  77192. */
  77193. Angle.BetweenTwoPoints = function (a, b) {
  77194. var delta = b.subtract(a);
  77195. var theta = Math.atan2(delta.y, delta.x);
  77196. return new Angle(theta);
  77197. };
  77198. /**
  77199. * Gets a new Angle object from the given float in radians
  77200. * @param radians defines the angle value in radians
  77201. * @returns a new Angle
  77202. */
  77203. Angle.FromRadians = function (radians) {
  77204. return new Angle(radians);
  77205. };
  77206. /**
  77207. * Gets a new Angle object from the given float in degrees
  77208. * @param degrees defines the angle value in degrees
  77209. * @returns a new Angle
  77210. */
  77211. Angle.FromDegrees = function (degrees) {
  77212. return new Angle(degrees * Math.PI / 180.0);
  77213. };
  77214. return Angle;
  77215. }());
  77216. /**
  77217. * This represents an arc in a 2d space.
  77218. */
  77219. var Arc2 = /** @class */ (function () {
  77220. /**
  77221. * Creates an Arc object from the three given points : start, middle and end.
  77222. * @param startPoint Defines the start point of the arc
  77223. * @param midPoint Defines the midlle point of the arc
  77224. * @param endPoint Defines the end point of the arc
  77225. */
  77226. function Arc2(
  77227. /** Defines the start point of the arc */
  77228. startPoint,
  77229. /** Defines the mid point of the arc */
  77230. midPoint,
  77231. /** Defines the end point of the arc */
  77232. endPoint) {
  77233. this.startPoint = startPoint;
  77234. this.midPoint = midPoint;
  77235. this.endPoint = endPoint;
  77236. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  77237. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  77238. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  77239. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  77240. this.centerPoint = new Vector2((startToMid * (midPoint.y - endPoint.y) - midToEnd * (startPoint.y - midPoint.y)) / det, ((startPoint.x - midPoint.x) * midToEnd - (midPoint.x - endPoint.x) * startToMid) / det);
  77241. this.radius = this.centerPoint.subtract(this.startPoint).length();
  77242. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  77243. var a1 = this.startAngle.degrees();
  77244. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  77245. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  77246. // angles correction
  77247. if (a2 - a1 > +180.0) {
  77248. a2 -= 360.0;
  77249. }
  77250. if (a2 - a1 < -180.0) {
  77251. a2 += 360.0;
  77252. }
  77253. if (a3 - a2 > +180.0) {
  77254. a3 -= 360.0;
  77255. }
  77256. if (a3 - a2 < -180.0) {
  77257. a3 += 360.0;
  77258. }
  77259. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  77260. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  77261. }
  77262. return Arc2;
  77263. }());
  77264. /**
  77265. * Represents a 2D path made up of multiple 2D points
  77266. */
  77267. var Path2 = /** @class */ (function () {
  77268. /**
  77269. * Creates a Path2 object from the starting 2D coordinates x and y.
  77270. * @param x the starting points x value
  77271. * @param y the starting points y value
  77272. */
  77273. function Path2(x, y) {
  77274. this._points = new Array();
  77275. this._length = 0.0;
  77276. /**
  77277. * If the path start and end point are the same
  77278. */
  77279. this.closed = false;
  77280. this._points.push(new Vector2(x, y));
  77281. }
  77282. /**
  77283. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  77284. * @param x the added points x value
  77285. * @param y the added points y value
  77286. * @returns the updated Path2.
  77287. */
  77288. Path2.prototype.addLineTo = function (x, y) {
  77289. if (this.closed) {
  77290. return this;
  77291. }
  77292. var newPoint = new Vector2(x, y);
  77293. var previousPoint = this._points[this._points.length - 1];
  77294. this._points.push(newPoint);
  77295. this._length += newPoint.subtract(previousPoint).length();
  77296. return this;
  77297. };
  77298. /**
  77299. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  77300. * @param midX middle point x value
  77301. * @param midY middle point y value
  77302. * @param endX end point x value
  77303. * @param endY end point y value
  77304. * @param numberOfSegments (default: 36)
  77305. * @returns the updated Path2.
  77306. */
  77307. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  77308. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  77309. if (this.closed) {
  77310. return this;
  77311. }
  77312. var startPoint = this._points[this._points.length - 1];
  77313. var midPoint = new Vector2(midX, midY);
  77314. var endPoint = new Vector2(endX, endY);
  77315. var arc = new Arc2(startPoint, midPoint, endPoint);
  77316. var increment = arc.angle.radians() / numberOfSegments;
  77317. if (arc.orientation === Orientation.CW) {
  77318. increment *= -1;
  77319. }
  77320. var currentAngle = arc.startAngle.radians() + increment;
  77321. for (var i = 0; i < numberOfSegments; i++) {
  77322. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  77323. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  77324. this.addLineTo(x, y);
  77325. currentAngle += increment;
  77326. }
  77327. return this;
  77328. };
  77329. /**
  77330. * Closes the Path2.
  77331. * @returns the Path2.
  77332. */
  77333. Path2.prototype.close = function () {
  77334. this.closed = true;
  77335. return this;
  77336. };
  77337. /**
  77338. * Gets the sum of the distance between each sequential point in the path
  77339. * @returns the Path2 total length (float).
  77340. */
  77341. Path2.prototype.length = function () {
  77342. var result = this._length;
  77343. if (!this.closed) {
  77344. var lastPoint = this._points[this._points.length - 1];
  77345. var firstPoint = this._points[0];
  77346. result += (firstPoint.subtract(lastPoint).length());
  77347. }
  77348. return result;
  77349. };
  77350. /**
  77351. * Gets the points which construct the path
  77352. * @returns the Path2 internal array of points.
  77353. */
  77354. Path2.prototype.getPoints = function () {
  77355. return this._points;
  77356. };
  77357. /**
  77358. * Retreives the point at the distance aways from the starting point
  77359. * @param normalizedLengthPosition the length along the path to retreive the point from
  77360. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  77361. */
  77362. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  77363. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  77364. return Vector2.Zero();
  77365. }
  77366. var lengthPosition = normalizedLengthPosition * this.length();
  77367. var previousOffset = 0;
  77368. for (var i = 0; i < this._points.length; i++) {
  77369. var j = (i + 1) % this._points.length;
  77370. var a = this._points[i];
  77371. var b = this._points[j];
  77372. var bToA = b.subtract(a);
  77373. var nextOffset = (bToA.length() + previousOffset);
  77374. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  77375. var dir = bToA.normalize();
  77376. var localOffset = lengthPosition - previousOffset;
  77377. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  77378. }
  77379. previousOffset = nextOffset;
  77380. }
  77381. return Vector2.Zero();
  77382. };
  77383. /**
  77384. * Creates a new path starting from an x and y position
  77385. * @param x starting x value
  77386. * @param y starting y value
  77387. * @returns a new Path2 starting at the coordinates (x, y).
  77388. */
  77389. Path2.StartingAt = function (x, y) {
  77390. return new Path2(x, y);
  77391. };
  77392. return Path2;
  77393. }());
  77394. /**
  77395. * Represents a 3D path made up of multiple 3D points
  77396. */
  77397. var Path3D = /** @class */ (function () {
  77398. /**
  77399. * new Path3D(path, normal, raw)
  77400. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  77401. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  77402. * @param path an array of Vector3, the curve axis of the Path3D
  77403. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  77404. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  77405. */
  77406. function Path3D(
  77407. /**
  77408. * an array of Vector3, the curve axis of the Path3D
  77409. */
  77410. path, firstNormal, raw) {
  77411. if (firstNormal === void 0) { firstNormal = null; }
  77412. this.path = path;
  77413. this._curve = new Array();
  77414. this._distances = new Array();
  77415. this._tangents = new Array();
  77416. this._normals = new Array();
  77417. this._binormals = new Array();
  77418. for (var p = 0; p < path.length; p++) {
  77419. this._curve[p] = path[p].clone(); // hard copy
  77420. }
  77421. this._raw = raw || false;
  77422. this._compute(firstNormal);
  77423. }
  77424. /**
  77425. * Returns the Path3D array of successive Vector3 designing its curve.
  77426. * @returns the Path3D array of successive Vector3 designing its curve.
  77427. */
  77428. Path3D.prototype.getCurve = function () {
  77429. return this._curve;
  77430. };
  77431. /**
  77432. * Returns an array populated with tangent vectors on each Path3D curve point.
  77433. * @returns an array populated with tangent vectors on each Path3D curve point.
  77434. */
  77435. Path3D.prototype.getTangents = function () {
  77436. return this._tangents;
  77437. };
  77438. /**
  77439. * Returns an array populated with normal vectors on each Path3D curve point.
  77440. * @returns an array populated with normal vectors on each Path3D curve point.
  77441. */
  77442. Path3D.prototype.getNormals = function () {
  77443. return this._normals;
  77444. };
  77445. /**
  77446. * Returns an array populated with binormal vectors on each Path3D curve point.
  77447. * @returns an array populated with binormal vectors on each Path3D curve point.
  77448. */
  77449. Path3D.prototype.getBinormals = function () {
  77450. return this._binormals;
  77451. };
  77452. /**
  77453. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  77454. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  77455. */
  77456. Path3D.prototype.getDistances = function () {
  77457. return this._distances;
  77458. };
  77459. /**
  77460. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  77461. * @param path path which all values are copied into the curves points
  77462. * @param firstNormal which should be projected onto the curve
  77463. * @returns the same object updated.
  77464. */
  77465. Path3D.prototype.update = function (path, firstNormal) {
  77466. if (firstNormal === void 0) { firstNormal = null; }
  77467. for (var p = 0; p < path.length; p++) {
  77468. this._curve[p].x = path[p].x;
  77469. this._curve[p].y = path[p].y;
  77470. this._curve[p].z = path[p].z;
  77471. }
  77472. this._compute(firstNormal);
  77473. return this;
  77474. };
  77475. // private function compute() : computes tangents, normals and binormals
  77476. Path3D.prototype._compute = function (firstNormal) {
  77477. var l = this._curve.length;
  77478. // first and last tangents
  77479. this._tangents[0] = this._getFirstNonNullVector(0);
  77480. if (!this._raw) {
  77481. this._tangents[0].normalize();
  77482. }
  77483. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  77484. if (!this._raw) {
  77485. this._tangents[l - 1].normalize();
  77486. }
  77487. // normals and binormals at first point : arbitrary vector with _normalVector()
  77488. var tg0 = this._tangents[0];
  77489. var pp0 = this._normalVector(tg0, firstNormal);
  77490. this._normals[0] = pp0;
  77491. if (!this._raw) {
  77492. this._normals[0].normalize();
  77493. }
  77494. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  77495. if (!this._raw) {
  77496. this._binormals[0].normalize();
  77497. }
  77498. this._distances[0] = 0.0;
  77499. // normals and binormals : next points
  77500. var prev; // previous vector (segment)
  77501. var cur; // current vector (segment)
  77502. var curTang; // current tangent
  77503. // previous normal
  77504. var prevBinor; // previous binormal
  77505. for (var i = 1; i < l; i++) {
  77506. // tangents
  77507. prev = this._getLastNonNullVector(i);
  77508. if (i < l - 1) {
  77509. cur = this._getFirstNonNullVector(i);
  77510. this._tangents[i] = prev.add(cur);
  77511. this._tangents[i].normalize();
  77512. }
  77513. this._distances[i] = this._distances[i - 1] + prev.length();
  77514. // normals and binormals
  77515. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  77516. curTang = this._tangents[i];
  77517. prevBinor = this._binormals[i - 1];
  77518. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  77519. if (!this._raw) {
  77520. this._normals[i].normalize();
  77521. }
  77522. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  77523. if (!this._raw) {
  77524. this._binormals[i].normalize();
  77525. }
  77526. }
  77527. };
  77528. // private function getFirstNonNullVector(index)
  77529. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  77530. Path3D.prototype._getFirstNonNullVector = function (index) {
  77531. var i = 1;
  77532. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  77533. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  77534. i++;
  77535. nNVector = this._curve[index + i].subtract(this._curve[index]);
  77536. }
  77537. return nNVector;
  77538. };
  77539. // private function getLastNonNullVector(index)
  77540. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  77541. Path3D.prototype._getLastNonNullVector = function (index) {
  77542. var i = 1;
  77543. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  77544. while (nLVector.length() === 0 && index > i + 1) {
  77545. i++;
  77546. nLVector = this._curve[index].subtract(this._curve[index - i]);
  77547. }
  77548. return nLVector;
  77549. };
  77550. // private function normalVector(v0, vt, va) :
  77551. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  77552. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  77553. Path3D.prototype._normalVector = function (vt, va) {
  77554. var normal0;
  77555. var tgl = vt.length();
  77556. if (tgl === 0.0) {
  77557. tgl = 1.0;
  77558. }
  77559. if (va === undefined || va === null) {
  77560. var point;
  77561. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  77562. point = new Vector3(0.0, -1.0, 0.0);
  77563. }
  77564. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  77565. point = new Vector3(1.0, 0.0, 0.0);
  77566. }
  77567. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  77568. point = new Vector3(0.0, 0.0, 1.0);
  77569. }
  77570. else {
  77571. point = Vector3.Zero();
  77572. }
  77573. normal0 = Vector3.Cross(vt, point);
  77574. }
  77575. else {
  77576. normal0 = Vector3.Cross(vt, va);
  77577. Vector3.CrossToRef(normal0, vt, normal0);
  77578. }
  77579. normal0.normalize();
  77580. return normal0;
  77581. };
  77582. return Path3D;
  77583. }());
  77584. /**
  77585. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77586. * A Curve3 is designed from a series of successive Vector3.
  77587. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  77588. */
  77589. var Curve3 = /** @class */ (function () {
  77590. /**
  77591. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77592. * A Curve3 is designed from a series of successive Vector3.
  77593. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  77594. * @param points points which make up the curve
  77595. */
  77596. function Curve3(points) {
  77597. this._length = 0.0;
  77598. this._points = points;
  77599. this._length = this._computeLength(points);
  77600. }
  77601. /**
  77602. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  77603. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  77604. * @param v1 (Vector3) the control point
  77605. * @param v2 (Vector3) the end point of the Quadratic Bezier
  77606. * @param nbPoints (integer) the wanted number of points in the curve
  77607. * @returns the created Curve3
  77608. */
  77609. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  77610. nbPoints = nbPoints > 2 ? nbPoints : 3;
  77611. var bez = new Array();
  77612. var equation = function (t, val0, val1, val2) {
  77613. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  77614. return res;
  77615. };
  77616. for (var i = 0; i <= nbPoints; i++) {
  77617. bez.push(new Vector3(equation(i / nbPoints, v0.x, v1.x, v2.x), equation(i / nbPoints, v0.y, v1.y, v2.y), equation(i / nbPoints, v0.z, v1.z, v2.z)));
  77618. }
  77619. return new Curve3(bez);
  77620. };
  77621. /**
  77622. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  77623. * @param v0 (Vector3) the origin point of the Cubic Bezier
  77624. * @param v1 (Vector3) the first control point
  77625. * @param v2 (Vector3) the second control point
  77626. * @param v3 (Vector3) the end point of the Cubic Bezier
  77627. * @param nbPoints (integer) the wanted number of points in the curve
  77628. * @returns the created Curve3
  77629. */
  77630. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  77631. nbPoints = nbPoints > 3 ? nbPoints : 4;
  77632. var bez = new Array();
  77633. var equation = function (t, val0, val1, val2, val3) {
  77634. var res = (1.0 - t) * (1.0 - t) * (1.0 - t) * val0 + 3.0 * t * (1.0 - t) * (1.0 - t) * val1 + 3.0 * t * t * (1.0 - t) * val2 + t * t * t * val3;
  77635. return res;
  77636. };
  77637. for (var i = 0; i <= nbPoints; i++) {
  77638. bez.push(new Vector3(equation(i / nbPoints, v0.x, v1.x, v2.x, v3.x), equation(i / nbPoints, v0.y, v1.y, v2.y, v3.y), equation(i / nbPoints, v0.z, v1.z, v2.z, v3.z)));
  77639. }
  77640. return new Curve3(bez);
  77641. };
  77642. /**
  77643. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  77644. * @param p1 (Vector3) the origin point of the Hermite Spline
  77645. * @param t1 (Vector3) the tangent vector at the origin point
  77646. * @param p2 (Vector3) the end point of the Hermite Spline
  77647. * @param t2 (Vector3) the tangent vector at the end point
  77648. * @param nbPoints (integer) the wanted number of points in the curve
  77649. * @returns the created Curve3
  77650. */
  77651. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  77652. var hermite = new Array();
  77653. var step = 1.0 / nbPoints;
  77654. for (var i = 0; i <= nbPoints; i++) {
  77655. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  77656. }
  77657. return new Curve3(hermite);
  77658. };
  77659. /**
  77660. * Returns a Curve3 object along a CatmullRom Spline curve :
  77661. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  77662. * @param nbPoints (integer) the wanted number of points between each curve control points
  77663. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  77664. * @returns the created Curve3
  77665. */
  77666. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  77667. var catmullRom = new Array();
  77668. var step = 1.0 / nbPoints;
  77669. var amount = 0.0;
  77670. if (closed) {
  77671. var pointsCount = points.length;
  77672. for (var i = 0; i < pointsCount; i++) {
  77673. amount = 0;
  77674. for (var c = 0; c < nbPoints; c++) {
  77675. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  77676. amount += step;
  77677. }
  77678. }
  77679. catmullRom.push(catmullRom[0]);
  77680. }
  77681. else {
  77682. var totalPoints = new Array();
  77683. totalPoints.push(points[0].clone());
  77684. Array.prototype.push.apply(totalPoints, points);
  77685. totalPoints.push(points[points.length - 1].clone());
  77686. for (var i = 0; i < totalPoints.length - 3; i++) {
  77687. amount = 0;
  77688. for (var c = 0; c < nbPoints; c++) {
  77689. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  77690. amount += step;
  77691. }
  77692. }
  77693. i--;
  77694. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  77695. }
  77696. return new Curve3(catmullRom);
  77697. };
  77698. /**
  77699. * @returns the Curve3 stored array of successive Vector3
  77700. */
  77701. Curve3.prototype.getPoints = function () {
  77702. return this._points;
  77703. };
  77704. /**
  77705. * @returns the computed length (float) of the curve.
  77706. */
  77707. Curve3.prototype.length = function () {
  77708. return this._length;
  77709. };
  77710. /**
  77711. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  77712. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  77713. * curveA and curveB keep unchanged.
  77714. * @param curve the curve to continue from this curve
  77715. * @returns the newly constructed curve
  77716. */
  77717. Curve3.prototype.continue = function (curve) {
  77718. var lastPoint = this._points[this._points.length - 1];
  77719. var continuedPoints = this._points.slice();
  77720. var curvePoints = curve.getPoints();
  77721. for (var i = 1; i < curvePoints.length; i++) {
  77722. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  77723. }
  77724. var continuedCurve = new Curve3(continuedPoints);
  77725. return continuedCurve;
  77726. };
  77727. Curve3.prototype._computeLength = function (path) {
  77728. var l = 0;
  77729. for (var i = 1; i < path.length; i++) {
  77730. l += (path[i].subtract(path[i - 1])).length();
  77731. }
  77732. return l;
  77733. };
  77734. return Curve3;
  77735. }());
  77736. // Vertex formats
  77737. /**
  77738. * Contains position and normal vectors for a vertex
  77739. */
  77740. var PositionNormalVertex = /** @class */ (function () {
  77741. /**
  77742. * Creates a PositionNormalVertex
  77743. * @param position the position of the vertex (defaut: 0,0,0)
  77744. * @param normal the normal of the vertex (defaut: 0,1,0)
  77745. */
  77746. function PositionNormalVertex(
  77747. /** the position of the vertex (defaut: 0,0,0) */
  77748. position,
  77749. /** the normal of the vertex (defaut: 0,1,0) */
  77750. normal) {
  77751. if (position === void 0) { position = Vector3.Zero(); }
  77752. if (normal === void 0) { normal = Vector3.Up(); }
  77753. this.position = position;
  77754. this.normal = normal;
  77755. }
  77756. /**
  77757. * Clones the PositionNormalVertex
  77758. * @returns the cloned PositionNormalVertex
  77759. */
  77760. PositionNormalVertex.prototype.clone = function () {
  77761. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  77762. };
  77763. return PositionNormalVertex;
  77764. }());
  77765. /**
  77766. * Contains position, normal and uv vectors for a vertex
  77767. */
  77768. var PositionNormalTextureVertex = /** @class */ (function () {
  77769. /**
  77770. * Creates a PositionNormalTextureVertex
  77771. * @param position the position of the vertex (defaut: 0,0,0)
  77772. * @param normal the normal of the vertex (defaut: 0,1,0)
  77773. * @param uv the uv of the vertex (default: 0,0)
  77774. */
  77775. function PositionNormalTextureVertex(
  77776. /** the position of the vertex (defaut: 0,0,0) */
  77777. position,
  77778. /** the normal of the vertex (defaut: 0,1,0) */
  77779. normal,
  77780. /** the uv of the vertex (default: 0,0) */
  77781. uv) {
  77782. if (position === void 0) { position = Vector3.Zero(); }
  77783. if (normal === void 0) { normal = Vector3.Up(); }
  77784. if (uv === void 0) { uv = Vector2.Zero(); }
  77785. this.position = position;
  77786. this.normal = normal;
  77787. this.uv = uv;
  77788. }
  77789. /**
  77790. * Clones the PositionNormalTextureVertex
  77791. * @returns the cloned PositionNormalTextureVertex
  77792. */
  77793. PositionNormalTextureVertex.prototype.clone = function () {
  77794. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  77795. };
  77796. return PositionNormalTextureVertex;
  77797. }());
  77798. // Temporary pre-allocated objects for engine internal use
  77799. // usage in any internal function :
  77800. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  77801. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  77802. /**
  77803. * @hidden
  77804. */
  77805. var Tmp = /** @class */ (function () {
  77806. function Tmp() {
  77807. }
  77808. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  77809. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  77810. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  77811. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  77812. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  77813. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  77814. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  77815. return Tmp;
  77816. }());
  77817. /**
  77818. * @hidden
  77819. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  77820. */
  77821. var MathTmp = /** @class */ (function () {
  77822. function MathTmp() {
  77823. }
  77824. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  77825. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  77826. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  77827. return MathTmp;
  77828. }());
  77829. /***/ }),
  77830. /***/ "./Maths/sphericalPolynomial.ts":
  77831. /*!**************************************!*\
  77832. !*** ./Maths/sphericalPolynomial.ts ***!
  77833. \**************************************/
  77834. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  77835. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77836. "use strict";
  77837. __webpack_require__.r(__webpack_exports__);
  77838. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  77839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  77840. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  77841. /**
  77842. * Class representing spherical polynomial coefficients to the 3rd degree
  77843. */
  77844. var SphericalPolynomial = /** @class */ (function () {
  77845. function SphericalPolynomial() {
  77846. /**
  77847. * The x coefficients of the spherical polynomial
  77848. */
  77849. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77850. /**
  77851. * The y coefficients of the spherical polynomial
  77852. */
  77853. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77854. /**
  77855. * The z coefficients of the spherical polynomial
  77856. */
  77857. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77858. /**
  77859. * The xx coefficients of the spherical polynomial
  77860. */
  77861. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77862. /**
  77863. * The yy coefficients of the spherical polynomial
  77864. */
  77865. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77866. /**
  77867. * The zz coefficients of the spherical polynomial
  77868. */
  77869. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77870. /**
  77871. * The xy coefficients of the spherical polynomial
  77872. */
  77873. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77874. /**
  77875. * The yz coefficients of the spherical polynomial
  77876. */
  77877. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77878. /**
  77879. * The zx coefficients of the spherical polynomial
  77880. */
  77881. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77882. }
  77883. /**
  77884. * Adds an ambient color to the spherical polynomial
  77885. * @param color the color to add
  77886. */
  77887. SphericalPolynomial.prototype.addAmbient = function (color) {
  77888. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  77889. this.xx = this.xx.add(colorVector);
  77890. this.yy = this.yy.add(colorVector);
  77891. this.zz = this.zz.add(colorVector);
  77892. };
  77893. /**
  77894. * Scales the spherical polynomial by the given amount
  77895. * @param scale the amount to scale
  77896. */
  77897. SphericalPolynomial.prototype.scale = function (scale) {
  77898. this.x = this.x.scale(scale);
  77899. this.y = this.y.scale(scale);
  77900. this.z = this.z.scale(scale);
  77901. this.xx = this.xx.scale(scale);
  77902. this.yy = this.yy.scale(scale);
  77903. this.zz = this.zz.scale(scale);
  77904. this.yz = this.yz.scale(scale);
  77905. this.zx = this.zx.scale(scale);
  77906. this.xy = this.xy.scale(scale);
  77907. };
  77908. /**
  77909. * Gets the spherical polynomial from harmonics
  77910. * @param harmonics the spherical harmonics
  77911. * @returns the spherical polynomial
  77912. */
  77913. SphericalPolynomial.FromHarmonics = function (harmonics) {
  77914. var result = new SphericalPolynomial();
  77915. result.x = harmonics.l11.scale(1.02333);
  77916. result.y = harmonics.l1_1.scale(1.02333);
  77917. result.z = harmonics.l10.scale(1.02333);
  77918. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  77919. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  77920. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  77921. result.yz = harmonics.l2_1.scale(0.858086);
  77922. result.zx = harmonics.l21.scale(0.858086);
  77923. result.xy = harmonics.l2_2.scale(0.858086);
  77924. result.scale(1.0 / Math.PI);
  77925. return result;
  77926. };
  77927. /**
  77928. * Constructs a spherical polynomial from an array.
  77929. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  77930. * @returns the spherical polynomial
  77931. */
  77932. SphericalPolynomial.FromArray = function (data) {
  77933. var sp = new SphericalPolynomial();
  77934. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  77935. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  77936. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  77937. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  77938. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  77939. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  77940. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  77941. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  77942. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  77943. return sp;
  77944. };
  77945. return SphericalPolynomial;
  77946. }());
  77947. /**
  77948. * Class representing spherical harmonics coefficients to the 3rd degree
  77949. */
  77950. var SphericalHarmonics = /** @class */ (function () {
  77951. function SphericalHarmonics() {
  77952. /**
  77953. * The l0,0 coefficients of the spherical harmonics
  77954. */
  77955. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77956. /**
  77957. * The l1,-1 coefficients of the spherical harmonics
  77958. */
  77959. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77960. /**
  77961. * The l1,0 coefficients of the spherical harmonics
  77962. */
  77963. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77964. /**
  77965. * The l1,1 coefficients of the spherical harmonics
  77966. */
  77967. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77968. /**
  77969. * The l2,-2 coefficients of the spherical harmonics
  77970. */
  77971. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77972. /**
  77973. * The l2,-1 coefficients of the spherical harmonics
  77974. */
  77975. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77976. /**
  77977. * The l2,0 coefficients of the spherical harmonics
  77978. */
  77979. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77980. /**
  77981. * The l2,1 coefficients of the spherical harmonics
  77982. */
  77983. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77984. /**
  77985. * The l2,2 coefficients of the spherical harmonics
  77986. */
  77987. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77988. }
  77989. /**
  77990. * Adds a light to the spherical harmonics
  77991. * @param direction the direction of the light
  77992. * @param color the color of the light
  77993. * @param deltaSolidAngle the delta solid angle of the light
  77994. */
  77995. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  77996. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  77997. var c = colorVector.scale(deltaSolidAngle);
  77998. this.l00 = this.l00.add(c.scale(0.282095));
  77999. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  78000. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  78001. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  78002. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  78003. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  78004. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  78005. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  78006. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  78007. };
  78008. /**
  78009. * Scales the spherical harmonics by the given amount
  78010. * @param scale the amount to scale
  78011. */
  78012. SphericalHarmonics.prototype.scale = function (scale) {
  78013. this.l00 = this.l00.scale(scale);
  78014. this.l1_1 = this.l1_1.scale(scale);
  78015. this.l10 = this.l10.scale(scale);
  78016. this.l11 = this.l11.scale(scale);
  78017. this.l2_2 = this.l2_2.scale(scale);
  78018. this.l2_1 = this.l2_1.scale(scale);
  78019. this.l20 = this.l20.scale(scale);
  78020. this.l21 = this.l21.scale(scale);
  78021. this.lL22 = this.lL22.scale(scale);
  78022. };
  78023. /**
  78024. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  78025. *
  78026. * ```
  78027. * E_lm = A_l * L_lm
  78028. * ```
  78029. *
  78030. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  78031. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  78032. * the scaling factors are given in equation 9.
  78033. */
  78034. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  78035. // Constant (Band 0)
  78036. this.l00 = this.l00.scale(3.141593);
  78037. // Linear (Band 1)
  78038. this.l1_1 = this.l1_1.scale(2.094395);
  78039. this.l10 = this.l10.scale(2.094395);
  78040. this.l11 = this.l11.scale(2.094395);
  78041. // Quadratic (Band 2)
  78042. this.l2_2 = this.l2_2.scale(0.785398);
  78043. this.l2_1 = this.l2_1.scale(0.785398);
  78044. this.l20 = this.l20.scale(0.785398);
  78045. this.l21 = this.l21.scale(0.785398);
  78046. this.lL22 = this.lL22.scale(0.785398);
  78047. };
  78048. /**
  78049. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  78050. *
  78051. * ```
  78052. * L = (1/pi) * E * rho
  78053. * ```
  78054. *
  78055. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  78056. */
  78057. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  78058. this.scale(1.0 / Math.PI);
  78059. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  78060. // (The pixel shader must apply albedo after texture fetches, etc).
  78061. };
  78062. /**
  78063. * Gets the spherical harmonics from polynomial
  78064. * @param polynomial the spherical polynomial
  78065. * @returns the spherical harmonics
  78066. */
  78067. SphericalHarmonics.FromPolynomial = function (polynomial) {
  78068. var result = new SphericalHarmonics();
  78069. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  78070. result.l1_1 = polynomial.y.scale(0.977204);
  78071. result.l10 = polynomial.z.scale(0.977204);
  78072. result.l11 = polynomial.x.scale(0.977204);
  78073. result.l2_2 = polynomial.xy.scale(1.16538);
  78074. result.l2_1 = polynomial.yz.scale(1.16538);
  78075. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  78076. result.l21 = polynomial.zx.scale(1.16538);
  78077. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  78078. result.scale(Math.PI);
  78079. return result;
  78080. };
  78081. /**
  78082. * Constructs a spherical harmonics from an array.
  78083. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  78084. * @returns the spherical harmonics
  78085. */
  78086. SphericalHarmonics.FromArray = function (data) {
  78087. var sh = new SphericalHarmonics();
  78088. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  78089. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  78090. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  78091. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  78092. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  78093. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  78094. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  78095. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  78096. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  78097. return sh;
  78098. };
  78099. return SphericalHarmonics;
  78100. }());
  78101. /***/ }),
  78102. /***/ "./Meshes/Builders/boxBuilder.ts":
  78103. /*!***************************************!*\
  78104. !*** ./Meshes/Builders/boxBuilder.ts ***!
  78105. \***************************************/
  78106. /*! exports provided: BoxBuilder */
  78107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78108. "use strict";
  78109. __webpack_require__.r(__webpack_exports__);
  78110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return BoxBuilder; });
  78111. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78112. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78113. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78114. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox = function (options) {
  78115. var nbFaces = 6;
  78116. var indices = [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];
  78117. var normals = [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];
  78118. var uvs = [];
  78119. var positions = [];
  78120. var width = options.width || options.size || 1;
  78121. var height = options.height || options.size || 1;
  78122. var depth = options.depth || options.size || 1;
  78123. var wrap = options.wrap || false;
  78124. var topBaseAt = (options.topBaseAt === void 0) ? 1 : options.topBaseAt;
  78125. var bottomBaseAt = (options.bottomBaseAt === void 0) ? 0 : options.bottomBaseAt;
  78126. topBaseAt = (topBaseAt + 4) % 4; // places values as 0 to 3
  78127. bottomBaseAt = (bottomBaseAt + 4) % 4; // places values as 0 to 3
  78128. var topOrder = [2, 0, 3, 1];
  78129. var bottomOrder = [2, 0, 1, 3];
  78130. var topIndex = topOrder[topBaseAt];
  78131. var bottomIndex = bottomOrder[bottomBaseAt];
  78132. var basePositions = [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];
  78133. if (wrap) {
  78134. indices = [2, 3, 0, 2, 0, 1, 4, 5, 6, 4, 6, 7, 9, 10, 11, 9, 11, 8, 12, 14, 15, 12, 13, 14];
  78135. basePositions = [-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];
  78136. var topFaceBase = [[1, 1, 1], [-1, 1, 1], [-1, 1, -1], [1, 1, -1]];
  78137. var bottomFaceBase = [[-1, -1, 1], [1, -1, 1], [1, -1, -1], [-1, -1, -1]];
  78138. var topFaceOrder = [17, 18, 19, 16];
  78139. var bottomFaceOrder = [22, 23, 20, 21];
  78140. while (topIndex > 0) {
  78141. topFaceBase.unshift(topFaceBase.pop());
  78142. topFaceOrder.unshift(topFaceOrder.pop());
  78143. topIndex--;
  78144. }
  78145. while (bottomIndex > 0) {
  78146. bottomFaceBase.unshift(bottomFaceBase.pop());
  78147. bottomFaceOrder.unshift(bottomFaceOrder.pop());
  78148. bottomIndex--;
  78149. }
  78150. topFaceBase = topFaceBase.flat();
  78151. bottomFaceBase = bottomFaceBase.flat();
  78152. basePositions = basePositions.concat(topFaceBase).concat(bottomFaceBase);
  78153. indices.push(topFaceOrder[0], topFaceOrder[2], topFaceOrder[3], topFaceOrder[0], topFaceOrder[1], topFaceOrder[2]);
  78154. indices.push(bottomFaceOrder[0], bottomFaceOrder[2], bottomFaceOrder[3], bottomFaceOrder[0], bottomFaceOrder[1], bottomFaceOrder[2]);
  78155. }
  78156. var scaleArray = [width / 2, height / 2, depth / 2];
  78157. positions = basePositions.reduce(function (accumulator, currentValue, currentIndex) { return accumulator.concat(currentValue * scaleArray[currentIndex % 3]); }, []);
  78158. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  78159. var faceUV = options.faceUV || new Array(6);
  78160. var faceColors = options.faceColors;
  78161. var colors = [];
  78162. // default face colors and UV if undefined
  78163. for (var f = 0; f < 6; f++) {
  78164. if (faceUV[f] === undefined) {
  78165. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  78166. }
  78167. if (faceColors && faceColors[f] === undefined) {
  78168. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  78169. }
  78170. }
  78171. // Create each face in turn.
  78172. for (var index = 0; index < nbFaces; index++) {
  78173. uvs.push(faceUV[index].z, faceUV[index].w);
  78174. uvs.push(faceUV[index].x, faceUV[index].w);
  78175. uvs.push(faceUV[index].x, faceUV[index].y);
  78176. uvs.push(faceUV[index].z, faceUV[index].y);
  78177. if (faceColors) {
  78178. for (var c = 0; c < 4; c++) {
  78179. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  78180. }
  78181. }
  78182. }
  78183. // sides
  78184. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78185. // Result
  78186. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78187. vertexData.indices = indices;
  78188. vertexData.positions = positions;
  78189. vertexData.normals = normals;
  78190. vertexData.uvs = uvs;
  78191. if (faceColors) {
  78192. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  78193. vertexData.colors = totalColors;
  78194. }
  78195. return vertexData;
  78196. };
  78197. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  78198. if (scene === void 0) { scene = null; }
  78199. var options = {
  78200. size: size,
  78201. sideOrientation: sideOrientation,
  78202. updatable: updatable
  78203. };
  78204. return BoxBuilder.CreateBox(name, options, scene);
  78205. };
  78206. /**
  78207. * Class containing static functions to help procedurally build meshes
  78208. */
  78209. var BoxBuilder = /** @class */ (function () {
  78210. function BoxBuilder() {
  78211. }
  78212. /**
  78213. * Creates a box mesh
  78214. * * The parameter `size` sets the size (float) of each box side (default 1)
  78215. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  78216. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  78217. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  78218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  78220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78221. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  78222. * @param name defines the name of the mesh
  78223. * @param options defines the options used to create the mesh
  78224. * @param scene defines the hosting scene
  78225. * @returns the box mesh
  78226. */
  78227. BoxBuilder.CreateBox = function (name, options, scene) {
  78228. if (scene === void 0) { scene = null; }
  78229. var box = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78230. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78231. box._originalBuilderSideOrientation = options.sideOrientation;
  78232. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox(options);
  78233. vertexData.applyToMesh(box, options.updatable);
  78234. return box;
  78235. };
  78236. return BoxBuilder;
  78237. }());
  78238. /***/ }),
  78239. /***/ "./Meshes/Builders/cylinderBuilder.ts":
  78240. /*!********************************************!*\
  78241. !*** ./Meshes/Builders/cylinderBuilder.ts ***!
  78242. \********************************************/
  78243. /*! exports provided: CylinderBuilder */
  78244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78245. "use strict";
  78246. __webpack_require__.r(__webpack_exports__);
  78247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return CylinderBuilder; });
  78248. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78249. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78250. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78251. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  78252. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder = function (options) {
  78253. var height = options.height || 2;
  78254. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  78255. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  78256. var tessellation = options.tessellation || 24;
  78257. var subdivisions = options.subdivisions || 1;
  78258. var hasRings = options.hasRings ? true : false;
  78259. var enclose = options.enclose ? true : false;
  78260. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  78261. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  78262. var faceUV = options.faceUV || new Array(3);
  78263. var faceColors = options.faceColors;
  78264. // default face colors and UV if undefined
  78265. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  78266. var ringNb = (hasRings) ? subdivisions : 1;
  78267. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  78268. var f;
  78269. for (f = 0; f < surfaceNb; f++) {
  78270. if (faceColors && faceColors[f] === undefined) {
  78271. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  78272. }
  78273. }
  78274. for (f = 0; f < surfaceNb; f++) {
  78275. if (faceUV && faceUV[f] === undefined) {
  78276. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  78277. }
  78278. }
  78279. var indices = new Array();
  78280. var positions = new Array();
  78281. var normals = new Array();
  78282. var uvs = new Array();
  78283. var colors = new Array();
  78284. var angle_step = Math.PI * 2 * arc / tessellation;
  78285. var angle;
  78286. var h;
  78287. var radius;
  78288. var tan = (diameterBottom - diameterTop) / 2 / height;
  78289. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78290. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78291. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78292. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78293. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78294. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  78295. // positions, normals, uvs
  78296. var i;
  78297. var j;
  78298. var r;
  78299. var ringIdx = 1;
  78300. var s = 1; // surface index
  78301. var cs = 0;
  78302. var v = 0;
  78303. for (i = 0; i <= subdivisions; i++) {
  78304. h = i / subdivisions;
  78305. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  78306. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  78307. for (r = 0; r < ringIdx; r++) {
  78308. if (hasRings) {
  78309. s += r;
  78310. }
  78311. if (enclose) {
  78312. s += 2 * r;
  78313. }
  78314. for (j = 0; j <= tessellation; j++) {
  78315. angle = j * angle_step;
  78316. // position
  78317. ringVertex.x = Math.cos(-angle) * radius;
  78318. ringVertex.y = -height / 2 + h * height;
  78319. ringVertex.z = Math.sin(-angle) * radius;
  78320. // normal
  78321. if (diameterTop === 0 && i === subdivisions) {
  78322. // if no top cap, reuse former normals
  78323. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  78324. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  78325. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  78326. }
  78327. else {
  78328. ringNormal.x = ringVertex.x;
  78329. ringNormal.z = ringVertex.z;
  78330. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  78331. ringNormal.normalize();
  78332. }
  78333. // keep first ring vertex values for enclose
  78334. if (j === 0) {
  78335. ringFirstVertex.copyFrom(ringVertex);
  78336. ringFirstNormal.copyFrom(ringNormal);
  78337. }
  78338. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  78339. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  78340. if (hasRings) {
  78341. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  78342. }
  78343. else {
  78344. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  78345. }
  78346. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  78347. if (faceColors) {
  78348. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  78349. }
  78350. }
  78351. // if enclose, add four vertices and their dedicated normals
  78352. if (arc !== 1 && enclose) {
  78353. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  78354. positions.push(0, ringVertex.y, 0);
  78355. positions.push(0, ringVertex.y, 0);
  78356. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  78357. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  78358. quadNormal.normalize();
  78359. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  78360. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  78361. quadNormal.normalize();
  78362. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  78363. if (hasRings) {
  78364. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  78365. }
  78366. else {
  78367. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  78368. }
  78369. uvs.push(faceUV[s + 1].x, v);
  78370. uvs.push(faceUV[s + 1].z, v);
  78371. if (hasRings) {
  78372. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  78373. }
  78374. else {
  78375. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  78376. }
  78377. uvs.push(faceUV[s + 2].x, v);
  78378. uvs.push(faceUV[s + 2].z, v);
  78379. if (faceColors) {
  78380. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  78381. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  78382. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  78383. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  78384. }
  78385. }
  78386. if (cs !== s) {
  78387. cs = s;
  78388. }
  78389. }
  78390. }
  78391. // indices
  78392. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  78393. var s;
  78394. i = 0;
  78395. for (s = 0; s < subdivisions; s++) {
  78396. var i0 = 0;
  78397. var i1 = 0;
  78398. var i2 = 0;
  78399. var i3 = 0;
  78400. for (j = 0; j < tessellation; j++) {
  78401. i0 = i * (e + 1) + j;
  78402. i1 = (i + 1) * (e + 1) + j;
  78403. i2 = i * (e + 1) + (j + 1);
  78404. i3 = (i + 1) * (e + 1) + (j + 1);
  78405. indices.push(i0, i1, i2);
  78406. indices.push(i3, i2, i1);
  78407. }
  78408. if (arc !== 1 && enclose) { // if enclose, add two quads
  78409. indices.push(i0 + 2, i1 + 2, i2 + 2);
  78410. indices.push(i3 + 2, i2 + 2, i1 + 2);
  78411. indices.push(i0 + 4, i1 + 4, i2 + 4);
  78412. indices.push(i3 + 4, i2 + 4, i1 + 4);
  78413. }
  78414. i = (hasRings) ? (i + 2) : (i + 1);
  78415. }
  78416. // Caps
  78417. var createCylinderCap = function (isTop) {
  78418. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  78419. if (radius === 0) {
  78420. return;
  78421. }
  78422. // Cap positions, normals & uvs
  78423. var angle;
  78424. var circleVector;
  78425. var i;
  78426. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  78427. var c = null;
  78428. if (faceColors) {
  78429. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  78430. }
  78431. // cap center
  78432. var vbase = positions.length / 3;
  78433. var offset = isTop ? height / 2 : -height / 2;
  78434. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  78435. positions.push(center.x, center.y, center.z);
  78436. normals.push(0, isTop ? 1 : -1, 0);
  78437. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  78438. if (c) {
  78439. colors.push(c.r, c.g, c.b, c.a);
  78440. }
  78441. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  78442. for (i = 0; i <= tessellation; i++) {
  78443. angle = Math.PI * 2 * i * arc / tessellation;
  78444. var cos = Math.cos(-angle);
  78445. var sin = Math.sin(-angle);
  78446. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  78447. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  78448. positions.push(circleVector.x, circleVector.y, circleVector.z);
  78449. normals.push(0, isTop ? 1 : -1, 0);
  78450. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  78451. if (c) {
  78452. colors.push(c.r, c.g, c.b, c.a);
  78453. }
  78454. }
  78455. // Cap indices
  78456. for (i = 0; i < tessellation; i++) {
  78457. if (!isTop) {
  78458. indices.push(vbase);
  78459. indices.push(vbase + (i + 1));
  78460. indices.push(vbase + (i + 2));
  78461. }
  78462. else {
  78463. indices.push(vbase);
  78464. indices.push(vbase + (i + 2));
  78465. indices.push(vbase + (i + 1));
  78466. }
  78467. }
  78468. };
  78469. // add caps to geometry
  78470. createCylinderCap(false);
  78471. createCylinderCap(true);
  78472. // Sides
  78473. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78474. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78475. vertexData.indices = indices;
  78476. vertexData.positions = positions;
  78477. vertexData.normals = normals;
  78478. vertexData.uvs = uvs;
  78479. if (faceColors) {
  78480. vertexData.colors = colors;
  78481. }
  78482. return vertexData;
  78483. };
  78484. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  78485. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"])) {
  78486. if (scene !== undefined) {
  78487. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DEFAULTSIDE;
  78488. updatable = scene;
  78489. }
  78490. scene = subdivisions;
  78491. subdivisions = 1;
  78492. }
  78493. var options = {
  78494. height: height,
  78495. diameterTop: diameterTop,
  78496. diameterBottom: diameterBottom,
  78497. tessellation: tessellation,
  78498. subdivisions: subdivisions,
  78499. sideOrientation: sideOrientation,
  78500. updatable: updatable
  78501. };
  78502. return CylinderBuilder.CreateCylinder(name, options, scene);
  78503. };
  78504. /**
  78505. * Class containing static functions to help procedurally build meshes
  78506. */
  78507. var CylinderBuilder = /** @class */ (function () {
  78508. function CylinderBuilder() {
  78509. }
  78510. /**
  78511. * Creates a cylinder or a cone mesh
  78512. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  78513. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  78514. * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  78515. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  78516. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  78517. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  78518. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  78519. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  78520. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  78521. * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  78522. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  78523. * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  78524. * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  78525. * * If `enclose` is false, a ring surface is one element.
  78526. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  78527. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  78528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78529. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  78530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78531. * @param name defines the name of the mesh
  78532. * @param options defines the options used to create the mesh
  78533. * @param scene defines the hosting scene
  78534. * @returns the cylinder mesh
  78535. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  78536. */
  78537. CylinderBuilder.CreateCylinder = function (name, options, scene) {
  78538. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78539. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78540. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  78541. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder(options);
  78542. vertexData.applyToMesh(cylinder, options.updatable);
  78543. return cylinder;
  78544. };
  78545. return CylinderBuilder;
  78546. }());
  78547. /***/ }),
  78548. /***/ "./Meshes/Builders/decalBuilder.ts":
  78549. /*!*****************************************!*\
  78550. !*** ./Meshes/Builders/decalBuilder.ts ***!
  78551. \*****************************************/
  78552. /*! exports provided: DecalBuilder */
  78553. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78554. "use strict";
  78555. __webpack_require__.r(__webpack_exports__);
  78556. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return DecalBuilder; });
  78557. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78558. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78559. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  78560. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78561. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  78562. var options = {
  78563. position: position,
  78564. normal: normal,
  78565. size: size,
  78566. angle: angle
  78567. };
  78568. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  78569. };
  78570. /**
  78571. * Class containing static functions to help procedurally build meshes
  78572. */
  78573. var DecalBuilder = /** @class */ (function () {
  78574. function DecalBuilder() {
  78575. }
  78576. /**
  78577. * Creates a decal mesh.
  78578. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
  78579. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  78580. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  78581. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  78582. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  78583. * @param name defines the name of the mesh
  78584. * @param sourceMesh defines the mesh where the decal must be applied
  78585. * @param options defines the options used to create the mesh
  78586. * @param scene defines the hosting scene
  78587. * @returns the decal mesh
  78588. * @see https://doc.babylonjs.com/how_to/decals
  78589. */
  78590. DecalBuilder.CreateDecal = function (name, sourceMesh, options) {
  78591. var indices = sourceMesh.getIndices();
  78592. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  78593. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  78594. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78595. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up();
  78596. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  78597. var angle = options.angle || 0;
  78598. // Getting correct rotation
  78599. if (!normal) {
  78600. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1);
  78601. var camera = sourceMesh.getScene().activeCamera;
  78602. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  78603. normal = camera.globalPosition.subtract(cameraWorldTarget);
  78604. }
  78605. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  78606. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  78607. var pitch = Math.atan2(normal.y, len);
  78608. // Matrix
  78609. var decalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRoll(yaw, pitch, angle).multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(position.x, position.y, position.z));
  78610. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Invert(decalWorldMatrix);
  78611. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  78612. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  78613. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  78614. vertexData.indices = [];
  78615. vertexData.positions = [];
  78616. vertexData.normals = [];
  78617. vertexData.uvs = [];
  78618. var currentVertexDataIndex = 0;
  78619. var extractDecalVector3 = function (indexId) {
  78620. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]();
  78621. if (!indices || !positions || !normals) {
  78622. return result;
  78623. }
  78624. var vertexId = indices[indexId];
  78625. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  78626. // Send vector to decal local world
  78627. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  78628. // Get normal
  78629. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  78630. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result.normal, transformMatrix);
  78631. return result;
  78632. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  78633. var clip = function (vertices, axis) {
  78634. if (vertices.length === 0) {
  78635. return vertices;
  78636. }
  78637. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(size, axis));
  78638. var clipVertices = function (v0, v1) {
  78639. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  78640. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"](_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(v0.position, v1.position, clipFactor), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(v0.normal, v1.normal, clipFactor));
  78641. };
  78642. var result = new Array();
  78643. for (var index = 0; index < vertices.length; index += 3) {
  78644. var v1Out;
  78645. var v2Out;
  78646. var v3Out;
  78647. var total = 0;
  78648. var nV1 = null;
  78649. var nV2 = null;
  78650. var nV3 = null;
  78651. var nV4 = null;
  78652. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  78653. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  78654. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  78655. v1Out = d1 > 0;
  78656. v2Out = d2 > 0;
  78657. v3Out = d3 > 0;
  78658. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  78659. switch (total) {
  78660. case 0:
  78661. result.push(vertices[index]);
  78662. result.push(vertices[index + 1]);
  78663. result.push(vertices[index + 2]);
  78664. break;
  78665. case 1:
  78666. if (v1Out) {
  78667. nV1 = vertices[index + 1];
  78668. nV2 = vertices[index + 2];
  78669. nV3 = clipVertices(vertices[index], nV1);
  78670. nV4 = clipVertices(vertices[index], nV2);
  78671. }
  78672. if (v2Out) {
  78673. nV1 = vertices[index];
  78674. nV2 = vertices[index + 2];
  78675. nV3 = clipVertices(vertices[index + 1], nV1);
  78676. nV4 = clipVertices(vertices[index + 1], nV2);
  78677. result.push(nV3);
  78678. result.push(nV2.clone());
  78679. result.push(nV1.clone());
  78680. result.push(nV2.clone());
  78681. result.push(nV3.clone());
  78682. result.push(nV4);
  78683. break;
  78684. }
  78685. if (v3Out) {
  78686. nV1 = vertices[index];
  78687. nV2 = vertices[index + 1];
  78688. nV3 = clipVertices(vertices[index + 2], nV1);
  78689. nV4 = clipVertices(vertices[index + 2], nV2);
  78690. }
  78691. if (nV1 && nV2 && nV3 && nV4) {
  78692. result.push(nV1.clone());
  78693. result.push(nV2.clone());
  78694. result.push(nV3);
  78695. result.push(nV4);
  78696. result.push(nV3.clone());
  78697. result.push(nV2.clone());
  78698. }
  78699. break;
  78700. case 2:
  78701. if (!v1Out) {
  78702. nV1 = vertices[index].clone();
  78703. nV2 = clipVertices(nV1, vertices[index + 1]);
  78704. nV3 = clipVertices(nV1, vertices[index + 2]);
  78705. result.push(nV1);
  78706. result.push(nV2);
  78707. result.push(nV3);
  78708. }
  78709. if (!v2Out) {
  78710. nV1 = vertices[index + 1].clone();
  78711. nV2 = clipVertices(nV1, vertices[index + 2]);
  78712. nV3 = clipVertices(nV1, vertices[index]);
  78713. result.push(nV1);
  78714. result.push(nV2);
  78715. result.push(nV3);
  78716. }
  78717. if (!v3Out) {
  78718. nV1 = vertices[index + 2].clone();
  78719. nV2 = clipVertices(nV1, vertices[index]);
  78720. nV3 = clipVertices(nV1, vertices[index + 1]);
  78721. result.push(nV1);
  78722. result.push(nV2);
  78723. result.push(nV3);
  78724. }
  78725. break;
  78726. case 3:
  78727. break;
  78728. }
  78729. }
  78730. return result;
  78731. };
  78732. for (var index = 0; index < indices.length; index += 3) {
  78733. var faceVertices = new Array();
  78734. faceVertices.push(extractDecalVector3(index));
  78735. faceVertices.push(extractDecalVector3(index + 1));
  78736. faceVertices.push(extractDecalVector3(index + 2));
  78737. // Clip
  78738. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0));
  78739. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0));
  78740. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0));
  78741. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0));
  78742. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1));
  78743. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1));
  78744. if (faceVertices.length === 0) {
  78745. continue;
  78746. }
  78747. // Add UVs and get back to world
  78748. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  78749. var vertex = faceVertices[vIndex];
  78750. //TODO check for Int32Array | Uint32Array | Uint16Array
  78751. vertexData.indices.push(currentVertexDataIndex);
  78752. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  78753. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  78754. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  78755. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  78756. currentVertexDataIndex++;
  78757. }
  78758. }
  78759. // Return mesh
  78760. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, sourceMesh.getScene());
  78761. vertexData.applyToMesh(decal);
  78762. decal.position = position.clone();
  78763. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pitch, yaw, angle);
  78764. return decal;
  78765. };
  78766. return DecalBuilder;
  78767. }());
  78768. /***/ }),
  78769. /***/ "./Meshes/Builders/discBuilder.ts":
  78770. /*!****************************************!*\
  78771. !*** ./Meshes/Builders/discBuilder.ts ***!
  78772. \****************************************/
  78773. /*! exports provided: DiscBuilder */
  78774. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78775. "use strict";
  78776. __webpack_require__.r(__webpack_exports__);
  78777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return DiscBuilder; });
  78778. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78779. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78780. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc = function (options) {
  78781. var positions = new Array();
  78782. var indices = new Array();
  78783. var normals = new Array();
  78784. var uvs = new Array();
  78785. var radius = options.radius || 0.5;
  78786. var tessellation = options.tessellation || 64;
  78787. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  78788. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  78789. // positions and uvs
  78790. positions.push(0, 0, 0); // disc center first
  78791. uvs.push(0.5, 0.5);
  78792. var theta = Math.PI * 2 * arc;
  78793. var step = theta / tessellation;
  78794. for (var a = 0; a < theta; a += step) {
  78795. var x = Math.cos(a);
  78796. var y = Math.sin(a);
  78797. var u = (x + 1) / 2;
  78798. var v = (1 - y) / 2;
  78799. positions.push(radius * x, radius * y, 0);
  78800. uvs.push(u, v);
  78801. }
  78802. if (arc === 1) {
  78803. positions.push(positions[3], positions[4], positions[5]); // close the circle
  78804. uvs.push(uvs[2], uvs[3]);
  78805. }
  78806. //indices
  78807. var vertexNb = positions.length / 3;
  78808. for (var i = 1; i < vertexNb - 1; i++) {
  78809. indices.push(i + 1, 0, i);
  78810. }
  78811. // result
  78812. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ComputeNormals(positions, indices, normals);
  78813. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78814. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  78815. vertexData.indices = indices;
  78816. vertexData.positions = positions;
  78817. vertexData.normals = normals;
  78818. vertexData.uvs = uvs;
  78819. return vertexData;
  78820. };
  78821. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  78822. if (scene === void 0) { scene = null; }
  78823. var options = {
  78824. radius: radius,
  78825. tessellation: tessellation,
  78826. sideOrientation: sideOrientation,
  78827. updatable: updatable
  78828. };
  78829. return DiscBuilder.CreateDisc(name, options, scene);
  78830. };
  78831. /**
  78832. * Class containing static functions to help procedurally build meshes
  78833. */
  78834. var DiscBuilder = /** @class */ (function () {
  78835. function DiscBuilder() {
  78836. }
  78837. /**
  78838. * Creates a plane polygonal mesh. By default, this is a disc
  78839. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  78840. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  78841. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  78842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78843. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  78844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78845. * @param name defines the name of the mesh
  78846. * @param options defines the options used to create the mesh
  78847. * @param scene defines the hosting scene
  78848. * @returns the plane polygonal mesh
  78849. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  78850. */
  78851. DiscBuilder.CreateDisc = function (name, options, scene) {
  78852. if (scene === void 0) { scene = null; }
  78853. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  78854. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78855. disc._originalBuilderSideOrientation = options.sideOrientation;
  78856. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc(options);
  78857. vertexData.applyToMesh(disc, options.updatable);
  78858. return disc;
  78859. };
  78860. return DiscBuilder;
  78861. }());
  78862. /***/ }),
  78863. /***/ "./Meshes/Builders/groundBuilder.ts":
  78864. /*!******************************************!*\
  78865. !*** ./Meshes/Builders/groundBuilder.ts ***!
  78866. \******************************************/
  78867. /*! exports provided: GroundBuilder */
  78868. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78869. "use strict";
  78870. __webpack_require__.r(__webpack_exports__);
  78871. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return GroundBuilder; });
  78872. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78873. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78874. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78875. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
  78876. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  78877. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  78878. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround = function (options) {
  78879. var indices = [];
  78880. var positions = [];
  78881. var normals = [];
  78882. var uvs = [];
  78883. var row, col;
  78884. var width = options.width || 1;
  78885. var height = options.height || 1;
  78886. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  78887. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  78888. for (row = 0; row <= subdivisionsY; row++) {
  78889. for (col = 0; col <= subdivisionsX; col++) {
  78890. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  78891. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  78892. positions.push(position.x, position.y, position.z);
  78893. normals.push(normal.x, normal.y, normal.z);
  78894. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  78895. }
  78896. }
  78897. for (row = 0; row < subdivisionsY; row++) {
  78898. for (col = 0; col < subdivisionsX; col++) {
  78899. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  78900. indices.push(col + 1 + row * (subdivisionsX + 1));
  78901. indices.push(col + row * (subdivisionsX + 1));
  78902. indices.push(col + (row + 1) * (subdivisionsX + 1));
  78903. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  78904. indices.push(col + row * (subdivisionsX + 1));
  78905. }
  78906. }
  78907. // Result
  78908. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78909. vertexData.indices = indices;
  78910. vertexData.positions = positions;
  78911. vertexData.normals = normals;
  78912. vertexData.uvs = uvs;
  78913. return vertexData;
  78914. };
  78915. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround = function (options) {
  78916. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  78917. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  78918. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  78919. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  78920. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  78921. var precision = options.precision || { w: 1, h: 1 };
  78922. var indices = new Array();
  78923. var positions = new Array();
  78924. var normals = new Array();
  78925. var uvs = new Array();
  78926. var row, col, tileRow, tileCol;
  78927. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  78928. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  78929. precision.w = (precision.w < 1) ? 1 : precision.w;
  78930. precision.h = (precision.h < 1) ? 1 : precision.h;
  78931. var tileSize = {
  78932. 'w': (xmax - xmin) / subdivisions.w,
  78933. 'h': (zmax - zmin) / subdivisions.h
  78934. };
  78935. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  78936. // Indices
  78937. var base = positions.length / 3;
  78938. var rowLength = precision.w + 1;
  78939. for (row = 0; row < precision.h; row++) {
  78940. for (col = 0; col < precision.w; col++) {
  78941. var square = [
  78942. base + col + row * rowLength,
  78943. base + (col + 1) + row * rowLength,
  78944. base + (col + 1) + (row + 1) * rowLength,
  78945. base + col + (row + 1) * rowLength
  78946. ];
  78947. indices.push(square[1]);
  78948. indices.push(square[2]);
  78949. indices.push(square[3]);
  78950. indices.push(square[0]);
  78951. indices.push(square[1]);
  78952. indices.push(square[3]);
  78953. }
  78954. }
  78955. // Position, normals and uvs
  78956. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78957. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  78958. for (row = 0; row <= precision.h; row++) {
  78959. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  78960. for (col = 0; col <= precision.w; col++) {
  78961. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  78962. position.y = 0;
  78963. positions.push(position.x, position.y, position.z);
  78964. normals.push(normal.x, normal.y, normal.z);
  78965. uvs.push(col / precision.w, row / precision.h);
  78966. }
  78967. }
  78968. }
  78969. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  78970. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  78971. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  78972. }
  78973. }
  78974. // Result
  78975. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78976. vertexData.indices = indices;
  78977. vertexData.positions = positions;
  78978. vertexData.normals = normals;
  78979. vertexData.uvs = uvs;
  78980. return vertexData;
  78981. };
  78982. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap = function (options) {
  78983. var indices = [];
  78984. var positions = [];
  78985. var normals = [];
  78986. var uvs = [];
  78987. var row, col;
  78988. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  78989. var alphaFilter = options.alphaFilter || 0.0;
  78990. var invert = false;
  78991. if (options.minHeight > options.maxHeight) {
  78992. invert = true;
  78993. var temp = options.maxHeight;
  78994. options.maxHeight = options.minHeight;
  78995. options.minHeight = temp;
  78996. }
  78997. // Vertices
  78998. for (row = 0; row <= options.subdivisions; row++) {
  78999. for (col = 0; col <= options.subdivisions; col++) {
  79000. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * options.width) / options.subdivisions - (options.width / 2.0), 0, ((options.subdivisions - row) * options.height) / options.subdivisions - (options.height / 2.0));
  79001. // Compute height
  79002. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  79003. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  79004. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  79005. var r = options.buffer[pos] / 255.0;
  79006. var g = options.buffer[pos + 1] / 255.0;
  79007. var b = options.buffer[pos + 2] / 255.0;
  79008. var a = options.buffer[pos + 3] / 255.0;
  79009. if (invert) {
  79010. r = 1.0 - r;
  79011. g = 1.0 - g;
  79012. b = 1.0 - b;
  79013. }
  79014. var gradient = r * filter.r + g * filter.g + b * filter.b;
  79015. // If our alpha channel is not within our filter then we will assign a 'special' height
  79016. // Then when building the indices, we will ignore any vertex that is using the special height
  79017. if (a >= alphaFilter) {
  79018. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  79019. }
  79020. else {
  79021. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  79022. }
  79023. // Add vertex
  79024. positions.push(position.x, position.y, position.z);
  79025. normals.push(0, 0, 0);
  79026. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  79027. }
  79028. }
  79029. // Indices
  79030. for (row = 0; row < options.subdivisions; row++) {
  79031. for (col = 0; col < options.subdivisions; col++) {
  79032. // Calculate Indices
  79033. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  79034. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  79035. var idx3 = (col + row * (options.subdivisions + 1));
  79036. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  79037. // Check that all indices are visible (based on our special height)
  79038. // Only display the vertex if all Indices are visible
  79039. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  79040. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  79041. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  79042. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  79043. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  79044. indices.push(idx1);
  79045. indices.push(idx2);
  79046. indices.push(idx3);
  79047. }
  79048. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  79049. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  79050. indices.push(idx4);
  79051. indices.push(idx1);
  79052. indices.push(idx3);
  79053. }
  79054. }
  79055. }
  79056. // Normals
  79057. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  79058. // Result
  79059. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79060. vertexData.indices = indices;
  79061. vertexData.positions = positions;
  79062. vertexData.normals = normals;
  79063. vertexData.uvs = uvs;
  79064. return vertexData;
  79065. };
  79066. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  79067. var options = {
  79068. width: width,
  79069. height: height,
  79070. subdivisions: subdivisions,
  79071. updatable: updatable
  79072. };
  79073. return GroundBuilder.CreateGround(name, options, scene);
  79074. };
  79075. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  79076. var options = {
  79077. xmin: xmin,
  79078. zmin: zmin,
  79079. xmax: xmax,
  79080. zmax: zmax,
  79081. subdivisions: subdivisions,
  79082. precision: precision,
  79083. updatable: updatable
  79084. };
  79085. return GroundBuilder.CreateTiledGround(name, options, scene);
  79086. };
  79087. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  79088. var options = {
  79089. width: width,
  79090. height: height,
  79091. subdivisions: subdivisions,
  79092. minHeight: minHeight,
  79093. maxHeight: maxHeight,
  79094. updatable: updatable,
  79095. onReady: onReady,
  79096. alphaFilter: alphaFilter
  79097. };
  79098. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  79099. };
  79100. /**
  79101. * Class containing static functions to help procedurally build meshes
  79102. */
  79103. var GroundBuilder = /** @class */ (function () {
  79104. function GroundBuilder() {
  79105. }
  79106. /**
  79107. * Creates a ground mesh
  79108. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  79109. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  79110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79111. * @param name defines the name of the mesh
  79112. * @param options defines the options used to create the mesh
  79113. * @param scene defines the hosting scene
  79114. * @returns the ground mesh
  79115. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  79116. */
  79117. GroundBuilder.CreateGround = function (name, options, scene) {
  79118. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  79119. ground._setReady(false);
  79120. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  79121. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  79122. ground._width = options.width || 1;
  79123. ground._height = options.height || 1;
  79124. ground._maxX = ground._width / 2;
  79125. ground._maxZ = ground._height / 2;
  79126. ground._minX = -ground._maxX;
  79127. ground._minZ = -ground._maxZ;
  79128. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround(options);
  79129. vertexData.applyToMesh(ground, options.updatable);
  79130. ground._setReady(true);
  79131. return ground;
  79132. };
  79133. /**
  79134. * Creates a tiled ground mesh
  79135. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  79136. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  79137. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  79138. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  79139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79140. * @param name defines the name of the mesh
  79141. * @param options defines the options used to create the mesh
  79142. * @param scene defines the hosting scene
  79143. * @returns the tiled ground mesh
  79144. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  79145. */
  79146. GroundBuilder.CreateTiledGround = function (name, options, scene) {
  79147. if (scene === void 0) { scene = null; }
  79148. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79149. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
  79150. vertexData.applyToMesh(tiledGround, options.updatable);
  79151. return tiledGround;
  79152. };
  79153. /**
  79154. * Creates a ground mesh from a height map
  79155. * * The parameter `url` sets the URL of the height map image resource.
  79156. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  79157. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  79158. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  79159. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  79160. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  79161. * * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  79162. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  79163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79164. * @param name defines the name of the mesh
  79165. * @param url defines the url to the height map
  79166. * @param options defines the options used to create the mesh
  79167. * @param scene defines the hosting scene
  79168. * @returns the ground mesh
  79169. * @see https://doc.babylonjs.com/babylon101/height_map
  79170. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  79171. */
  79172. GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  79173. if (scene === void 0) { scene = null; }
  79174. var width = options.width || 10.0;
  79175. var height = options.height || 10.0;
  79176. var subdivisions = options.subdivisions || 1 | 0;
  79177. var minHeight = options.minHeight || 0.0;
  79178. var maxHeight = options.maxHeight || 1.0;
  79179. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  79180. var alphaFilter = options.alphaFilter || 0.0;
  79181. var updatable = options.updatable;
  79182. var onReady = options.onReady;
  79183. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  79184. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  79185. ground._subdivisionsX = subdivisions;
  79186. ground._subdivisionsY = subdivisions;
  79187. ground._width = width;
  79188. ground._height = height;
  79189. ground._maxX = ground._width / 2.0;
  79190. ground._maxZ = ground._height / 2.0;
  79191. ground._minX = -ground._maxX;
  79192. ground._minZ = -ground._maxZ;
  79193. ground._setReady(false);
  79194. var onload = function (img) {
  79195. // Getting height map data
  79196. var canvas = document.createElement("canvas");
  79197. var context = canvas.getContext("2d");
  79198. if (!context) {
  79199. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  79200. }
  79201. if (scene.isDisposed) {
  79202. return;
  79203. }
  79204. var bufferWidth = img.width;
  79205. var bufferHeight = img.height;
  79206. canvas.width = bufferWidth;
  79207. canvas.height = bufferHeight;
  79208. context.drawImage(img, 0, 0);
  79209. // Create VertexData from map data
  79210. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  79211. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  79212. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap({
  79213. width: width, height: height,
  79214. subdivisions: subdivisions,
  79215. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  79216. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  79217. alphaFilter: alphaFilter
  79218. });
  79219. vertexData.applyToMesh(ground, updatable);
  79220. //execute ready callback, if set
  79221. if (onReady) {
  79222. onReady(ground);
  79223. }
  79224. ground._setReady(true);
  79225. };
  79226. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  79227. return ground;
  79228. };
  79229. return GroundBuilder;
  79230. }());
  79231. /***/ }),
  79232. /***/ "./Meshes/Builders/hemisphereBuilder.ts":
  79233. /*!**********************************************!*\
  79234. !*** ./Meshes/Builders/hemisphereBuilder.ts ***!
  79235. \**********************************************/
  79236. /*! exports provided: HemisphereBuilder */
  79237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79238. "use strict";
  79239. __webpack_require__.r(__webpack_exports__);
  79240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return HemisphereBuilder; });
  79241. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79242. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  79243. /**
  79244. * Creates a hemispheric light
  79245. */
  79246. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateHemisphere = function (name, segments, diameter, scene) {
  79247. var options = {
  79248. segments: segments,
  79249. diameter: diameter
  79250. };
  79251. return HemisphereBuilder.CreateHemisphere(name, options, scene);
  79252. };
  79253. /**
  79254. * Class containing static functions to help procedurally build meshes
  79255. */
  79256. var HemisphereBuilder = /** @class */ (function () {
  79257. function HemisphereBuilder() {
  79258. }
  79259. /**
  79260. * Creates a hemisphere mesh
  79261. * @param name defines the name of the mesh
  79262. * @param options defines the options used to create the mesh
  79263. * @param scene defines the hosting scene
  79264. * @returns the hemisphere mesh
  79265. */
  79266. HemisphereBuilder.CreateHemisphere = function (name, options, scene) {
  79267. if (!options.diameter) {
  79268. options.diameter = 1;
  79269. }
  79270. if (!options.segments) {
  79271. options.segments = 16;
  79272. }
  79273. var halfSphere = _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("", { slice: 0.5, diameter: options.diameter, segments: options.segments }, scene);
  79274. var disc = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc("", options.diameter / 2, (options.segments * 3) + (4 - options.segments), scene);
  79275. disc.rotation.x = -Math.PI / 2;
  79276. disc.parent = halfSphere;
  79277. var merged = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].MergeMeshes([disc, halfSphere], true);
  79278. merged.name = name;
  79279. return merged;
  79280. };
  79281. return HemisphereBuilder;
  79282. }());
  79283. /***/ }),
  79284. /***/ "./Meshes/Builders/icoSphereBuilder.ts":
  79285. /*!*********************************************!*\
  79286. !*** ./Meshes/Builders/icoSphereBuilder.ts ***!
  79287. \*********************************************/
  79288. /*! exports provided: IcoSphereBuilder */
  79289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79290. "use strict";
  79291. __webpack_require__.r(__webpack_exports__);
  79292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return IcoSphereBuilder; });
  79293. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79294. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79295. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79296. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere = function (options) {
  79297. var sideOrientation = options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  79298. var radius = options.radius || 1;
  79299. var flat = (options.flat === undefined) ? true : options.flat;
  79300. var subdivisions = options.subdivisions || 4;
  79301. var radiusX = options.radiusX || radius;
  79302. var radiusY = options.radiusY || radius;
  79303. var radiusZ = options.radiusZ || radius;
  79304. var t = (1 + Math.sqrt(5)) / 2;
  79305. // 12 vertex x,y,z
  79306. var ico_vertices = [
  79307. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  79308. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  79309. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  79310. ];
  79311. // index of 3 vertex makes a face of icopshere
  79312. var ico_indices = [
  79313. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  79314. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  79315. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  79316. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  79317. ];
  79318. // vertex for uv have aliased position, not for UV
  79319. var vertices_unalias_id = [
  79320. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  79321. // vertex alias
  79322. 0,
  79323. 2,
  79324. 3,
  79325. 3,
  79326. 3,
  79327. 4,
  79328. 7,
  79329. 8,
  79330. 9,
  79331. 9,
  79332. 10,
  79333. 11 // 23: B + 12
  79334. ];
  79335. // uv as integer step (not pixels !)
  79336. var ico_vertexuv = [
  79337. 5, 1, 3, 1, 6, 4, 0, 0,
  79338. 5, 3, 4, 2, 2, 2, 4, 0,
  79339. 2, 0, 1, 1, 6, 0, 6, 2,
  79340. // vertex alias (for same vertex on different faces)
  79341. 0, 4,
  79342. 3, 3,
  79343. 4, 4,
  79344. 3, 1,
  79345. 4, 2,
  79346. 4, 4,
  79347. 0, 2,
  79348. 1, 1,
  79349. 2, 2,
  79350. 3, 3,
  79351. 1, 3,
  79352. 2, 4 // 23: B + 12
  79353. ];
  79354. // Vertices[0, 1, ...9, A, B] : position on UV plane
  79355. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  79356. // First island of uv mapping
  79357. // v = 4h 3+ 2
  79358. // v = 3h 9+ 4
  79359. // v = 2h 9+ 5 B
  79360. // v = 1h 9 1 0
  79361. // v = 0h 3 8 7 A
  79362. // u = 0 1 2 3 4 5 6 *a
  79363. // Second island of uv mapping
  79364. // v = 4h 0+ B+ 4+
  79365. // v = 3h A+ 2+
  79366. // v = 2h 7+ 6 3+
  79367. // v = 1h 8+ 3+
  79368. // v = 0h
  79369. // u = 0 1 2 3 4 5 6 *a
  79370. // Face layout on texture UV mapping
  79371. // ============
  79372. // \ 4 /\ 16 / ======
  79373. // \ / \ / /\ 11 /
  79374. // \/ 7 \/ / \ /
  79375. // ======= / 10 \/
  79376. // /\ 17 /\ =======
  79377. // / \ / \ \ 15 /\
  79378. // / 8 \/ 12 \ \ / \
  79379. // ============ \/ 6 \
  79380. // \ 18 /\ ============
  79381. // \ / \ \ 5 /\ 0 /
  79382. // \/ 13 \ \ / \ /
  79383. // ======= \/ 1 \/
  79384. // =============
  79385. // /\ 19 /\ 2 /\
  79386. // / \ / \ / \
  79387. // / 14 \/ 9 \/ 3 \
  79388. // ===================
  79389. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  79390. var ustep = 138 / 1024;
  79391. var vstep = 239 / 1024;
  79392. var uoffset = 60 / 1024;
  79393. var voffset = 26 / 1024;
  79394. // Second island should have margin, not to touch the first island
  79395. // avoid any borderline artefact in pixel rounding
  79396. var island_u_offset = -40 / 1024;
  79397. var island_v_offset = +20 / 1024;
  79398. // face is either island 0 or 1 :
  79399. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  79400. var island = [
  79401. 0, 0, 0, 0, 1,
  79402. 0, 0, 1, 1, 0,
  79403. 0, 0, 1, 1, 0,
  79404. 0, 1, 1, 1, 0 // 15 - 19
  79405. ];
  79406. var indices = new Array();
  79407. var positions = new Array();
  79408. var normals = new Array();
  79409. var uvs = new Array();
  79410. var current_indice = 0;
  79411. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  79412. var face_vertex_pos = new Array(3);
  79413. var face_vertex_uv = new Array(3);
  79414. var v012;
  79415. for (v012 = 0; v012 < 3; v012++) {
  79416. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79417. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  79418. }
  79419. // create all with normals
  79420. for (var face = 0; face < 20; face++) {
  79421. // 3 vertex per face
  79422. for (v012 = 0; v012 < 3; v012++) {
  79423. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  79424. var v_id = ico_indices[3 * face + v012];
  79425. // vertex have 3D position (x,y,z)
  79426. face_vertex_pos[v012].copyFromFloats(ico_vertices[3 * vertices_unalias_id[v_id]], ico_vertices[3 * vertices_unalias_id[v_id] + 1], ico_vertices[3 * vertices_unalias_id[v_id] + 2]);
  79427. // Normalize to get normal, then scale to radius
  79428. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  79429. // uv Coordinates from vertex ID
  79430. face_vertex_uv[v012].copyFromFloats(ico_vertexuv[2 * v_id] * ustep + uoffset + island[face] * island_u_offset, ico_vertexuv[2 * v_id + 1] * vstep + voffset + island[face] * island_v_offset);
  79431. }
  79432. // Subdivide the face (interpolate pos, norm, uv)
  79433. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  79434. // - norm is linear interpolation of vertex corner normal
  79435. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  79436. // - uv is linear interpolation
  79437. //
  79438. // Topology is as below for sub-divide by 2
  79439. // vertex shown as v0,v1,v2
  79440. // interp index is i1 to progress in range [v0,v1[
  79441. // interp index is i2 to progress in range [v0,v2[
  79442. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  79443. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  79444. //
  79445. //
  79446. // i2 v2
  79447. // ^ ^
  79448. // / / \
  79449. // / / \
  79450. // / / \
  79451. // / / (0,1) \
  79452. // / #---------\
  79453. // / / \ (0,0)'/ \
  79454. // / / \ / \
  79455. // / / \ / \
  79456. // / / (0,0) \ / (1,0) \
  79457. // / #---------#---------\
  79458. // v0 v1
  79459. //
  79460. // --------------------> i1
  79461. //
  79462. // interp of (i1,i2):
  79463. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  79464. // along i1 : lerp(x0,x1, i1/(S-i2))
  79465. //
  79466. // centroid of triangle is needed to get help normal computation
  79467. // (c1,c2) are used for centroid location
  79468. var interp_vertex = function (i1, i2, c1, c2) {
  79469. // vertex is interpolated from
  79470. // - face_vertex_pos[0..2]
  79471. // - face_vertex_uv[0..2]
  79472. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  79473. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  79474. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  79475. pos_interp.normalize();
  79476. var vertex_normal;
  79477. if (flat) {
  79478. // in flat mode, recalculate normal as face centroid normal
  79479. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  79480. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  79481. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  79482. }
  79483. else {
  79484. // in smooth mode, recalculate normal from each single vertex position
  79485. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  79486. }
  79487. // Vertex normal need correction due to X,Y,Z radius scaling
  79488. vertex_normal.x /= radiusX;
  79489. vertex_normal.y /= radiusY;
  79490. vertex_normal.z /= radiusZ;
  79491. vertex_normal.normalize();
  79492. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  79493. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  79494. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  79495. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  79496. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  79497. uvs.push(uv_interp.x, uv_interp.y);
  79498. // push each vertex has member of a face
  79499. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  79500. indices.push(current_indice);
  79501. current_indice++;
  79502. };
  79503. for (var i2 = 0; i2 < subdivisions; i2++) {
  79504. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  79505. // face : (i1,i2) for /\ :
  79506. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  79507. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  79508. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  79509. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  79510. if (i1 + i2 + 1 < subdivisions) {
  79511. // face : (i1,i2)' for \/ :
  79512. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  79513. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  79514. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  79515. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  79516. }
  79517. }
  79518. }
  79519. }
  79520. // Sides
  79521. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79522. // Result
  79523. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79524. vertexData.indices = indices;
  79525. vertexData.positions = positions;
  79526. vertexData.normals = normals;
  79527. vertexData.uvs = uvs;
  79528. return vertexData;
  79529. };
  79530. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  79531. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  79532. };
  79533. /**
  79534. * Class containing static functions to help procedurally build meshes
  79535. */
  79536. var IcoSphereBuilder = /** @class */ (function () {
  79537. function IcoSphereBuilder() {
  79538. }
  79539. /**
  79540. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  79541. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  79542. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value of `radius`)
  79543. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  79544. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  79545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79546. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79548. * @param name defines the name of the mesh
  79549. * @param options defines the options used to create the mesh
  79550. * @param scene defines the hosting scene
  79551. * @returns the icosahedron mesh
  79552. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  79553. */
  79554. IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
  79555. if (scene === void 0) { scene = null; }
  79556. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79557. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79558. sphere._originalBuilderSideOrientation = options.sideOrientation;
  79559. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere(options);
  79560. vertexData.applyToMesh(sphere, options.updatable);
  79561. return sphere;
  79562. };
  79563. return IcoSphereBuilder;
  79564. }());
  79565. /***/ }),
  79566. /***/ "./Meshes/Builders/index.ts":
  79567. /*!**********************************!*\
  79568. !*** ./Meshes/Builders/index.ts ***!
  79569. \**********************************/
  79570. /*! exports provided: BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  79571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79572. "use strict";
  79573. __webpack_require__.r(__webpack_exports__);
  79574. /* harmony import */ var _boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  79575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  79576. /* harmony import */ var _discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./discBuilder */ "./Meshes/Builders/discBuilder.ts");
  79577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"]; });
  79578. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  79579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"]; });
  79580. /* harmony import */ var _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  79581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"]; });
  79582. /* harmony import */ var _hemisphereBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphereBuilder */ "./Meshes/Builders/hemisphereBuilder.ts");
  79583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _hemisphereBuilder__WEBPACK_IMPORTED_MODULE_4__["HemisphereBuilder"]; });
  79584. /* harmony import */ var _cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  79585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__["CylinderBuilder"]; });
  79586. /* harmony import */ var _torusBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  79587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _torusBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusBuilder"]; });
  79588. /* harmony import */ var _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  79589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_7__["TorusKnotBuilder"]; });
  79590. /* harmony import */ var _linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  79591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"]; });
  79592. /* harmony import */ var _polygonBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  79593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _polygonBuilder__WEBPACK_IMPORTED_MODULE_9__["PolygonBuilder"]; });
  79594. /* harmony import */ var _shapeBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  79595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _shapeBuilder__WEBPACK_IMPORTED_MODULE_10__["ShapeBuilder"]; });
  79596. /* harmony import */ var _latheBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  79597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _latheBuilder__WEBPACK_IMPORTED_MODULE_11__["LatheBuilder"]; });
  79598. /* harmony import */ var _planeBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  79599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _planeBuilder__WEBPACK_IMPORTED_MODULE_12__["PlaneBuilder"]; });
  79600. /* harmony import */ var _groundBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  79601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _groundBuilder__WEBPACK_IMPORTED_MODULE_13__["GroundBuilder"]; });
  79602. /* harmony import */ var _tubeBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  79603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _tubeBuilder__WEBPACK_IMPORTED_MODULE_14__["TubeBuilder"]; });
  79604. /* harmony import */ var _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  79605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_15__["PolyhedronBuilder"]; });
  79606. /* harmony import */ var _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  79607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_16__["IcoSphereBuilder"]; });
  79608. /* harmony import */ var _decalBuilder__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  79609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _decalBuilder__WEBPACK_IMPORTED_MODULE_17__["DecalBuilder"]; });
  79610. /***/ }),
  79611. /***/ "./Meshes/Builders/latheBuilder.ts":
  79612. /*!*****************************************!*\
  79613. !*** ./Meshes/Builders/latheBuilder.ts ***!
  79614. \*****************************************/
  79615. /*! exports provided: LatheBuilder */
  79616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79617. "use strict";
  79618. __webpack_require__.r(__webpack_exports__);
  79619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return LatheBuilder; });
  79620. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79621. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79622. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  79623. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  79624. var options = {
  79625. shape: shape,
  79626. radius: radius,
  79627. tessellation: tessellation,
  79628. sideOrientation: sideOrientation,
  79629. updatable: updatable
  79630. };
  79631. return LatheBuilder.CreateLathe(name, options, scene);
  79632. };
  79633. /**
  79634. * Class containing static functions to help procedurally build meshes
  79635. */
  79636. var LatheBuilder = /** @class */ (function () {
  79637. function LatheBuilder() {
  79638. }
  79639. /**
  79640. * Creates lathe mesh.
  79641. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  79642. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  79643. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  79644. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  79645. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  79646. * * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape
  79647. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  79648. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  79649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79651. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  79652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79653. * @param name defines the name of the mesh
  79654. * @param options defines the options used to create the mesh
  79655. * @param scene defines the hosting scene
  79656. * @returns the lathe mesh
  79657. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  79658. */
  79659. LatheBuilder.CreateLathe = function (name, options, scene) {
  79660. if (scene === void 0) { scene = null; }
  79661. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  79662. var closed = (options.closed === undefined) ? true : options.closed;
  79663. var shape = options.shape;
  79664. var radius = options.radius || 1;
  79665. var tessellation = options.tessellation || 64;
  79666. var clip = options.clip || 0;
  79667. var updatable = options.updatable;
  79668. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79669. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  79670. var pi2 = Math.PI * 2;
  79671. var paths = new Array();
  79672. var invertUV = options.invertUV || false;
  79673. var i = 0;
  79674. var p = 0;
  79675. var step = pi2 / tessellation * arc;
  79676. var rotated;
  79677. var path = new Array();
  79678. for (i = 0; i <= tessellation - clip; i++) {
  79679. var path = [];
  79680. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  79681. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[0].y, 0));
  79682. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](Math.cos(i * step) * shape[0].x * radius, shape[0].y, Math.sin(i * step) * shape[0].x * radius));
  79683. }
  79684. for (p = 0; p < shape.length; p++) {
  79685. rotated = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](Math.cos(i * step) * shape[p].x * radius, shape[p].y, Math.sin(i * step) * shape[p].x * radius);
  79686. path.push(rotated);
  79687. }
  79688. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  79689. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](Math.cos(i * step) * shape[shape.length - 1].x * radius, shape[shape.length - 1].y, Math.sin(i * step) * shape[shape.length - 1].x * radius));
  79690. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[shape.length - 1].y, 0));
  79691. }
  79692. paths.push(path);
  79693. }
  79694. // lathe ribbon
  79695. var lathe = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon(name, { pathArray: paths, closeArray: closed, sideOrientation: sideOrientation, updatable: updatable, invertUV: invertUV, frontUVs: options.frontUVs, backUVs: options.backUVs }, scene);
  79696. return lathe;
  79697. };
  79698. return LatheBuilder;
  79699. }());
  79700. /***/ }),
  79701. /***/ "./Meshes/Builders/linesBuilder.ts":
  79702. /*!*****************************************!*\
  79703. !*** ./Meshes/Builders/linesBuilder.ts ***!
  79704. \*****************************************/
  79705. /*! exports provided: LinesBuilder */
  79706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79707. "use strict";
  79708. __webpack_require__.r(__webpack_exports__);
  79709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return LinesBuilder; });
  79710. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79711. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79712. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79713. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  79714. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  79715. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem = function (options) {
  79716. var indices = [];
  79717. var positions = [];
  79718. var lines = options.lines;
  79719. var colors = options.colors;
  79720. var vertexColors = [];
  79721. var idx = 0;
  79722. for (var l = 0; l < lines.length; l++) {
  79723. var points = lines[l];
  79724. for (var index = 0; index < points.length; index++) {
  79725. positions.push(points[index].x, points[index].y, points[index].z);
  79726. if (colors) {
  79727. var color = colors[l];
  79728. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  79729. }
  79730. if (index > 0) {
  79731. indices.push(idx - 1);
  79732. indices.push(idx);
  79733. }
  79734. idx++;
  79735. }
  79736. }
  79737. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79738. vertexData.indices = indices;
  79739. vertexData.positions = positions;
  79740. if (colors) {
  79741. vertexData.colors = vertexColors;
  79742. }
  79743. return vertexData;
  79744. };
  79745. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines = function (options) {
  79746. var dashSize = options.dashSize || 3;
  79747. var gapSize = options.gapSize || 1;
  79748. var dashNb = options.dashNb || 200;
  79749. var points = options.points;
  79750. var positions = new Array();
  79751. var indices = new Array();
  79752. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79753. var lg = 0;
  79754. var nb = 0;
  79755. var shft = 0;
  79756. var dashshft = 0;
  79757. var curshft = 0;
  79758. var idx = 0;
  79759. var i = 0;
  79760. for (i = 0; i < points.length - 1; i++) {
  79761. points[i + 1].subtractToRef(points[i], curvect);
  79762. lg += curvect.length();
  79763. }
  79764. shft = lg / dashNb;
  79765. dashshft = dashSize * shft / (dashSize + gapSize);
  79766. for (i = 0; i < points.length - 1; i++) {
  79767. points[i + 1].subtractToRef(points[i], curvect);
  79768. nb = Math.floor(curvect.length() / shft);
  79769. curvect.normalize();
  79770. for (var j = 0; j < nb; j++) {
  79771. curshft = shft * j;
  79772. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  79773. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  79774. indices.push(idx, idx + 1);
  79775. idx += 2;
  79776. }
  79777. }
  79778. // Result
  79779. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79780. vertexData.positions = positions;
  79781. vertexData.indices = indices;
  79782. return vertexData;
  79783. };
  79784. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  79785. if (scene === void 0) { scene = null; }
  79786. if (updatable === void 0) { updatable = false; }
  79787. if (instance === void 0) { instance = null; }
  79788. var options = {
  79789. points: points,
  79790. updatable: updatable,
  79791. instance: instance
  79792. };
  79793. return LinesBuilder.CreateLines(name, options, scene);
  79794. };
  79795. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  79796. if (scene === void 0) { scene = null; }
  79797. var options = {
  79798. points: points,
  79799. dashSize: dashSize,
  79800. gapSize: gapSize,
  79801. dashNb: dashNb,
  79802. updatable: updatable,
  79803. instance: instance
  79804. };
  79805. return LinesBuilder.CreateDashedLines(name, options, scene);
  79806. };
  79807. /**
  79808. * Class containing static functions to help procedurally build meshes
  79809. */
  79810. var LinesBuilder = /** @class */ (function () {
  79811. function LinesBuilder() {
  79812. }
  79813. /**
  79814. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  79815. * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
  79816. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  79817. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  79818. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  79819. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  79820. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  79821. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  79822. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  79823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79824. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  79825. * @param name defines the name of the new line system
  79826. * @param options defines the options used to create the line system
  79827. * @param scene defines the hosting scene
  79828. * @returns a new line system mesh
  79829. */
  79830. LinesBuilder.CreateLineSystem = function (name, options, scene) {
  79831. var instance = options.instance;
  79832. var lines = options.lines;
  79833. var colors = options.colors;
  79834. if (instance) { // lines update
  79835. var positions = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  79836. var vertexColor;
  79837. var lineColors;
  79838. if (colors) {
  79839. vertexColor = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  79840. }
  79841. var i = 0;
  79842. var c = 0;
  79843. for (var l = 0; l < lines.length; l++) {
  79844. var points = lines[l];
  79845. for (var p = 0; p < points.length; p++) {
  79846. positions[i] = points[p].x;
  79847. positions[i + 1] = points[p].y;
  79848. positions[i + 2] = points[p].z;
  79849. if (colors && vertexColor) {
  79850. lineColors = colors[l];
  79851. vertexColor[c] = lineColors[p].r;
  79852. vertexColor[c + 1] = lineColors[p].g;
  79853. vertexColor[c + 2] = lineColors[p].b;
  79854. vertexColor[c + 3] = lineColors[p].a;
  79855. c += 4;
  79856. }
  79857. i += 3;
  79858. }
  79859. }
  79860. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  79861. if (colors && vertexColor) {
  79862. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  79863. }
  79864. return instance;
  79865. }
  79866. // line system creation
  79867. var useVertexColor = (colors) ? true : false;
  79868. var lineSystem = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  79869. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem(options);
  79870. vertexData.applyToMesh(lineSystem, options.updatable);
  79871. return lineSystem;
  79872. };
  79873. /**
  79874. * Creates a line mesh
  79875. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  79876. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  79877. * * The parameter `points` is an array successive Vector3
  79878. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  79879. * * The optional parameter `colors` is an array of successive Color4, one per line point
  79880. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  79881. * * When updating an instance, remember that only point positions can change, not the number of points
  79882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79883. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  79884. * @param name defines the name of the new line system
  79885. * @param options defines the options used to create the line system
  79886. * @param scene defines the hosting scene
  79887. * @returns a new line mesh
  79888. */
  79889. LinesBuilder.CreateLines = function (name, options, scene) {
  79890. if (scene === void 0) { scene = null; }
  79891. var colors = (options.colors) ? [options.colors] : null;
  79892. var lines = LinesBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  79893. return lines;
  79894. };
  79895. /**
  79896. * Creates a dashed line mesh
  79897. * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  79898. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  79899. * * The parameter `points` is an array successive Vector3
  79900. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  79901. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  79902. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  79903. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  79904. * * When updating an instance, remember that only point positions can change, not the number of points
  79905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79906. * @param name defines the name of the mesh
  79907. * @param options defines the options used to create the mesh
  79908. * @param scene defines the hosting scene
  79909. * @returns the dashed line mesh
  79910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  79911. */
  79912. LinesBuilder.CreateDashedLines = function (name, options, scene) {
  79913. if (scene === void 0) { scene = null; }
  79914. var points = options.points;
  79915. var instance = options.instance;
  79916. var gapSize = options.gapSize || 1;
  79917. var dashSize = options.dashSize || 3;
  79918. if (instance) { // dashed lines update
  79919. var positionFunction = function (positions) {
  79920. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79921. var nbSeg = positions.length / 6;
  79922. var lg = 0;
  79923. var nb = 0;
  79924. var shft = 0;
  79925. var dashshft = 0;
  79926. var curshft = 0;
  79927. var p = 0;
  79928. var i = 0;
  79929. var j = 0;
  79930. for (i = 0; i < points.length - 1; i++) {
  79931. points[i + 1].subtractToRef(points[i], curvect);
  79932. lg += curvect.length();
  79933. }
  79934. shft = lg / nbSeg;
  79935. var dashSize = instance._creationDataStorage.dashSize;
  79936. var gapSize = instance._creationDataStorage.gapSize;
  79937. dashshft = dashSize * shft / (dashSize + gapSize);
  79938. for (i = 0; i < points.length - 1; i++) {
  79939. points[i + 1].subtractToRef(points[i], curvect);
  79940. nb = Math.floor(curvect.length() / shft);
  79941. curvect.normalize();
  79942. j = 0;
  79943. while (j < nb && p < positions.length) {
  79944. curshft = shft * j;
  79945. positions[p] = points[i].x + curshft * curvect.x;
  79946. positions[p + 1] = points[i].y + curshft * curvect.y;
  79947. positions[p + 2] = points[i].z + curshft * curvect.z;
  79948. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  79949. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  79950. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  79951. p += 6;
  79952. j++;
  79953. }
  79954. }
  79955. while (p < positions.length) {
  79956. positions[p] = points[i].x;
  79957. positions[p + 1] = points[i].y;
  79958. positions[p + 2] = points[i].z;
  79959. p += 3;
  79960. }
  79961. };
  79962. instance.updateMeshPositions(positionFunction, false);
  79963. return instance;
  79964. }
  79965. // dashed lines creation
  79966. var dashedLines = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene);
  79967. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines(options);
  79968. vertexData.applyToMesh(dashedLines, options.updatable);
  79969. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  79970. dashedLines._creationDataStorage.dashSize = dashSize;
  79971. dashedLines._creationDataStorage.gapSize = gapSize;
  79972. return dashedLines;
  79973. };
  79974. return LinesBuilder;
  79975. }());
  79976. /***/ }),
  79977. /***/ "./Meshes/Builders/planeBuilder.ts":
  79978. /*!*****************************************!*\
  79979. !*** ./Meshes/Builders/planeBuilder.ts ***!
  79980. \*****************************************/
  79981. /*! exports provided: PlaneBuilder */
  79982. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79983. "use strict";
  79984. __webpack_require__.r(__webpack_exports__);
  79985. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return PlaneBuilder; });
  79986. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79987. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79988. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane = function (options) {
  79989. var indices = [];
  79990. var positions = [];
  79991. var normals = [];
  79992. var uvs = [];
  79993. var width = options.width || options.size || 1;
  79994. var height = options.height || options.size || 1;
  79995. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  79996. // Vertices
  79997. var halfWidth = width / 2.0;
  79998. var halfHeight = height / 2.0;
  79999. positions.push(-halfWidth, -halfHeight, 0);
  80000. normals.push(0, 0, -1.0);
  80001. uvs.push(0.0, 0.0);
  80002. positions.push(halfWidth, -halfHeight, 0);
  80003. normals.push(0, 0, -1.0);
  80004. uvs.push(1.0, 0.0);
  80005. positions.push(halfWidth, halfHeight, 0);
  80006. normals.push(0, 0, -1.0);
  80007. uvs.push(1.0, 1.0);
  80008. positions.push(-halfWidth, halfHeight, 0);
  80009. normals.push(0, 0, -1.0);
  80010. uvs.push(0.0, 1.0);
  80011. // Indices
  80012. indices.push(0);
  80013. indices.push(1);
  80014. indices.push(2);
  80015. indices.push(0);
  80016. indices.push(2);
  80017. indices.push(3);
  80018. // Sides
  80019. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80020. // Result
  80021. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  80022. vertexData.indices = indices;
  80023. vertexData.positions = positions;
  80024. vertexData.normals = normals;
  80025. vertexData.uvs = uvs;
  80026. return vertexData;
  80027. };
  80028. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  80029. var options = {
  80030. size: size,
  80031. width: size,
  80032. height: size,
  80033. sideOrientation: sideOrientation,
  80034. updatable: updatable
  80035. };
  80036. return PlaneBuilder.CreatePlane(name, options, scene);
  80037. };
  80038. /**
  80039. * Class containing static functions to help procedurally build meshes
  80040. */
  80041. var PlaneBuilder = /** @class */ (function () {
  80042. function PlaneBuilder() {
  80043. }
  80044. /**
  80045. * Creates a plane mesh
  80046. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  80047. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  80048. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  80049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80050. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  80051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80052. * @param name defines the name of the mesh
  80053. * @param options defines the options used to create the mesh
  80054. * @param scene defines the hosting scene
  80055. * @returns the plane mesh
  80056. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  80057. */
  80058. PlaneBuilder.CreatePlane = function (name, options, scene) {
  80059. if (scene === void 0) { scene = null; }
  80060. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  80061. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80062. plane._originalBuilderSideOrientation = options.sideOrientation;
  80063. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane(options);
  80064. vertexData.applyToMesh(plane, options.updatable);
  80065. if (options.sourcePlane) {
  80066. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  80067. plane.setDirection(options.sourcePlane.normal.scale(-1));
  80068. }
  80069. return plane;
  80070. };
  80071. return PlaneBuilder;
  80072. }());
  80073. /***/ }),
  80074. /***/ "./Meshes/Builders/polygonBuilder.ts":
  80075. /*!*******************************************!*\
  80076. !*** ./Meshes/Builders/polygonBuilder.ts ***!
  80077. \*******************************************/
  80078. /*! exports provided: PolygonBuilder */
  80079. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80080. "use strict";
  80081. __webpack_require__.r(__webpack_exports__);
  80082. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return PolygonBuilder; });
  80083. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80084. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80085. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80086. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
  80087. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  80088. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  80089. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  80090. var faceUV = fUV || new Array(3);
  80091. var faceColors = fColors;
  80092. var colors = [];
  80093. // default face colors and UV if undefined
  80094. for (var f = 0; f < 3; f++) {
  80095. if (faceUV[f] === undefined) {
  80096. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  80097. }
  80098. if (faceColors && faceColors[f] === undefined) {
  80099. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  80100. }
  80101. }
  80102. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  80103. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  80104. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  80105. var indices = polygon.getIndices();
  80106. // set face colours and textures
  80107. var idx = 0;
  80108. var face = 0;
  80109. for (var index = 0; index < normals.length; index += 3) {
  80110. //Edge Face no. 1
  80111. if (Math.abs(normals[index + 1]) < 0.001) {
  80112. face = 1;
  80113. }
  80114. //Top Face no. 0
  80115. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  80116. face = 0;
  80117. }
  80118. //Bottom Face no. 2
  80119. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  80120. face = 2;
  80121. }
  80122. idx = index / 3;
  80123. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  80124. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  80125. if (faceColors) {
  80126. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  80127. }
  80128. }
  80129. // sides
  80130. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  80131. // Result
  80132. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80133. vertexData.indices = indices;
  80134. vertexData.positions = positions;
  80135. vertexData.normals = normals;
  80136. vertexData.uvs = uvs;
  80137. if (faceColors) {
  80138. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  80139. vertexData.colors = totalColors;
  80140. }
  80141. return vertexData;
  80142. };
  80143. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  80144. if (earcutInjection === void 0) { earcutInjection = earcut; }
  80145. var options = {
  80146. shape: shape,
  80147. holes: holes,
  80148. updatable: updatable,
  80149. sideOrientation: sideOrientation
  80150. };
  80151. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  80152. };
  80153. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  80154. if (earcutInjection === void 0) { earcutInjection = earcut; }
  80155. var options = {
  80156. shape: shape,
  80157. holes: holes,
  80158. depth: depth,
  80159. updatable: updatable,
  80160. sideOrientation: sideOrientation
  80161. };
  80162. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  80163. };
  80164. /**
  80165. * Class containing static functions to help procedurally build meshes
  80166. */
  80167. var PolygonBuilder = /** @class */ (function () {
  80168. function PolygonBuilder() {
  80169. }
  80170. /**
  80171. * Creates a polygon mesh
  80172. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  80173. * * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  80174. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80176. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  80177. * * Remember you can only change the shape positions, not their number when updating a polygon
  80178. * @param name defines the name of the mesh
  80179. * @param options defines the options used to create the mesh
  80180. * @param scene defines the hosting scene
  80181. * @param earcutInjection can be used to inject your own earcut reference
  80182. * @returns the polygon mesh
  80183. */
  80184. PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  80185. if (scene === void 0) { scene = null; }
  80186. if (earcutInjection === void 0) { earcutInjection = earcut; }
  80187. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80188. var shape = options.shape;
  80189. var holes = options.holes || [];
  80190. var depth = options.depth || 0;
  80191. var contours = [];
  80192. var hole = [];
  80193. for (var i = 0; i < shape.length; i++) {
  80194. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](shape[i].x, shape[i].z);
  80195. }
  80196. var epsilon = 0.00000001;
  80197. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  80198. contours.pop();
  80199. }
  80200. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene, earcutInjection);
  80201. for (var hNb = 0; hNb < holes.length; hNb++) {
  80202. hole = [];
  80203. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  80204. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  80205. }
  80206. polygonTriangulation.addHole(hole);
  80207. }
  80208. var polygon = polygonTriangulation.build(options.updatable, depth);
  80209. polygon._originalBuilderSideOrientation = options.sideOrientation;
  80210. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  80211. vertexData.applyToMesh(polygon, options.updatable);
  80212. return polygon;
  80213. };
  80214. /**
  80215. * Creates an extruded polygon mesh, with depth in the Y direction.
  80216. * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
  80217. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  80218. * @param name defines the name of the mesh
  80219. * @param options defines the options used to create the mesh
  80220. * @param scene defines the hosting scene
  80221. * @param earcutInjection can be used to inject your own earcut reference
  80222. * @returns the polygon mesh
  80223. */
  80224. PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  80225. if (scene === void 0) { scene = null; }
  80226. if (earcutInjection === void 0) { earcutInjection = earcut; }
  80227. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  80228. };
  80229. return PolygonBuilder;
  80230. }());
  80231. /***/ }),
  80232. /***/ "./Meshes/Builders/polyhedronBuilder.ts":
  80233. /*!**********************************************!*\
  80234. !*** ./Meshes/Builders/polyhedronBuilder.ts ***!
  80235. \**********************************************/
  80236. /*! exports provided: PolyhedronBuilder */
  80237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80238. "use strict";
  80239. __webpack_require__.r(__webpack_exports__);
  80240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return PolyhedronBuilder; });
  80241. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80242. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80243. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80244. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron = function (options) {
  80245. // provided polyhedron types :
  80246. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  80247. // 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  80248. var polyhedra = [];
  80249. polyhedra[0] = { vertex: [[0, 0, 1.732051], [1.632993, 0, -0.5773503], [-0.8164966, 1.414214, -0.5773503], [-0.8164966, -1.414214, -0.5773503]], face: [[0, 1, 2], [0, 2, 3], [0, 3, 1], [1, 3, 2]] };
  80250. polyhedra[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]] };
  80251. polyhedra[2] = {
  80252. vertex: [[0, 0, 1.070466], [0.7136442, 0, 0.7978784], [-0.3568221, 0.618034, 0.7978784], [-0.3568221, -0.618034, 0.7978784], [0.7978784, 0.618034, 0.3568221], [0.7978784, -0.618034, 0.3568221], [-0.9341724, 0.381966, 0.3568221], [0.1362939, 1, 0.3568221], [0.1362939, -1, 0.3568221], [-0.9341724, -0.381966, 0.3568221], [0.9341724, 0.381966, -0.3568221], [0.9341724, -0.381966, -0.3568221], [-0.7978784, 0.618034, -0.3568221], [-0.1362939, 1, -0.3568221], [-0.1362939, -1, -0.3568221], [-0.7978784, -0.618034, -0.3568221], [0.3568221, 0.618034, -0.7978784], [0.3568221, -0.618034, -0.7978784], [-0.7136442, 0, -0.7978784], [0, 0, -1.070466]],
  80253. 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]]
  80254. };
  80255. polyhedra[3] = {
  80256. vertex: [[0, 0, 1.175571], [1.051462, 0, 0.5257311], [0.3249197, 1, 0.5257311], [-0.8506508, 0.618034, 0.5257311], [-0.8506508, -0.618034, 0.5257311], [0.3249197, -1, 0.5257311], [0.8506508, 0.618034, -0.5257311], [0.8506508, -0.618034, -0.5257311], [-0.3249197, 1, -0.5257311], [-1.051462, 0, -0.5257311], [-0.3249197, -1, -0.5257311], [0, 0, -1.175571]],
  80257. 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]]
  80258. };
  80259. polyhedra[4] = {
  80260. vertex: [[0, 0, 1.070722], [0.7148135, 0, 0.7971752], [-0.104682, 0.7071068, 0.7971752], [-0.6841528, 0.2071068, 0.7971752], [-0.104682, -0.7071068, 0.7971752], [0.6101315, 0.7071068, 0.5236279], [1.04156, 0.2071068, 0.1367736], [0.6101315, -0.7071068, 0.5236279], [-0.3574067, 1, 0.1367736], [-0.7888348, -0.5, 0.5236279], [-0.9368776, 0.5, 0.1367736], [-0.3574067, -1, 0.1367736], [0.3574067, 1, -0.1367736], [0.9368776, -0.5, -0.1367736], [0.7888348, 0.5, -0.5236279], [0.3574067, -1, -0.1367736], [-0.6101315, 0.7071068, -0.5236279], [-1.04156, -0.2071068, -0.1367736], [-0.6101315, -0.7071068, -0.5236279], [0.104682, 0.7071068, -0.7971752], [0.6841528, -0.2071068, -0.7971752], [0.104682, -0.7071068, -0.7971752], [-0.7148135, 0, -0.7971752], [0, 0, -1.070722]],
  80261. 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]]
  80262. };
  80263. polyhedra[5] = { vertex: [[0, 0, 1.322876], [1.309307, 0, 0.1889822], [-0.9819805, 0.8660254, 0.1889822], [0.1636634, -1.299038, 0.1889822], [0.3273268, 0.8660254, -0.9449112], [-0.8183171, -0.4330127, -0.9449112]], face: [[0, 3, 1], [2, 4, 5], [0, 1, 4, 2], [0, 2, 5, 3], [1, 3, 5, 4]] };
  80264. polyhedra[6] = { vertex: [[0, 0, 1.159953], [1.013464, 0, 0.5642542], [-0.3501431, 0.9510565, 0.5642542], [-0.7715208, -0.6571639, 0.5642542], [0.6633206, 0.9510565, -0.03144481], [0.8682979, -0.6571639, -0.3996071], [-1.121664, 0.2938926, -0.03144481], [-0.2348831, -1.063314, -0.3996071], [0.5181548, 0.2938926, -0.9953061], [-0.5850262, -0.112257, -0.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]] };
  80265. polyhedra[7] = { vertex: [[0, 0, 1.118034], [0.8944272, 0, 0.6708204], [-0.2236068, 0.8660254, 0.6708204], [-0.7826238, -0.4330127, 0.6708204], [0.6708204, 0.8660254, 0.2236068], [1.006231, -0.4330127, -0.2236068], [-1.006231, 0.4330127, 0.2236068], [-0.6708204, -0.8660254, -0.2236068], [0.7826238, 0.4330127, -0.6708204], [0.2236068, -0.8660254, -0.6708204], [-0.8944272, 0, -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]] };
  80266. polyhedra[8] = { vertex: [[-0.729665, 0.670121, 0.319155], [-0.655235, -0.29213, -0.754096], [-0.093922, -0.607123, 0.537818], [0.702196, 0.595691, 0.485187], [0.776626, -0.36656, -0.588064]], face: [[1, 4, 2], [0, 1, 2], [3, 0, 2], [4, 3, 2], [4, 1, 0, 3]] };
  80267. polyhedra[9] = { vertex: [[-0.868849, -0.100041, 0.61257], [-0.329458, 0.976099, 0.28078], [-0.26629, -0.013796, -0.477654], [-0.13392, -1.034115, 0.229829], [0.738834, 0.707117, -0.307018], [0.859683, -0.535264, -0.338508]], face: [[3, 0, 2], [5, 3, 2], [4, 5, 2], [1, 4, 2], [0, 1, 2], [0, 3, 5, 4, 1]] };
  80268. polyhedra[10] = { vertex: [[-0.610389, 0.243975, 0.531213], [-0.187812, -0.48795, -0.664016], [-0.187812, 0.9759, -0.664016], [0.187812, -0.9759, 0.664016], [0.798201, 0.243975, 0.132803]], face: [[1, 3, 0], [3, 4, 0], [3, 1, 4], [0, 2, 1], [0, 4, 2], [2, 4, 1]] };
  80269. polyhedra[11] = { vertex: [[-1.028778, 0.392027, -0.048786], [-0.640503, -0.646161, 0.621837], [-0.125162, -0.395663, -0.540059], [0.004683, 0.888447, -0.651988], [0.125161, 0.395663, 0.540059], [0.632925, -0.791376, 0.433102], [1.031672, 0.157063, -0.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]] };
  80270. polyhedra[12] = { vertex: [[-0.669867, 0.334933, -0.529576], [-0.669867, 0.334933, 0.529577], [-0.4043, 1.212901, 0], [-0.334933, -0.669867, -0.529576], [-0.334933, -0.669867, 0.529577], [0.334933, 0.669867, -0.529576], [0.334933, 0.669867, 0.529577], [0.4043, -1.212901, 0], [0.669867, -0.334933, -0.529576], [0.669867, -0.334933, 0.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]] };
  80271. polyhedra[13] = { vertex: [[-0.931836, 0.219976, -0.264632], [-0.636706, 0.318353, 0.692816], [-0.613483, -0.735083, -0.264632], [-0.326545, 0.979634, 0], [-0.318353, -0.636706, 0.692816], [-0.159176, 0.477529, -0.856368], [0.159176, -0.477529, -0.856368], [0.318353, 0.636706, 0.692816], [0.326545, -0.979634, 0], [0.613482, 0.735082, -0.264632], [0.636706, -0.318353, 0.692816], [0.931835, -0.219977, -0.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]] };
  80272. polyhedra[14] = {
  80273. vertex: [[-0.93465, 0.300459, -0.271185], [-0.838689, -0.260219, -0.516017], [-0.711319, 0.717591, 0.128359], [-0.710334, -0.156922, 0.080946], [-0.599799, 0.556003, -0.725148], [-0.503838, -0.004675, -0.969981], [-0.487004, 0.26021, 0.48049], [-0.460089, -0.750282, -0.512622], [-0.376468, 0.973135, -0.325605], [-0.331735, -0.646985, 0.084342], [-0.254001, 0.831847, 0.530001], [-0.125239, -0.494738, -0.966586], [0.029622, 0.027949, 0.730817], [0.056536, -0.982543, -0.262295], [0.08085, 1.087391, 0.076037], [0.125583, -0.532729, 0.485984], [0.262625, 0.599586, 0.780328], [0.391387, -0.726999, -0.716259], [0.513854, -0.868287, 0.139347], [0.597475, 0.85513, 0.326364], [0.641224, 0.109523, 0.783723], [0.737185, -0.451155, 0.538891], [0.848705, -0.612742, -0.314616], [0.976075, 0.365067, 0.32976], [1.072036, -0.19561, 0.084927]],
  80274. 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]]
  80275. };
  80276. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  80277. var size = options.size;
  80278. var sizeX = options.sizeX || size || 1;
  80279. var sizeY = options.sizeY || size || 1;
  80280. var sizeZ = options.sizeZ || size || 1;
  80281. var data = options.custom || polyhedra[type];
  80282. var nbfaces = data.face.length;
  80283. var faceUV = options.faceUV || new Array(nbfaces);
  80284. var faceColors = options.faceColors;
  80285. var flat = (options.flat === undefined) ? true : options.flat;
  80286. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  80287. var positions = new Array();
  80288. var indices = new Array();
  80289. var normals = new Array();
  80290. var uvs = new Array();
  80291. var colors = new Array();
  80292. var index = 0;
  80293. var faceIdx = 0; // face cursor in the array "indexes"
  80294. var indexes = new Array();
  80295. var i = 0;
  80296. var f = 0;
  80297. var u, v, ang, x, y, tmp;
  80298. // default face colors and UV if undefined
  80299. if (flat) {
  80300. for (f = 0; f < nbfaces; f++) {
  80301. if (faceColors && faceColors[f] === undefined) {
  80302. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  80303. }
  80304. if (faceUV && faceUV[f] === undefined) {
  80305. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  80306. }
  80307. }
  80308. }
  80309. if (!flat) {
  80310. for (i = 0; i < data.vertex.length; i++) {
  80311. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  80312. uvs.push(0, 0);
  80313. }
  80314. for (f = 0; f < nbfaces; f++) {
  80315. for (i = 0; i < data.face[f].length - 2; i++) {
  80316. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  80317. }
  80318. }
  80319. }
  80320. else {
  80321. for (f = 0; f < nbfaces; f++) {
  80322. var fl = data.face[f].length; // number of vertices of the current face
  80323. ang = 2 * Math.PI / fl;
  80324. x = 0.5 * Math.tan(ang / 2);
  80325. y = 0.5;
  80326. // positions, uvs, colors
  80327. for (i = 0; i < fl; i++) {
  80328. // positions
  80329. positions.push(data.vertex[data.face[f][i]][0] * sizeX, data.vertex[data.face[f][i]][1] * sizeY, data.vertex[data.face[f][i]][2] * sizeZ);
  80330. indexes.push(index);
  80331. index++;
  80332. // uvs
  80333. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  80334. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  80335. uvs.push(u, v);
  80336. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  80337. y = x * Math.sin(ang) + y * Math.cos(ang);
  80338. x = tmp;
  80339. // colors
  80340. if (faceColors) {
  80341. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  80342. }
  80343. }
  80344. // indices from indexes
  80345. for (i = 0; i < fl - 2; i++) {
  80346. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  80347. }
  80348. faceIdx += fl;
  80349. }
  80350. }
  80351. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  80352. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80353. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80354. vertexData.positions = positions;
  80355. vertexData.indices = indices;
  80356. vertexData.normals = normals;
  80357. vertexData.uvs = uvs;
  80358. if (faceColors && flat) {
  80359. vertexData.colors = colors;
  80360. }
  80361. return vertexData;
  80362. };
  80363. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  80364. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  80365. };
  80366. /**
  80367. * Class containing static functions to help procedurally build meshes
  80368. */
  80369. var PolyhedronBuilder = /** @class */ (function () {
  80370. function PolyhedronBuilder() {
  80371. }
  80372. /**
  80373. * Creates a polyhedron mesh
  80374. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  80375. * * The parameter `size` (positive float, default 1) sets the polygon size
  80376. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  80377. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  80378. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  80379. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  80380. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  80381. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  80382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  80384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80385. * @param name defines the name of the mesh
  80386. * @param options defines the options used to create the mesh
  80387. * @param scene defines the hosting scene
  80388. * @returns the polyhedron mesh
  80389. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  80390. */
  80391. PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
  80392. if (scene === void 0) { scene = null; }
  80393. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  80394. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80395. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  80396. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron(options);
  80397. vertexData.applyToMesh(polyhedron, options.updatable);
  80398. return polyhedron;
  80399. };
  80400. return PolyhedronBuilder;
  80401. }());
  80402. /***/ }),
  80403. /***/ "./Meshes/Builders/ribbonBuilder.ts":
  80404. /*!******************************************!*\
  80405. !*** ./Meshes/Builders/ribbonBuilder.ts ***!
  80406. \******************************************/
  80407. /*! exports provided: RibbonBuilder */
  80408. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80409. "use strict";
  80410. __webpack_require__.r(__webpack_exports__);
  80411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return RibbonBuilder; });
  80412. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80413. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80414. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  80415. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80416. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  80417. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon = function (options) {
  80418. var pathArray = options.pathArray;
  80419. var closeArray = options.closeArray || false;
  80420. var closePath = options.closePath || false;
  80421. var invertUV = options.invertUV || false;
  80422. var defaultOffset = Math.floor(pathArray[0].length / 2);
  80423. var offset = options.offset || defaultOffset;
  80424. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  80425. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  80426. var customUV = options.uvs;
  80427. var customColors = options.colors;
  80428. var positions = [];
  80429. var indices = [];
  80430. var normals = [];
  80431. var uvs = [];
  80432. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  80433. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  80434. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  80435. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  80436. var minlg; // minimal length among all paths from pathArray
  80437. var lg = []; // array of path lengths : nb of vertex per path
  80438. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  80439. var p; // path iterator
  80440. var i; // point iterator
  80441. var j; // point iterator
  80442. // if single path in pathArray
  80443. if (pathArray.length < 2) {
  80444. var ar1 = [];
  80445. var ar2 = [];
  80446. for (i = 0; i < pathArray[0].length - offset; i++) {
  80447. ar1.push(pathArray[0][i]);
  80448. ar2.push(pathArray[0][i + offset]);
  80449. }
  80450. pathArray = [ar1, ar2];
  80451. }
  80452. // positions and horizontal distances (u)
  80453. var idc = 0;
  80454. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  80455. var path;
  80456. var l;
  80457. minlg = pathArray[0].length;
  80458. var vectlg;
  80459. var dist;
  80460. for (p = 0; p < pathArray.length; p++) {
  80461. uTotalDistance[p] = 0;
  80462. us[p] = [0];
  80463. path = pathArray[p];
  80464. l = path.length;
  80465. minlg = (minlg < l) ? minlg : l;
  80466. j = 0;
  80467. while (j < l) {
  80468. positions.push(path[j].x, path[j].y, path[j].z);
  80469. if (j > 0) {
  80470. vectlg = path[j].subtract(path[j - 1]).length();
  80471. dist = vectlg + uTotalDistance[p];
  80472. us[p].push(dist);
  80473. uTotalDistance[p] = dist;
  80474. }
  80475. j++;
  80476. }
  80477. if (closePath) { // an extra hidden vertex is added in the "positions" array
  80478. j--;
  80479. positions.push(path[0].x, path[0].y, path[0].z);
  80480. vectlg = path[j].subtract(path[0]).length();
  80481. dist = vectlg + uTotalDistance[p];
  80482. us[p].push(dist);
  80483. uTotalDistance[p] = dist;
  80484. }
  80485. lg[p] = l + closePathCorr;
  80486. idx[p] = idc;
  80487. idc += (l + closePathCorr);
  80488. }
  80489. // vertical distances (v)
  80490. var path1;
  80491. var path2;
  80492. var vertex1 = null;
  80493. var vertex2 = null;
  80494. for (i = 0; i < minlg + closePathCorr; i++) {
  80495. vTotalDistance[i] = 0;
  80496. vs[i] = [0];
  80497. for (p = 0; p < pathArray.length - 1; p++) {
  80498. path1 = pathArray[p];
  80499. path2 = pathArray[p + 1];
  80500. if (i === minlg) { // closePath
  80501. vertex1 = path1[0];
  80502. vertex2 = path2[0];
  80503. }
  80504. else {
  80505. vertex1 = path1[i];
  80506. vertex2 = path2[i];
  80507. }
  80508. vectlg = vertex2.subtract(vertex1).length();
  80509. dist = vectlg + vTotalDistance[i];
  80510. vs[i].push(dist);
  80511. vTotalDistance[i] = dist;
  80512. }
  80513. if (closeArray && vertex2 && vertex1) {
  80514. path1 = pathArray[p];
  80515. path2 = pathArray[0];
  80516. if (i === minlg) { // closePath
  80517. vertex2 = path2[0];
  80518. }
  80519. vectlg = vertex2.subtract(vertex1).length();
  80520. dist = vectlg + vTotalDistance[i];
  80521. vTotalDistance[i] = dist;
  80522. }
  80523. }
  80524. // uvs
  80525. var u;
  80526. var v;
  80527. if (customUV) {
  80528. for (p = 0; p < customUV.length; p++) {
  80529. uvs.push(customUV[p].x, customUV[p].y);
  80530. }
  80531. }
  80532. else {
  80533. for (p = 0; p < pathArray.length; p++) {
  80534. for (i = 0; i < minlg + closePathCorr; i++) {
  80535. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  80536. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  80537. if (invertUV) {
  80538. uvs.push(v, u);
  80539. }
  80540. else {
  80541. uvs.push(u, v);
  80542. }
  80543. }
  80544. }
  80545. }
  80546. // indices
  80547. p = 0; // path index
  80548. var pi = 0; // positions array index
  80549. var l1 = lg[p] - 1; // path1 length
  80550. var l2 = lg[p + 1] - 1; // path2 length
  80551. var min = (l1 < l2) ? l1 : l2; // current path stop index
  80552. var shft = idx[1] - idx[0]; // shift
  80553. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  80554. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  80555. // draw two triangles between path1 (p1) and path2 (p2) : (p1.pi, p2.pi, p1.pi+1) and (p2.pi+1, p1.pi+1, p2.pi) clockwise
  80556. indices.push(pi, pi + shft, pi + 1);
  80557. indices.push(pi + shft + 1, pi + 1, pi + shft);
  80558. pi += 1;
  80559. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  80560. p++;
  80561. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  80562. shft = idx[0] - idx[p];
  80563. l1 = lg[p] - 1;
  80564. l2 = lg[0] - 1;
  80565. }
  80566. else {
  80567. shft = idx[p + 1] - idx[p];
  80568. l1 = lg[p] - 1;
  80569. l2 = lg[p + 1] - 1;
  80570. }
  80571. pi = idx[p];
  80572. min = (l1 < l2) ? l1 + pi : l2 + pi;
  80573. }
  80574. }
  80575. // normals
  80576. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  80577. if (closePath) { // update both the first and last vertex normals to their average value
  80578. var indexFirst = 0;
  80579. var indexLast = 0;
  80580. for (p = 0; p < pathArray.length; p++) {
  80581. indexFirst = idx[p] * 3;
  80582. if (p + 1 < pathArray.length) {
  80583. indexLast = (idx[p + 1] - 1) * 3;
  80584. }
  80585. else {
  80586. indexLast = normals.length - 3;
  80587. }
  80588. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  80589. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  80590. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  80591. normals[indexLast] = normals[indexFirst];
  80592. normals[indexLast + 1] = normals[indexFirst + 1];
  80593. normals[indexLast + 2] = normals[indexFirst + 2];
  80594. }
  80595. }
  80596. // sides
  80597. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80598. // Colors
  80599. var colors = null;
  80600. if (customColors) {
  80601. colors = new Float32Array(customColors.length * 4);
  80602. for (var c = 0; c < customColors.length; c++) {
  80603. colors[c * 4] = customColors[c].r;
  80604. colors[c * 4 + 1] = customColors[c].g;
  80605. colors[c * 4 + 2] = customColors[c].b;
  80606. colors[c * 4 + 3] = customColors[c].a;
  80607. }
  80608. }
  80609. // Result
  80610. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  80611. var positions32 = new Float32Array(positions);
  80612. var normals32 = new Float32Array(normals);
  80613. var uvs32 = new Float32Array(uvs);
  80614. vertexData.indices = indices;
  80615. vertexData.positions = positions32;
  80616. vertexData.normals = normals32;
  80617. vertexData.uvs = uvs32;
  80618. if (colors) {
  80619. vertexData.set(colors, _buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  80620. }
  80621. if (closePath) {
  80622. vertexData._idx = idx;
  80623. }
  80624. return vertexData;
  80625. };
  80626. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  80627. if (closeArray === void 0) { closeArray = false; }
  80628. if (updatable === void 0) { updatable = false; }
  80629. return RibbonBuilder.CreateRibbon(name, {
  80630. pathArray: pathArray,
  80631. closeArray: closeArray,
  80632. closePath: closePath,
  80633. offset: offset,
  80634. updatable: updatable,
  80635. sideOrientation: sideOrientation,
  80636. instance: instance
  80637. }, scene);
  80638. };
  80639. /**
  80640. * Class containing static functions to help procedurally build meshes
  80641. */
  80642. var RibbonBuilder = /** @class */ (function () {
  80643. function RibbonBuilder() {
  80644. }
  80645. /**
  80646. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  80647. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  80648. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  80649. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  80650. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  80651. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  80652. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  80653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80654. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  80655. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  80656. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  80657. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  80658. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  80659. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  80660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80661. * @param name defines the name of the mesh
  80662. * @param options defines the options used to create the mesh
  80663. * @param scene defines the hosting scene
  80664. * @returns the ribbon mesh
  80665. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  80666. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  80667. */
  80668. RibbonBuilder.CreateRibbon = function (name, options, scene) {
  80669. if (scene === void 0) { scene = null; }
  80670. var pathArray = options.pathArray;
  80671. var closeArray = options.closeArray;
  80672. var closePath = options.closePath;
  80673. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80674. var instance = options.instance;
  80675. var updatable = options.updatable;
  80676. if (instance) { // existing ribbon instance update
  80677. // positionFunction : ribbon case
  80678. // only pathArray and sideOrientation parameters are taken into account for positions update
  80679. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  80680. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  80681. var positionFunction = function (positions) {
  80682. var minlg = pathArray[0].length;
  80683. var mesh = instance;
  80684. var i = 0;
  80685. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE) ? 2 : 1;
  80686. for (var si = 1; si <= ns; ++si) {
  80687. for (var p = 0; p < pathArray.length; ++p) {
  80688. var path = pathArray[p];
  80689. var l = path.length;
  80690. minlg = (minlg < l) ? minlg : l;
  80691. for (var j = 0; j < minlg; ++j) {
  80692. var pathPoint = path[j];
  80693. positions[i] = pathPoint.x;
  80694. positions[i + 1] = pathPoint.y;
  80695. positions[i + 2] = pathPoint.z;
  80696. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  80697. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  80698. i += 3;
  80699. }
  80700. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  80701. var pathPoint = path[0];
  80702. positions[i] = pathPoint.x;
  80703. positions[i + 1] = pathPoint.y;
  80704. positions[i + 2] = pathPoint.z;
  80705. i += 3;
  80706. }
  80707. }
  80708. }
  80709. };
  80710. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  80711. positionFunction(positions);
  80712. if (instance._boundingInfo) {
  80713. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  80714. }
  80715. else {
  80716. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  80717. }
  80718. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions, false, false);
  80719. if (options.colors) {
  80720. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  80721. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  80722. var color = options.colors[c];
  80723. colors[colorIndex] = color.r;
  80724. colors[colorIndex + 1] = color.g;
  80725. colors[colorIndex + 2] = color.b;
  80726. colors[colorIndex + 3] = color.a;
  80727. }
  80728. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors, false, false);
  80729. }
  80730. if (options.uvs) {
  80731. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  80732. for (var i = 0; i < options.uvs.length; i++) {
  80733. uvs[i * 2] = options.uvs[i].x;
  80734. uvs[i * 2 + 1] = options.uvs[i].y;
  80735. }
  80736. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs, false, false);
  80737. }
  80738. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  80739. var indices = instance.getIndices();
  80740. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  80741. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  80742. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals, params);
  80743. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  80744. var indexFirst = 0;
  80745. var indexLast = 0;
  80746. for (var p = 0; p < pathArray.length; p++) {
  80747. indexFirst = instance._creationDataStorage.idx[p] * 3;
  80748. if (p + 1 < pathArray.length) {
  80749. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  80750. }
  80751. else {
  80752. indexLast = normals.length - 3;
  80753. }
  80754. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  80755. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  80756. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  80757. normals[indexLast] = normals[indexFirst];
  80758. normals[indexLast + 1] = normals[indexFirst + 1];
  80759. normals[indexLast + 2] = normals[indexFirst + 2];
  80760. }
  80761. }
  80762. if (!(instance.areNormalsFrozen)) {
  80763. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals, false, false);
  80764. }
  80765. }
  80766. return instance;
  80767. }
  80768. else { // new ribbon creation
  80769. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  80770. ribbon._originalBuilderSideOrientation = sideOrientation;
  80771. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  80772. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon(options);
  80773. if (closePath) {
  80774. ribbon._creationDataStorage.idx = vertexData._idx;
  80775. }
  80776. ribbon._creationDataStorage.closePath = closePath;
  80777. ribbon._creationDataStorage.closeArray = closeArray;
  80778. vertexData.applyToMesh(ribbon, updatable);
  80779. return ribbon;
  80780. }
  80781. };
  80782. return RibbonBuilder;
  80783. }());
  80784. /***/ }),
  80785. /***/ "./Meshes/Builders/shapeBuilder.ts":
  80786. /*!*****************************************!*\
  80787. !*** ./Meshes/Builders/shapeBuilder.ts ***!
  80788. \*****************************************/
  80789. /*! exports provided: ShapeBuilder */
  80790. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80791. "use strict";
  80792. __webpack_require__.r(__webpack_exports__);
  80793. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return ShapeBuilder; });
  80794. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80795. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80796. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  80797. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  80798. if (scene === void 0) { scene = null; }
  80799. var options = {
  80800. shape: shape,
  80801. path: path,
  80802. scale: scale,
  80803. rotation: rotation,
  80804. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  80805. sideOrientation: sideOrientation,
  80806. instance: instance,
  80807. updatable: updatable
  80808. };
  80809. return ShapeBuilder.ExtrudeShape(name, options, scene);
  80810. };
  80811. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  80812. var options = {
  80813. shape: shape,
  80814. path: path,
  80815. scaleFunction: scaleFunction,
  80816. rotationFunction: rotationFunction,
  80817. ribbonCloseArray: ribbonCloseArray,
  80818. ribbonClosePath: ribbonClosePath,
  80819. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  80820. sideOrientation: sideOrientation,
  80821. instance: instance,
  80822. updatable: updatable
  80823. };
  80824. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  80825. };
  80826. /**
  80827. * Class containing static functions to help procedurally build meshes
  80828. */
  80829. var ShapeBuilder = /** @class */ (function () {
  80830. function ShapeBuilder() {
  80831. }
  80832. /**
  80833. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  80834. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  80835. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  80836. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  80837. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  80838. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  80839. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  80840. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  80841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  80843. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  80844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80845. * @param name defines the name of the mesh
  80846. * @param options defines the options used to create the mesh
  80847. * @param scene defines the hosting scene
  80848. * @returns the extruded shape mesh
  80849. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  80850. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80851. */
  80852. ShapeBuilder.ExtrudeShape = function (name, options, scene) {
  80853. if (scene === void 0) { scene = null; }
  80854. var path = options.path;
  80855. var shape = options.shape;
  80856. var scale = options.scale || 1;
  80857. var rotation = options.rotation || 0;
  80858. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  80859. var updatable = options.updatable;
  80860. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80861. var instance = options.instance || null;
  80862. var invertUV = options.invertUV || false;
  80863. return ShapeBuilder._ExtrudeShapeGeneric(name, shape, path, scale, rotation, null, null, false, false, cap, false, scene, updatable ? true : false, sideOrientation, instance, invertUV, options.frontUVs || null, options.backUVs || null);
  80864. };
  80865. /**
  80866. * Creates an custom extruded shape mesh.
  80867. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  80868. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  80869. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  80870. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  80871. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  80872. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  80873. * * It must returns a float value that will be the scale value applied to the shape on each path point
  80874. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  80875. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  80876. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  80877. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  80878. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  80879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  80881. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  80882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80883. * @param name defines the name of the mesh
  80884. * @param options defines the options used to create the mesh
  80885. * @param scene defines the hosting scene
  80886. * @returns the custom extruded shape mesh
  80887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  80888. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  80889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80890. */
  80891. ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  80892. if (scene === void 0) { scene = null; }
  80893. var path = options.path;
  80894. var shape = options.shape;
  80895. var scaleFunction = options.scaleFunction || (function () { return 1; });
  80896. var rotationFunction = options.rotationFunction || (function () { return 0; });
  80897. var ribbonCloseArray = options.ribbonCloseArray || false;
  80898. var ribbonClosePath = options.ribbonClosePath || false;
  80899. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  80900. var updatable = options.updatable;
  80901. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80902. var instance = options.instance;
  80903. var invertUV = options.invertUV || false;
  80904. return ShapeBuilder._ExtrudeShapeGeneric(name, shape, path, null, null, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, true, scene, updatable ? true : false, sideOrientation, instance || null, invertUV, options.frontUVs || null, options.backUVs || null);
  80905. };
  80906. ShapeBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  80907. // extrusion geometry
  80908. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  80909. var tangents = path3D.getTangents();
  80910. var normals = path3D.getNormals();
  80911. var binormals = path3D.getBinormals();
  80912. var distances = path3D.getDistances();
  80913. var angle = 0;
  80914. var returnScale = function () { return scale !== null ? scale : 1; };
  80915. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  80916. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  80917. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  80918. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  80919. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  80920. for (var i = 0; i < curve.length; i++) {
  80921. var shapePath = new Array();
  80922. var angleStep = rotate(i, distances[i]);
  80923. var scaleRatio = scl(i, distances[i]);
  80924. for (var p = 0; p < shape.length; p++) {
  80925. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  80926. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  80927. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80928. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  80929. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  80930. shapePath[p] = rotated;
  80931. }
  80932. shapePaths[index] = shapePath;
  80933. angle += angleStep;
  80934. index++;
  80935. }
  80936. // cap
  80937. var capPath = function (shapePath) {
  80938. var pointCap = Array();
  80939. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80940. var i;
  80941. for (i = 0; i < shapePath.length; i++) {
  80942. barycenter.addInPlace(shapePath[i]);
  80943. }
  80944. barycenter.scaleInPlace(1.0 / shapePath.length);
  80945. for (i = 0; i < shapePath.length; i++) {
  80946. pointCap.push(barycenter);
  80947. }
  80948. return pointCap;
  80949. };
  80950. switch (cap) {
  80951. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  80952. break;
  80953. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  80954. shapePaths[0] = capPath(shapePaths[2]);
  80955. shapePaths[1] = shapePaths[2];
  80956. break;
  80957. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  80958. shapePaths[index] = shapePaths[index - 1];
  80959. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  80960. break;
  80961. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  80962. shapePaths[0] = capPath(shapePaths[2]);
  80963. shapePaths[1] = shapePaths[2];
  80964. shapePaths[index] = shapePaths[index - 1];
  80965. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  80966. break;
  80967. default:
  80968. break;
  80969. }
  80970. return shapePaths;
  80971. };
  80972. var path3D;
  80973. var pathArray;
  80974. if (instance) { // instance update
  80975. var storage = instance._creationDataStorage;
  80976. path3D = storage.path3D.update(curve);
  80977. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  80978. instance = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  80979. return instance;
  80980. }
  80981. // extruded shape creation
  80982. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](curve);
  80983. var newShapePaths = new Array();
  80984. cap = (cap < 0 || cap > 3) ? 0 : cap;
  80985. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  80986. var extrudedGeneric = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon(name, { pathArray: pathArray, closeArray: rbCA, closePath: rbCP, updatable: updtbl, sideOrientation: side, invertUV: invertUV, frontUVs: frontUVs || undefined, backUVs: backUVs || undefined }, scene);
  80987. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  80988. extrudedGeneric._creationDataStorage.path3D = path3D;
  80989. extrudedGeneric._creationDataStorage.cap = cap;
  80990. return extrudedGeneric;
  80991. };
  80992. return ShapeBuilder;
  80993. }());
  80994. /***/ }),
  80995. /***/ "./Meshes/Builders/sphereBuilder.ts":
  80996. /*!******************************************!*\
  80997. !*** ./Meshes/Builders/sphereBuilder.ts ***!
  80998. \******************************************/
  80999. /*! exports provided: SphereBuilder */
  81000. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81001. "use strict";
  81002. __webpack_require__.r(__webpack_exports__);
  81003. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return SphereBuilder; });
  81004. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  81005. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81006. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81007. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere = function (options) {
  81008. var segments = options.segments || 32;
  81009. var diameterX = options.diameterX || options.diameter || 1;
  81010. var diameterY = options.diameterY || options.diameter || 1;
  81011. var diameterZ = options.diameterZ || options.diameter || 1;
  81012. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  81013. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  81014. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  81015. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  81016. var totalZRotationSteps = 2 + segments;
  81017. var totalYRotationSteps = 2 * totalZRotationSteps;
  81018. var indices = [];
  81019. var positions = [];
  81020. var normals = [];
  81021. var uvs = [];
  81022. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  81023. var normalizedZ = zRotationStep / totalZRotationSteps;
  81024. var angleZ = normalizedZ * Math.PI * slice;
  81025. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  81026. var normalizedY = yRotationStep / totalYRotationSteps;
  81027. var angleY = normalizedY * Math.PI * 2 * arc;
  81028. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  81029. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  81030. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  81031. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  81032. var vertex = complete.multiply(radius);
  81033. var normal = complete.divide(radius).normalize();
  81034. positions.push(vertex.x, vertex.y, vertex.z);
  81035. normals.push(normal.x, normal.y, normal.z);
  81036. uvs.push(normalizedY, normalizedZ);
  81037. }
  81038. if (zRotationStep > 0) {
  81039. var verticesCount = positions.length / 3;
  81040. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  81041. indices.push((firstIndex));
  81042. indices.push((firstIndex + 1));
  81043. indices.push(firstIndex + totalYRotationSteps + 1);
  81044. indices.push((firstIndex + totalYRotationSteps + 1));
  81045. indices.push((firstIndex + 1));
  81046. indices.push((firstIndex + totalYRotationSteps + 2));
  81047. }
  81048. }
  81049. }
  81050. // Sides
  81051. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  81052. // Result
  81053. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  81054. vertexData.indices = indices;
  81055. vertexData.positions = positions;
  81056. vertexData.normals = normals;
  81057. vertexData.uvs = uvs;
  81058. return vertexData;
  81059. };
  81060. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  81061. var options = {
  81062. segments: segments,
  81063. diameterX: diameter,
  81064. diameterY: diameter,
  81065. diameterZ: diameter,
  81066. sideOrientation: sideOrientation,
  81067. updatable: updatable
  81068. };
  81069. return SphereBuilder.CreateSphere(name, options, scene);
  81070. };
  81071. /**
  81072. * Class containing static functions to help procedurally build meshes
  81073. */
  81074. var SphereBuilder = /** @class */ (function () {
  81075. function SphereBuilder() {
  81076. }
  81077. /**
  81078. * Creates a sphere mesh
  81079. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  81080. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  81081. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  81082. * * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  81083. * * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude)
  81084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  81086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81087. * @param name defines the name of the mesh
  81088. * @param options defines the options used to create the mesh
  81089. * @param scene defines the hosting scene
  81090. * @returns the sphere mesh
  81091. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  81092. */
  81093. SphereBuilder.CreateSphere = function (name, options, scene) {
  81094. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  81095. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81096. sphere._originalBuilderSideOrientation = options.sideOrientation;
  81097. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere(options);
  81098. vertexData.applyToMesh(sphere, options.updatable);
  81099. return sphere;
  81100. };
  81101. return SphereBuilder;
  81102. }());
  81103. /***/ }),
  81104. /***/ "./Meshes/Builders/torusBuilder.ts":
  81105. /*!*****************************************!*\
  81106. !*** ./Meshes/Builders/torusBuilder.ts ***!
  81107. \*****************************************/
  81108. /*! exports provided: TorusBuilder */
  81109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81110. "use strict";
  81111. __webpack_require__.r(__webpack_exports__);
  81112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return TorusBuilder; });
  81113. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  81114. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81115. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81116. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus = function (options) {
  81117. var indices = [];
  81118. var positions = [];
  81119. var normals = [];
  81120. var uvs = [];
  81121. var diameter = options.diameter || 1;
  81122. var thickness = options.thickness || 0.5;
  81123. var tessellation = options.tessellation || 16;
  81124. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  81125. var stride = tessellation + 1;
  81126. for (var i = 0; i <= tessellation; i++) {
  81127. var u = i / tessellation;
  81128. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  81129. var transform = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(diameter / 2.0, 0, 0).multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(outerAngle));
  81130. for (var j = 0; j <= tessellation; j++) {
  81131. var v = 1 - j / tessellation;
  81132. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  81133. var dx = Math.cos(innerAngle);
  81134. var dy = Math.sin(innerAngle);
  81135. // Create a vertex.
  81136. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  81137. var position = normal.scale(thickness / 2);
  81138. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  81139. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  81140. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  81141. positions.push(position.x, position.y, position.z);
  81142. normals.push(normal.x, normal.y, normal.z);
  81143. uvs.push(textureCoordinate.x, textureCoordinate.y);
  81144. // And create indices for two triangles.
  81145. var nextI = (i + 1) % stride;
  81146. var nextJ = (j + 1) % stride;
  81147. indices.push(i * stride + j);
  81148. indices.push(i * stride + nextJ);
  81149. indices.push(nextI * stride + j);
  81150. indices.push(i * stride + nextJ);
  81151. indices.push(nextI * stride + nextJ);
  81152. indices.push(nextI * stride + j);
  81153. }
  81154. }
  81155. // Sides
  81156. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  81157. // Result
  81158. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  81159. vertexData.indices = indices;
  81160. vertexData.positions = positions;
  81161. vertexData.normals = normals;
  81162. vertexData.uvs = uvs;
  81163. return vertexData;
  81164. };
  81165. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  81166. var options = {
  81167. diameter: diameter,
  81168. thickness: thickness,
  81169. tessellation: tessellation,
  81170. sideOrientation: sideOrientation,
  81171. updatable: updatable
  81172. };
  81173. return TorusBuilder.CreateTorus(name, options, scene);
  81174. };
  81175. /**
  81176. * Class containing static functions to help procedurally build meshes
  81177. */
  81178. var TorusBuilder = /** @class */ (function () {
  81179. function TorusBuilder() {
  81180. }
  81181. /**
  81182. * Creates a torus mesh
  81183. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  81184. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  81185. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  81186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  81188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81189. * @param name defines the name of the mesh
  81190. * @param options defines the options used to create the mesh
  81191. * @param scene defines the hosting scene
  81192. * @returns the torus mesh
  81193. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  81194. */
  81195. TorusBuilder.CreateTorus = function (name, options, scene) {
  81196. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  81197. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81198. torus._originalBuilderSideOrientation = options.sideOrientation;
  81199. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus(options);
  81200. vertexData.applyToMesh(torus, options.updatable);
  81201. return torus;
  81202. };
  81203. return TorusBuilder;
  81204. }());
  81205. /***/ }),
  81206. /***/ "./Meshes/Builders/torusKnotBuilder.ts":
  81207. /*!*********************************************!*\
  81208. !*** ./Meshes/Builders/torusKnotBuilder.ts ***!
  81209. \*********************************************/
  81210. /*! exports provided: TorusKnotBuilder */
  81211. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81212. "use strict";
  81213. __webpack_require__.r(__webpack_exports__);
  81214. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return TorusKnotBuilder; });
  81215. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  81216. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81217. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81218. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot = function (options) {
  81219. var indices = new Array();
  81220. var positions = new Array();
  81221. var normals = new Array();
  81222. var uvs = new Array();
  81223. var radius = options.radius || 2;
  81224. var tube = options.tube || 0.5;
  81225. var radialSegments = options.radialSegments || 32;
  81226. var tubularSegments = options.tubularSegments || 32;
  81227. var p = options.p || 2;
  81228. var q = options.q || 3;
  81229. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  81230. // Helper
  81231. var getPos = function (angle) {
  81232. var cu = Math.cos(angle);
  81233. var su = Math.sin(angle);
  81234. var quOverP = q / p * angle;
  81235. var cs = Math.cos(quOverP);
  81236. var tx = radius * (2 + cs) * 0.5 * cu;
  81237. var ty = radius * (2 + cs) * su * 0.5;
  81238. var tz = radius * Math.sin(quOverP) * 0.5;
  81239. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  81240. };
  81241. // Vertices
  81242. var i;
  81243. var j;
  81244. for (i = 0; i <= radialSegments; i++) {
  81245. var modI = i % radialSegments;
  81246. var u = modI / radialSegments * 2 * p * Math.PI;
  81247. var p1 = getPos(u);
  81248. var p2 = getPos(u + 0.01);
  81249. var tang = p2.subtract(p1);
  81250. var n = p2.add(p1);
  81251. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  81252. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  81253. bitan.normalize();
  81254. n.normalize();
  81255. for (j = 0; j < tubularSegments; j++) {
  81256. var modJ = j % tubularSegments;
  81257. var v = modJ / tubularSegments * 2 * Math.PI;
  81258. var cx = -tube * Math.cos(v);
  81259. var cy = tube * Math.sin(v);
  81260. positions.push(p1.x + cx * n.x + cy * bitan.x);
  81261. positions.push(p1.y + cx * n.y + cy * bitan.y);
  81262. positions.push(p1.z + cx * n.z + cy * bitan.z);
  81263. uvs.push(i / radialSegments);
  81264. uvs.push(j / tubularSegments);
  81265. }
  81266. }
  81267. for (i = 0; i < radialSegments; i++) {
  81268. for (j = 0; j < tubularSegments; j++) {
  81269. var jNext = (j + 1) % tubularSegments;
  81270. var a = i * tubularSegments + j;
  81271. var b = (i + 1) * tubularSegments + j;
  81272. var c = (i + 1) * tubularSegments + jNext;
  81273. var d = i * tubularSegments + jNext;
  81274. indices.push(d);
  81275. indices.push(b);
  81276. indices.push(a);
  81277. indices.push(d);
  81278. indices.push(c);
  81279. indices.push(b);
  81280. }
  81281. }
  81282. // Normals
  81283. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  81284. // Sides
  81285. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  81286. // Result
  81287. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  81288. vertexData.indices = indices;
  81289. vertexData.positions = positions;
  81290. vertexData.normals = normals;
  81291. vertexData.uvs = uvs;
  81292. return vertexData;
  81293. };
  81294. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  81295. var options = {
  81296. radius: radius,
  81297. tube: tube,
  81298. radialSegments: radialSegments,
  81299. tubularSegments: tubularSegments,
  81300. p: p,
  81301. q: q,
  81302. sideOrientation: sideOrientation,
  81303. updatable: updatable
  81304. };
  81305. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  81306. };
  81307. /**
  81308. * Class containing static functions to help procedurally build meshes
  81309. */
  81310. var TorusKnotBuilder = /** @class */ (function () {
  81311. function TorusKnotBuilder() {
  81312. }
  81313. /**
  81314. * Creates a torus knot mesh
  81315. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  81316. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  81317. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  81318. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  81319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  81321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81322. * @param name defines the name of the mesh
  81323. * @param options defines the options used to create the mesh
  81324. * @param scene defines the hosting scene
  81325. * @returns the torus knot mesh
  81326. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  81327. */
  81328. TorusKnotBuilder.CreateTorusKnot = function (name, options, scene) {
  81329. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  81330. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81331. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  81332. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot(options);
  81333. vertexData.applyToMesh(torusKnot, options.updatable);
  81334. return torusKnot;
  81335. };
  81336. return TorusKnotBuilder;
  81337. }());
  81338. /***/ }),
  81339. /***/ "./Meshes/Builders/tubeBuilder.ts":
  81340. /*!****************************************!*\
  81341. !*** ./Meshes/Builders/tubeBuilder.ts ***!
  81342. \****************************************/
  81343. /*! exports provided: TubeBuilder */
  81344. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81345. "use strict";
  81346. __webpack_require__.r(__webpack_exports__);
  81347. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return TubeBuilder; });
  81348. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  81349. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81350. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  81351. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  81352. var options = {
  81353. path: path,
  81354. radius: radius,
  81355. tessellation: tessellation,
  81356. radiusFunction: radiusFunction,
  81357. arc: 1,
  81358. cap: cap,
  81359. updatable: updatable,
  81360. sideOrientation: sideOrientation,
  81361. instance: instance
  81362. };
  81363. return TubeBuilder.CreateTube(name, options, scene);
  81364. };
  81365. /**
  81366. * Class containing static functions to help procedurally build meshes
  81367. */
  81368. var TubeBuilder = /** @class */ (function () {
  81369. function TubeBuilder() {
  81370. }
  81371. /**
  81372. * Creates a tube mesh.
  81373. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  81374. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  81375. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  81376. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  81377. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  81378. * * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float)
  81379. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  81380. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  81381. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  81382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  81384. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  81385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81386. * @param name defines the name of the mesh
  81387. * @param options defines the options used to create the mesh
  81388. * @param scene defines the hosting scene
  81389. * @returns the tube mesh
  81390. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  81391. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  81392. */
  81393. TubeBuilder.CreateTube = function (name, options, scene) {
  81394. if (scene === void 0) { scene = null; }
  81395. var path = options.path;
  81396. var instance = options.instance;
  81397. var radius = 1.0;
  81398. if (options.radius !== undefined) {
  81399. radius = options.radius;
  81400. }
  81401. else if (instance) {
  81402. radius = instance._creationDataStorage.radius;
  81403. }
  81404. var tessellation = options.tessellation || 64 | 0;
  81405. var radiusFunction = options.radiusFunction || null;
  81406. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  81407. var invertUV = options.invertUV || false;
  81408. var updatable = options.updatable;
  81409. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81410. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  81411. // tube geometry
  81412. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  81413. var tangents = path3D.getTangents();
  81414. var normals = path3D.getNormals();
  81415. var distances = path3D.getDistances();
  81416. var pi2 = Math.PI * 2;
  81417. var step = pi2 / tessellation * arc;
  81418. var returnRadius = function () { return radius; };
  81419. var radiusFunctionFinal = radiusFunction || returnRadius;
  81420. var circlePath;
  81421. var rad;
  81422. var normal;
  81423. var rotated;
  81424. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  81425. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  81426. for (var i = 0; i < path.length; i++) {
  81427. rad = radiusFunctionFinal(i, distances[i]); // current radius
  81428. circlePath = Array(); // current circle array
  81429. normal = normals[i]; // current normal
  81430. for (var t = 0; t < tessellation; t++) {
  81431. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  81432. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  81433. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  81434. rotated.scaleInPlace(rad).addInPlace(path[i]);
  81435. circlePath[t] = rotated;
  81436. }
  81437. circlePaths[index] = circlePath;
  81438. index++;
  81439. }
  81440. // cap
  81441. var capPath = function (nbPoints, pathIndex) {
  81442. var pointCap = Array();
  81443. for (var i = 0; i < nbPoints; i++) {
  81444. pointCap.push(path[pathIndex]);
  81445. }
  81446. return pointCap;
  81447. };
  81448. switch (cap) {
  81449. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  81450. break;
  81451. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  81452. circlePaths[0] = capPath(tessellation, 0);
  81453. circlePaths[1] = circlePaths[2].slice(0);
  81454. break;
  81455. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  81456. circlePaths[index] = circlePaths[index - 1].slice(0);
  81457. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  81458. break;
  81459. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  81460. circlePaths[0] = capPath(tessellation, 0);
  81461. circlePaths[1] = circlePaths[2].slice(0);
  81462. circlePaths[index] = circlePaths[index - 1].slice(0);
  81463. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  81464. break;
  81465. default:
  81466. break;
  81467. }
  81468. return circlePaths;
  81469. };
  81470. var path3D;
  81471. var pathArray;
  81472. if (instance) { // tube update
  81473. var storage = instance._creationDataStorage;
  81474. var arc = options.arc || storage.arc;
  81475. path3D = storage.path3D.update(path);
  81476. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  81477. instance = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon("", { pathArray: pathArray, instance: instance });
  81478. // Update mode, no need to recreate the storage.
  81479. storage.path3D = path3D;
  81480. storage.pathArray = pathArray;
  81481. storage.arc = arc;
  81482. storage.radius = radius;
  81483. return instance;
  81484. }
  81485. // tube creation
  81486. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](path);
  81487. var newPathArray = new Array();
  81488. cap = (cap < 0 || cap > 3) ? 0 : cap;
  81489. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  81490. var tube = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon(name, { pathArray: pathArray, closePath: true, closeArray: false, updatable: updatable, sideOrientation: sideOrientation, invertUV: invertUV, frontUVs: options.frontUVs, backUVs: options.backUVs }, scene);
  81491. tube._creationDataStorage.pathArray = pathArray;
  81492. tube._creationDataStorage.path3D = path3D;
  81493. tube._creationDataStorage.tessellation = tessellation;
  81494. tube._creationDataStorage.cap = cap;
  81495. tube._creationDataStorage.arc = options.arc;
  81496. tube._creationDataStorage.radius = radius;
  81497. return tube;
  81498. };
  81499. return TubeBuilder;
  81500. }());
  81501. /***/ }),
  81502. /***/ "./Meshes/Compression/dracoCompression.ts":
  81503. /*!************************************************!*\
  81504. !*** ./Meshes/Compression/dracoCompression.ts ***!
  81505. \************************************************/
  81506. /*! exports provided: DracoCompression */
  81507. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81508. "use strict";
  81509. __webpack_require__.r(__webpack_exports__);
  81510. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  81511. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  81512. /* harmony import */ var _Misc_workerPool__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/workerPool */ "./Misc/workerPool.ts");
  81513. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81514. /**
  81515. * Draco compression (https://google.github.io/draco/)
  81516. *
  81517. * This class wraps the Draco module.
  81518. *
  81519. * **Encoder**
  81520. *
  81521. * The encoder is not currently implemented.
  81522. *
  81523. * **Decoder**
  81524. *
  81525. * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.
  81526. *
  81527. * To update the configuration, use the following code:
  81528. * ```javascript
  81529. * DracoCompression.Configuration = {
  81530. * decoder: {
  81531. * wasmUrl: "<url to the WebAssembly library>",
  81532. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  81533. * fallbackUrl: "<url to the fallback JavaScript library>",
  81534. * }
  81535. * };
  81536. * ```
  81537. *
  81538. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  81539. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  81540. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  81541. *
  81542. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  81543. * ```javascript
  81544. * var dracoCompression = new DracoCompression();
  81545. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  81546. * [VertexBuffer.PositionKind]: 0
  81547. * });
  81548. * ```
  81549. *
  81550. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  81551. */
  81552. var DracoCompression = /** @class */ (function () {
  81553. /**
  81554. * Constructor
  81555. * @param numWorkers The number of workers for async operations
  81556. */
  81557. function DracoCompression(numWorkers) {
  81558. if (numWorkers === void 0) { numWorkers = DracoCompression.DefaultNumWorkers; }
  81559. if (!URL || !URL.createObjectURL) {
  81560. throw new Error("Object URLs are not available");
  81561. }
  81562. if (!Worker) {
  81563. throw new Error("Workers are not available");
  81564. }
  81565. this._workerPoolPromise = this._loadDecoderWasmBinaryAsync().then(function (decoderWasmBinary) {
  81566. var workerBlobUrl = URL.createObjectURL(new Blob(["(" + DracoCompression._Worker.toString() + ")()"], { type: "application/javascript" }));
  81567. var workerPromises = new Array(numWorkers);
  81568. for (var i = 0; i < workerPromises.length; i++) {
  81569. workerPromises[i] = new Promise(function (resolve, reject) {
  81570. var decoder = DracoCompression.Configuration.decoder;
  81571. if (decoder) {
  81572. var worker_1 = new Worker(workerBlobUrl);
  81573. var onError_1 = function (error) {
  81574. worker_1.removeEventListener("error", onError_1);
  81575. worker_1.removeEventListener("message", onMessage_1);
  81576. reject(error);
  81577. };
  81578. var onMessage_1 = function (message) {
  81579. if (message.data === "done") {
  81580. worker_1.removeEventListener("error", onError_1);
  81581. worker_1.removeEventListener("message", onMessage_1);
  81582. resolve(worker_1);
  81583. }
  81584. };
  81585. worker_1.addEventListener("error", onError_1);
  81586. worker_1.addEventListener("message", onMessage_1);
  81587. worker_1.postMessage({
  81588. id: "initDecoder",
  81589. decoderWasmUrl: decoder.wasmUrl ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetAbsoluteUrl(decoder.wasmUrl) : null,
  81590. decoderWasmBinary: decoderWasmBinary,
  81591. fallbackUrl: decoder.fallbackUrl ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetAbsoluteUrl(decoder.fallbackUrl) : null
  81592. });
  81593. }
  81594. });
  81595. }
  81596. return Promise.all(workerPromises).then(function (workers) {
  81597. return new _Misc_workerPool__WEBPACK_IMPORTED_MODULE_1__["WorkerPool"](workers);
  81598. });
  81599. });
  81600. }
  81601. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  81602. /**
  81603. * Returns true if the decoder is available.
  81604. */
  81605. get: function () {
  81606. if (typeof DracoDecoderModule !== "undefined") {
  81607. return true;
  81608. }
  81609. var decoder = DracoCompression.Configuration.decoder;
  81610. if (decoder) {
  81611. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  81612. return true;
  81613. }
  81614. if (decoder.fallbackUrl) {
  81615. return true;
  81616. }
  81617. }
  81618. return false;
  81619. },
  81620. enumerable: true,
  81621. configurable: true
  81622. });
  81623. DracoCompression.GetDefaultNumWorkers = function () {
  81624. var hardwareConcurrency = navigator && navigator.hardwareConcurrency;
  81625. if (!hardwareConcurrency) {
  81626. return 1;
  81627. }
  81628. // Use 50% of the available logical processors but capped at 4.
  81629. return Math.min(Math.floor(hardwareConcurrency * 0.5), 4);
  81630. };
  81631. /**
  81632. * Stop all async operations and release resources.
  81633. */
  81634. DracoCompression.prototype.dispose = function () {
  81635. this._workerPoolPromise.then(function (workerPool) {
  81636. workerPool.dispose();
  81637. });
  81638. delete this._workerPoolPromise;
  81639. };
  81640. /**
  81641. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  81642. * @returns a promise that resolves when ready
  81643. */
  81644. DracoCompression.prototype.whenReadyAsync = function () {
  81645. return this._workerPoolPromise.then(function () { });
  81646. };
  81647. /**
  81648. * Decode Draco compressed mesh data to vertex data.
  81649. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  81650. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  81651. * @returns A promise that resolves with the decoded vertex data
  81652. */
  81653. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  81654. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  81655. return this._workerPoolPromise.then(function (workerPool) {
  81656. return new Promise(function (resolve, reject) {
  81657. workerPool.push(function (worker, onComplete) {
  81658. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  81659. var onError = function (error) {
  81660. worker.removeEventListener("error", onError);
  81661. worker.removeEventListener("message", onMessage);
  81662. reject(error);
  81663. onComplete();
  81664. };
  81665. var onMessage = function (message) {
  81666. if (message.data === "done") {
  81667. worker.removeEventListener("error", onError);
  81668. worker.removeEventListener("message", onMessage);
  81669. resolve(vertexData);
  81670. onComplete();
  81671. }
  81672. else if (message.data.id === "indices") {
  81673. vertexData.indices = message.data.value;
  81674. }
  81675. else {
  81676. vertexData.set(message.data.value, message.data.id);
  81677. }
  81678. };
  81679. worker.addEventListener("error", onError);
  81680. worker.addEventListener("message", onMessage);
  81681. var dataViewCopy = new Uint8Array(dataView.byteLength);
  81682. dataViewCopy.set(new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength));
  81683. worker.postMessage({ id: "decodeMesh", dataView: dataViewCopy, attributes: attributes }, [dataViewCopy.buffer]);
  81684. });
  81685. });
  81686. });
  81687. };
  81688. /**
  81689. * The worker function that gets converted to a blob url to pass into a worker.
  81690. */
  81691. DracoCompression._Worker = function () {
  81692. var nativeAttributeTypes = {
  81693. "position": "POSITION",
  81694. "normal": "NORMAL",
  81695. "color": "COLOR",
  81696. "uv": "TEX_COORD"
  81697. };
  81698. // self is actually a DedicatedWorkerGlobalScope
  81699. var _self = self;
  81700. var decoderModulePromise;
  81701. function initDecoder(decoderWasmUrl, decoderWasmBinary, fallbackUrl) {
  81702. if (decoderWasmUrl && decoderWasmBinary && typeof WebAssembly === "object") {
  81703. importScripts(decoderWasmUrl);
  81704. decoderModulePromise = DracoDecoderModule({
  81705. wasmBinary: decoderWasmBinary
  81706. });
  81707. }
  81708. else if (fallbackUrl) {
  81709. importScripts(fallbackUrl);
  81710. decoderModulePromise = DracoDecoderModule();
  81711. }
  81712. else {
  81713. throw Error("Failed to initialize Draco decoder");
  81714. }
  81715. _self.postMessage("done");
  81716. }
  81717. function decodeMesh(dataView, attributes) {
  81718. decoderModulePromise.then(function (decoderModule) {
  81719. var buffer = new decoderModule.DecoderBuffer();
  81720. buffer.Init(dataView, dataView.byteLength);
  81721. var decoder = new decoderModule.Decoder();
  81722. var geometry;
  81723. var status;
  81724. try {
  81725. var type = decoder.GetEncodedGeometryType(buffer);
  81726. switch (type) {
  81727. case decoderModule.TRIANGULAR_MESH:
  81728. geometry = new decoderModule.Mesh();
  81729. status = decoder.DecodeBufferToMesh(buffer, geometry);
  81730. break;
  81731. case decoderModule.POINT_CLOUD:
  81732. geometry = new decoderModule.PointCloud();
  81733. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  81734. break;
  81735. default:
  81736. throw new Error("Invalid geometry type " + type);
  81737. }
  81738. if (!status.ok() || !geometry.ptr) {
  81739. throw new Error(status.error_msg());
  81740. }
  81741. var numPoints_1 = geometry.num_points();
  81742. if (type === decoderModule.TRIANGULAR_MESH) {
  81743. var numFaces = geometry.num_faces();
  81744. var faceIndices = new decoderModule.DracoInt32Array();
  81745. try {
  81746. var indices = new Uint32Array(numFaces * 3);
  81747. for (var i = 0; i < numFaces; i++) {
  81748. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  81749. var offset = i * 3;
  81750. indices[offset + 0] = faceIndices.GetValue(0);
  81751. indices[offset + 1] = faceIndices.GetValue(1);
  81752. indices[offset + 2] = faceIndices.GetValue(2);
  81753. }
  81754. _self.postMessage({ id: "indices", value: indices }, [indices.buffer]);
  81755. }
  81756. finally {
  81757. decoderModule.destroy(faceIndices);
  81758. }
  81759. }
  81760. var processAttribute = function (kind, attribute) {
  81761. var dracoData = new decoderModule.DracoFloat32Array();
  81762. try {
  81763. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  81764. var babylonData = new Float32Array(numPoints_1 * attribute.num_components());
  81765. for (var i = 0; i < babylonData.length; i++) {
  81766. babylonData[i] = dracoData.GetValue(i);
  81767. }
  81768. _self.postMessage({ id: kind, value: babylonData }, [babylonData.buffer]);
  81769. }
  81770. finally {
  81771. decoderModule.destroy(dracoData);
  81772. }
  81773. };
  81774. if (attributes) {
  81775. for (var kind in attributes) {
  81776. var id = attributes[kind];
  81777. var attribute = decoder.GetAttributeByUniqueId(geometry, id);
  81778. processAttribute(kind, attribute);
  81779. }
  81780. }
  81781. else {
  81782. for (var kind in nativeAttributeTypes) {
  81783. var id = decoder.GetAttributeId(geometry, decoderModule[nativeAttributeTypes[kind]]);
  81784. if (id !== -1) {
  81785. var attribute = decoder.GetAttribute(geometry, id);
  81786. processAttribute(kind, attribute);
  81787. }
  81788. }
  81789. }
  81790. }
  81791. finally {
  81792. if (geometry) {
  81793. decoderModule.destroy(geometry);
  81794. }
  81795. decoderModule.destroy(decoder);
  81796. decoderModule.destroy(buffer);
  81797. }
  81798. _self.postMessage("done");
  81799. });
  81800. }
  81801. _self.onmessage = function (event) {
  81802. var data = event.data;
  81803. switch (data.id) {
  81804. case "initDecoder": {
  81805. initDecoder(data.decoderWasmUrl, data.decoderWasmBinary, data.fallbackUrl);
  81806. break;
  81807. }
  81808. case "decodeMesh": {
  81809. decodeMesh(data.dataView, data.attributes);
  81810. break;
  81811. }
  81812. }
  81813. };
  81814. };
  81815. DracoCompression.prototype._loadDecoderWasmBinaryAsync = function () {
  81816. var decoder = DracoCompression.Configuration.decoder;
  81817. if (decoder && decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  81818. var wasmBinaryUrl_1 = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetAbsoluteUrl(decoder.wasmBinaryUrl);
  81819. return new Promise(function (resolve, reject) {
  81820. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(wasmBinaryUrl_1, function (data) {
  81821. resolve(data);
  81822. }, undefined, undefined, true, function (request, exception) {
  81823. reject(exception);
  81824. });
  81825. });
  81826. }
  81827. else {
  81828. return Promise.resolve(null);
  81829. }
  81830. };
  81831. /**
  81832. * The configuration. Defaults to the following urls:
  81833. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  81834. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  81835. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  81836. */
  81837. DracoCompression.Configuration = {
  81838. decoder: {
  81839. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  81840. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  81841. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  81842. }
  81843. };
  81844. /**
  81845. * Default number of workers to create when creating the draco compression object.
  81846. */
  81847. DracoCompression.DefaultNumWorkers = DracoCompression.GetDefaultNumWorkers();
  81848. return DracoCompression;
  81849. }());
  81850. /***/ }),
  81851. /***/ "./Meshes/Compression/index.ts":
  81852. /*!*************************************!*\
  81853. !*** ./Meshes/Compression/index.ts ***!
  81854. \*************************************/
  81855. /*! exports provided: DracoCompression */
  81856. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81857. "use strict";
  81858. __webpack_require__.r(__webpack_exports__);
  81859. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  81860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  81861. /***/ }),
  81862. /***/ "./Meshes/abstractMesh.ts":
  81863. /*!********************************!*\
  81864. !*** ./Meshes/abstractMesh.ts ***!
  81865. \********************************/
  81866. /*! exports provided: AbstractMesh */
  81867. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81868. "use strict";
  81869. __webpack_require__.r(__webpack_exports__);
  81870. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  81871. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  81872. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  81873. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  81874. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  81875. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  81876. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  81877. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81878. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  81879. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  81880. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  81881. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  81882. /** @hidden */
  81883. var _FacetDataStorage = /** @class */ (function () {
  81884. function _FacetDataStorage() {
  81885. this.facetNb = 0; // facet number
  81886. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  81887. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  81888. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  81889. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  81890. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  81891. this.subDiv = {
  81892. max: 1,
  81893. X: 1,
  81894. Y: 1,
  81895. Z: 1
  81896. };
  81897. this.facetDepthSort = false; // is the facet depth sort to be computed
  81898. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  81899. }
  81900. return _FacetDataStorage;
  81901. }());
  81902. /**
  81903. * Class used to store all common mesh properties
  81904. */
  81905. var AbstractMesh = /** @class */ (function (_super) {
  81906. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  81907. // Constructor
  81908. /**
  81909. * Creates a new AbstractMesh
  81910. * @param name defines the name of the mesh
  81911. * @param scene defines the hosting scene
  81912. */
  81913. function AbstractMesh(name, scene) {
  81914. if (scene === void 0) { scene = null; }
  81915. var _this = _super.call(this, name, scene, false) || this;
  81916. _this._facetData = new _FacetDataStorage();
  81917. /**
  81918. * The culling strategy to use to check whether the mesh must be rendered or not.
  81919. * This value can be changed at any time and will be used on the next render mesh selection.
  81920. * The possible values are :
  81921. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  81922. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81923. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  81924. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  81925. * Please read each static variable documentation to get details about the culling process.
  81926. * */
  81927. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  81928. // Events
  81929. /**
  81930. * An event triggered when this mesh collides with another one
  81931. */
  81932. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  81933. /**
  81934. * An event triggered when the collision's position changes
  81935. */
  81936. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  81937. /**
  81938. * An event triggered when material is changed
  81939. */
  81940. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  81941. // Properties
  81942. /**
  81943. * Gets or sets the orientation for POV movement & rotation
  81944. */
  81945. _this.definedFacingForward = true;
  81946. _this._visibility = 1.0;
  81947. /** @hidden */
  81948. _this._isActive = false;
  81949. /** Gets or sets the alpha index used to sort transparent meshes
  81950. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  81951. */
  81952. _this.alphaIndex = Number.MAX_VALUE;
  81953. /**
  81954. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  81955. */
  81956. _this.isVisible = true;
  81957. /**
  81958. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  81959. */
  81960. _this.isPickable = true;
  81961. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  81962. _this.showSubMeshesBoundingBox = false;
  81963. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  81964. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  81965. */
  81966. _this.isBlocker = false;
  81967. /**
  81968. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  81969. */
  81970. _this.enablePointerMoveEvents = false;
  81971. /**
  81972. * Specifies the rendering group id for this mesh (0 by default)
  81973. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  81974. */
  81975. _this.renderingGroupId = 0;
  81976. _this._receiveShadows = false;
  81977. /** Defines color to use when rendering outline */
  81978. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  81979. /** Define width to use when rendering outline */
  81980. _this.outlineWidth = 0.02;
  81981. /** Defines color to use when rendering overlay */
  81982. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  81983. /** Defines alpha to use when rendering overlay */
  81984. _this.overlayAlpha = 0.5;
  81985. _this._hasVertexAlpha = false;
  81986. _this._useVertexColors = true;
  81987. _this._computeBonesUsingShaders = true;
  81988. _this._numBoneInfluencers = 4;
  81989. _this._applyFog = true;
  81990. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  81991. _this.useOctreeForRenderingSelection = true;
  81992. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  81993. _this.useOctreeForPicking = true;
  81994. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  81995. _this.useOctreeForCollisions = true;
  81996. _this._layerMask = 0x0FFFFFFF;
  81997. /**
  81998. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  81999. */
  82000. _this.alwaysSelectAsActiveMesh = false;
  82001. /**
  82002. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  82003. */
  82004. _this.doNotSyncBoundingInfo = false;
  82005. /**
  82006. * Gets or sets the current action manager
  82007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82008. */
  82009. _this.actionManager = null;
  82010. // Collisions
  82011. _this._checkCollisions = false;
  82012. _this._collisionMask = -1;
  82013. _this._collisionGroup = -1;
  82014. /**
  82015. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  82016. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82017. */
  82018. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  82019. /**
  82020. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  82021. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82022. */
  82023. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  82024. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  82025. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  82026. // Edges
  82027. /**
  82028. * Defines edge width used when edgesRenderer is enabled
  82029. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82030. */
  82031. _this.edgesWidth = 1;
  82032. /**
  82033. * Defines edge color used when edgesRenderer is enabled
  82034. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82035. */
  82036. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  82037. /** @hidden */
  82038. _this._renderId = 0;
  82039. /** @hidden */
  82040. _this._intersectionsInProgress = new Array();
  82041. /** @hidden */
  82042. _this._unIndexed = false;
  82043. /** @hidden */
  82044. _this._lightSources = new Array();
  82045. /**
  82046. * An event triggered when the mesh is rebuilt.
  82047. */
  82048. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  82049. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  82050. if (collidedMesh === void 0) { collidedMesh = null; }
  82051. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  82052. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  82053. _this.position.addInPlace(_this._diffPositionForCollisions);
  82054. }
  82055. if (collidedMesh) {
  82056. _this.onCollideObservable.notifyObservers(collidedMesh);
  82057. }
  82058. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  82059. };
  82060. _this.getScene().addMesh(_this);
  82061. _this._resyncLightSources();
  82062. return _this;
  82063. }
  82064. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  82065. /**
  82066. * No billboard
  82067. */
  82068. get: function () {
  82069. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  82070. },
  82071. enumerable: true,
  82072. configurable: true
  82073. });
  82074. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  82075. /** Billboard on X axis */
  82076. get: function () {
  82077. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  82078. },
  82079. enumerable: true,
  82080. configurable: true
  82081. });
  82082. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  82083. /** Billboard on Y axis */
  82084. get: function () {
  82085. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  82086. },
  82087. enumerable: true,
  82088. configurable: true
  82089. });
  82090. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  82091. /** Billboard on Z axis */
  82092. get: function () {
  82093. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  82094. },
  82095. enumerable: true,
  82096. configurable: true
  82097. });
  82098. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  82099. /** Billboard on all axes */
  82100. get: function () {
  82101. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  82102. },
  82103. enumerable: true,
  82104. configurable: true
  82105. });
  82106. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  82107. /**
  82108. * Gets the number of facets in the mesh
  82109. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82110. */
  82111. get: function () {
  82112. return this._facetData.facetNb;
  82113. },
  82114. enumerable: true,
  82115. configurable: true
  82116. });
  82117. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  82118. /**
  82119. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  82120. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82121. */
  82122. get: function () {
  82123. return this._facetData.partitioningSubdivisions;
  82124. },
  82125. set: function (nb) {
  82126. this._facetData.partitioningSubdivisions = nb;
  82127. },
  82128. enumerable: true,
  82129. configurable: true
  82130. });
  82131. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  82132. /**
  82133. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  82134. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  82135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82136. */
  82137. get: function () {
  82138. return this._facetData.partitioningBBoxRatio;
  82139. },
  82140. set: function (ratio) {
  82141. this._facetData.partitioningBBoxRatio = ratio;
  82142. },
  82143. enumerable: true,
  82144. configurable: true
  82145. });
  82146. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  82147. /**
  82148. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  82149. * Works only for updatable meshes.
  82150. * Doesn't work with multi-materials
  82151. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82152. */
  82153. get: function () {
  82154. return this._facetData.facetDepthSort;
  82155. },
  82156. set: function (sort) {
  82157. this._facetData.facetDepthSort = sort;
  82158. },
  82159. enumerable: true,
  82160. configurable: true
  82161. });
  82162. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  82163. /**
  82164. * The location (Vector3) where the facet depth sort must be computed from.
  82165. * By default, the active camera position.
  82166. * Used only when facet depth sort is enabled
  82167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82168. */
  82169. get: function () {
  82170. return this._facetData.facetDepthSortFrom;
  82171. },
  82172. set: function (location) {
  82173. this._facetData.facetDepthSortFrom = location;
  82174. },
  82175. enumerable: true,
  82176. configurable: true
  82177. });
  82178. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  82179. /**
  82180. * gets a boolean indicating if facetData is enabled
  82181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82182. */
  82183. get: function () {
  82184. return this._facetData.facetDataEnabled;
  82185. },
  82186. enumerable: true,
  82187. configurable: true
  82188. });
  82189. /** @hidden */
  82190. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  82191. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  82192. return false;
  82193. }
  82194. this._markSubMeshesAsMiscDirty();
  82195. return true;
  82196. };
  82197. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  82198. /** Set a function to call when this mesh collides with another one */
  82199. set: function (callback) {
  82200. if (this._onCollideObserver) {
  82201. this.onCollideObservable.remove(this._onCollideObserver);
  82202. }
  82203. this._onCollideObserver = this.onCollideObservable.add(callback);
  82204. },
  82205. enumerable: true,
  82206. configurable: true
  82207. });
  82208. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  82209. /** Set a function to call when the collision's position changes */
  82210. set: function (callback) {
  82211. if (this._onCollisionPositionChangeObserver) {
  82212. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  82213. }
  82214. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  82215. },
  82216. enumerable: true,
  82217. configurable: true
  82218. });
  82219. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  82220. /**
  82221. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82222. */
  82223. get: function () {
  82224. return this._visibility;
  82225. },
  82226. /**
  82227. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82228. */
  82229. set: function (value) {
  82230. if (this._visibility === value) {
  82231. return;
  82232. }
  82233. this._visibility = value;
  82234. this._markSubMeshesAsMiscDirty();
  82235. },
  82236. enumerable: true,
  82237. configurable: true
  82238. });
  82239. Object.defineProperty(AbstractMesh.prototype, "material", {
  82240. /** Gets or sets current material */
  82241. get: function () {
  82242. return this._material;
  82243. },
  82244. set: function (value) {
  82245. if (this._material === value) {
  82246. return;
  82247. }
  82248. // remove from material mesh map id needed
  82249. if (this._material && this._material.meshMap) {
  82250. this._material.meshMap[this.uniqueId] = undefined;
  82251. }
  82252. this._material = value;
  82253. if (value && value.meshMap) {
  82254. value.meshMap[this.uniqueId] = this;
  82255. }
  82256. if (this.onMaterialChangedObservable.hasObservers) {
  82257. this.onMaterialChangedObservable.notifyObservers(this);
  82258. }
  82259. if (!this.subMeshes) {
  82260. return;
  82261. }
  82262. this._unBindEffect();
  82263. },
  82264. enumerable: true,
  82265. configurable: true
  82266. });
  82267. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  82268. /**
  82269. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  82270. * @see http://doc.babylonjs.com/babylon101/shadows
  82271. */
  82272. get: function () {
  82273. return this._receiveShadows;
  82274. },
  82275. set: function (value) {
  82276. if (this._receiveShadows === value) {
  82277. return;
  82278. }
  82279. this._receiveShadows = value;
  82280. this._markSubMeshesAsLightDirty();
  82281. },
  82282. enumerable: true,
  82283. configurable: true
  82284. });
  82285. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  82286. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  82287. get: function () {
  82288. return this._hasVertexAlpha;
  82289. },
  82290. set: function (value) {
  82291. if (this._hasVertexAlpha === value) {
  82292. return;
  82293. }
  82294. this._hasVertexAlpha = value;
  82295. this._markSubMeshesAsAttributesDirty();
  82296. this._markSubMeshesAsMiscDirty();
  82297. },
  82298. enumerable: true,
  82299. configurable: true
  82300. });
  82301. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  82302. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  82303. get: function () {
  82304. return this._useVertexColors;
  82305. },
  82306. set: function (value) {
  82307. if (this._useVertexColors === value) {
  82308. return;
  82309. }
  82310. this._useVertexColors = value;
  82311. this._markSubMeshesAsAttributesDirty();
  82312. },
  82313. enumerable: true,
  82314. configurable: true
  82315. });
  82316. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  82317. /**
  82318. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  82319. */
  82320. get: function () {
  82321. return this._computeBonesUsingShaders;
  82322. },
  82323. set: function (value) {
  82324. if (this._computeBonesUsingShaders === value) {
  82325. return;
  82326. }
  82327. this._computeBonesUsingShaders = value;
  82328. this._markSubMeshesAsAttributesDirty();
  82329. },
  82330. enumerable: true,
  82331. configurable: true
  82332. });
  82333. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  82334. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  82335. get: function () {
  82336. return this._numBoneInfluencers;
  82337. },
  82338. set: function (value) {
  82339. if (this._numBoneInfluencers === value) {
  82340. return;
  82341. }
  82342. this._numBoneInfluencers = value;
  82343. this._markSubMeshesAsAttributesDirty();
  82344. },
  82345. enumerable: true,
  82346. configurable: true
  82347. });
  82348. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  82349. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  82350. get: function () {
  82351. return this._applyFog;
  82352. },
  82353. set: function (value) {
  82354. if (this._applyFog === value) {
  82355. return;
  82356. }
  82357. this._applyFog = value;
  82358. this._markSubMeshesAsMiscDirty();
  82359. },
  82360. enumerable: true,
  82361. configurable: true
  82362. });
  82363. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  82364. /**
  82365. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  82366. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  82367. */
  82368. get: function () {
  82369. return this._layerMask;
  82370. },
  82371. set: function (value) {
  82372. if (value === this._layerMask) {
  82373. return;
  82374. }
  82375. this._layerMask = value;
  82376. this._resyncLightSources();
  82377. },
  82378. enumerable: true,
  82379. configurable: true
  82380. });
  82381. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  82382. /**
  82383. * Gets or sets a collision mask used to mask collisions (default is -1).
  82384. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82385. */
  82386. get: function () {
  82387. return this._collisionMask;
  82388. },
  82389. set: function (mask) {
  82390. this._collisionMask = !isNaN(mask) ? mask : -1;
  82391. },
  82392. enumerable: true,
  82393. configurable: true
  82394. });
  82395. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  82396. /**
  82397. * Gets or sets the current collision group mask (-1 by default).
  82398. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82399. */
  82400. get: function () {
  82401. return this._collisionGroup;
  82402. },
  82403. set: function (mask) {
  82404. this._collisionGroup = !isNaN(mask) ? mask : -1;
  82405. },
  82406. enumerable: true,
  82407. configurable: true
  82408. });
  82409. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  82410. /** @hidden */
  82411. get: function () {
  82412. return null;
  82413. },
  82414. enumerable: true,
  82415. configurable: true
  82416. });
  82417. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  82418. get: function () {
  82419. return this._skeleton;
  82420. },
  82421. /**
  82422. * Gets or sets a skeleton to apply skining transformations
  82423. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82424. */
  82425. set: function (value) {
  82426. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  82427. this._skeleton._unregisterMeshWithPoseMatrix(this);
  82428. }
  82429. if (value && value.needInitialSkinMatrix) {
  82430. value._registerMeshWithPoseMatrix(this);
  82431. }
  82432. this._skeleton = value;
  82433. if (!this._skeleton) {
  82434. this._bonesTransformMatrices = null;
  82435. }
  82436. this._markSubMeshesAsAttributesDirty();
  82437. },
  82438. enumerable: true,
  82439. configurable: true
  82440. });
  82441. /**
  82442. * Returns the string "AbstractMesh"
  82443. * @returns "AbstractMesh"
  82444. */
  82445. AbstractMesh.prototype.getClassName = function () {
  82446. return "AbstractMesh";
  82447. };
  82448. /**
  82449. * Gets a string representation of the current mesh
  82450. * @param fullDetails defines a boolean indicating if full details must be included
  82451. * @returns a string representation of the current mesh
  82452. */
  82453. AbstractMesh.prototype.toString = function (fullDetails) {
  82454. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  82455. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  82456. if (this._skeleton) {
  82457. ret += ", skeleton: " + this._skeleton.name;
  82458. }
  82459. if (fullDetails) {
  82460. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  82461. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  82462. }
  82463. return ret;
  82464. };
  82465. /**
  82466. * @hidden
  82467. */
  82468. AbstractMesh.prototype._getEffectiveParent = function () {
  82469. if (this._masterMesh && this.billboardMode !== _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE) {
  82470. return this._masterMesh;
  82471. }
  82472. return _super.prototype._getEffectiveParent.call(this);
  82473. };
  82474. /** @hidden */
  82475. AbstractMesh.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  82476. if (initialCall === void 0) { initialCall = true; }
  82477. if (this.actionManager && (initialCall || this.actionManager.isRecursive)) {
  82478. if (trigger) {
  82479. if (this.actionManager.hasSpecificTrigger(trigger)) {
  82480. return this.actionManager;
  82481. }
  82482. }
  82483. else {
  82484. return this.actionManager;
  82485. }
  82486. }
  82487. if (!this.parent) {
  82488. return null;
  82489. }
  82490. return this.parent._getActionManagerForTrigger(trigger, false);
  82491. };
  82492. /** @hidden */
  82493. AbstractMesh.prototype._rebuild = function () {
  82494. this.onRebuildObservable.notifyObservers(this);
  82495. if (this._occlusionQuery) {
  82496. this._occlusionQuery = null;
  82497. }
  82498. if (!this.subMeshes) {
  82499. return;
  82500. }
  82501. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  82502. var subMesh = _a[_i];
  82503. subMesh._rebuild();
  82504. }
  82505. };
  82506. /** @hidden */
  82507. AbstractMesh.prototype._resyncLightSources = function () {
  82508. this._lightSources.length = 0;
  82509. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  82510. var light = _a[_i];
  82511. if (!light.isEnabled()) {
  82512. continue;
  82513. }
  82514. if (light.canAffectMesh(this)) {
  82515. this._lightSources.push(light);
  82516. }
  82517. }
  82518. this._markSubMeshesAsLightDirty();
  82519. };
  82520. /** @hidden */
  82521. AbstractMesh.prototype._resyncLighSource = function (light) {
  82522. var isIn = light.isEnabled() && light.canAffectMesh(this);
  82523. var index = this._lightSources.indexOf(light);
  82524. if (index === -1) {
  82525. if (!isIn) {
  82526. return;
  82527. }
  82528. this._lightSources.push(light);
  82529. }
  82530. else {
  82531. if (isIn) {
  82532. return;
  82533. }
  82534. this._lightSources.splice(index, 1);
  82535. }
  82536. this._markSubMeshesAsLightDirty();
  82537. };
  82538. /** @hidden */
  82539. AbstractMesh.prototype._unBindEffect = function () {
  82540. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  82541. var subMesh = _a[_i];
  82542. subMesh.setEffect(null);
  82543. }
  82544. };
  82545. /** @hidden */
  82546. AbstractMesh.prototype._removeLightSource = function (light) {
  82547. var index = this._lightSources.indexOf(light);
  82548. if (index === -1) {
  82549. return;
  82550. }
  82551. this._lightSources.splice(index, 1);
  82552. this._markSubMeshesAsLightDirty();
  82553. };
  82554. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  82555. if (!this.subMeshes) {
  82556. return;
  82557. }
  82558. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  82559. var subMesh = _a[_i];
  82560. if (subMesh._materialDefines) {
  82561. func(subMesh._materialDefines);
  82562. }
  82563. }
  82564. };
  82565. /** @hidden */
  82566. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  82567. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  82568. };
  82569. /** @hidden */
  82570. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  82571. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  82572. };
  82573. /** @hidden */
  82574. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  82575. if (!this.subMeshes) {
  82576. return;
  82577. }
  82578. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  82579. var subMesh = _a[_i];
  82580. var material = subMesh.getMaterial();
  82581. if (material) {
  82582. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MATERIAL_MiscDirtyFlag);
  82583. }
  82584. }
  82585. };
  82586. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  82587. /**
  82588. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  82589. */
  82590. get: function () {
  82591. return this._scaling;
  82592. },
  82593. set: function (newScaling) {
  82594. this._scaling = newScaling;
  82595. if (this.physicsImpostor) {
  82596. this.physicsImpostor.forceUpdate();
  82597. }
  82598. },
  82599. enumerable: true,
  82600. configurable: true
  82601. });
  82602. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  82603. // Methods
  82604. /**
  82605. * Returns true if the mesh is blocked. Implemented by child classes
  82606. */
  82607. get: function () {
  82608. return false;
  82609. },
  82610. enumerable: true,
  82611. configurable: true
  82612. });
  82613. /**
  82614. * Returns the mesh itself by default. Implemented by child classes
  82615. * @param camera defines the camera to use to pick the right LOD level
  82616. * @returns the currentAbstractMesh
  82617. */
  82618. AbstractMesh.prototype.getLOD = function (camera) {
  82619. return this;
  82620. };
  82621. /**
  82622. * Returns 0 by default. Implemented by child classes
  82623. * @returns an integer
  82624. */
  82625. AbstractMesh.prototype.getTotalVertices = function () {
  82626. return 0;
  82627. };
  82628. /**
  82629. * Returns a positive integer : the total number of indices in this mesh geometry.
  82630. * @returns the numner of indices or zero if the mesh has no geometry.
  82631. */
  82632. AbstractMesh.prototype.getTotalIndices = function () {
  82633. return 0;
  82634. };
  82635. /**
  82636. * Returns null by default. Implemented by child classes
  82637. * @returns null
  82638. */
  82639. AbstractMesh.prototype.getIndices = function () {
  82640. return null;
  82641. };
  82642. /**
  82643. * Returns the array of the requested vertex data kind. Implemented by child classes
  82644. * @param kind defines the vertex data kind to use
  82645. * @returns null
  82646. */
  82647. AbstractMesh.prototype.getVerticesData = function (kind) {
  82648. return null;
  82649. };
  82650. /**
  82651. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82652. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82653. * Note that a new underlying VertexBuffer object is created each call.
  82654. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82655. * @param kind defines vertex data kind:
  82656. * * VertexBuffer.PositionKind
  82657. * * VertexBuffer.UVKind
  82658. * * VertexBuffer.UV2Kind
  82659. * * VertexBuffer.UV3Kind
  82660. * * VertexBuffer.UV4Kind
  82661. * * VertexBuffer.UV5Kind
  82662. * * VertexBuffer.UV6Kind
  82663. * * VertexBuffer.ColorKind
  82664. * * VertexBuffer.MatricesIndicesKind
  82665. * * VertexBuffer.MatricesIndicesExtraKind
  82666. * * VertexBuffer.MatricesWeightsKind
  82667. * * VertexBuffer.MatricesWeightsExtraKind
  82668. * @param data defines the data source
  82669. * @param updatable defines if the data must be flagged as updatable (or static)
  82670. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  82671. * @returns the current mesh
  82672. */
  82673. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  82674. return this;
  82675. };
  82676. /**
  82677. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82678. * If the mesh has no geometry, it is simply returned as it is.
  82679. * @param kind defines vertex data kind:
  82680. * * VertexBuffer.PositionKind
  82681. * * VertexBuffer.UVKind
  82682. * * VertexBuffer.UV2Kind
  82683. * * VertexBuffer.UV3Kind
  82684. * * VertexBuffer.UV4Kind
  82685. * * VertexBuffer.UV5Kind
  82686. * * VertexBuffer.UV6Kind
  82687. * * VertexBuffer.ColorKind
  82688. * * VertexBuffer.MatricesIndicesKind
  82689. * * VertexBuffer.MatricesIndicesExtraKind
  82690. * * VertexBuffer.MatricesWeightsKind
  82691. * * VertexBuffer.MatricesWeightsExtraKind
  82692. * @param data defines the data source
  82693. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  82694. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  82695. * @returns the current mesh
  82696. */
  82697. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  82698. return this;
  82699. };
  82700. /**
  82701. * Sets the mesh indices,
  82702. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82703. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  82704. * @param totalVertices Defines the total number of vertices
  82705. * @returns the current mesh
  82706. */
  82707. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  82708. return this;
  82709. };
  82710. /**
  82711. * Gets a boolean indicating if specific vertex data is present
  82712. * @param kind defines the vertex data kind to use
  82713. * @returns true is data kind is present
  82714. */
  82715. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  82716. return false;
  82717. };
  82718. /**
  82719. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  82720. * @returns a BoundingInfo
  82721. */
  82722. AbstractMesh.prototype.getBoundingInfo = function () {
  82723. if (this._masterMesh) {
  82724. return this._masterMesh.getBoundingInfo();
  82725. }
  82726. if (!this._boundingInfo) {
  82727. // this._boundingInfo is being created here
  82728. this._updateBoundingInfo();
  82729. }
  82730. // cannot be null.
  82731. return this._boundingInfo;
  82732. };
  82733. /**
  82734. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82735. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82736. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82737. * @returns the current mesh
  82738. */
  82739. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants, ignoreRotation) {
  82740. if (includeDescendants === void 0) { includeDescendants = true; }
  82741. if (ignoreRotation === void 0) { ignoreRotation = false; }
  82742. var storedRotation = null;
  82743. var storedRotationQuaternion = null;
  82744. if (ignoreRotation) {
  82745. if (this.rotationQuaternion) {
  82746. storedRotationQuaternion = this.rotationQuaternion.clone();
  82747. this.rotationQuaternion.copyFromFloats(0, 0, 0, 1);
  82748. }
  82749. else if (this.rotation) {
  82750. storedRotation = this.rotation.clone();
  82751. this.rotation.copyFromFloats(0, 0, 0);
  82752. }
  82753. }
  82754. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  82755. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  82756. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  82757. if (maxDimension === 0) {
  82758. return this;
  82759. }
  82760. var scale = 1 / maxDimension;
  82761. this.scaling.scaleInPlace(scale);
  82762. if (ignoreRotation) {
  82763. if (this.rotationQuaternion && storedRotationQuaternion) {
  82764. this.rotationQuaternion.copyFrom(storedRotationQuaternion);
  82765. }
  82766. else if (this.rotation && storedRotation) {
  82767. this.rotation.copyFrom(storedRotation);
  82768. }
  82769. }
  82770. return this;
  82771. };
  82772. /**
  82773. * Overwrite the current bounding info
  82774. * @param boundingInfo defines the new bounding info
  82775. * @returns the current mesh
  82776. */
  82777. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  82778. this._boundingInfo = boundingInfo;
  82779. return this;
  82780. };
  82781. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  82782. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  82783. get: function () {
  82784. return (this.skeleton && this.getScene().skeletonsEnabled && this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind) && this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind));
  82785. },
  82786. enumerable: true,
  82787. configurable: true
  82788. });
  82789. /** @hidden */
  82790. AbstractMesh.prototype._preActivate = function () {
  82791. };
  82792. /** @hidden */
  82793. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  82794. };
  82795. /** @hidden */
  82796. AbstractMesh.prototype._activate = function (renderId) {
  82797. this._renderId = renderId;
  82798. return true;
  82799. };
  82800. /** @hidden */
  82801. AbstractMesh.prototype._freeze = function () {
  82802. // Do nothing
  82803. };
  82804. /** @hidden */
  82805. AbstractMesh.prototype._unFreeze = function () {
  82806. // Do nothing
  82807. };
  82808. /**
  82809. * Gets the current world matrix
  82810. * @returns a Matrix
  82811. */
  82812. AbstractMesh.prototype.getWorldMatrix = function () {
  82813. if (this._masterMesh && this.billboardMode === _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE) {
  82814. return this._masterMesh.getWorldMatrix();
  82815. }
  82816. return _super.prototype.getWorldMatrix.call(this);
  82817. };
  82818. /** @hidden */
  82819. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  82820. if (this._masterMesh) {
  82821. return this._masterMesh._getWorldMatrixDeterminant();
  82822. }
  82823. return _super.prototype._getWorldMatrixDeterminant.call(this);
  82824. };
  82825. // ================================== Point of View Movement =================================
  82826. /**
  82827. * Perform relative position change from the point of view of behind the front of the mesh.
  82828. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82829. * Supports definition of mesh facing forward or backward
  82830. * @param amountRight defines the distance on the right axis
  82831. * @param amountUp defines the distance on the up axis
  82832. * @param amountForward defines the distance on the forward axis
  82833. * @returns the current mesh
  82834. */
  82835. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  82836. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  82837. return this;
  82838. };
  82839. /**
  82840. * Calculate relative position change from the point of view of behind the front of the mesh.
  82841. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82842. * Supports definition of mesh facing forward or backward
  82843. * @param amountRight defines the distance on the right axis
  82844. * @param amountUp defines the distance on the up axis
  82845. * @param amountForward defines the distance on the forward axis
  82846. * @returns the new displacement vector
  82847. */
  82848. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  82849. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  82850. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  82851. rotQuaternion.toRotationMatrix(rotMatrix);
  82852. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82853. var defForwardMult = this.definedFacingForward ? -1 : 1;
  82854. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  82855. return translationDelta;
  82856. };
  82857. // ================================== Point of View Rotation =================================
  82858. /**
  82859. * Perform relative rotation change from the point of view of behind the front of the mesh.
  82860. * Supports definition of mesh facing forward or backward
  82861. * @param flipBack defines the flip
  82862. * @param twirlClockwise defines the twirl
  82863. * @param tiltRight defines the tilt
  82864. * @returns the current mesh
  82865. */
  82866. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  82867. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  82868. return this;
  82869. };
  82870. /**
  82871. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  82872. * Supports definition of mesh facing forward or backward.
  82873. * @param flipBack defines the flip
  82874. * @param twirlClockwise defines the twirl
  82875. * @param tiltRight defines the tilt
  82876. * @returns the new rotation vector
  82877. */
  82878. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  82879. var defForwardMult = this.definedFacingForward ? 1 : -1;
  82880. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  82881. };
  82882. /**
  82883. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  82884. * @param includeDescendants Include bounding info from descendants as well (true by default)
  82885. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  82886. * @returns the new bounding vectors
  82887. */
  82888. AbstractMesh.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  82889. if (includeDescendants === void 0) { includeDescendants = true; }
  82890. if (predicate === void 0) { predicate = null; }
  82891. // Ensures that all world matrix will be recomputed.
  82892. this.getScene().incrementRenderId();
  82893. this.computeWorldMatrix(true);
  82894. var min;
  82895. var max;
  82896. var boundingInfo = this.getBoundingInfo();
  82897. if (!this.subMeshes) {
  82898. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  82899. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  82900. }
  82901. else {
  82902. min = boundingInfo.boundingBox.minimumWorld;
  82903. max = boundingInfo.boundingBox.maximumWorld;
  82904. }
  82905. if (includeDescendants) {
  82906. var descendants = this.getDescendants(false);
  82907. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  82908. var descendant = descendants_1[_i];
  82909. var childMesh = descendant;
  82910. childMesh.computeWorldMatrix(true);
  82911. // Filters meshes based on custom predicate function.
  82912. if (predicate && !predicate(childMesh)) {
  82913. continue;
  82914. }
  82915. //make sure we have the needed params to get mix and max
  82916. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  82917. continue;
  82918. }
  82919. var childBoundingInfo = childMesh.getBoundingInfo();
  82920. var boundingBox = childBoundingInfo.boundingBox;
  82921. var minBox = boundingBox.minimumWorld;
  82922. var maxBox = boundingBox.maximumWorld;
  82923. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  82924. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  82925. }
  82926. }
  82927. return {
  82928. min: min,
  82929. max: max
  82930. };
  82931. };
  82932. /**
  82933. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82934. * This means the mesh underlying bounding box and sphere are recomputed.
  82935. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82936. * @returns the current mesh
  82937. */
  82938. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  82939. if (applySkeleton === void 0) { applySkeleton = false; }
  82940. if (this._boundingInfo && this._boundingInfo.isLocked) {
  82941. return this;
  82942. }
  82943. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  82944. return this;
  82945. };
  82946. /** @hidden */
  82947. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  82948. if (data) {
  82949. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  82950. if (this._boundingInfo) {
  82951. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  82952. }
  82953. else {
  82954. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](extend.minimum, extend.maximum);
  82955. }
  82956. }
  82957. if (this.subMeshes) {
  82958. for (var index = 0; index < this.subMeshes.length; index++) {
  82959. this.subMeshes[index].refreshBoundingInfo();
  82960. }
  82961. }
  82962. this._updateBoundingInfo();
  82963. };
  82964. /** @hidden */
  82965. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  82966. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  82967. if (data && applySkeleton && this.skeleton) {
  82968. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  82969. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  82970. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  82971. if (matricesWeightsData && matricesIndicesData) {
  82972. var needExtras = this.numBoneInfluencers > 4;
  82973. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  82974. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  82975. this.skeleton.prepare();
  82976. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  82977. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  82978. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  82979. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  82980. var matWeightIdx = 0;
  82981. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  82982. finalMatrix.reset();
  82983. var inf;
  82984. var weight;
  82985. for (inf = 0; inf < 4; inf++) {
  82986. weight = matricesWeightsData[matWeightIdx + inf];
  82987. if (weight > 0) {
  82988. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  82989. finalMatrix.addToSelf(tempMatrix);
  82990. }
  82991. }
  82992. if (needExtras) {
  82993. for (inf = 0; inf < 4; inf++) {
  82994. weight = matricesWeightsExtraData[matWeightIdx + inf];
  82995. if (weight > 0) {
  82996. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  82997. finalMatrix.addToSelf(tempMatrix);
  82998. }
  82999. }
  83000. }
  83001. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  83002. tempVector.toArray(data, index);
  83003. }
  83004. }
  83005. }
  83006. return data;
  83007. };
  83008. /** @hidden */
  83009. AbstractMesh.prototype._updateBoundingInfo = function () {
  83010. var effectiveMesh = this._effectiveMesh;
  83011. if (this._boundingInfo) {
  83012. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  83013. }
  83014. else {
  83015. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  83016. }
  83017. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  83018. return this;
  83019. };
  83020. /** @hidden */
  83021. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  83022. if (!this.subMeshes) {
  83023. return this;
  83024. }
  83025. var count = this.subMeshes.length;
  83026. for (var subIndex = 0; subIndex < count; subIndex++) {
  83027. var subMesh = this.subMeshes[subIndex];
  83028. if (count > 1 || !subMesh.IsGlobal) {
  83029. subMesh.updateBoundingInfo(matrix);
  83030. }
  83031. }
  83032. return this;
  83033. };
  83034. /** @hidden */
  83035. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  83036. if (this.doNotSyncBoundingInfo) {
  83037. return;
  83038. }
  83039. // Bounding info
  83040. this._updateBoundingInfo();
  83041. };
  83042. Object.defineProperty(AbstractMesh.prototype, "_effectiveMesh", {
  83043. /** @hidden */
  83044. get: function () {
  83045. return (this.skeleton && this.skeleton.overrideMesh) || this;
  83046. },
  83047. enumerable: true,
  83048. configurable: true
  83049. });
  83050. /**
  83051. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83052. * A mesh is in the frustum if its bounding box intersects the frustum
  83053. * @param frustumPlanes defines the frustum to test
  83054. * @returns true if the mesh is in the frustum planes
  83055. */
  83056. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  83057. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  83058. };
  83059. /**
  83060. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  83061. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  83062. * @param frustumPlanes defines the frustum to test
  83063. * @returns true if the mesh is completely in the frustum planes
  83064. */
  83065. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  83066. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  83067. };
  83068. /**
  83069. * True if the mesh intersects another mesh or a SolidParticle object
  83070. * @param mesh defines a target mesh or SolidParticle to test
  83071. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  83072. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  83073. * @returns true if there is an intersection
  83074. */
  83075. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  83076. if (precise === void 0) { precise = false; }
  83077. if (!this._boundingInfo || !mesh._boundingInfo) {
  83078. return false;
  83079. }
  83080. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  83081. return true;
  83082. }
  83083. if (includeDescendants) {
  83084. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  83085. var child = _a[_i];
  83086. if (child.intersectsMesh(mesh, precise, true)) {
  83087. return true;
  83088. }
  83089. }
  83090. }
  83091. return false;
  83092. };
  83093. /**
  83094. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  83095. * @param point defines the point to test
  83096. * @returns true if there is an intersection
  83097. */
  83098. AbstractMesh.prototype.intersectsPoint = function (point) {
  83099. if (!this._boundingInfo) {
  83100. return false;
  83101. }
  83102. return this._boundingInfo.intersectsPoint(point);
  83103. };
  83104. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  83105. // Collisions
  83106. /**
  83107. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  83108. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83109. */
  83110. get: function () {
  83111. return this._checkCollisions;
  83112. },
  83113. set: function (collisionEnabled) {
  83114. this._checkCollisions = collisionEnabled;
  83115. },
  83116. enumerable: true,
  83117. configurable: true
  83118. });
  83119. Object.defineProperty(AbstractMesh.prototype, "collider", {
  83120. /**
  83121. * Gets Collider object used to compute collisions (not physics)
  83122. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83123. */
  83124. get: function () {
  83125. return this._collider;
  83126. },
  83127. enumerable: true,
  83128. configurable: true
  83129. });
  83130. /**
  83131. * Move the mesh using collision engine
  83132. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83133. * @param displacement defines the requested displacement vector
  83134. * @returns the current mesh
  83135. */
  83136. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  83137. var globalPosition = this.getAbsolutePosition();
  83138. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  83139. var coordinator = this.getScene().collisionCoordinator;
  83140. if (!this._collider) {
  83141. this._collider = coordinator.createCollider();
  83142. }
  83143. this._collider._radius = this.ellipsoid;
  83144. coordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  83145. return this;
  83146. };
  83147. // Collisions
  83148. /** @hidden */
  83149. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  83150. this._generatePointsArray();
  83151. if (!this._positions) {
  83152. return this;
  83153. }
  83154. // Transformation
  83155. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  83156. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  83157. subMesh._lastColliderWorldVertices = [];
  83158. subMesh._trianglePlanes = [];
  83159. var start = subMesh.verticesStart;
  83160. var end = (subMesh.verticesStart + subMesh.verticesCount);
  83161. for (var i = start; i < end; i++) {
  83162. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  83163. }
  83164. }
  83165. // Collide
  83166. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  83167. if (collider.collisionFound) {
  83168. collider.collidedMesh = this;
  83169. }
  83170. return this;
  83171. };
  83172. /** @hidden */
  83173. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  83174. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  83175. var len = subMeshes.length;
  83176. for (var index = 0; index < len; index++) {
  83177. var subMesh = subMeshes.data[index];
  83178. // Bounding test
  83179. if (len > 1 && !subMesh._checkCollision(collider)) {
  83180. continue;
  83181. }
  83182. this._collideForSubMesh(subMesh, transformMatrix, collider);
  83183. }
  83184. return this;
  83185. };
  83186. /** @hidden */
  83187. AbstractMesh.prototype._checkCollision = function (collider) {
  83188. // Bounding box test
  83189. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  83190. return this;
  83191. }
  83192. // Transformation matrix
  83193. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  83194. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  83195. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  83196. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  83197. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  83198. return this;
  83199. };
  83200. // Picking
  83201. /** @hidden */
  83202. AbstractMesh.prototype._generatePointsArray = function () {
  83203. return false;
  83204. };
  83205. /**
  83206. * Checks if the passed Ray intersects with the mesh
  83207. * @param ray defines the ray to use
  83208. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  83209. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  83210. * @returns the picking info
  83211. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83212. */
  83213. AbstractMesh.prototype.intersects = function (ray, fastCheck, trianglePredicate) {
  83214. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  83215. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  83216. var boundingInfo = this._boundingInfo;
  83217. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  83218. return pickingInfo;
  83219. }
  83220. if (!this._generatePointsArray()) {
  83221. return pickingInfo;
  83222. }
  83223. var intersectInfo = null;
  83224. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  83225. var len = subMeshes.length;
  83226. for (var index = 0; index < len; index++) {
  83227. var subMesh = subMeshes.data[index];
  83228. // Bounding test
  83229. if (len > 1 && !subMesh.canIntersects(ray)) {
  83230. continue;
  83231. }
  83232. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck, trianglePredicate);
  83233. if (currentIntersectInfo) {
  83234. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  83235. intersectInfo = currentIntersectInfo;
  83236. intersectInfo.subMeshId = index;
  83237. if (fastCheck) {
  83238. break;
  83239. }
  83240. }
  83241. }
  83242. }
  83243. if (intersectInfo) {
  83244. // Get picked point
  83245. var world = this.getWorldMatrix();
  83246. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  83247. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  83248. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  83249. ray.direction.scaleToRef(intersectInfo.distance, direction);
  83250. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  83251. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  83252. // Return result
  83253. pickingInfo.hit = true;
  83254. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  83255. pickingInfo.pickedPoint = pickedPoint;
  83256. pickingInfo.pickedMesh = this;
  83257. pickingInfo.bu = intersectInfo.bu || 0;
  83258. pickingInfo.bv = intersectInfo.bv || 0;
  83259. pickingInfo.faceId = intersectInfo.faceId;
  83260. pickingInfo.subMeshId = intersectInfo.subMeshId;
  83261. return pickingInfo;
  83262. }
  83263. return pickingInfo;
  83264. };
  83265. /**
  83266. * Clones the current mesh
  83267. * @param name defines the mesh name
  83268. * @param newParent defines the new mesh parent
  83269. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  83270. * @returns the new mesh
  83271. */
  83272. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  83273. return null;
  83274. };
  83275. /**
  83276. * Disposes all the submeshes of the current meshnp
  83277. * @returns the current mesh
  83278. */
  83279. AbstractMesh.prototype.releaseSubMeshes = function () {
  83280. if (this.subMeshes) {
  83281. while (this.subMeshes.length) {
  83282. this.subMeshes[0].dispose();
  83283. }
  83284. }
  83285. else {
  83286. this.subMeshes = new Array();
  83287. }
  83288. return this;
  83289. };
  83290. /**
  83291. * Releases resources associated with this abstract mesh.
  83292. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83293. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83294. */
  83295. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  83296. var _this = this;
  83297. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  83298. var index;
  83299. // Smart Array Retainers.
  83300. this.getScene().freeActiveMeshes();
  83301. this.getScene().freeRenderingGroups();
  83302. // Action manager
  83303. if (this.actionManager !== undefined && this.actionManager !== null) {
  83304. this.actionManager.dispose();
  83305. this.actionManager = null;
  83306. }
  83307. // Skeleton
  83308. this._skeleton = null;
  83309. // Intersections in progress
  83310. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  83311. var other = this._intersectionsInProgress[index];
  83312. var pos = other._intersectionsInProgress.indexOf(this);
  83313. other._intersectionsInProgress.splice(pos, 1);
  83314. }
  83315. this._intersectionsInProgress = [];
  83316. // Lights
  83317. var lights = this.getScene().lights;
  83318. lights.forEach(function (light) {
  83319. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  83320. if (meshIndex !== -1) {
  83321. light.includedOnlyMeshes.splice(meshIndex, 1);
  83322. }
  83323. meshIndex = light.excludedMeshes.indexOf(_this);
  83324. if (meshIndex !== -1) {
  83325. light.excludedMeshes.splice(meshIndex, 1);
  83326. }
  83327. // Shadow generators
  83328. var generator = light.getShadowGenerator();
  83329. if (generator) {
  83330. var shadowMap = generator.getShadowMap();
  83331. if (shadowMap && shadowMap.renderList) {
  83332. meshIndex = shadowMap.renderList.indexOf(_this);
  83333. if (meshIndex !== -1) {
  83334. shadowMap.renderList.splice(meshIndex, 1);
  83335. }
  83336. }
  83337. }
  83338. });
  83339. // SubMeshes
  83340. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  83341. this.releaseSubMeshes();
  83342. }
  83343. // Query
  83344. var engine = this.getScene().getEngine();
  83345. if (this._occlusionQuery) {
  83346. this.isOcclusionQueryInProgress = false;
  83347. engine.deleteQuery(this._occlusionQuery);
  83348. this._occlusionQuery = null;
  83349. }
  83350. // Engine
  83351. engine.wipeCaches();
  83352. // Remove from scene
  83353. this.getScene().removeMesh(this);
  83354. if (disposeMaterialAndTextures) {
  83355. if (this.material) {
  83356. if (this.material.getClassName() === "MultiMaterial") {
  83357. this.material.dispose(false, true, true);
  83358. }
  83359. else {
  83360. this.material.dispose(false, true);
  83361. }
  83362. }
  83363. }
  83364. if (!doNotRecurse) {
  83365. // Particles
  83366. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  83367. if (this.getScene().particleSystems[index].emitter === this) {
  83368. this.getScene().particleSystems[index].dispose();
  83369. index--;
  83370. }
  83371. }
  83372. }
  83373. // facet data
  83374. if (this._facetData.facetDataEnabled) {
  83375. this.disableFacetData();
  83376. }
  83377. this.onAfterWorldMatrixUpdateObservable.clear();
  83378. this.onCollideObservable.clear();
  83379. this.onCollisionPositionChangeObservable.clear();
  83380. this.onRebuildObservable.clear();
  83381. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  83382. };
  83383. /**
  83384. * Adds the passed mesh as a child to the current mesh
  83385. * @param mesh defines the child mesh
  83386. * @returns the current mesh
  83387. */
  83388. AbstractMesh.prototype.addChild = function (mesh) {
  83389. mesh.setParent(this);
  83390. return this;
  83391. };
  83392. /**
  83393. * Removes the passed mesh from the current mesh children list
  83394. * @param mesh defines the child mesh
  83395. * @returns the current mesh
  83396. */
  83397. AbstractMesh.prototype.removeChild = function (mesh) {
  83398. mesh.setParent(null);
  83399. return this;
  83400. };
  83401. // Facet data
  83402. /** @hidden */
  83403. AbstractMesh.prototype._initFacetData = function () {
  83404. var data = this._facetData;
  83405. if (!data.facetNormals) {
  83406. data.facetNormals = new Array();
  83407. }
  83408. if (!data.facetPositions) {
  83409. data.facetPositions = new Array();
  83410. }
  83411. if (!data.facetPartitioning) {
  83412. data.facetPartitioning = new Array();
  83413. }
  83414. data.facetNb = (this.getIndices().length / 3) | 0;
  83415. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  83416. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  83417. for (var f = 0; f < data.facetNb; f++) {
  83418. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83419. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83420. }
  83421. data.facetDataEnabled = true;
  83422. return this;
  83423. };
  83424. /**
  83425. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  83426. * This method can be called within the render loop.
  83427. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  83428. * @returns the current mesh
  83429. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83430. */
  83431. AbstractMesh.prototype.updateFacetData = function () {
  83432. var data = this._facetData;
  83433. if (!data.facetDataEnabled) {
  83434. this._initFacetData();
  83435. }
  83436. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  83437. var indices = this.getIndices();
  83438. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  83439. var bInfo = this.getBoundingInfo();
  83440. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  83441. // init arrays, matrix and sort function on first call
  83442. data.facetDepthSortEnabled = true;
  83443. if (indices instanceof Uint16Array) {
  83444. data.depthSortedIndices = new Uint16Array(indices);
  83445. }
  83446. else if (indices instanceof Uint32Array) {
  83447. data.depthSortedIndices = new Uint32Array(indices);
  83448. }
  83449. else {
  83450. var needs32bits = false;
  83451. for (var i = 0; i < indices.length; i++) {
  83452. if (indices[i] > 65535) {
  83453. needs32bits = true;
  83454. break;
  83455. }
  83456. }
  83457. if (needs32bits) {
  83458. data.depthSortedIndices = new Uint32Array(indices);
  83459. }
  83460. else {
  83461. data.depthSortedIndices = new Uint16Array(indices);
  83462. }
  83463. }
  83464. data.facetDepthSortFunction = function (f1, f2) {
  83465. return (f2.sqDistance - f1.sqDistance);
  83466. };
  83467. if (!data.facetDepthSortFrom) {
  83468. var camera = this.getScene().activeCamera;
  83469. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83470. }
  83471. data.depthSortedFacets = [];
  83472. for (var f = 0; f < data.facetNb; f++) {
  83473. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  83474. data.depthSortedFacets.push(depthSortedFacet);
  83475. }
  83476. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  83477. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83478. }
  83479. data.bbSize.x = (bInfo.maximum.x - bInfo.minimum.x > _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) ? bInfo.maximum.x - bInfo.minimum.x : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  83480. data.bbSize.y = (bInfo.maximum.y - bInfo.minimum.y > _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) ? bInfo.maximum.y - bInfo.minimum.y : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  83481. data.bbSize.z = (bInfo.maximum.z - bInfo.minimum.z > _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) ? bInfo.maximum.z - bInfo.minimum.z : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  83482. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  83483. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  83484. data.subDiv.max = data.partitioningSubdivisions;
  83485. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  83486. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  83487. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  83488. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  83489. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  83490. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  83491. // set the parameters for ComputeNormals()
  83492. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  83493. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  83494. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  83495. data.facetParameters.bInfo = bInfo;
  83496. data.facetParameters.bbSize = data.bbSize;
  83497. data.facetParameters.subDiv = data.subDiv;
  83498. data.facetParameters.ratio = this.partitioningBBoxRatio;
  83499. data.facetParameters.depthSort = data.facetDepthSort;
  83500. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  83501. this.computeWorldMatrix(true);
  83502. this._worldMatrix.invertToRef(data.invertedMatrix);
  83503. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  83504. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  83505. }
  83506. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  83507. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  83508. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  83509. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  83510. var l = (data.depthSortedIndices.length / 3) | 0;
  83511. for (var f = 0; f < l; f++) {
  83512. var sind = data.depthSortedFacets[f].ind;
  83513. data.depthSortedIndices[f * 3] = indices[sind];
  83514. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  83515. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  83516. }
  83517. this.updateIndices(data.depthSortedIndices, undefined, true);
  83518. }
  83519. return this;
  83520. };
  83521. /**
  83522. * Returns the facetLocalNormals array.
  83523. * The normals are expressed in the mesh local spac
  83524. * @returns an array of Vector3
  83525. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83526. */
  83527. AbstractMesh.prototype.getFacetLocalNormals = function () {
  83528. if (!this._facetData.facetNormals) {
  83529. this.updateFacetData();
  83530. }
  83531. return this._facetData.facetNormals;
  83532. };
  83533. /**
  83534. * Returns the facetLocalPositions array.
  83535. * The facet positions are expressed in the mesh local space
  83536. * @returns an array of Vector3
  83537. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83538. */
  83539. AbstractMesh.prototype.getFacetLocalPositions = function () {
  83540. if (!this._facetData.facetPositions) {
  83541. this.updateFacetData();
  83542. }
  83543. return this._facetData.facetPositions;
  83544. };
  83545. /**
  83546. * Returns the facetLocalPartioning array
  83547. * @returns an array of array of numbers
  83548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83549. */
  83550. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  83551. if (!this._facetData.facetPartitioning) {
  83552. this.updateFacetData();
  83553. }
  83554. return this._facetData.facetPartitioning;
  83555. };
  83556. /**
  83557. * Returns the i-th facet position in the world system.
  83558. * This method allocates a new Vector3 per call
  83559. * @param i defines the facet index
  83560. * @returns a new Vector3
  83561. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83562. */
  83563. AbstractMesh.prototype.getFacetPosition = function (i) {
  83564. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83565. this.getFacetPositionToRef(i, pos);
  83566. return pos;
  83567. };
  83568. /**
  83569. * Sets the reference Vector3 with the i-th facet position in the world system
  83570. * @param i defines the facet index
  83571. * @param ref defines the target vector
  83572. * @returns the current mesh
  83573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83574. */
  83575. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  83576. var localPos = (this.getFacetLocalPositions())[i];
  83577. var world = this.getWorldMatrix();
  83578. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  83579. return this;
  83580. };
  83581. /**
  83582. * Returns the i-th facet normal in the world system.
  83583. * This method allocates a new Vector3 per call
  83584. * @param i defines the facet index
  83585. * @returns a new Vector3
  83586. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83587. */
  83588. AbstractMesh.prototype.getFacetNormal = function (i) {
  83589. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83590. this.getFacetNormalToRef(i, norm);
  83591. return norm;
  83592. };
  83593. /**
  83594. * Sets the reference Vector3 with the i-th facet normal in the world system
  83595. * @param i defines the facet index
  83596. * @param ref defines the target vector
  83597. * @returns the current mesh
  83598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83599. */
  83600. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  83601. var localNorm = (this.getFacetLocalNormals())[i];
  83602. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  83603. return this;
  83604. };
  83605. /**
  83606. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  83607. * @param x defines x coordinate
  83608. * @param y defines y coordinate
  83609. * @param z defines z coordinate
  83610. * @returns the array of facet indexes
  83611. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83612. */
  83613. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  83614. var bInfo = this.getBoundingInfo();
  83615. var data = this._facetData;
  83616. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  83617. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  83618. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  83619. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  83620. return null;
  83621. }
  83622. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  83623. };
  83624. /**
  83625. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  83626. * @param projected sets as the (x,y,z) world projection on the facet
  83627. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  83628. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  83629. * @param x defines x coordinate
  83630. * @param y defines y coordinate
  83631. * @param z defines z coordinate
  83632. * @returns the face index if found (or null instead)
  83633. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83634. */
  83635. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  83636. if (checkFace === void 0) { checkFace = false; }
  83637. if (facing === void 0) { facing = true; }
  83638. var world = this.getWorldMatrix();
  83639. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  83640. world.invertToRef(invMat);
  83641. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  83642. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  83643. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  83644. if (projected) {
  83645. // tranform the local computed projected vector to world coordinates
  83646. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  83647. }
  83648. return closest;
  83649. };
  83650. /**
  83651. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  83652. * @param projected sets as the (x,y,z) local projection on the facet
  83653. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  83654. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  83655. * @param x defines x coordinate
  83656. * @param y defines y coordinate
  83657. * @param z defines z coordinate
  83658. * @returns the face index if found (or null instead)
  83659. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83660. */
  83661. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  83662. if (checkFace === void 0) { checkFace = false; }
  83663. if (facing === void 0) { facing = true; }
  83664. var closest = null;
  83665. var tmpx = 0.0;
  83666. var tmpy = 0.0;
  83667. var tmpz = 0.0;
  83668. var d = 0.0; // tmp dot facet normal * facet position
  83669. var t0 = 0.0;
  83670. var projx = 0.0;
  83671. var projy = 0.0;
  83672. var projz = 0.0;
  83673. // Get all the facets in the same partitioning block than (x, y, z)
  83674. var facetPositions = this.getFacetLocalPositions();
  83675. var facetNormals = this.getFacetLocalNormals();
  83676. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  83677. if (!facetsInBlock) {
  83678. return null;
  83679. }
  83680. // Get the closest facet to (x, y, z)
  83681. var shortest = Number.MAX_VALUE; // init distance vars
  83682. var tmpDistance = shortest;
  83683. var fib; // current facet in the block
  83684. var norm; // current facet normal
  83685. var p0; // current facet barycenter position
  83686. // loop on all the facets in the current partitioning block
  83687. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  83688. fib = facetsInBlock[idx];
  83689. norm = facetNormals[fib];
  83690. p0 = facetPositions[fib];
  83691. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  83692. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  83693. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  83694. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  83695. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  83696. projx = x + norm.x * t0;
  83697. projy = y + norm.y * t0;
  83698. projz = z + norm.z * t0;
  83699. tmpx = projx - x;
  83700. tmpy = projy - y;
  83701. tmpz = projz - z;
  83702. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  83703. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  83704. shortest = tmpDistance;
  83705. closest = fib;
  83706. if (projected) {
  83707. projected.x = projx;
  83708. projected.y = projy;
  83709. projected.z = projz;
  83710. }
  83711. }
  83712. }
  83713. }
  83714. return closest;
  83715. };
  83716. /**
  83717. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  83718. * @returns the parameters
  83719. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83720. */
  83721. AbstractMesh.prototype.getFacetDataParameters = function () {
  83722. return this._facetData.facetParameters;
  83723. };
  83724. /**
  83725. * Disables the feature FacetData and frees the related memory
  83726. * @returns the current mesh
  83727. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83728. */
  83729. AbstractMesh.prototype.disableFacetData = function () {
  83730. if (this._facetData.facetDataEnabled) {
  83731. this._facetData.facetDataEnabled = false;
  83732. this._facetData.facetPositions = new Array();
  83733. this._facetData.facetNormals = new Array();
  83734. this._facetData.facetPartitioning = new Array();
  83735. this._facetData.facetParameters = null;
  83736. this._facetData.depthSortedIndices = new Uint32Array(0);
  83737. }
  83738. return this;
  83739. };
  83740. /**
  83741. * Updates the AbstractMesh indices array
  83742. * @param indices defines the data source
  83743. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83744. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  83745. * @returns the current mesh
  83746. */
  83747. AbstractMesh.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  83748. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  83749. return this;
  83750. };
  83751. /**
  83752. * Creates new normals data for the mesh
  83753. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  83754. * @returns the current mesh
  83755. */
  83756. AbstractMesh.prototype.createNormals = function (updatable) {
  83757. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  83758. var indices = this.getIndices();
  83759. var normals;
  83760. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  83761. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  83762. }
  83763. else {
  83764. normals = [];
  83765. }
  83766. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  83767. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  83768. return this;
  83769. };
  83770. /**
  83771. * Align the mesh with a normal
  83772. * @param normal defines the normal to use
  83773. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  83774. * @returns the current mesh
  83775. */
  83776. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  83777. if (!upDirection) {
  83778. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  83779. }
  83780. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  83781. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  83782. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  83783. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  83784. if (this.rotationQuaternion) {
  83785. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  83786. }
  83787. else {
  83788. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  83789. }
  83790. return this;
  83791. };
  83792. /** @hidden */
  83793. AbstractMesh.prototype._checkOcclusionQuery = function () {
  83794. return false;
  83795. };
  83796. /** No occlusion */
  83797. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  83798. /** Occlusion set to optimisitic */
  83799. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  83800. /** Occlusion set to strict */
  83801. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  83802. /** Use an accurante occlusion algorithm */
  83803. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  83804. /** Use a conservative occlusion algorithm */
  83805. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  83806. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  83807. * Test order :
  83808. * Is the bounding sphere outside the frustum ?
  83809. * If not, are the bounding box vertices outside the frustum ?
  83810. * It not, then the cullable object is in the frustum.
  83811. */
  83812. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  83813. /** Culling strategy : Bounding Sphere Only.
  83814. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  83815. * It's also less accurate than the standard because some not visible objects can still be selected.
  83816. * Test : is the bounding sphere outside the frustum ?
  83817. * If not, then the cullable object is in the frustum.
  83818. */
  83819. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  83820. /** Culling strategy : Optimistic Inclusion.
  83821. * This in an inclusion test first, then the standard exclusion test.
  83822. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  83823. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  83824. * Anyway, it's as accurate as the standard strategy.
  83825. * Test :
  83826. * Is the cullable object bounding sphere center in the frustum ?
  83827. * If not, apply the default culling strategy.
  83828. */
  83829. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  83830. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  83831. * This in an inclusion test first, then the bounding sphere only exclusion test.
  83832. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  83833. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  83834. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  83835. * Test :
  83836. * Is the cullable object bounding sphere center in the frustum ?
  83837. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  83838. */
  83839. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  83840. return AbstractMesh;
  83841. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  83842. /***/ }),
  83843. /***/ "./Meshes/buffer.ts":
  83844. /*!**************************!*\
  83845. !*** ./Meshes/buffer.ts ***!
  83846. \**************************/
  83847. /*! exports provided: Buffer, VertexBuffer */
  83848. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83849. "use strict";
  83850. __webpack_require__.r(__webpack_exports__);
  83851. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  83852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  83853. /**
  83854. * Class used to store data that will be store in GPU memory
  83855. */
  83856. var Buffer = /** @class */ (function () {
  83857. /**
  83858. * Constructor
  83859. * @param engine the engine
  83860. * @param data the data to use for this buffer
  83861. * @param updatable whether the data is updatable
  83862. * @param stride the stride (optional)
  83863. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83864. * @param instanced whether the buffer is instanced (optional)
  83865. * @param useBytes set to true if the stride in in bytes (optional)
  83866. */
  83867. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  83868. if (stride === void 0) { stride = 0; }
  83869. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  83870. if (instanced === void 0) { instanced = false; }
  83871. if (useBytes === void 0) { useBytes = false; }
  83872. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  83873. this._engine = engine.getScene().getEngine();
  83874. }
  83875. else {
  83876. this._engine = engine;
  83877. }
  83878. this._updatable = updatable;
  83879. this._instanced = instanced;
  83880. this._data = data;
  83881. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  83882. if (!postponeInternalCreation) { // by default
  83883. this.create();
  83884. }
  83885. }
  83886. /**
  83887. * Create a new VertexBuffer based on the current buffer
  83888. * @param kind defines the vertex buffer kind (position, normal, etc.)
  83889. * @param offset defines offset in the buffer (0 by default)
  83890. * @param size defines the size in floats of attributes (position is 3 for instance)
  83891. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  83892. * @param instanced defines if the vertex buffer contains indexed data
  83893. * @param useBytes defines if the offset and stride are in bytes
  83894. * @returns the new vertex buffer
  83895. */
  83896. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  83897. if (useBytes === void 0) { useBytes = false; }
  83898. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  83899. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  83900. // a lot of these parameters are ignored as they are overriden by the buffer
  83901. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  83902. };
  83903. // Properties
  83904. /**
  83905. * Gets a boolean indicating if the Buffer is updatable?
  83906. * @returns true if the buffer is updatable
  83907. */
  83908. Buffer.prototype.isUpdatable = function () {
  83909. return this._updatable;
  83910. };
  83911. /**
  83912. * Gets current buffer's data
  83913. * @returns a DataArray or null
  83914. */
  83915. Buffer.prototype.getData = function () {
  83916. return this._data;
  83917. };
  83918. /**
  83919. * Gets underlying native buffer
  83920. * @returns underlying native buffer
  83921. */
  83922. Buffer.prototype.getBuffer = function () {
  83923. return this._buffer;
  83924. };
  83925. /**
  83926. * Gets the stride in float32 units (i.e. byte stride / 4).
  83927. * May not be an integer if the byte stride is not divisible by 4.
  83928. * DEPRECATED. Use byteStride instead.
  83929. * @returns the stride in float32 units
  83930. */
  83931. Buffer.prototype.getStrideSize = function () {
  83932. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  83933. };
  83934. // Methods
  83935. /**
  83936. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83937. * @param data defines the data to store
  83938. */
  83939. Buffer.prototype.create = function (data) {
  83940. if (data === void 0) { data = null; }
  83941. if (!data && this._buffer) {
  83942. return; // nothing to do
  83943. }
  83944. data = data || this._data;
  83945. if (!data) {
  83946. return;
  83947. }
  83948. if (!this._buffer) { // create buffer
  83949. if (this._updatable) {
  83950. this._buffer = this._engine.createDynamicVertexBuffer(data);
  83951. this._data = data;
  83952. }
  83953. else {
  83954. this._buffer = this._engine.createVertexBuffer(data);
  83955. }
  83956. }
  83957. else if (this._updatable) { // update buffer
  83958. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  83959. this._data = data;
  83960. }
  83961. };
  83962. /** @hidden */
  83963. Buffer.prototype._rebuild = function () {
  83964. this._buffer = null;
  83965. this.create(this._data);
  83966. };
  83967. /**
  83968. * Update current buffer data
  83969. * @param data defines the data to store
  83970. */
  83971. Buffer.prototype.update = function (data) {
  83972. this.create(data);
  83973. };
  83974. /**
  83975. * Updates the data directly.
  83976. * @param data the new data
  83977. * @param offset the new offset
  83978. * @param vertexCount the vertex count (optional)
  83979. * @param useBytes set to true if the offset is in bytes
  83980. */
  83981. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  83982. if (useBytes === void 0) { useBytes = false; }
  83983. if (!this._buffer) {
  83984. return;
  83985. }
  83986. if (this._updatable) { // update buffer
  83987. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  83988. this._data = null;
  83989. }
  83990. };
  83991. /**
  83992. * Release all resources
  83993. */
  83994. Buffer.prototype.dispose = function () {
  83995. if (!this._buffer) {
  83996. return;
  83997. }
  83998. if (this._engine._releaseBuffer(this._buffer)) {
  83999. this._buffer = null;
  84000. }
  84001. };
  84002. return Buffer;
  84003. }());
  84004. /**
  84005. * Specialized buffer used to store vertex data
  84006. */
  84007. var VertexBuffer = /** @class */ (function () {
  84008. /**
  84009. * Constructor
  84010. * @param engine the engine
  84011. * @param data the data to use for this vertex buffer
  84012. * @param kind the vertex buffer kind
  84013. * @param updatable whether the data is updatable
  84014. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84015. * @param stride the stride (optional)
  84016. * @param instanced whether the buffer is instanced (optional)
  84017. * @param offset the offset of the data (optional)
  84018. * @param size the number of components (optional)
  84019. * @param type the type of the component (optional)
  84020. * @param normalized whether the data contains normalized data (optional)
  84021. * @param useBytes set to true if stride and offset are in bytes (optional)
  84022. */
  84023. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  84024. if (normalized === void 0) { normalized = false; }
  84025. if (useBytes === void 0) { useBytes = false; }
  84026. if (data instanceof Buffer) {
  84027. this._buffer = data;
  84028. this._ownsBuffer = false;
  84029. }
  84030. else {
  84031. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  84032. this._ownsBuffer = true;
  84033. }
  84034. this._kind = kind;
  84035. if (type == undefined) {
  84036. var data_1 = this.getData();
  84037. this.type = VertexBuffer.FLOAT;
  84038. if (data_1 instanceof Int8Array) {
  84039. this.type = VertexBuffer.BYTE;
  84040. }
  84041. else if (data_1 instanceof Uint8Array) {
  84042. this.type = VertexBuffer.UNSIGNED_BYTE;
  84043. }
  84044. else if (data_1 instanceof Int16Array) {
  84045. this.type = VertexBuffer.SHORT;
  84046. }
  84047. else if (data_1 instanceof Uint16Array) {
  84048. this.type = VertexBuffer.UNSIGNED_SHORT;
  84049. }
  84050. else if (data_1 instanceof Int32Array) {
  84051. this.type = VertexBuffer.INT;
  84052. }
  84053. else if (data_1 instanceof Uint32Array) {
  84054. this.type = VertexBuffer.UNSIGNED_INT;
  84055. }
  84056. }
  84057. else {
  84058. this.type = type;
  84059. }
  84060. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  84061. if (useBytes) {
  84062. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  84063. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  84064. this.byteOffset = offset || 0;
  84065. }
  84066. else {
  84067. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  84068. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  84069. this.byteOffset = (offset || 0) * typeByteLength;
  84070. }
  84071. this.normalized = normalized;
  84072. this._instanced = instanced !== undefined ? instanced : false;
  84073. this._instanceDivisor = instanced ? 1 : 0;
  84074. }
  84075. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  84076. /**
  84077. * Gets or sets the instance divisor when in instanced mode
  84078. */
  84079. get: function () {
  84080. return this._instanceDivisor;
  84081. },
  84082. set: function (value) {
  84083. this._instanceDivisor = value;
  84084. if (value == 0) {
  84085. this._instanced = false;
  84086. }
  84087. else {
  84088. this._instanced = true;
  84089. }
  84090. },
  84091. enumerable: true,
  84092. configurable: true
  84093. });
  84094. /** @hidden */
  84095. VertexBuffer.prototype._rebuild = function () {
  84096. if (!this._buffer) {
  84097. return;
  84098. }
  84099. this._buffer._rebuild();
  84100. };
  84101. /**
  84102. * Returns the kind of the VertexBuffer (string)
  84103. * @returns a string
  84104. */
  84105. VertexBuffer.prototype.getKind = function () {
  84106. return this._kind;
  84107. };
  84108. // Properties
  84109. /**
  84110. * Gets a boolean indicating if the VertexBuffer is updatable?
  84111. * @returns true if the buffer is updatable
  84112. */
  84113. VertexBuffer.prototype.isUpdatable = function () {
  84114. return this._buffer.isUpdatable();
  84115. };
  84116. /**
  84117. * Gets current buffer's data
  84118. * @returns a DataArray or null
  84119. */
  84120. VertexBuffer.prototype.getData = function () {
  84121. return this._buffer.getData();
  84122. };
  84123. /**
  84124. * Gets underlying native buffer
  84125. * @returns underlying native buffer
  84126. */
  84127. VertexBuffer.prototype.getBuffer = function () {
  84128. return this._buffer.getBuffer();
  84129. };
  84130. /**
  84131. * Gets the stride in float32 units (i.e. byte stride / 4).
  84132. * May not be an integer if the byte stride is not divisible by 4.
  84133. * DEPRECATED. Use byteStride instead.
  84134. * @returns the stride in float32 units
  84135. */
  84136. VertexBuffer.prototype.getStrideSize = function () {
  84137. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  84138. };
  84139. /**
  84140. * Returns the offset as a multiple of the type byte length.
  84141. * DEPRECATED. Use byteOffset instead.
  84142. * @returns the offset in bytes
  84143. */
  84144. VertexBuffer.prototype.getOffset = function () {
  84145. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  84146. };
  84147. /**
  84148. * Returns the number of components per vertex attribute (integer)
  84149. * @returns the size in float
  84150. */
  84151. VertexBuffer.prototype.getSize = function () {
  84152. return this._size;
  84153. };
  84154. /**
  84155. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  84156. * @returns true if this buffer is instanced
  84157. */
  84158. VertexBuffer.prototype.getIsInstanced = function () {
  84159. return this._instanced;
  84160. };
  84161. /**
  84162. * Returns the instancing divisor, zero for non-instanced (integer).
  84163. * @returns a number
  84164. */
  84165. VertexBuffer.prototype.getInstanceDivisor = function () {
  84166. return this._instanceDivisor;
  84167. };
  84168. // Methods
  84169. /**
  84170. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84171. * @param data defines the data to store
  84172. */
  84173. VertexBuffer.prototype.create = function (data) {
  84174. this._buffer.create(data);
  84175. };
  84176. /**
  84177. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  84178. * This function will create a new buffer if the current one is not updatable
  84179. * @param data defines the data to store
  84180. */
  84181. VertexBuffer.prototype.update = function (data) {
  84182. this._buffer.update(data);
  84183. };
  84184. /**
  84185. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  84186. * Returns the directly updated WebGLBuffer.
  84187. * @param data the new data
  84188. * @param offset the new offset
  84189. * @param useBytes set to true if the offset is in bytes
  84190. */
  84191. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  84192. if (useBytes === void 0) { useBytes = false; }
  84193. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  84194. };
  84195. /**
  84196. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  84197. */
  84198. VertexBuffer.prototype.dispose = function () {
  84199. if (this._ownsBuffer) {
  84200. this._buffer.dispose();
  84201. }
  84202. };
  84203. /**
  84204. * Enumerates each value of this vertex buffer as numbers.
  84205. * @param count the number of values to enumerate
  84206. * @param callback the callback function called for each value
  84207. */
  84208. VertexBuffer.prototype.forEach = function (count, callback) {
  84209. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  84210. };
  84211. /**
  84212. * Deduces the stride given a kind.
  84213. * @param kind The kind string to deduce
  84214. * @returns The deduced stride
  84215. */
  84216. VertexBuffer.DeduceStride = function (kind) {
  84217. switch (kind) {
  84218. case VertexBuffer.UVKind:
  84219. case VertexBuffer.UV2Kind:
  84220. case VertexBuffer.UV3Kind:
  84221. case VertexBuffer.UV4Kind:
  84222. case VertexBuffer.UV5Kind:
  84223. case VertexBuffer.UV6Kind:
  84224. return 2;
  84225. case VertexBuffer.NormalKind:
  84226. case VertexBuffer.PositionKind:
  84227. return 3;
  84228. case VertexBuffer.ColorKind:
  84229. case VertexBuffer.MatricesIndicesKind:
  84230. case VertexBuffer.MatricesIndicesExtraKind:
  84231. case VertexBuffer.MatricesWeightsKind:
  84232. case VertexBuffer.MatricesWeightsExtraKind:
  84233. case VertexBuffer.TangentKind:
  84234. return 4;
  84235. default:
  84236. throw new Error("Invalid kind '" + kind + "'");
  84237. }
  84238. };
  84239. /**
  84240. * Gets the byte length of the given type.
  84241. * @param type the type
  84242. * @returns the number of bytes
  84243. */
  84244. VertexBuffer.GetTypeByteLength = function (type) {
  84245. switch (type) {
  84246. case VertexBuffer.BYTE:
  84247. case VertexBuffer.UNSIGNED_BYTE:
  84248. return 1;
  84249. case VertexBuffer.SHORT:
  84250. case VertexBuffer.UNSIGNED_SHORT:
  84251. return 2;
  84252. case VertexBuffer.INT:
  84253. case VertexBuffer.FLOAT:
  84254. return 4;
  84255. default:
  84256. throw new Error("Invalid type '" + type + "'");
  84257. }
  84258. };
  84259. /**
  84260. * Enumerates each value of the given parameters as numbers.
  84261. * @param data the data to enumerate
  84262. * @param byteOffset the byte offset of the data
  84263. * @param byteStride the byte stride of the data
  84264. * @param componentCount the number of components per element
  84265. * @param componentType the type of the component
  84266. * @param count the total number of components
  84267. * @param normalized whether the data is normalized
  84268. * @param callback the callback function called for each value
  84269. */
  84270. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  84271. if (data instanceof Array) {
  84272. var offset = byteOffset / 4;
  84273. var stride = byteStride / 4;
  84274. for (var index = 0; index < count; index += componentCount) {
  84275. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  84276. callback(data[offset + componentIndex], index + componentIndex);
  84277. }
  84278. offset += stride;
  84279. }
  84280. }
  84281. else {
  84282. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  84283. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  84284. for (var index = 0; index < count; index += componentCount) {
  84285. var componentByteOffset = byteOffset;
  84286. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  84287. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  84288. callback(value, index + componentIndex);
  84289. componentByteOffset += componentByteLength;
  84290. }
  84291. byteOffset += byteStride;
  84292. }
  84293. }
  84294. };
  84295. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  84296. switch (type) {
  84297. case VertexBuffer.BYTE: {
  84298. var value = dataView.getInt8(byteOffset);
  84299. if (normalized) {
  84300. value = Math.max(value / 127, -1);
  84301. }
  84302. return value;
  84303. }
  84304. case VertexBuffer.UNSIGNED_BYTE: {
  84305. var value = dataView.getUint8(byteOffset);
  84306. if (normalized) {
  84307. value = value / 255;
  84308. }
  84309. return value;
  84310. }
  84311. case VertexBuffer.SHORT: {
  84312. var value = dataView.getInt16(byteOffset, true);
  84313. if (normalized) {
  84314. value = Math.max(value / 16383, -1);
  84315. }
  84316. return value;
  84317. }
  84318. case VertexBuffer.UNSIGNED_SHORT: {
  84319. var value = dataView.getUint16(byteOffset, true);
  84320. if (normalized) {
  84321. value = value / 65535;
  84322. }
  84323. return value;
  84324. }
  84325. case VertexBuffer.FLOAT: {
  84326. return dataView.getFloat32(byteOffset, true);
  84327. }
  84328. default: {
  84329. throw new Error("Invalid component type " + type);
  84330. }
  84331. }
  84332. };
  84333. /**
  84334. * The byte type.
  84335. */
  84336. VertexBuffer.BYTE = 5120;
  84337. /**
  84338. * The unsigned byte type.
  84339. */
  84340. VertexBuffer.UNSIGNED_BYTE = 5121;
  84341. /**
  84342. * The short type.
  84343. */
  84344. VertexBuffer.SHORT = 5122;
  84345. /**
  84346. * The unsigned short type.
  84347. */
  84348. VertexBuffer.UNSIGNED_SHORT = 5123;
  84349. /**
  84350. * The integer type.
  84351. */
  84352. VertexBuffer.INT = 5124;
  84353. /**
  84354. * The unsigned integer type.
  84355. */
  84356. VertexBuffer.UNSIGNED_INT = 5125;
  84357. /**
  84358. * The float type.
  84359. */
  84360. VertexBuffer.FLOAT = 5126;
  84361. // Enums
  84362. /**
  84363. * Positions
  84364. */
  84365. VertexBuffer.PositionKind = "position";
  84366. /**
  84367. * Normals
  84368. */
  84369. VertexBuffer.NormalKind = "normal";
  84370. /**
  84371. * Tangents
  84372. */
  84373. VertexBuffer.TangentKind = "tangent";
  84374. /**
  84375. * Texture coordinates
  84376. */
  84377. VertexBuffer.UVKind = "uv";
  84378. /**
  84379. * Texture coordinates 2
  84380. */
  84381. VertexBuffer.UV2Kind = "uv2";
  84382. /**
  84383. * Texture coordinates 3
  84384. */
  84385. VertexBuffer.UV3Kind = "uv3";
  84386. /**
  84387. * Texture coordinates 4
  84388. */
  84389. VertexBuffer.UV4Kind = "uv4";
  84390. /**
  84391. * Texture coordinates 5
  84392. */
  84393. VertexBuffer.UV5Kind = "uv5";
  84394. /**
  84395. * Texture coordinates 6
  84396. */
  84397. VertexBuffer.UV6Kind = "uv6";
  84398. /**
  84399. * Colors
  84400. */
  84401. VertexBuffer.ColorKind = "color";
  84402. /**
  84403. * Matrix indices (for bones)
  84404. */
  84405. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  84406. /**
  84407. * Matrix weights (for bones)
  84408. */
  84409. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  84410. /**
  84411. * Additional matrix indices (for bones)
  84412. */
  84413. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  84414. /**
  84415. * Additional matrix weights (for bones)
  84416. */
  84417. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  84418. return VertexBuffer;
  84419. }());
  84420. /***/ }),
  84421. /***/ "./Meshes/csg.ts":
  84422. /*!***********************!*\
  84423. !*** ./Meshes/csg.ts ***!
  84424. \***********************/
  84425. /*! exports provided: CSG */
  84426. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  84427. "use strict";
  84428. __webpack_require__.r(__webpack_exports__);
  84429. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  84430. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  84431. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  84432. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  84433. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  84434. /**
  84435. * Unique ID when we import meshes from Babylon to CSG
  84436. */
  84437. var currentCSGMeshId = 0;
  84438. /**
  84439. * Represents a vertex of a polygon. Use your own vertex class instead of this
  84440. * one to provide additional features like texture coordinates and vertex
  84441. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  84442. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  84443. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  84444. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  84445. * is not used anywhere else.
  84446. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  84447. */
  84448. var Vertex = /** @class */ (function () {
  84449. /**
  84450. * Initializes the vertex
  84451. * @param pos The position of the vertex
  84452. * @param normal The normal of the vertex
  84453. * @param uv The texture coordinate of the vertex
  84454. */
  84455. function Vertex(
  84456. /**
  84457. * The position of the vertex
  84458. */
  84459. pos,
  84460. /**
  84461. * The normal of the vertex
  84462. */
  84463. normal,
  84464. /**
  84465. * The texture coordinate of the vertex
  84466. */
  84467. uv) {
  84468. this.pos = pos;
  84469. this.normal = normal;
  84470. this.uv = uv;
  84471. }
  84472. /**
  84473. * Make a clone, or deep copy, of the vertex
  84474. * @returns A new Vertex
  84475. */
  84476. Vertex.prototype.clone = function () {
  84477. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  84478. };
  84479. /**
  84480. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  84481. * orientation of a polygon is flipped.
  84482. */
  84483. Vertex.prototype.flip = function () {
  84484. this.normal = this.normal.scale(-1);
  84485. };
  84486. /**
  84487. * Create a new vertex between this vertex and `other` by linearly
  84488. * interpolating all properties using a parameter of `t`. Subclasses should
  84489. * override this to interpolate additional properties.
  84490. * @param other the vertex to interpolate against
  84491. * @param t The factor used to linearly interpolate between the vertices
  84492. */
  84493. Vertex.prototype.interpolate = function (other, t) {
  84494. return new Vertex(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(this.pos, other.pos, t), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(this.normal, other.normal, t), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(this.uv, other.uv, t));
  84495. };
  84496. return Vertex;
  84497. }());
  84498. /**
  84499. * Represents a plane in 3D space.
  84500. */
  84501. var Plane = /** @class */ (function () {
  84502. /**
  84503. * Initializes the plane
  84504. * @param normal The normal for the plane
  84505. * @param w
  84506. */
  84507. function Plane(normal, w) {
  84508. this.normal = normal;
  84509. this.w = w;
  84510. }
  84511. /**
  84512. * Construct a plane from three points
  84513. * @param a Point a
  84514. * @param b Point b
  84515. * @param c Point c
  84516. */
  84517. Plane.FromPoints = function (a, b, c) {
  84518. var v0 = c.subtract(a);
  84519. var v1 = b.subtract(a);
  84520. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  84521. return null;
  84522. }
  84523. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  84524. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  84525. };
  84526. /**
  84527. * Clone, or make a deep copy of the plane
  84528. * @returns a new Plane
  84529. */
  84530. Plane.prototype.clone = function () {
  84531. return new Plane(this.normal.clone(), this.w);
  84532. };
  84533. /**
  84534. * Flip the face of the plane
  84535. */
  84536. Plane.prototype.flip = function () {
  84537. this.normal.scaleInPlace(-1);
  84538. this.w = -this.w;
  84539. };
  84540. /**
  84541. * Split `polygon` by this plane if needed, then put the polygon or polygon
  84542. * fragments in the appropriate lists. Coplanar polygons go into either
  84543. `* coplanarFront` or `coplanarBack` depending on their orientation with
  84544. * respect to this plane. Polygons in front or in back of this plane go into
  84545. * either `front` or `back`
  84546. * @param polygon The polygon to be split
  84547. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  84548. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  84549. * @param front Will contain the polygons in front of the plane
  84550. * @param back Will contain the polygons begind the plane
  84551. */
  84552. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  84553. var COPLANAR = 0;
  84554. var FRONT = 1;
  84555. var BACK = 2;
  84556. var SPANNING = 3;
  84557. // Classify each point as well as the entire polygon into one of the above
  84558. // four classes.
  84559. var polygonType = 0;
  84560. var types = [];
  84561. var i;
  84562. var t;
  84563. for (i = 0; i < polygon.vertices.length; i++) {
  84564. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  84565. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  84566. polygonType |= type;
  84567. types.push(type);
  84568. }
  84569. // Put the polygon in the correct list, splitting it when necessary
  84570. switch (polygonType) {
  84571. case COPLANAR:
  84572. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  84573. break;
  84574. case FRONT:
  84575. front.push(polygon);
  84576. break;
  84577. case BACK:
  84578. back.push(polygon);
  84579. break;
  84580. case SPANNING:
  84581. var f = [], b = [];
  84582. for (i = 0; i < polygon.vertices.length; i++) {
  84583. var j = (i + 1) % polygon.vertices.length;
  84584. var ti = types[i], tj = types[j];
  84585. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  84586. if (ti !== BACK) {
  84587. f.push(vi);
  84588. }
  84589. if (ti !== FRONT) {
  84590. b.push(ti !== BACK ? vi.clone() : vi);
  84591. }
  84592. if ((ti | tj) === SPANNING) {
  84593. t = (this.w - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, vi.pos)) / _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, vj.pos.subtract(vi.pos));
  84594. var v = vi.interpolate(vj, t);
  84595. f.push(v);
  84596. b.push(v.clone());
  84597. }
  84598. }
  84599. var poly;
  84600. if (f.length >= 3) {
  84601. poly = new Polygon(f, polygon.shared);
  84602. if (poly.plane) {
  84603. front.push(poly);
  84604. }
  84605. }
  84606. if (b.length >= 3) {
  84607. poly = new Polygon(b, polygon.shared);
  84608. if (poly.plane) {
  84609. back.push(poly);
  84610. }
  84611. }
  84612. break;
  84613. }
  84614. };
  84615. /**
  84616. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  84617. * point is on the plane
  84618. */
  84619. Plane.EPSILON = 1e-5;
  84620. return Plane;
  84621. }());
  84622. /**
  84623. * Represents a convex polygon. The vertices used to initialize a polygon must
  84624. * be coplanar and form a convex loop.
  84625. *
  84626. * Each convex polygon has a `shared` property, which is shared between all
  84627. * polygons that are clones of each other or were split from the same polygon.
  84628. * This can be used to define per-polygon properties (such as surface color)
  84629. */
  84630. var Polygon = /** @class */ (function () {
  84631. /**
  84632. * Initializes the polygon
  84633. * @param vertices The vertices of the polygon
  84634. * @param shared The properties shared across all polygons
  84635. */
  84636. function Polygon(vertices, shared) {
  84637. this.vertices = vertices;
  84638. this.shared = shared;
  84639. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  84640. }
  84641. /**
  84642. * Clones, or makes a deep copy, or the polygon
  84643. */
  84644. Polygon.prototype.clone = function () {
  84645. var vertices = this.vertices.map(function (v) { return v.clone(); });
  84646. return new Polygon(vertices, this.shared);
  84647. };
  84648. /**
  84649. * Flips the faces of the polygon
  84650. */
  84651. Polygon.prototype.flip = function () {
  84652. this.vertices.reverse().map(function (v) { v.flip(); });
  84653. this.plane.flip();
  84654. };
  84655. return Polygon;
  84656. }());
  84657. /**
  84658. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  84659. * by picking a polygon to split along. That polygon (and all other coplanar
  84660. * polygons) are added directly to that node and the other polygons are added to
  84661. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  84662. * no distinction between internal and leaf nodes
  84663. */
  84664. var Node = /** @class */ (function () {
  84665. /**
  84666. * Initializes the node
  84667. * @param polygons A collection of polygons held in the node
  84668. */
  84669. function Node(polygons) {
  84670. this.plane = null;
  84671. this.front = null;
  84672. this.back = null;
  84673. this.polygons = new Array();
  84674. if (polygons) {
  84675. this.build(polygons);
  84676. }
  84677. }
  84678. /**
  84679. * Clones, or makes a deep copy, of the node
  84680. * @returns The cloned node
  84681. */
  84682. Node.prototype.clone = function () {
  84683. var node = new Node();
  84684. node.plane = this.plane && this.plane.clone();
  84685. node.front = this.front && this.front.clone();
  84686. node.back = this.back && this.back.clone();
  84687. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  84688. return node;
  84689. };
  84690. /**
  84691. * Convert solid space to empty space and empty space to solid space
  84692. */
  84693. Node.prototype.invert = function () {
  84694. for (var i = 0; i < this.polygons.length; i++) {
  84695. this.polygons[i].flip();
  84696. }
  84697. if (this.plane) {
  84698. this.plane.flip();
  84699. }
  84700. if (this.front) {
  84701. this.front.invert();
  84702. }
  84703. if (this.back) {
  84704. this.back.invert();
  84705. }
  84706. var temp = this.front;
  84707. this.front = this.back;
  84708. this.back = temp;
  84709. };
  84710. /**
  84711. * Recursively remove all polygons in `polygons` that are inside this BSP
  84712. * tree.
  84713. * @param polygons Polygons to remove from the BSP
  84714. * @returns Polygons clipped from the BSP
  84715. */
  84716. Node.prototype.clipPolygons = function (polygons) {
  84717. if (!this.plane) {
  84718. return polygons.slice();
  84719. }
  84720. var front = new Array(), back = new Array();
  84721. for (var i = 0; i < polygons.length; i++) {
  84722. this.plane.splitPolygon(polygons[i], front, back, front, back);
  84723. }
  84724. if (this.front) {
  84725. front = this.front.clipPolygons(front);
  84726. }
  84727. if (this.back) {
  84728. back = this.back.clipPolygons(back);
  84729. }
  84730. else {
  84731. back = [];
  84732. }
  84733. return front.concat(back);
  84734. };
  84735. /**
  84736. * Remove all polygons in this BSP tree that are inside the other BSP tree
  84737. * `bsp`.
  84738. * @param bsp BSP containing polygons to remove from this BSP
  84739. */
  84740. Node.prototype.clipTo = function (bsp) {
  84741. this.polygons = bsp.clipPolygons(this.polygons);
  84742. if (this.front) {
  84743. this.front.clipTo(bsp);
  84744. }
  84745. if (this.back) {
  84746. this.back.clipTo(bsp);
  84747. }
  84748. };
  84749. /**
  84750. * Return a list of all polygons in this BSP tree
  84751. * @returns List of all polygons in this BSP tree
  84752. */
  84753. Node.prototype.allPolygons = function () {
  84754. var polygons = this.polygons.slice();
  84755. if (this.front) {
  84756. polygons = polygons.concat(this.front.allPolygons());
  84757. }
  84758. if (this.back) {
  84759. polygons = polygons.concat(this.back.allPolygons());
  84760. }
  84761. return polygons;
  84762. };
  84763. /**
  84764. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  84765. * new polygons are filtered down to the bottom of the tree and become new
  84766. * nodes there. Each set of polygons is partitioned using the first polygon
  84767. * (no heuristic is used to pick a good split)
  84768. * @param polygons Polygons used to construct the BSP tree
  84769. */
  84770. Node.prototype.build = function (polygons) {
  84771. if (!polygons.length) {
  84772. return;
  84773. }
  84774. if (!this.plane) {
  84775. this.plane = polygons[0].plane.clone();
  84776. }
  84777. var front = new Array(), back = new Array();
  84778. for (var i = 0; i < polygons.length; i++) {
  84779. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  84780. }
  84781. if (front.length) {
  84782. if (!this.front) {
  84783. this.front = new Node();
  84784. }
  84785. this.front.build(front);
  84786. }
  84787. if (back.length) {
  84788. if (!this.back) {
  84789. this.back = new Node();
  84790. }
  84791. this.back.build(back);
  84792. }
  84793. };
  84794. return Node;
  84795. }());
  84796. /**
  84797. * Class for building Constructive Solid Geometry
  84798. */
  84799. var CSG = /** @class */ (function () {
  84800. function CSG() {
  84801. this.polygons = new Array();
  84802. }
  84803. /**
  84804. * Convert the Mesh to CSG
  84805. * @param mesh The Mesh to convert to CSG
  84806. * @returns A new CSG from the Mesh
  84807. */
  84808. CSG.FromMesh = function (mesh) {
  84809. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  84810. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  84811. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  84812. mesh.computeWorldMatrix(true);
  84813. matrix = mesh.getWorldMatrix();
  84814. meshPosition = mesh.position.clone();
  84815. meshRotation = mesh.rotation.clone();
  84816. if (mesh.rotationQuaternion) {
  84817. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  84818. }
  84819. meshScaling = mesh.scaling.clone();
  84820. }
  84821. else {
  84822. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  84823. }
  84824. var indices = mesh.getIndices(), positions = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind), normals = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind), uvs = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  84825. var subMeshes = mesh.subMeshes;
  84826. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  84827. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  84828. vertices = [];
  84829. for (var j = 0; j < 3; j++) {
  84830. var sourceNormal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[indices[i + j] * 3], normals[indices[i + j] * 3 + 1], normals[indices[i + j] * 3 + 2]);
  84831. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  84832. var sourcePosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[indices[i + j] * 3], positions[indices[i + j] * 3 + 1], positions[indices[i + j] * 3 + 2]);
  84833. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  84834. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  84835. vertex = new Vertex(position, normal, uv);
  84836. vertices.push(vertex);
  84837. }
  84838. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  84839. // To handle the case of degenerated triangle
  84840. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  84841. if (polygon.plane) {
  84842. polygons.push(polygon);
  84843. }
  84844. }
  84845. }
  84846. var csg = CSG.FromPolygons(polygons);
  84847. csg.matrix = matrix;
  84848. csg.position = meshPosition;
  84849. csg.rotation = meshRotation;
  84850. csg.scaling = meshScaling;
  84851. csg.rotationQuaternion = meshRotationQuaternion;
  84852. currentCSGMeshId++;
  84853. return csg;
  84854. };
  84855. /**
  84856. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  84857. * @param polygons Polygons used to construct a CSG solid
  84858. */
  84859. CSG.FromPolygons = function (polygons) {
  84860. var csg = new CSG();
  84861. csg.polygons = polygons;
  84862. return csg;
  84863. };
  84864. /**
  84865. * Clones, or makes a deep copy, of the CSG
  84866. * @returns A new CSG
  84867. */
  84868. CSG.prototype.clone = function () {
  84869. var csg = new CSG();
  84870. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  84871. csg.copyTransformAttributes(this);
  84872. return csg;
  84873. };
  84874. /**
  84875. * Unions this CSG with another CSG
  84876. * @param csg The CSG to union against this CSG
  84877. * @returns The unioned CSG
  84878. */
  84879. CSG.prototype.union = function (csg) {
  84880. var a = new Node(this.clone().polygons);
  84881. var b = new Node(csg.clone().polygons);
  84882. a.clipTo(b);
  84883. b.clipTo(a);
  84884. b.invert();
  84885. b.clipTo(a);
  84886. b.invert();
  84887. a.build(b.allPolygons());
  84888. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  84889. };
  84890. /**
  84891. * Unions this CSG with another CSG in place
  84892. * @param csg The CSG to union against this CSG
  84893. */
  84894. CSG.prototype.unionInPlace = function (csg) {
  84895. var a = new Node(this.polygons);
  84896. var b = new Node(csg.polygons);
  84897. a.clipTo(b);
  84898. b.clipTo(a);
  84899. b.invert();
  84900. b.clipTo(a);
  84901. b.invert();
  84902. a.build(b.allPolygons());
  84903. this.polygons = a.allPolygons();
  84904. };
  84905. /**
  84906. * Subtracts this CSG with another CSG
  84907. * @param csg The CSG to subtract against this CSG
  84908. * @returns A new CSG
  84909. */
  84910. CSG.prototype.subtract = function (csg) {
  84911. var a = new Node(this.clone().polygons);
  84912. var b = new Node(csg.clone().polygons);
  84913. a.invert();
  84914. a.clipTo(b);
  84915. b.clipTo(a);
  84916. b.invert();
  84917. b.clipTo(a);
  84918. b.invert();
  84919. a.build(b.allPolygons());
  84920. a.invert();
  84921. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  84922. };
  84923. /**
  84924. * Subtracts this CSG with another CSG in place
  84925. * @param csg The CSG to subtact against this CSG
  84926. */
  84927. CSG.prototype.subtractInPlace = function (csg) {
  84928. var a = new Node(this.polygons);
  84929. var b = new Node(csg.polygons);
  84930. a.invert();
  84931. a.clipTo(b);
  84932. b.clipTo(a);
  84933. b.invert();
  84934. b.clipTo(a);
  84935. b.invert();
  84936. a.build(b.allPolygons());
  84937. a.invert();
  84938. this.polygons = a.allPolygons();
  84939. };
  84940. /**
  84941. * Intersect this CSG with another CSG
  84942. * @param csg The CSG to intersect against this CSG
  84943. * @returns A new CSG
  84944. */
  84945. CSG.prototype.intersect = function (csg) {
  84946. var a = new Node(this.clone().polygons);
  84947. var b = new Node(csg.clone().polygons);
  84948. a.invert();
  84949. b.clipTo(a);
  84950. b.invert();
  84951. a.clipTo(b);
  84952. b.clipTo(a);
  84953. a.build(b.allPolygons());
  84954. a.invert();
  84955. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  84956. };
  84957. /**
  84958. * Intersects this CSG with another CSG in place
  84959. * @param csg The CSG to intersect against this CSG
  84960. */
  84961. CSG.prototype.intersectInPlace = function (csg) {
  84962. var a = new Node(this.polygons);
  84963. var b = new Node(csg.polygons);
  84964. a.invert();
  84965. b.clipTo(a);
  84966. b.invert();
  84967. a.clipTo(b);
  84968. b.clipTo(a);
  84969. a.build(b.allPolygons());
  84970. a.invert();
  84971. this.polygons = a.allPolygons();
  84972. };
  84973. /**
  84974. * Return a new CSG solid with solid and empty space switched. This solid is
  84975. * not modified.
  84976. * @returns A new CSG solid with solid and empty space switched
  84977. */
  84978. CSG.prototype.inverse = function () {
  84979. var csg = this.clone();
  84980. csg.inverseInPlace();
  84981. return csg;
  84982. };
  84983. /**
  84984. * Inverses the CSG in place
  84985. */
  84986. CSG.prototype.inverseInPlace = function () {
  84987. this.polygons.map(function (p) { p.flip(); });
  84988. };
  84989. /**
  84990. * This is used to keep meshes transformations so they can be restored
  84991. * when we build back a Babylon Mesh
  84992. * NB : All CSG operations are performed in world coordinates
  84993. * @param csg The CSG to copy the transform attributes from
  84994. * @returns This CSG
  84995. */
  84996. CSG.prototype.copyTransformAttributes = function (csg) {
  84997. this.matrix = csg.matrix;
  84998. this.position = csg.position;
  84999. this.rotation = csg.rotation;
  85000. this.scaling = csg.scaling;
  85001. this.rotationQuaternion = csg.rotationQuaternion;
  85002. return this;
  85003. };
  85004. /**
  85005. * Build Raw mesh from CSG
  85006. * Coordinates here are in world space
  85007. * @param name The name of the mesh geometry
  85008. * @param scene The Scene
  85009. * @param keepSubMeshes Specifies if the submeshes should be kept
  85010. * @returns A new Mesh
  85011. */
  85012. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  85013. var matrix = this.matrix.clone();
  85014. matrix.invert();
  85015. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene), vertices = [], indices = [], normals = [], uvs = [], vertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), uv = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), polygons = this.polygons, polygonIndices = [0, 0, 0], polygon, vertice_dict = {}, vertex_idx, currentIndex = 0, subMesh_dict = {}, subMesh_obj;
  85016. if (keepSubMeshes) {
  85017. // Sort Polygons, since subMeshes are indices range
  85018. polygons.sort(function (a, b) {
  85019. if (a.shared.meshId === b.shared.meshId) {
  85020. return a.shared.subMeshId - b.shared.subMeshId;
  85021. }
  85022. else {
  85023. return a.shared.meshId - b.shared.meshId;
  85024. }
  85025. });
  85026. }
  85027. for (var i = 0, il = polygons.length; i < il; i++) {
  85028. polygon = polygons[i];
  85029. // Building SubMeshes
  85030. if (!subMesh_dict[polygon.shared.meshId]) {
  85031. subMesh_dict[polygon.shared.meshId] = {};
  85032. }
  85033. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  85034. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  85035. indexStart: +Infinity,
  85036. indexEnd: -Infinity,
  85037. materialIndex: polygon.shared.materialIndex
  85038. };
  85039. }
  85040. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  85041. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  85042. polygonIndices[0] = 0;
  85043. polygonIndices[1] = j - 1;
  85044. polygonIndices[2] = j;
  85045. for (var k = 0; k < 3; k++) {
  85046. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  85047. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  85048. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  85049. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  85050. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  85051. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  85052. // Check if 2 points can be merged
  85053. if (!(typeof vertex_idx !== 'undefined' &&
  85054. normals[vertex_idx * 3] === localNormal.x &&
  85055. normals[vertex_idx * 3 + 1] === localNormal.y &&
  85056. normals[vertex_idx * 3 + 2] === localNormal.z &&
  85057. uvs[vertex_idx * 2] === uv.x &&
  85058. uvs[vertex_idx * 2 + 1] === uv.y)) {
  85059. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  85060. uvs.push(uv.x, uv.y);
  85061. normals.push(normal.x, normal.y, normal.z);
  85062. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  85063. }
  85064. indices.push(vertex_idx);
  85065. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  85066. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  85067. currentIndex++;
  85068. }
  85069. }
  85070. }
  85071. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  85072. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  85073. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  85074. mesh.setIndices(indices, null);
  85075. if (keepSubMeshes) {
  85076. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  85077. var materialIndexOffset = 0, materialMaxIndex;
  85078. mesh.subMeshes = new Array();
  85079. for (var m in subMesh_dict) {
  85080. materialMaxIndex = -1;
  85081. for (var sm in subMesh_dict[m]) {
  85082. subMesh_obj = subMesh_dict[m][sm];
  85083. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  85084. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  85085. }
  85086. materialIndexOffset += ++materialMaxIndex;
  85087. }
  85088. }
  85089. return mesh;
  85090. };
  85091. /**
  85092. * Build Mesh from CSG taking material and transforms into account
  85093. * @param name The name of the Mesh
  85094. * @param material The material of the Mesh
  85095. * @param scene The Scene
  85096. * @param keepSubMeshes Specifies if submeshes should be kept
  85097. * @returns The new Mesh
  85098. */
  85099. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  85100. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  85101. mesh.material = material;
  85102. mesh.position.copyFrom(this.position);
  85103. mesh.rotation.copyFrom(this.rotation);
  85104. if (this.rotationQuaternion) {
  85105. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  85106. }
  85107. mesh.scaling.copyFrom(this.scaling);
  85108. mesh.computeWorldMatrix(true);
  85109. return mesh;
  85110. };
  85111. return CSG;
  85112. }());
  85113. /***/ }),
  85114. /***/ "./Meshes/geometry.ts":
  85115. /*!****************************!*\
  85116. !*** ./Meshes/geometry.ts ***!
  85117. \****************************/
  85118. /*! exports provided: Geometry */
  85119. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85120. "use strict";
  85121. __webpack_require__.r(__webpack_exports__);
  85122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  85123. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  85124. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  85125. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  85126. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  85127. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  85128. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  85129. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  85130. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  85131. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  85132. /**
  85133. * Class used to store geometry data (vertex buffers + index buffer)
  85134. */
  85135. var Geometry = /** @class */ (function () {
  85136. /**
  85137. * Creates a new geometry
  85138. * @param id defines the unique ID
  85139. * @param scene defines the hosting scene
  85140. * @param vertexData defines the VertexData used to get geometry data
  85141. * @param updatable defines if geometry must be updatable (false by default)
  85142. * @param mesh defines the mesh that will be associated with the geometry
  85143. */
  85144. function Geometry(id, scene, vertexData, updatable, mesh) {
  85145. if (updatable === void 0) { updatable = false; }
  85146. if (mesh === void 0) { mesh = null; }
  85147. /**
  85148. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85149. */
  85150. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  85151. this._totalVertices = 0;
  85152. this._isDisposed = false;
  85153. this._indexBufferIsUpdatable = false;
  85154. this.id = id;
  85155. this.uniqueId = scene.getUniqueId();
  85156. this._engine = scene.getEngine();
  85157. this._meshes = [];
  85158. this._scene = scene;
  85159. //Init vertex buffer cache
  85160. this._vertexBuffers = {};
  85161. this._indices = [];
  85162. this._updatable = updatable;
  85163. // vertexData
  85164. if (vertexData) {
  85165. this.setAllVerticesData(vertexData, updatable);
  85166. }
  85167. else {
  85168. this._totalVertices = 0;
  85169. this._indices = [];
  85170. }
  85171. if (this._engine.getCaps().vertexArrayObject) {
  85172. this._vertexArrayObjects = {};
  85173. }
  85174. // applyToMesh
  85175. if (mesh) {
  85176. this.applyToMesh(mesh);
  85177. mesh.computeWorldMatrix(true);
  85178. }
  85179. }
  85180. Object.defineProperty(Geometry.prototype, "boundingBias", {
  85181. /**
  85182. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  85183. */
  85184. get: function () {
  85185. return this._boundingBias;
  85186. },
  85187. /**
  85188. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  85189. */
  85190. set: function (value) {
  85191. if (this._boundingBias) {
  85192. this._boundingBias.copyFrom(value);
  85193. }
  85194. else {
  85195. this._boundingBias = value.clone();
  85196. }
  85197. this._updateBoundingInfo(true, null);
  85198. },
  85199. enumerable: true,
  85200. configurable: true
  85201. });
  85202. /**
  85203. * Static function used to attach a new empty geometry to a mesh
  85204. * @param mesh defines the mesh to attach the geometry to
  85205. * @returns the new Geometry
  85206. */
  85207. Geometry.CreateGeometryForMesh = function (mesh) {
  85208. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  85209. geometry.applyToMesh(mesh);
  85210. return geometry;
  85211. };
  85212. Object.defineProperty(Geometry.prototype, "extend", {
  85213. /**
  85214. * Gets the current extend of the geometry
  85215. */
  85216. get: function () {
  85217. return this._extend;
  85218. },
  85219. enumerable: true,
  85220. configurable: true
  85221. });
  85222. /**
  85223. * Gets the hosting scene
  85224. * @returns the hosting Scene
  85225. */
  85226. Geometry.prototype.getScene = function () {
  85227. return this._scene;
  85228. };
  85229. /**
  85230. * Gets the hosting engine
  85231. * @returns the hosting Engine
  85232. */
  85233. Geometry.prototype.getEngine = function () {
  85234. return this._engine;
  85235. };
  85236. /**
  85237. * Defines if the geometry is ready to use
  85238. * @returns true if the geometry is ready to be used
  85239. */
  85240. Geometry.prototype.isReady = function () {
  85241. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  85242. };
  85243. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  85244. /**
  85245. * Gets a value indicating that the geometry should not be serialized
  85246. */
  85247. get: function () {
  85248. for (var index = 0; index < this._meshes.length; index++) {
  85249. if (!this._meshes[index].doNotSerialize) {
  85250. return false;
  85251. }
  85252. }
  85253. return true;
  85254. },
  85255. enumerable: true,
  85256. configurable: true
  85257. });
  85258. /** @hidden */
  85259. Geometry.prototype._rebuild = function () {
  85260. if (this._vertexArrayObjects) {
  85261. this._vertexArrayObjects = {};
  85262. }
  85263. // Index buffer
  85264. if (this._meshes.length !== 0 && this._indices) {
  85265. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  85266. }
  85267. // Vertex buffers
  85268. for (var key in this._vertexBuffers) {
  85269. var vertexBuffer = this._vertexBuffers[key];
  85270. vertexBuffer._rebuild();
  85271. }
  85272. };
  85273. /**
  85274. * Affects all geometry data in one call
  85275. * @param vertexData defines the geometry data
  85276. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85277. */
  85278. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  85279. vertexData.applyToGeometry(this, updatable);
  85280. this.notifyUpdate();
  85281. };
  85282. /**
  85283. * Set specific vertex data
  85284. * @param kind defines the data kind (Position, normal, etc...)
  85285. * @param data defines the vertex data to use
  85286. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85287. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85288. */
  85289. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  85290. if (updatable === void 0) { updatable = false; }
  85291. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  85292. this.setVerticesBuffer(buffer);
  85293. };
  85294. /**
  85295. * Removes a specific vertex data
  85296. * @param kind defines the data kind (Position, normal, etc...)
  85297. */
  85298. Geometry.prototype.removeVerticesData = function (kind) {
  85299. if (this._vertexBuffers[kind]) {
  85300. this._vertexBuffers[kind].dispose();
  85301. delete this._vertexBuffers[kind];
  85302. }
  85303. };
  85304. /**
  85305. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85306. * @param buffer defines the vertex buffer to use
  85307. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85308. */
  85309. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  85310. if (totalVertices === void 0) { totalVertices = null; }
  85311. var kind = buffer.getKind();
  85312. if (this._vertexBuffers[kind]) {
  85313. this._vertexBuffers[kind].dispose();
  85314. }
  85315. this._vertexBuffers[kind] = buffer;
  85316. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  85317. var data = buffer.getData();
  85318. if (totalVertices != null) {
  85319. this._totalVertices = totalVertices;
  85320. }
  85321. else {
  85322. if (data != null) {
  85323. this._totalVertices = data.length / (buffer.byteStride / 4);
  85324. }
  85325. }
  85326. this._updateExtend(data);
  85327. this._resetPointsArrayCache();
  85328. var meshes = this._meshes;
  85329. var numOfMeshes = meshes.length;
  85330. for (var index = 0; index < numOfMeshes; index++) {
  85331. var mesh = meshes[index];
  85332. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  85333. mesh._createGlobalSubMesh(false);
  85334. mesh.computeWorldMatrix(true);
  85335. }
  85336. }
  85337. this.notifyUpdate(kind);
  85338. if (this._vertexArrayObjects) {
  85339. this._disposeVertexArrayObjects();
  85340. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  85341. }
  85342. };
  85343. /**
  85344. * Update a specific vertex buffer
  85345. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  85346. * It will do nothing if the buffer is not updatable
  85347. * @param kind defines the data kind (Position, normal, etc...)
  85348. * @param data defines the data to use
  85349. * @param offset defines the offset in the target buffer where to store the data
  85350. * @param useBytes set to true if the offset is in bytes
  85351. */
  85352. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  85353. if (useBytes === void 0) { useBytes = false; }
  85354. var vertexBuffer = this.getVertexBuffer(kind);
  85355. if (!vertexBuffer) {
  85356. return;
  85357. }
  85358. vertexBuffer.updateDirectly(data, offset, useBytes);
  85359. this.notifyUpdate(kind);
  85360. };
  85361. /**
  85362. * Update a specific vertex buffer
  85363. * This function will create a new buffer if the current one is not updatable
  85364. * @param kind defines the data kind (Position, normal, etc...)
  85365. * @param data defines the data to use
  85366. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85367. */
  85368. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  85369. if (updateExtends === void 0) { updateExtends = false; }
  85370. var vertexBuffer = this.getVertexBuffer(kind);
  85371. if (!vertexBuffer) {
  85372. return;
  85373. }
  85374. vertexBuffer.update(data);
  85375. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  85376. this._updateBoundingInfo(updateExtends, data);
  85377. }
  85378. this.notifyUpdate(kind);
  85379. };
  85380. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  85381. if (updateExtends) {
  85382. this._updateExtend(data);
  85383. }
  85384. this._resetPointsArrayCache();
  85385. if (updateExtends) {
  85386. var meshes = this._meshes;
  85387. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  85388. var mesh = meshes_1[_i];
  85389. if (mesh._boundingInfo) {
  85390. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  85391. }
  85392. else {
  85393. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  85394. }
  85395. var subMeshes = mesh.subMeshes;
  85396. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  85397. var subMesh = subMeshes_1[_a];
  85398. subMesh.refreshBoundingInfo();
  85399. }
  85400. }
  85401. }
  85402. };
  85403. /** @hidden */
  85404. Geometry.prototype._bind = function (effect, indexToBind) {
  85405. if (!effect) {
  85406. return;
  85407. }
  85408. if (indexToBind === undefined) {
  85409. indexToBind = this._indexBuffer;
  85410. }
  85411. var vbs = this.getVertexBuffers();
  85412. if (!vbs) {
  85413. return;
  85414. }
  85415. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  85416. this._engine.bindBuffers(vbs, indexToBind, effect);
  85417. return;
  85418. }
  85419. // Using VAO
  85420. if (!this._vertexArrayObjects[effect.key]) {
  85421. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  85422. }
  85423. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  85424. };
  85425. /**
  85426. * Gets total number of vertices
  85427. * @returns the total number of vertices
  85428. */
  85429. Geometry.prototype.getTotalVertices = function () {
  85430. if (!this.isReady()) {
  85431. return 0;
  85432. }
  85433. return this._totalVertices;
  85434. };
  85435. /**
  85436. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85437. * @param kind defines the data kind (Position, normal, etc...)
  85438. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85439. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85440. * @returns a float array containing vertex data
  85441. */
  85442. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  85443. var vertexBuffer = this.getVertexBuffer(kind);
  85444. if (!vertexBuffer) {
  85445. return null;
  85446. }
  85447. var data = vertexBuffer.getData();
  85448. if (!data) {
  85449. return null;
  85450. }
  85451. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  85452. var count = this._totalVertices * vertexBuffer.getSize();
  85453. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  85454. var copy_1 = [];
  85455. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  85456. return copy_1;
  85457. }
  85458. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  85459. if (data instanceof Array) {
  85460. var offset = vertexBuffer.byteOffset / 4;
  85461. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data, offset, offset + count);
  85462. }
  85463. else if (data instanceof ArrayBuffer) {
  85464. return new Float32Array(data, vertexBuffer.byteOffset, count);
  85465. }
  85466. else {
  85467. var offset = data.byteOffset + vertexBuffer.byteOffset;
  85468. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  85469. var result = new Float32Array(count);
  85470. var source = new Float32Array(data.buffer, offset, count);
  85471. result.set(source);
  85472. return result;
  85473. }
  85474. return new Float32Array(data.buffer, offset, count);
  85475. }
  85476. }
  85477. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  85478. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data);
  85479. }
  85480. return data;
  85481. };
  85482. /**
  85483. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85484. * @param kind defines the data kind (Position, normal, etc...)
  85485. * @returns true if the vertex buffer with the specified kind is updatable
  85486. */
  85487. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  85488. var vb = this._vertexBuffers[kind];
  85489. if (!vb) {
  85490. return false;
  85491. }
  85492. return vb.isUpdatable();
  85493. };
  85494. /**
  85495. * Gets a specific vertex buffer
  85496. * @param kind defines the data kind (Position, normal, etc...)
  85497. * @returns a VertexBuffer
  85498. */
  85499. Geometry.prototype.getVertexBuffer = function (kind) {
  85500. if (!this.isReady()) {
  85501. return null;
  85502. }
  85503. return this._vertexBuffers[kind];
  85504. };
  85505. /**
  85506. * Returns all vertex buffers
  85507. * @return an object holding all vertex buffers indexed by kind
  85508. */
  85509. Geometry.prototype.getVertexBuffers = function () {
  85510. if (!this.isReady()) {
  85511. return null;
  85512. }
  85513. return this._vertexBuffers;
  85514. };
  85515. /**
  85516. * Gets a boolean indicating if specific vertex buffer is present
  85517. * @param kind defines the data kind (Position, normal, etc...)
  85518. * @returns true if data is present
  85519. */
  85520. Geometry.prototype.isVerticesDataPresent = function (kind) {
  85521. if (!this._vertexBuffers) {
  85522. if (this._delayInfo) {
  85523. return this._delayInfo.indexOf(kind) !== -1;
  85524. }
  85525. return false;
  85526. }
  85527. return this._vertexBuffers[kind] !== undefined;
  85528. };
  85529. /**
  85530. * Gets a list of all attached data kinds (Position, normal, etc...)
  85531. * @returns a list of string containing all kinds
  85532. */
  85533. Geometry.prototype.getVerticesDataKinds = function () {
  85534. var result = [];
  85535. var kind;
  85536. if (!this._vertexBuffers && this._delayInfo) {
  85537. for (kind in this._delayInfo) {
  85538. result.push(kind);
  85539. }
  85540. }
  85541. else {
  85542. for (kind in this._vertexBuffers) {
  85543. result.push(kind);
  85544. }
  85545. }
  85546. return result;
  85547. };
  85548. /**
  85549. * Update index buffer
  85550. * @param indices defines the indices to store in the index buffer
  85551. * @param offset defines the offset in the target buffer where to store the data
  85552. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  85553. */
  85554. Geometry.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  85555. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  85556. if (!this._indexBuffer) {
  85557. return;
  85558. }
  85559. if (!this._indexBufferIsUpdatable) {
  85560. this.setIndices(indices, null, true);
  85561. }
  85562. else {
  85563. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  85564. if (!gpuMemoryOnly) {
  85565. this._indices = indices.slice();
  85566. }
  85567. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  85568. if (needToUpdateSubMeshes) {
  85569. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  85570. var mesh = _a[_i];
  85571. mesh._createGlobalSubMesh(true);
  85572. }
  85573. }
  85574. }
  85575. };
  85576. /**
  85577. * Creates a new index buffer
  85578. * @param indices defines the indices to store in the index buffer
  85579. * @param totalVertices defines the total number of vertices (could be null)
  85580. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85581. */
  85582. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  85583. if (totalVertices === void 0) { totalVertices = null; }
  85584. if (updatable === void 0) { updatable = false; }
  85585. if (this._indexBuffer) {
  85586. this._engine._releaseBuffer(this._indexBuffer);
  85587. }
  85588. this._disposeVertexArrayObjects();
  85589. this._indices = indices;
  85590. this._indexBufferIsUpdatable = updatable;
  85591. if (this._meshes.length !== 0 && this._indices) {
  85592. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  85593. }
  85594. if (totalVertices != undefined) { // including null and undefined
  85595. this._totalVertices = totalVertices;
  85596. }
  85597. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  85598. var mesh = _a[_i];
  85599. mesh._createGlobalSubMesh(true);
  85600. }
  85601. this.notifyUpdate();
  85602. };
  85603. /**
  85604. * Return the total number of indices
  85605. * @returns the total number of indices
  85606. */
  85607. Geometry.prototype.getTotalIndices = function () {
  85608. if (!this.isReady()) {
  85609. return 0;
  85610. }
  85611. return this._indices.length;
  85612. };
  85613. /**
  85614. * Gets the index buffer array
  85615. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85616. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85617. * @returns the index buffer array
  85618. */
  85619. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  85620. if (!this.isReady()) {
  85621. return null;
  85622. }
  85623. var orig = this._indices;
  85624. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  85625. return orig;
  85626. }
  85627. else {
  85628. var len = orig.length;
  85629. var copy = [];
  85630. for (var i = 0; i < len; i++) {
  85631. copy.push(orig[i]);
  85632. }
  85633. return copy;
  85634. }
  85635. };
  85636. /**
  85637. * Gets the index buffer
  85638. * @return the index buffer
  85639. */
  85640. Geometry.prototype.getIndexBuffer = function () {
  85641. if (!this.isReady()) {
  85642. return null;
  85643. }
  85644. return this._indexBuffer;
  85645. };
  85646. /** @hidden */
  85647. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  85648. if (effect === void 0) { effect = null; }
  85649. if (!effect || !this._vertexArrayObjects) {
  85650. return;
  85651. }
  85652. if (this._vertexArrayObjects[effect.key]) {
  85653. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  85654. delete this._vertexArrayObjects[effect.key];
  85655. }
  85656. };
  85657. /**
  85658. * Release the associated resources for a specific mesh
  85659. * @param mesh defines the source mesh
  85660. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85661. */
  85662. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  85663. var meshes = this._meshes;
  85664. var index = meshes.indexOf(mesh);
  85665. if (index === -1) {
  85666. return;
  85667. }
  85668. meshes.splice(index, 1);
  85669. mesh._geometry = null;
  85670. if (meshes.length === 0 && shouldDispose) {
  85671. this.dispose();
  85672. }
  85673. };
  85674. /**
  85675. * Apply current geometry to a given mesh
  85676. * @param mesh defines the mesh to apply geometry to
  85677. */
  85678. Geometry.prototype.applyToMesh = function (mesh) {
  85679. if (mesh._geometry === this) {
  85680. return;
  85681. }
  85682. var previousGeometry = mesh._geometry;
  85683. if (previousGeometry) {
  85684. previousGeometry.releaseForMesh(mesh);
  85685. }
  85686. var meshes = this._meshes;
  85687. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  85688. mesh._geometry = this;
  85689. this._scene.pushGeometry(this);
  85690. meshes.push(mesh);
  85691. if (this.isReady()) {
  85692. this._applyToMesh(mesh);
  85693. }
  85694. else {
  85695. mesh._boundingInfo = this._boundingInfo;
  85696. }
  85697. };
  85698. Geometry.prototype._updateExtend = function (data) {
  85699. if (data === void 0) { data = null; }
  85700. if (!data) {
  85701. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  85702. }
  85703. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  85704. };
  85705. Geometry.prototype._applyToMesh = function (mesh) {
  85706. var numOfMeshes = this._meshes.length;
  85707. // vertexBuffers
  85708. for (var kind in this._vertexBuffers) {
  85709. if (numOfMeshes === 1) {
  85710. this._vertexBuffers[kind].create();
  85711. }
  85712. var buffer = this._vertexBuffers[kind].getBuffer();
  85713. if (buffer) {
  85714. buffer.references = numOfMeshes;
  85715. }
  85716. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  85717. if (!this._extend) {
  85718. this._updateExtend();
  85719. }
  85720. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  85721. mesh._createGlobalSubMesh(false);
  85722. //bounding info was just created again, world matrix should be applied again.
  85723. mesh._updateBoundingInfo();
  85724. }
  85725. }
  85726. // indexBuffer
  85727. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  85728. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  85729. }
  85730. if (this._indexBuffer) {
  85731. this._indexBuffer.references = numOfMeshes;
  85732. }
  85733. // morphTargets
  85734. mesh._syncGeometryWithMorphTargetManager();
  85735. // instances
  85736. mesh.synchronizeInstances();
  85737. };
  85738. Geometry.prototype.notifyUpdate = function (kind) {
  85739. if (this.onGeometryUpdated) {
  85740. this.onGeometryUpdated(this, kind);
  85741. }
  85742. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  85743. var mesh = _a[_i];
  85744. mesh._markSubMeshesAsAttributesDirty();
  85745. }
  85746. };
  85747. /**
  85748. * Load the geometry if it was flagged as delay loaded
  85749. * @param scene defines the hosting scene
  85750. * @param onLoaded defines a callback called when the geometry is loaded
  85751. */
  85752. Geometry.prototype.load = function (scene, onLoaded) {
  85753. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING) {
  85754. return;
  85755. }
  85756. if (this.isReady()) {
  85757. if (onLoaded) {
  85758. onLoaded();
  85759. }
  85760. return;
  85761. }
  85762. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING;
  85763. this._queueLoad(scene, onLoaded);
  85764. };
  85765. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  85766. var _this = this;
  85767. if (!this.delayLoadingFile) {
  85768. return;
  85769. }
  85770. scene._addPendingData(this);
  85771. scene._loadFile(this.delayLoadingFile, function (data) {
  85772. if (!_this._delayLoadingFunction) {
  85773. return;
  85774. }
  85775. _this._delayLoadingFunction(JSON.parse(data), _this);
  85776. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  85777. _this._delayInfo = [];
  85778. scene._removePendingData(_this);
  85779. var meshes = _this._meshes;
  85780. var numOfMeshes = meshes.length;
  85781. for (var index = 0; index < numOfMeshes; index++) {
  85782. _this._applyToMesh(meshes[index]);
  85783. }
  85784. if (onLoaded) {
  85785. onLoaded();
  85786. }
  85787. }, undefined, true);
  85788. };
  85789. /**
  85790. * Invert the geometry to move from a right handed system to a left handed one.
  85791. */
  85792. Geometry.prototype.toLeftHanded = function () {
  85793. // Flip faces
  85794. var tIndices = this.getIndices(false);
  85795. if (tIndices != null && tIndices.length > 0) {
  85796. for (var i = 0; i < tIndices.length; i += 3) {
  85797. var tTemp = tIndices[i + 0];
  85798. tIndices[i + 0] = tIndices[i + 2];
  85799. tIndices[i + 2] = tTemp;
  85800. }
  85801. this.setIndices(tIndices);
  85802. }
  85803. // Negate position.z
  85804. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, false);
  85805. if (tPositions != null && tPositions.length > 0) {
  85806. for (var i = 0; i < tPositions.length; i += 3) {
  85807. tPositions[i + 2] = -tPositions[i + 2];
  85808. }
  85809. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, tPositions, false);
  85810. }
  85811. // Negate normal.z
  85812. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, false);
  85813. if (tNormals != null && tNormals.length > 0) {
  85814. for (var i = 0; i < tNormals.length; i += 3) {
  85815. tNormals[i + 2] = -tNormals[i + 2];
  85816. }
  85817. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, tNormals, false);
  85818. }
  85819. };
  85820. // Cache
  85821. /** @hidden */
  85822. Geometry.prototype._resetPointsArrayCache = function () {
  85823. this._positions = null;
  85824. };
  85825. /** @hidden */
  85826. Geometry.prototype._generatePointsArray = function () {
  85827. if (this._positions) {
  85828. return true;
  85829. }
  85830. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  85831. if (!data || data.length === 0) {
  85832. return false;
  85833. }
  85834. this._positions = [];
  85835. for (var index = 0; index < data.length; index += 3) {
  85836. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data, index));
  85837. }
  85838. return true;
  85839. };
  85840. /**
  85841. * Gets a value indicating if the geometry is disposed
  85842. * @returns true if the geometry was disposed
  85843. */
  85844. Geometry.prototype.isDisposed = function () {
  85845. return this._isDisposed;
  85846. };
  85847. Geometry.prototype._disposeVertexArrayObjects = function () {
  85848. if (this._vertexArrayObjects) {
  85849. for (var kind in this._vertexArrayObjects) {
  85850. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  85851. }
  85852. this._vertexArrayObjects = {};
  85853. }
  85854. };
  85855. /**
  85856. * Free all associated resources
  85857. */
  85858. Geometry.prototype.dispose = function () {
  85859. var meshes = this._meshes;
  85860. var numOfMeshes = meshes.length;
  85861. var index;
  85862. for (index = 0; index < numOfMeshes; index++) {
  85863. this.releaseForMesh(meshes[index]);
  85864. }
  85865. this._meshes = [];
  85866. this._disposeVertexArrayObjects();
  85867. for (var kind in this._vertexBuffers) {
  85868. this._vertexBuffers[kind].dispose();
  85869. }
  85870. this._vertexBuffers = {};
  85871. this._totalVertices = 0;
  85872. if (this._indexBuffer) {
  85873. this._engine._releaseBuffer(this._indexBuffer);
  85874. }
  85875. this._indexBuffer = null;
  85876. this._indices = [];
  85877. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  85878. this.delayLoadingFile = null;
  85879. this._delayLoadingFunction = null;
  85880. this._delayInfo = [];
  85881. this._boundingInfo = null;
  85882. this._scene.removeGeometry(this);
  85883. this._isDisposed = true;
  85884. };
  85885. /**
  85886. * Clone the current geometry into a new geometry
  85887. * @param id defines the unique ID of the new geometry
  85888. * @returns a new geometry object
  85889. */
  85890. Geometry.prototype.copy = function (id) {
  85891. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  85892. vertexData.indices = [];
  85893. var indices = this.getIndices();
  85894. if (indices) {
  85895. for (var index = 0; index < indices.length; index++) {
  85896. vertexData.indices.push(indices[index]);
  85897. }
  85898. }
  85899. var updatable = false;
  85900. var stopChecking = false;
  85901. var kind;
  85902. for (kind in this._vertexBuffers) {
  85903. // using slice() to make a copy of the array and not just reference it
  85904. var data = this.getVerticesData(kind);
  85905. if (data) {
  85906. if (data instanceof Float32Array) {
  85907. vertexData.set(new Float32Array(data), kind);
  85908. }
  85909. else {
  85910. vertexData.set(data.slice(0), kind);
  85911. }
  85912. if (!stopChecking) {
  85913. var vb = this.getVertexBuffer(kind);
  85914. if (vb) {
  85915. updatable = vb.isUpdatable();
  85916. stopChecking = !updatable;
  85917. }
  85918. }
  85919. }
  85920. }
  85921. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  85922. geometry.delayLoadState = this.delayLoadState;
  85923. geometry.delayLoadingFile = this.delayLoadingFile;
  85924. geometry._delayLoadingFunction = this._delayLoadingFunction;
  85925. for (kind in this._delayInfo) {
  85926. geometry._delayInfo = geometry._delayInfo || [];
  85927. geometry._delayInfo.push(kind);
  85928. }
  85929. // Bounding info
  85930. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  85931. return geometry;
  85932. };
  85933. /**
  85934. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85935. * @return a JSON representation of the current geometry data (without the vertices data)
  85936. */
  85937. Geometry.prototype.serialize = function () {
  85938. var serializationObject = {};
  85939. serializationObject.id = this.id;
  85940. serializationObject.updatable = this._updatable;
  85941. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].HasTags(this)) {
  85942. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].GetTags(this);
  85943. }
  85944. return serializationObject;
  85945. };
  85946. Geometry.prototype.toNumberArray = function (origin) {
  85947. if (Array.isArray(origin)) {
  85948. return origin;
  85949. }
  85950. else {
  85951. return Array.prototype.slice.call(origin);
  85952. }
  85953. };
  85954. /**
  85955. * Serialize all vertices data into a JSON oject
  85956. * @returns a JSON representation of the current geometry data
  85957. */
  85958. Geometry.prototype.serializeVerticeData = function () {
  85959. var serializationObject = this.serialize();
  85960. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  85961. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  85962. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  85963. serializationObject.positions._updatable = true;
  85964. }
  85965. }
  85966. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  85967. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind));
  85968. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  85969. serializationObject.normals._updatable = true;
  85970. }
  85971. }
  85972. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  85973. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind));
  85974. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  85975. serializationObject.tangets._updatable = true;
  85976. }
  85977. }
  85978. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  85979. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind));
  85980. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  85981. serializationObject.uvs._updatable = true;
  85982. }
  85983. }
  85984. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  85985. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind));
  85986. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  85987. serializationObject.uv2s._updatable = true;
  85988. }
  85989. }
  85990. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  85991. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind));
  85992. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  85993. serializationObject.uv3s._updatable = true;
  85994. }
  85995. }
  85996. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  85997. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind));
  85998. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  85999. serializationObject.uv4s._updatable = true;
  86000. }
  86001. }
  86002. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  86003. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind));
  86004. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  86005. serializationObject.uv5s._updatable = true;
  86006. }
  86007. }
  86008. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  86009. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind));
  86010. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  86011. serializationObject.uv6s._updatable = true;
  86012. }
  86013. }
  86014. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  86015. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind));
  86016. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  86017. serializationObject.colors._updatable = true;
  86018. }
  86019. }
  86020. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  86021. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind));
  86022. serializationObject.matricesIndices._isExpanded = true;
  86023. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  86024. serializationObject.matricesIndices._updatable = true;
  86025. }
  86026. }
  86027. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  86028. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind));
  86029. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  86030. serializationObject.matricesWeights._updatable = true;
  86031. }
  86032. }
  86033. serializationObject.indices = this.toNumberArray(this.getIndices());
  86034. return serializationObject;
  86035. };
  86036. // Statics
  86037. /**
  86038. * Extracts a clone of a mesh geometry
  86039. * @param mesh defines the source mesh
  86040. * @param id defines the unique ID of the new geometry object
  86041. * @returns the new geometry object
  86042. */
  86043. Geometry.ExtractFromMesh = function (mesh, id) {
  86044. var geometry = mesh._geometry;
  86045. if (!geometry) {
  86046. return null;
  86047. }
  86048. return geometry.copy(id);
  86049. };
  86050. /**
  86051. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86052. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86053. * Be aware Math.random() could cause collisions, but:
  86054. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  86055. * @returns a string containing a new GUID
  86056. */
  86057. Geometry.RandomId = function () {
  86058. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].RandomId();
  86059. };
  86060. /** @hidden */
  86061. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  86062. var scene = mesh.getScene();
  86063. // Geometry
  86064. var geometryId = parsedGeometry.geometryId;
  86065. if (geometryId) {
  86066. var geometry = scene.getGeometryByID(geometryId);
  86067. if (geometry) {
  86068. geometry.applyToMesh(mesh);
  86069. }
  86070. }
  86071. else if (parsedGeometry instanceof ArrayBuffer) {
  86072. var binaryInfo = mesh._binaryInfo;
  86073. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  86074. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  86075. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positionsData, false);
  86076. }
  86077. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  86078. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  86079. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normalsData, false);
  86080. }
  86081. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  86082. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  86083. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, tangentsData, false);
  86084. }
  86085. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  86086. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  86087. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvsData, false);
  86088. }
  86089. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  86090. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  86091. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, uvs2Data, false);
  86092. }
  86093. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  86094. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  86095. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, uvs3Data, false);
  86096. }
  86097. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  86098. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  86099. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, uvs4Data, false);
  86100. }
  86101. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  86102. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  86103. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, uvs5Data, false);
  86104. }
  86105. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  86106. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  86107. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, uvs6Data, false);
  86108. }
  86109. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  86110. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  86111. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  86112. }
  86113. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  86114. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  86115. var floatIndices = [];
  86116. for (var i = 0; i < matricesIndicesData.length; i++) {
  86117. var index = matricesIndicesData[i];
  86118. floatIndices.push(index & 0x000000FF);
  86119. floatIndices.push((index & 0x0000FF00) >> 8);
  86120. floatIndices.push((index & 0x00FF0000) >> 16);
  86121. floatIndices.push(index >> 24);
  86122. }
  86123. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  86124. }
  86125. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  86126. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  86127. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  86128. }
  86129. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  86130. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  86131. mesh.setIndices(indicesData, null);
  86132. }
  86133. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  86134. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  86135. mesh.subMeshes = [];
  86136. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  86137. var materialIndex = subMeshesData[(i * 5) + 0];
  86138. var verticesStart = subMeshesData[(i * 5) + 1];
  86139. var verticesCount = subMeshesData[(i * 5) + 2];
  86140. var indexStart = subMeshesData[(i * 5) + 3];
  86141. var indexCount = subMeshesData[(i * 5) + 4];
  86142. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  86143. }
  86144. }
  86145. }
  86146. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  86147. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  86148. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  86149. if (parsedGeometry.tangents) {
  86150. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  86151. }
  86152. if (parsedGeometry.uvs) {
  86153. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  86154. }
  86155. if (parsedGeometry.uvs2) {
  86156. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  86157. }
  86158. if (parsedGeometry.uvs3) {
  86159. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  86160. }
  86161. if (parsedGeometry.uvs4) {
  86162. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  86163. }
  86164. if (parsedGeometry.uvs5) {
  86165. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  86166. }
  86167. if (parsedGeometry.uvs6) {
  86168. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  86169. }
  86170. if (parsedGeometry.colors) {
  86171. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(parsedGeometry.colors, parsedGeometry.positions.length / 3), parsedGeometry.colors._updatable);
  86172. }
  86173. if (parsedGeometry.matricesIndices) {
  86174. if (!parsedGeometry.matricesIndices._isExpanded) {
  86175. var floatIndices = [];
  86176. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  86177. var matricesIndex = parsedGeometry.matricesIndices[i];
  86178. floatIndices.push(matricesIndex & 0x000000FF);
  86179. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  86180. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  86181. floatIndices.push(matricesIndex >> 24);
  86182. }
  86183. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  86184. }
  86185. else {
  86186. delete parsedGeometry.matricesIndices._isExpanded;
  86187. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  86188. }
  86189. }
  86190. if (parsedGeometry.matricesIndicesExtra) {
  86191. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  86192. var floatIndices = [];
  86193. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  86194. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  86195. floatIndices.push(matricesIndex & 0x000000FF);
  86196. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  86197. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  86198. floatIndices.push(matricesIndex >> 24);
  86199. }
  86200. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  86201. }
  86202. else {
  86203. delete parsedGeometry.matricesIndices._isExpanded;
  86204. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  86205. }
  86206. }
  86207. if (parsedGeometry.matricesWeights) {
  86208. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  86209. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  86210. }
  86211. if (parsedGeometry.matricesWeightsExtra) {
  86212. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  86213. }
  86214. mesh.setIndices(parsedGeometry.indices, null);
  86215. }
  86216. // SubMeshes
  86217. if (parsedGeometry.subMeshes) {
  86218. mesh.subMeshes = [];
  86219. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  86220. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  86221. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  86222. }
  86223. }
  86224. // Flat shading
  86225. if (mesh._shouldGenerateFlatShading) {
  86226. mesh.convertToFlatShadedMesh();
  86227. delete mesh._shouldGenerateFlatShading;
  86228. }
  86229. // Update
  86230. mesh.computeWorldMatrix(true);
  86231. scene.onMeshImportedObservable.notifyObservers(mesh);
  86232. };
  86233. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  86234. var epsilon = 1e-3;
  86235. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  86236. return;
  86237. }
  86238. var noInfluenceBoneIndex = 0.0;
  86239. if (parsedGeometry.skeletonId > -1) {
  86240. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  86241. if (!skeleton) {
  86242. return;
  86243. }
  86244. noInfluenceBoneIndex = skeleton.bones.length;
  86245. }
  86246. else {
  86247. return;
  86248. }
  86249. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  86250. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  86251. var matricesWeights = parsedGeometry.matricesWeights;
  86252. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  86253. var influencers = parsedGeometry.numBoneInfluencer;
  86254. var size = matricesWeights.length;
  86255. for (var i = 0; i < size; i += 4) {
  86256. var weight = 0.0;
  86257. var firstZeroWeight = -1;
  86258. for (var j = 0; j < 4; j++) {
  86259. var w = matricesWeights[i + j];
  86260. weight += w;
  86261. if (w < epsilon && firstZeroWeight < 0) {
  86262. firstZeroWeight = j;
  86263. }
  86264. }
  86265. if (matricesWeightsExtra) {
  86266. for (var j = 0; j < 4; j++) {
  86267. var w = matricesWeightsExtra[i + j];
  86268. weight += w;
  86269. if (w < epsilon && firstZeroWeight < 0) {
  86270. firstZeroWeight = j + 4;
  86271. }
  86272. }
  86273. }
  86274. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  86275. firstZeroWeight = influencers - 1;
  86276. }
  86277. if (weight > epsilon) {
  86278. var mweight = 1.0 / weight;
  86279. for (var j = 0; j < 4; j++) {
  86280. matricesWeights[i + j] *= mweight;
  86281. }
  86282. if (matricesWeightsExtra) {
  86283. for (var j = 0; j < 4; j++) {
  86284. matricesWeightsExtra[i + j] *= mweight;
  86285. }
  86286. }
  86287. }
  86288. else {
  86289. if (firstZeroWeight >= 4) {
  86290. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  86291. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  86292. }
  86293. else {
  86294. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  86295. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  86296. }
  86297. }
  86298. }
  86299. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  86300. if (parsedGeometry.matricesWeightsExtra) {
  86301. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  86302. }
  86303. };
  86304. /**
  86305. * Create a new geometry from persisted data (Using .babylon file format)
  86306. * @param parsedVertexData defines the persisted data
  86307. * @param scene defines the hosting scene
  86308. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86309. * @returns the new geometry object
  86310. */
  86311. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  86312. if (scene.getGeometryByID(parsedVertexData.id)) {
  86313. return null; // null since geometry could be something else than a box...
  86314. }
  86315. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  86316. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"]) {
  86317. _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  86318. }
  86319. if (parsedVertexData.delayLoadingFile) {
  86320. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  86321. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  86322. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(parsedVertexData.boundingBoxMinimum), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(parsedVertexData.boundingBoxMaximum));
  86323. geometry._delayInfo = [];
  86324. if (parsedVertexData.hasUVs) {
  86325. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  86326. }
  86327. if (parsedVertexData.hasUVs2) {
  86328. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  86329. }
  86330. if (parsedVertexData.hasUVs3) {
  86331. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind);
  86332. }
  86333. if (parsedVertexData.hasUVs4) {
  86334. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind);
  86335. }
  86336. if (parsedVertexData.hasUVs5) {
  86337. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind);
  86338. }
  86339. if (parsedVertexData.hasUVs6) {
  86340. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind);
  86341. }
  86342. if (parsedVertexData.hasColors) {
  86343. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  86344. }
  86345. if (parsedVertexData.hasMatricesIndices) {
  86346. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  86347. }
  86348. if (parsedVertexData.hasMatricesWeights) {
  86349. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  86350. }
  86351. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData;
  86352. }
  86353. else {
  86354. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  86355. }
  86356. scene.pushGeometry(geometry, true);
  86357. return geometry;
  86358. };
  86359. return Geometry;
  86360. }());
  86361. /***/ }),
  86362. /***/ "./Meshes/groundMesh.ts":
  86363. /*!******************************!*\
  86364. !*** ./Meshes/groundMesh.ts ***!
  86365. \******************************/
  86366. /*! exports provided: GroundMesh */
  86367. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86368. "use strict";
  86369. __webpack_require__.r(__webpack_exports__);
  86370. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  86371. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  86372. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  86373. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  86374. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  86375. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  86376. return GroundMesh.Parse(parsedMesh, scene);
  86377. };
  86378. /**
  86379. * Mesh representing the gorund
  86380. */
  86381. var GroundMesh = /** @class */ (function (_super) {
  86382. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  86383. function GroundMesh(name, scene) {
  86384. var _this = _super.call(this, name, scene) || this;
  86385. /** If octree should be generated */
  86386. _this.generateOctree = false;
  86387. return _this;
  86388. }
  86389. /**
  86390. * "GroundMesh"
  86391. * @returns "GroundMesh"
  86392. */
  86393. GroundMesh.prototype.getClassName = function () {
  86394. return "GroundMesh";
  86395. };
  86396. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  86397. /**
  86398. * The minimum of x and y subdivisions
  86399. */
  86400. get: function () {
  86401. return Math.min(this._subdivisionsX, this._subdivisionsY);
  86402. },
  86403. enumerable: true,
  86404. configurable: true
  86405. });
  86406. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  86407. /**
  86408. * X subdivisions
  86409. */
  86410. get: function () {
  86411. return this._subdivisionsX;
  86412. },
  86413. enumerable: true,
  86414. configurable: true
  86415. });
  86416. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  86417. /**
  86418. * Y subdivisions
  86419. */
  86420. get: function () {
  86421. return this._subdivisionsY;
  86422. },
  86423. enumerable: true,
  86424. configurable: true
  86425. });
  86426. /**
  86427. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  86428. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  86429. * @param chunksCount the number of subdivisions for x and y
  86430. * @param octreeBlocksSize (Default: 32)
  86431. */
  86432. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  86433. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  86434. this._subdivisionsX = chunksCount;
  86435. this._subdivisionsY = chunksCount;
  86436. this.subdivide(chunksCount);
  86437. // Call the octree system optimization if it is defined.
  86438. var thisAsAny = this;
  86439. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  86440. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  86441. }
  86442. };
  86443. /**
  86444. * Returns a height (y) value in the Worl system :
  86445. * the ground altitude at the coordinates (x, z) expressed in the World system.
  86446. * @param x x coordinate
  86447. * @param z z coordinate
  86448. * @returns the ground y position if (x, z) are outside the ground surface.
  86449. */
  86450. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  86451. var world = this.getWorldMatrix();
  86452. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  86453. world.invertToRef(invMat);
  86454. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  86455. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  86456. x = tmpVect.x;
  86457. z = tmpVect.z;
  86458. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  86459. return this.position.y;
  86460. }
  86461. if (!this._heightQuads || this._heightQuads.length == 0) {
  86462. this._initHeightQuads();
  86463. this._computeHeightQuads();
  86464. }
  86465. var facet = this._getFacetAt(x, z);
  86466. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  86467. // return y in the World system
  86468. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  86469. return tmpVect.y;
  86470. };
  86471. /**
  86472. * Returns a normalized vector (Vector3) orthogonal to the ground
  86473. * at the ground coordinates (x, z) expressed in the World system.
  86474. * @param x x coordinate
  86475. * @param z z coordinate
  86476. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  86477. */
  86478. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  86479. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  86480. this.getNormalAtCoordinatesToRef(x, z, normal);
  86481. return normal;
  86482. };
  86483. /**
  86484. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  86485. * at the ground coordinates (x, z) expressed in the World system.
  86486. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  86487. * @param x x coordinate
  86488. * @param z z coordinate
  86489. * @param ref vector to store the result
  86490. * @returns the GroundMesh.
  86491. */
  86492. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  86493. var world = this.getWorldMatrix();
  86494. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  86495. world.invertToRef(tmpMat);
  86496. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  86497. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  86498. x = tmpVect.x;
  86499. z = tmpVect.z;
  86500. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  86501. return this;
  86502. }
  86503. if (!this._heightQuads || this._heightQuads.length == 0) {
  86504. this._initHeightQuads();
  86505. this._computeHeightQuads();
  86506. }
  86507. var facet = this._getFacetAt(x, z);
  86508. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  86509. return this;
  86510. };
  86511. /**
  86512. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  86513. * if the ground has been updated.
  86514. * This can be used in the render loop.
  86515. * @returns the GroundMesh.
  86516. */
  86517. GroundMesh.prototype.updateCoordinateHeights = function () {
  86518. if (!this._heightQuads || this._heightQuads.length == 0) {
  86519. this._initHeightQuads();
  86520. }
  86521. this._computeHeightQuads();
  86522. return this;
  86523. };
  86524. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  86525. GroundMesh.prototype._getFacetAt = function (x, z) {
  86526. // retrieve col and row from x, z coordinates in the ground local system
  86527. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  86528. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  86529. var quad = this._heightQuads[row * this._subdivisionsX + col];
  86530. var facet;
  86531. if (z < quad.slope.x * x + quad.slope.y) {
  86532. facet = quad.facet1;
  86533. }
  86534. else {
  86535. facet = quad.facet2;
  86536. }
  86537. return facet;
  86538. };
  86539. // Creates and populates the heightMap array with "facet" elements :
  86540. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  86541. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  86542. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  86543. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  86544. // Returns the GroundMesh.
  86545. GroundMesh.prototype._initHeightQuads = function () {
  86546. var subdivisionsX = this._subdivisionsX;
  86547. var subdivisionsY = this._subdivisionsY;
  86548. this._heightQuads = new Array();
  86549. for (var row = 0; row < subdivisionsY; row++) {
  86550. for (var col = 0; col < subdivisionsX; col++) {
  86551. var quad = { slope: _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero(), facet1: new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0.0, 0.0, 0.0, 0.0), facet2: new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0.0, 0.0, 0.0, 0.0) };
  86552. this._heightQuads[row * subdivisionsX + col] = quad;
  86553. }
  86554. }
  86555. return this;
  86556. };
  86557. // Compute each quad element values and update the the heightMap array :
  86558. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  86559. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  86560. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  86561. // Returns the GroundMesh.
  86562. GroundMesh.prototype._computeHeightQuads = function () {
  86563. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  86564. if (!positions) {
  86565. return this;
  86566. }
  86567. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  86568. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  86569. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  86570. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  86571. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  86572. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  86573. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  86574. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  86575. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  86576. var i = 0;
  86577. var j = 0;
  86578. var k = 0;
  86579. var cd = 0; // 2D slope coefficient : z = cd * x + h
  86580. var h = 0;
  86581. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  86582. var d2 = 0;
  86583. var subdivisionsX = this._subdivisionsX;
  86584. var subdivisionsY = this._subdivisionsY;
  86585. for (var row = 0; row < subdivisionsY; row++) {
  86586. for (var col = 0; col < subdivisionsX; col++) {
  86587. i = col * 3;
  86588. j = row * (subdivisionsX + 1) * 3;
  86589. k = (row + 1) * (subdivisionsX + 1) * 3;
  86590. v1.x = positions[j + i];
  86591. v1.y = positions[j + i + 1];
  86592. v1.z = positions[j + i + 2];
  86593. v2.x = positions[j + i + 3];
  86594. v2.y = positions[j + i + 4];
  86595. v2.z = positions[j + i + 5];
  86596. v3.x = positions[k + i];
  86597. v3.y = positions[k + i + 1];
  86598. v3.z = positions[k + i + 2];
  86599. v4.x = positions[k + i + 3];
  86600. v4.y = positions[k + i + 4];
  86601. v4.z = positions[k + i + 5];
  86602. // 2D slope V1V4
  86603. cd = (v4.z - v1.z) / (v4.x - v1.x);
  86604. h = v1.z - cd * v1.x; // v1 belongs to the slope
  86605. // facet equations :
  86606. // we compute each facet normal vector
  86607. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  86608. // we compute the value d by applying the equation to v1 which belongs to the plane
  86609. // then we store the facet equation in a Vector4
  86610. v2.subtractToRef(v1, v1v2);
  86611. v3.subtractToRef(v1, v1v3);
  86612. v4.subtractToRef(v1, v1v4);
  86613. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  86614. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  86615. norm1.normalize();
  86616. norm2.normalize();
  86617. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  86618. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  86619. var quad = this._heightQuads[row * subdivisionsX + col];
  86620. quad.slope.copyFromFloats(cd, h);
  86621. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  86622. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  86623. }
  86624. }
  86625. return this;
  86626. };
  86627. /**
  86628. * Serializes this ground mesh
  86629. * @param serializationObject object to write serialization to
  86630. */
  86631. GroundMesh.prototype.serialize = function (serializationObject) {
  86632. _super.prototype.serialize.call(this, serializationObject);
  86633. serializationObject.subdivisionsX = this._subdivisionsX;
  86634. serializationObject.subdivisionsY = this._subdivisionsY;
  86635. serializationObject.minX = this._minX;
  86636. serializationObject.maxX = this._maxX;
  86637. serializationObject.minZ = this._minZ;
  86638. serializationObject.maxZ = this._maxZ;
  86639. serializationObject.width = this._width;
  86640. serializationObject.height = this._height;
  86641. };
  86642. /**
  86643. * Parses a serialized ground mesh
  86644. * @param parsedMesh the serialized mesh
  86645. * @param scene the scene to create the ground mesh in
  86646. * @returns the created ground mesh
  86647. */
  86648. GroundMesh.Parse = function (parsedMesh, scene) {
  86649. var result = new GroundMesh(parsedMesh.name, scene);
  86650. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  86651. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  86652. result._minX = parsedMesh.minX;
  86653. result._maxX = parsedMesh.maxX;
  86654. result._minZ = parsedMesh.minZ;
  86655. result._maxZ = parsedMesh.maxZ;
  86656. result._width = parsedMesh.width;
  86657. result._height = parsedMesh.height;
  86658. return result;
  86659. };
  86660. return GroundMesh;
  86661. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  86662. /***/ }),
  86663. /***/ "./Meshes/index.ts":
  86664. /*!*************************!*\
  86665. !*** ./Meshes/index.ts ***!
  86666. \*************************/
  86667. /*! exports provided: AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DracoCompression, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  86668. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86669. "use strict";
  86670. __webpack_require__.r(__webpack_exports__);
  86671. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  86672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  86673. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  86674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  86675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  86676. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  86677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  86678. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  86679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  86680. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  86681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  86682. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  86683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  86684. /* harmony import */ var _trailMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./trailMesh */ "./Meshes/trailMesh.ts");
  86685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _trailMesh__WEBPACK_IMPORTED_MODULE_6__["TrailMesh"]; });
  86686. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  86687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedMesh"]; });
  86688. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  86689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["LinesMesh"]; });
  86690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["InstancedLinesMesh"]; });
  86691. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  86692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["MeshLODLevel"]; });
  86693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_CreationDataStorage"]; });
  86694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_InstancesBatch"]; });
  86695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["Mesh"]; });
  86696. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  86697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__["VertexData"]; });
  86698. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  86699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_11__["MeshBuilder"]; });
  86700. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  86701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationSettings"]; });
  86702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationQueue"]; });
  86703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationType"]; });
  86704. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  86705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__["SimplicationQueueSceneComponent"]; });
  86706. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  86707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["Polygon"]; });
  86708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["PolygonMeshBuilder"]; });
  86709. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  86710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["BaseSubMesh"]; });
  86711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["SubMesh"]; });
  86712. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  86713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_16__["TransformNode"]; });
  86714. /* harmony import */ var _Builders_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Builders/index */ "./Meshes/Builders/index.ts");
  86715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["BoxBuilder"]; });
  86716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["SphereBuilder"]; });
  86717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["CylinderBuilder"]; });
  86718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LinesBuilder"]; });
  86719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PlaneBuilder"]; });
  86720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DiscBuilder"]; });
  86721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["RibbonBuilder"]; });
  86722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["HemisphereBuilder"]; });
  86723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusBuilder"]; });
  86724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusKnotBuilder"]; });
  86725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolygonBuilder"]; });
  86726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["ShapeBuilder"]; });
  86727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LatheBuilder"]; });
  86728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["GroundBuilder"]; });
  86729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TubeBuilder"]; });
  86730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolyhedronBuilder"]; });
  86731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["IcoSphereBuilder"]; });
  86732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DecalBuilder"]; });
  86733. /***/ }),
  86734. /***/ "./Meshes/instancedMesh.ts":
  86735. /*!*********************************!*\
  86736. !*** ./Meshes/instancedMesh.ts ***!
  86737. \*********************************/
  86738. /*! exports provided: InstancedMesh */
  86739. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86740. "use strict";
  86741. __webpack_require__.r(__webpack_exports__);
  86742. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  86743. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  86744. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  86745. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  86746. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  86747. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  86748. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  86749. return new InstancedMesh(name, mesh);
  86750. };
  86751. /**
  86752. * Creates an instance based on a source mesh.
  86753. */
  86754. var InstancedMesh = /** @class */ (function (_super) {
  86755. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  86756. function InstancedMesh(name, source) {
  86757. var _this = _super.call(this, name, source.getScene()) || this;
  86758. /** @hidden */
  86759. _this._indexInSourceMeshInstanceArray = -1;
  86760. source.addInstance(_this);
  86761. _this._sourceMesh = source;
  86762. _this.position.copyFrom(source.position);
  86763. _this.rotation.copyFrom(source.rotation);
  86764. _this.scaling.copyFrom(source.scaling);
  86765. if (source.rotationQuaternion) {
  86766. _this.rotationQuaternion = source.rotationQuaternion.clone();
  86767. }
  86768. _this.infiniteDistance = source.infiniteDistance;
  86769. _this.setPivotMatrix(source.getPivotMatrix());
  86770. _this.refreshBoundingInfo();
  86771. _this._syncSubMeshes();
  86772. return _this;
  86773. }
  86774. /**
  86775. * Returns the string "InstancedMesh".
  86776. */
  86777. InstancedMesh.prototype.getClassName = function () {
  86778. return "InstancedMesh";
  86779. };
  86780. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  86781. // Methods
  86782. /**
  86783. * If the source mesh receives shadows
  86784. */
  86785. get: function () {
  86786. return this._sourceMesh.receiveShadows;
  86787. },
  86788. enumerable: true,
  86789. configurable: true
  86790. });
  86791. Object.defineProperty(InstancedMesh.prototype, "material", {
  86792. /**
  86793. * The material of the source mesh
  86794. */
  86795. get: function () {
  86796. return this._sourceMesh.material;
  86797. },
  86798. enumerable: true,
  86799. configurable: true
  86800. });
  86801. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  86802. /**
  86803. * Visibility of the source mesh
  86804. */
  86805. get: function () {
  86806. return this._sourceMesh.visibility;
  86807. },
  86808. enumerable: true,
  86809. configurable: true
  86810. });
  86811. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  86812. /**
  86813. * Skeleton of the source mesh
  86814. */
  86815. get: function () {
  86816. return this._sourceMesh.skeleton;
  86817. },
  86818. enumerable: true,
  86819. configurable: true
  86820. });
  86821. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  86822. /**
  86823. * Rendering ground id of the source mesh
  86824. */
  86825. get: function () {
  86826. return this._sourceMesh.renderingGroupId;
  86827. },
  86828. set: function (value) {
  86829. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  86830. return;
  86831. }
  86832. //no-op with warning
  86833. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  86834. },
  86835. enumerable: true,
  86836. configurable: true
  86837. });
  86838. /**
  86839. * Returns the total number of vertices (integer).
  86840. */
  86841. InstancedMesh.prototype.getTotalVertices = function () {
  86842. return this._sourceMesh.getTotalVertices();
  86843. };
  86844. /**
  86845. * Returns a positive integer : the total number of indices in this mesh geometry.
  86846. * @returns the numner of indices or zero if the mesh has no geometry.
  86847. */
  86848. InstancedMesh.prototype.getTotalIndices = function () {
  86849. return this._sourceMesh.getTotalIndices();
  86850. };
  86851. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  86852. /**
  86853. * The source mesh of the instance
  86854. */
  86855. get: function () {
  86856. return this._sourceMesh;
  86857. },
  86858. enumerable: true,
  86859. configurable: true
  86860. });
  86861. /**
  86862. * Is this node ready to be used/rendered
  86863. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86864. * @return {boolean} is it ready
  86865. */
  86866. InstancedMesh.prototype.isReady = function (completeCheck) {
  86867. if (completeCheck === void 0) { completeCheck = false; }
  86868. return this._sourceMesh.isReady(completeCheck, true);
  86869. };
  86870. /**
  86871. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86872. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86873. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  86874. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86875. */
  86876. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  86877. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  86878. };
  86879. /**
  86880. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86881. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86882. * The `data` are either a numeric array either a Float32Array.
  86883. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86884. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  86885. * Note that a new underlying VertexBuffer object is created each call.
  86886. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86887. *
  86888. * Possible `kind` values :
  86889. * - VertexBuffer.PositionKind
  86890. * - VertexBuffer.UVKind
  86891. * - VertexBuffer.UV2Kind
  86892. * - VertexBuffer.UV3Kind
  86893. * - VertexBuffer.UV4Kind
  86894. * - VertexBuffer.UV5Kind
  86895. * - VertexBuffer.UV6Kind
  86896. * - VertexBuffer.ColorKind
  86897. * - VertexBuffer.MatricesIndicesKind
  86898. * - VertexBuffer.MatricesIndicesExtraKind
  86899. * - VertexBuffer.MatricesWeightsKind
  86900. * - VertexBuffer.MatricesWeightsExtraKind
  86901. *
  86902. * Returns the Mesh.
  86903. */
  86904. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  86905. if (this.sourceMesh) {
  86906. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  86907. }
  86908. return this.sourceMesh;
  86909. };
  86910. /**
  86911. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86912. * If the mesh has no geometry, it is simply returned as it is.
  86913. * The `data` are either a numeric array either a Float32Array.
  86914. * No new underlying VertexBuffer object is created.
  86915. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86916. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  86917. *
  86918. * Possible `kind` values :
  86919. * - VertexBuffer.PositionKind
  86920. * - VertexBuffer.UVKind
  86921. * - VertexBuffer.UV2Kind
  86922. * - VertexBuffer.UV3Kind
  86923. * - VertexBuffer.UV4Kind
  86924. * - VertexBuffer.UV5Kind
  86925. * - VertexBuffer.UV6Kind
  86926. * - VertexBuffer.ColorKind
  86927. * - VertexBuffer.MatricesIndicesKind
  86928. * - VertexBuffer.MatricesIndicesExtraKind
  86929. * - VertexBuffer.MatricesWeightsKind
  86930. * - VertexBuffer.MatricesWeightsExtraKind
  86931. *
  86932. * Returns the Mesh.
  86933. */
  86934. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  86935. if (this.sourceMesh) {
  86936. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  86937. }
  86938. return this.sourceMesh;
  86939. };
  86940. /**
  86941. * Sets the mesh indices.
  86942. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  86943. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  86944. * This method creates a new index buffer each call.
  86945. * Returns the Mesh.
  86946. */
  86947. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  86948. if (totalVertices === void 0) { totalVertices = null; }
  86949. if (this.sourceMesh) {
  86950. this.sourceMesh.setIndices(indices, totalVertices);
  86951. }
  86952. return this.sourceMesh;
  86953. };
  86954. /**
  86955. * Boolean : True if the mesh owns the requested kind of data.
  86956. */
  86957. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  86958. return this._sourceMesh.isVerticesDataPresent(kind);
  86959. };
  86960. /**
  86961. * Returns an array of indices (IndicesArray).
  86962. */
  86963. InstancedMesh.prototype.getIndices = function () {
  86964. return this._sourceMesh.getIndices();
  86965. };
  86966. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  86967. get: function () {
  86968. return this._sourceMesh._positions;
  86969. },
  86970. enumerable: true,
  86971. configurable: true
  86972. });
  86973. /**
  86974. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86975. * This means the mesh underlying bounding box and sphere are recomputed.
  86976. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86977. * @returns the current mesh
  86978. */
  86979. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  86980. if (applySkeleton === void 0) { applySkeleton = false; }
  86981. if (this._boundingInfo && this._boundingInfo.isLocked) {
  86982. return this;
  86983. }
  86984. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  86985. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  86986. return this;
  86987. };
  86988. /** @hidden */
  86989. InstancedMesh.prototype._preActivate = function () {
  86990. if (this._currentLOD) {
  86991. this._currentLOD._preActivate();
  86992. }
  86993. return this;
  86994. };
  86995. /** @hidden */
  86996. InstancedMesh.prototype._activate = function (renderId) {
  86997. if (this._currentLOD) {
  86998. this._currentLOD._registerInstanceForRenderId(this, renderId);
  86999. }
  87000. if (this._edgesRenderer && this._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup) {
  87001. this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer);
  87002. }
  87003. if (!this._currentLOD._isActive) {
  87004. this._currentLOD._isActive = true;
  87005. return true;
  87006. }
  87007. return false;
  87008. };
  87009. /**
  87010. * Returns the current associated LOD AbstractMesh.
  87011. */
  87012. InstancedMesh.prototype.getLOD = function (camera) {
  87013. if (!camera) {
  87014. return this;
  87015. }
  87016. var boundingInfo = this.getBoundingInfo();
  87017. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  87018. if (this._currentLOD === this.sourceMesh) {
  87019. return this;
  87020. }
  87021. return this._currentLOD;
  87022. };
  87023. /** @hidden */
  87024. InstancedMesh.prototype._syncSubMeshes = function () {
  87025. this.releaseSubMeshes();
  87026. if (this._sourceMesh.subMeshes) {
  87027. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  87028. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  87029. }
  87030. }
  87031. return this;
  87032. };
  87033. /** @hidden */
  87034. InstancedMesh.prototype._generatePointsArray = function () {
  87035. return this._sourceMesh._generatePointsArray();
  87036. };
  87037. /**
  87038. * Creates a new InstancedMesh from the current mesh.
  87039. * - name (string) : the cloned mesh name
  87040. * - newParent (optional Node) : the optional Node to parent the clone to.
  87041. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  87042. *
  87043. * Returns the clone.
  87044. */
  87045. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  87046. var result = this._sourceMesh.createInstance(name);
  87047. // Deep copy
  87048. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  87049. // Bounding info
  87050. this.refreshBoundingInfo();
  87051. // Parent
  87052. if (newParent) {
  87053. result.parent = newParent;
  87054. }
  87055. if (!doNotCloneChildren) {
  87056. // Children
  87057. for (var index = 0; index < this.getScene().meshes.length; index++) {
  87058. var mesh = this.getScene().meshes[index];
  87059. if (mesh.parent === this) {
  87060. mesh.clone(mesh.name, result);
  87061. }
  87062. }
  87063. }
  87064. result.computeWorldMatrix(true);
  87065. return result;
  87066. };
  87067. /**
  87068. * Disposes the InstancedMesh.
  87069. * Returns nothing.
  87070. */
  87071. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  87072. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  87073. // Remove from mesh
  87074. this._sourceMesh.removeInstance(this);
  87075. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  87076. };
  87077. return InstancedMesh;
  87078. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  87079. /***/ }),
  87080. /***/ "./Meshes/linesMesh.ts":
  87081. /*!*****************************!*\
  87082. !*** ./Meshes/linesMesh.ts ***!
  87083. \*****************************/
  87084. /*! exports provided: LinesMesh, InstancedLinesMesh */
  87085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87086. "use strict";
  87087. __webpack_require__.r(__webpack_exports__);
  87088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  87089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  87090. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  87091. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  87092. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  87093. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  87094. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  87095. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  87096. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  87097. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  87098. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  87099. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  87100. /**
  87101. * Line mesh
  87102. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  87103. */
  87104. var LinesMesh = /** @class */ (function (_super) {
  87105. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  87106. /**
  87107. * Creates a new LinesMesh
  87108. * @param name defines the name
  87109. * @param scene defines the hosting scene
  87110. * @param parent defines the parent mesh if any
  87111. * @param source defines the optional source LinesMesh used to clone data from
  87112. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87113. * When false, achieved by calling a clone(), also passing False.
  87114. * This will make creation of children, recursive.
  87115. * @param useVertexColor defines if this LinesMesh supports vertex color
  87116. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  87117. */
  87118. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  87119. /**
  87120. * If vertex color should be applied to the mesh
  87121. */
  87122. useVertexColor,
  87123. /**
  87124. * If vertex alpha should be applied to the mesh
  87125. */
  87126. useVertexAlpha) {
  87127. if (scene === void 0) { scene = null; }
  87128. if (parent === void 0) { parent = null; }
  87129. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  87130. _this.useVertexColor = useVertexColor;
  87131. _this.useVertexAlpha = useVertexAlpha;
  87132. /**
  87133. * Color of the line (Default: White)
  87134. */
  87135. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  87136. /**
  87137. * Alpha of the line (Default: 1)
  87138. */
  87139. _this.alpha = 1;
  87140. if (source) {
  87141. _this.color = source.color.clone();
  87142. _this.alpha = source.alpha;
  87143. _this.useVertexColor = source.useVertexColor;
  87144. _this.useVertexAlpha = source.useVertexAlpha;
  87145. }
  87146. _this.intersectionThreshold = 0.1;
  87147. var defines = [];
  87148. var options = {
  87149. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  87150. uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "world", "viewProjection"],
  87151. needAlphaBlending: true,
  87152. defines: defines
  87153. };
  87154. if (useVertexAlpha === false) {
  87155. options.needAlphaBlending = false;
  87156. }
  87157. if (!useVertexColor) {
  87158. options.uniforms.push("color");
  87159. }
  87160. else {
  87161. options.defines.push("#define VERTEXCOLOR");
  87162. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  87163. }
  87164. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  87165. return _this;
  87166. }
  87167. LinesMesh.prototype._addClipPlaneDefine = function (label) {
  87168. var define = "#define " + label;
  87169. var index = this._colorShader.options.defines.indexOf(define);
  87170. if (index !== -1) {
  87171. return;
  87172. }
  87173. this._colorShader.options.defines.push(define);
  87174. };
  87175. LinesMesh.prototype._removeClipPlaneDefine = function (label) {
  87176. var define = "#define " + label;
  87177. var index = this._colorShader.options.defines.indexOf(define);
  87178. if (index === -1) {
  87179. return;
  87180. }
  87181. this._colorShader.options.defines.splice(index, 1);
  87182. };
  87183. LinesMesh.prototype.isReady = function () {
  87184. var scene = this.getScene();
  87185. // Clip planes
  87186. scene.clipPlane ? this._addClipPlaneDefine("CLIPPLANE") : this._removeClipPlaneDefine("CLIPPLANE");
  87187. scene.clipPlane2 ? this._addClipPlaneDefine("CLIPPLANE2") : this._removeClipPlaneDefine("CLIPPLANE2");
  87188. scene.clipPlane3 ? this._addClipPlaneDefine("CLIPPLANE3") : this._removeClipPlaneDefine("CLIPPLANE3");
  87189. scene.clipPlane4 ? this._addClipPlaneDefine("CLIPPLANE4") : this._removeClipPlaneDefine("CLIPPLANE4");
  87190. if (!this._colorShader.isReady()) {
  87191. return false;
  87192. }
  87193. return _super.prototype.isReady.call(this);
  87194. };
  87195. /**
  87196. * Returns the string "LineMesh"
  87197. */
  87198. LinesMesh.prototype.getClassName = function () {
  87199. return "LinesMesh";
  87200. };
  87201. Object.defineProperty(LinesMesh.prototype, "material", {
  87202. /**
  87203. * @hidden
  87204. */
  87205. get: function () {
  87206. return this._colorShader;
  87207. },
  87208. /**
  87209. * @hidden
  87210. */
  87211. set: function (value) {
  87212. // Do nothing
  87213. },
  87214. enumerable: true,
  87215. configurable: true
  87216. });
  87217. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  87218. /**
  87219. * @hidden
  87220. */
  87221. get: function () {
  87222. return false;
  87223. },
  87224. enumerable: true,
  87225. configurable: true
  87226. });
  87227. /** @hidden */
  87228. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  87229. if (!this._geometry) {
  87230. return this;
  87231. }
  87232. var colorEffect = this._colorShader.getEffect();
  87233. // VBOs
  87234. this._geometry._bind(colorEffect);
  87235. // Color
  87236. if (!this.useVertexColor) {
  87237. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  87238. }
  87239. // Clip planes
  87240. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_9__["MaterialHelper"].BindClipPlane(colorEffect, this.getScene());
  87241. return this;
  87242. };
  87243. /** @hidden */
  87244. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  87245. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  87246. return this;
  87247. }
  87248. var engine = this.getScene().getEngine();
  87249. // Draw order
  87250. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  87251. return this;
  87252. };
  87253. /**
  87254. * Disposes of the line mesh
  87255. * @param doNotRecurse If children should be disposed
  87256. */
  87257. LinesMesh.prototype.dispose = function (doNotRecurse) {
  87258. this._colorShader.dispose(false, false, true);
  87259. _super.prototype.dispose.call(this, doNotRecurse);
  87260. };
  87261. /**
  87262. * Returns a new LineMesh object cloned from the current one.
  87263. */
  87264. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  87265. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  87266. };
  87267. /**
  87268. * Creates a new InstancedLinesMesh object from the mesh model.
  87269. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87270. * @param name defines the name of the new instance
  87271. * @returns a new InstancedLinesMesh
  87272. */
  87273. LinesMesh.prototype.createInstance = function (name) {
  87274. return new InstancedLinesMesh(name, this);
  87275. };
  87276. return LinesMesh;
  87277. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  87278. /**
  87279. * Creates an instance based on a source LinesMesh
  87280. */
  87281. var InstancedLinesMesh = /** @class */ (function (_super) {
  87282. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  87283. function InstancedLinesMesh(name, source) {
  87284. var _this = _super.call(this, name, source) || this;
  87285. _this.intersectionThreshold = source.intersectionThreshold;
  87286. return _this;
  87287. }
  87288. /**
  87289. * Returns the string "InstancedLinesMesh".
  87290. */
  87291. InstancedLinesMesh.prototype.getClassName = function () {
  87292. return "InstancedLinesMesh";
  87293. };
  87294. return InstancedLinesMesh;
  87295. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  87296. /***/ }),
  87297. /***/ "./Meshes/mesh.ts":
  87298. /*!************************!*\
  87299. !*** ./Meshes/mesh.ts ***!
  87300. \************************/
  87301. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  87302. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87303. "use strict";
  87304. __webpack_require__.r(__webpack_exports__);
  87305. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  87306. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  87307. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  87308. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  87309. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  87310. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  87311. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  87312. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  87313. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  87314. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  87315. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  87316. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  87317. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  87318. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  87319. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  87320. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  87321. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  87322. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  87323. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  87324. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  87325. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  87326. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  87327. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  87328. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  87329. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  87330. /**
  87331. * Class used to represent a specific level of detail of a mesh
  87332. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87333. */
  87334. var MeshLODLevel = /** @class */ (function () {
  87335. /**
  87336. * Creates a new LOD level
  87337. * @param distance defines the distance where this level should star being displayed
  87338. * @param mesh defines the mesh to use to render this level
  87339. */
  87340. function MeshLODLevel(
  87341. /** Defines the distance where this level should star being displayed */
  87342. distance,
  87343. /** Defines the mesh to use to render this level */
  87344. mesh) {
  87345. this.distance = distance;
  87346. this.mesh = mesh;
  87347. }
  87348. return MeshLODLevel;
  87349. }());
  87350. /**
  87351. * @hidden
  87352. **/
  87353. var _CreationDataStorage = /** @class */ (function () {
  87354. function _CreationDataStorage() {
  87355. }
  87356. return _CreationDataStorage;
  87357. }());
  87358. /**
  87359. * @hidden
  87360. **/
  87361. var _InstanceDataStorage = /** @class */ (function () {
  87362. function _InstanceDataStorage() {
  87363. this.visibleInstances = {};
  87364. this.batchCache = new _InstancesBatch();
  87365. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  87366. }
  87367. return _InstanceDataStorage;
  87368. }());
  87369. /**
  87370. * @hidden
  87371. **/
  87372. var _InstancesBatch = /** @class */ (function () {
  87373. function _InstancesBatch() {
  87374. this.mustReturn = false;
  87375. this.visibleInstances = new Array();
  87376. this.renderSelf = new Array();
  87377. this.hardwareInstancedRendering = new Array();
  87378. }
  87379. return _InstancesBatch;
  87380. }());
  87381. /**
  87382. * Class used to represent renderable models
  87383. */
  87384. var Mesh = /** @class */ (function (_super) {
  87385. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  87386. /**
  87387. * @constructor
  87388. * @param name The value used by scene.getMeshByName() to do a lookup.
  87389. * @param scene The scene to add this mesh to.
  87390. * @param parent The parent of this mesh, if it has one
  87391. * @param source An optional Mesh from which geometry is shared, cloned.
  87392. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87393. * When false, achieved by calling a clone(), also passing False.
  87394. * This will make creation of children, recursive.
  87395. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  87396. */
  87397. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  87398. if (scene === void 0) { scene = null; }
  87399. if (parent === void 0) { parent = null; }
  87400. if (source === void 0) { source = null; }
  87401. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  87402. var _this = _super.call(this, name, scene) || this;
  87403. // Members
  87404. /**
  87405. * Gets the delay loading state of the mesh (when delay loading is turned on)
  87406. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  87407. */
  87408. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NONE;
  87409. /**
  87410. * Gets the list of instances created from this mesh
  87411. * it is not supposed to be modified manually.
  87412. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  87413. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87414. */
  87415. _this.instances = new Array();
  87416. _this._LODLevels = new Array();
  87417. /** @hidden */
  87418. _this._instanceDataStorage = new _InstanceDataStorage();
  87419. // Use by builder only to know what orientation were the mesh build in.
  87420. /** @hidden */
  87421. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  87422. /**
  87423. * Use this property to change the original side orientation defined at construction time
  87424. */
  87425. _this.overrideMaterialSideOrientation = null;
  87426. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  87427. // Will be used to save a source mesh reference, If any
  87428. _this._source = null;
  87429. /** @hidden */
  87430. _this._isMesh = true;
  87431. scene = _this.getScene();
  87432. if (source) {
  87433. // Geometry
  87434. if (source._geometry) {
  87435. source._geometry.applyToMesh(_this);
  87436. }
  87437. // Deep copy
  87438. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  87439. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  87440. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  87441. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  87442. "onDisposeObservable"
  87443. ], ["_poseMatrix"]);
  87444. // Source mesh
  87445. _this._source = source;
  87446. if (scene.useClonedMeshhMap) {
  87447. if (!source.meshMap) {
  87448. source.meshMap = {};
  87449. }
  87450. source.meshMap[_this.uniqueId] = _this;
  87451. }
  87452. // Construction Params
  87453. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  87454. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  87455. _this._creationDataStorage = source._creationDataStorage;
  87456. // Animation ranges
  87457. if (_this._source._ranges) {
  87458. var ranges = _this._source._ranges;
  87459. for (var name in ranges) {
  87460. if (!ranges.hasOwnProperty(name)) {
  87461. continue;
  87462. }
  87463. if (!ranges[name]) {
  87464. continue;
  87465. }
  87466. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  87467. }
  87468. }
  87469. // Metadata
  87470. if (source.metadata && source.metadata.clone) {
  87471. _this.metadata = source.metadata.clone();
  87472. }
  87473. else {
  87474. _this.metadata = source.metadata;
  87475. }
  87476. // Tags
  87477. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  87478. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  87479. }
  87480. // Parent
  87481. _this.parent = source.parent;
  87482. // Pivot
  87483. _this.setPivotMatrix(source.getPivotMatrix());
  87484. _this.id = name + "." + source.id;
  87485. // Material
  87486. _this.material = source.material;
  87487. var index;
  87488. if (!doNotCloneChildren) {
  87489. // Children
  87490. var directDescendants = source.getDescendants(true);
  87491. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  87492. var child = directDescendants[index_1];
  87493. if (child.clone) {
  87494. child.clone(name + "." + child.name, _this);
  87495. }
  87496. }
  87497. }
  87498. // Physics clone
  87499. var physicsEngine = _this.getScene().getPhysicsEngine();
  87500. if (clonePhysicsImpostor && physicsEngine) {
  87501. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  87502. if (impostor) {
  87503. _this.physicsImpostor = impostor.clone(_this);
  87504. }
  87505. }
  87506. // Particles
  87507. for (index = 0; index < scene.particleSystems.length; index++) {
  87508. var system = scene.particleSystems[index];
  87509. if (system.emitter === source) {
  87510. system.clone(system.name, _this);
  87511. }
  87512. }
  87513. _this.refreshBoundingInfo();
  87514. _this.computeWorldMatrix(true);
  87515. }
  87516. // Parent
  87517. if (parent !== null) {
  87518. _this.parent = parent;
  87519. }
  87520. _this._instanceDataStorage.hardwareInstancedRendering = _this.getEngine().getCaps().instancedArrays;
  87521. return _this;
  87522. }
  87523. /**
  87524. * Gets the default side orientation.
  87525. * @param orientation the orientation to value to attempt to get
  87526. * @returns the default orientation
  87527. * @hidden
  87528. */
  87529. Mesh._GetDefaultSideOrientation = function (orientation) {
  87530. return orientation || Mesh.FRONTSIDE; // works as Mesh.FRONTSIDE is 0
  87531. };
  87532. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  87533. /**
  87534. * An event triggered before rendering the mesh
  87535. */
  87536. get: function () {
  87537. if (!this._onBeforeRenderObservable) {
  87538. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  87539. }
  87540. return this._onBeforeRenderObservable;
  87541. },
  87542. enumerable: true,
  87543. configurable: true
  87544. });
  87545. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  87546. /**
  87547. * An event triggered before binding the mesh
  87548. */
  87549. get: function () {
  87550. if (!this._onBeforeBindObservable) {
  87551. this._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  87552. }
  87553. return this._onBeforeBindObservable;
  87554. },
  87555. enumerable: true,
  87556. configurable: true
  87557. });
  87558. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  87559. /**
  87560. * An event triggered after rendering the mesh
  87561. */
  87562. get: function () {
  87563. if (!this._onAfterRenderObservable) {
  87564. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  87565. }
  87566. return this._onAfterRenderObservable;
  87567. },
  87568. enumerable: true,
  87569. configurable: true
  87570. });
  87571. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  87572. /**
  87573. * An event triggered before drawing the mesh
  87574. */
  87575. get: function () {
  87576. if (!this._onBeforeDrawObservable) {
  87577. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  87578. }
  87579. return this._onBeforeDrawObservable;
  87580. },
  87581. enumerable: true,
  87582. configurable: true
  87583. });
  87584. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  87585. /**
  87586. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  87587. */
  87588. set: function (callback) {
  87589. if (this._onBeforeDrawObserver) {
  87590. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  87591. }
  87592. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  87593. },
  87594. enumerable: true,
  87595. configurable: true
  87596. });
  87597. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  87598. /**
  87599. * Gets or sets the morph target manager
  87600. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87601. */
  87602. get: function () {
  87603. return this._morphTargetManager;
  87604. },
  87605. set: function (value) {
  87606. if (this._morphTargetManager === value) {
  87607. return;
  87608. }
  87609. this._morphTargetManager = value;
  87610. this._syncGeometryWithMorphTargetManager();
  87611. },
  87612. enumerable: true,
  87613. configurable: true
  87614. });
  87615. Object.defineProperty(Mesh.prototype, "source", {
  87616. /**
  87617. * Gets the source mesh (the one used to clone this one from)
  87618. */
  87619. get: function () {
  87620. return this._source;
  87621. },
  87622. enumerable: true,
  87623. configurable: true
  87624. });
  87625. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  87626. /**
  87627. * Gets or sets a boolean indicating that this mesh does not use index buffer
  87628. */
  87629. get: function () {
  87630. return this._unIndexed;
  87631. },
  87632. set: function (value) {
  87633. if (this._unIndexed !== value) {
  87634. this._unIndexed = value;
  87635. this._markSubMeshesAsAttributesDirty();
  87636. }
  87637. },
  87638. enumerable: true,
  87639. configurable: true
  87640. });
  87641. // Methods
  87642. /**
  87643. * Gets the class name
  87644. * @returns the string "Mesh".
  87645. */
  87646. Mesh.prototype.getClassName = function () {
  87647. return "Mesh";
  87648. };
  87649. /**
  87650. * Returns a description of this mesh
  87651. * @param fullDetails define if full details about this mesh must be used
  87652. * @returns a descriptive string representing this mesh
  87653. */
  87654. Mesh.prototype.toString = function (fullDetails) {
  87655. var ret = _super.prototype.toString.call(this, fullDetails);
  87656. ret += ", n vertices: " + this.getTotalVertices();
  87657. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  87658. if (this.animations) {
  87659. for (var i = 0; i < this.animations.length; i++) {
  87660. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  87661. }
  87662. }
  87663. if (fullDetails) {
  87664. if (this._geometry) {
  87665. var ib = this.getIndices();
  87666. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  87667. if (vb && ib) {
  87668. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  87669. }
  87670. }
  87671. else {
  87672. ret += ", flat shading: UNKNOWN";
  87673. }
  87674. }
  87675. return ret;
  87676. };
  87677. /** @hidden */
  87678. Mesh.prototype._unBindEffect = function () {
  87679. _super.prototype._unBindEffect.call(this);
  87680. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  87681. var instance = _a[_i];
  87682. instance._unBindEffect();
  87683. }
  87684. };
  87685. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  87686. /**
  87687. * Gets a boolean indicating if this mesh has LOD
  87688. */
  87689. get: function () {
  87690. return this._LODLevels.length > 0;
  87691. },
  87692. enumerable: true,
  87693. configurable: true
  87694. });
  87695. /**
  87696. * Gets the list of MeshLODLevel associated with the current mesh
  87697. * @returns an array of MeshLODLevel
  87698. */
  87699. Mesh.prototype.getLODLevels = function () {
  87700. return this._LODLevels;
  87701. };
  87702. Mesh.prototype._sortLODLevels = function () {
  87703. this._LODLevels.sort(function (a, b) {
  87704. if (a.distance < b.distance) {
  87705. return 1;
  87706. }
  87707. if (a.distance > b.distance) {
  87708. return -1;
  87709. }
  87710. return 0;
  87711. });
  87712. };
  87713. /**
  87714. * Add a mesh as LOD level triggered at the given distance.
  87715. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87716. * @param distance The distance from the center of the object to show this level
  87717. * @param mesh The mesh to be added as LOD level (can be null)
  87718. * @return This mesh (for chaining)
  87719. */
  87720. Mesh.prototype.addLODLevel = function (distance, mesh) {
  87721. if (mesh && mesh._masterMesh) {
  87722. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  87723. return this;
  87724. }
  87725. var level = new MeshLODLevel(distance, mesh);
  87726. this._LODLevels.push(level);
  87727. if (mesh) {
  87728. mesh._masterMesh = this;
  87729. }
  87730. this._sortLODLevels();
  87731. return this;
  87732. };
  87733. /**
  87734. * Returns the LOD level mesh at the passed distance or null if not found.
  87735. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87736. * @param distance The distance from the center of the object to show this level
  87737. * @returns a Mesh or `null`
  87738. */
  87739. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  87740. for (var index = 0; index < this._LODLevels.length; index++) {
  87741. var level = this._LODLevels[index];
  87742. if (level.distance === distance) {
  87743. return level.mesh;
  87744. }
  87745. }
  87746. return null;
  87747. };
  87748. /**
  87749. * Remove a mesh from the LOD array
  87750. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87751. * @param mesh defines the mesh to be removed
  87752. * @return This mesh (for chaining)
  87753. */
  87754. Mesh.prototype.removeLODLevel = function (mesh) {
  87755. for (var index = 0; index < this._LODLevels.length; index++) {
  87756. if (this._LODLevels[index].mesh === mesh) {
  87757. this._LODLevels.splice(index, 1);
  87758. if (mesh) {
  87759. mesh._masterMesh = null;
  87760. }
  87761. }
  87762. }
  87763. this._sortLODLevels();
  87764. return this;
  87765. };
  87766. /**
  87767. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  87768. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87769. * @param camera defines the camera to use to compute distance
  87770. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  87771. * @return This mesh (for chaining)
  87772. */
  87773. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  87774. if (!this._LODLevels || this._LODLevels.length === 0) {
  87775. return this;
  87776. }
  87777. var bSphere;
  87778. if (boundingSphere) {
  87779. bSphere = boundingSphere;
  87780. }
  87781. else {
  87782. var boundingInfo = this.getBoundingInfo();
  87783. bSphere = boundingInfo.boundingSphere;
  87784. }
  87785. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  87786. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  87787. if (this.onLODLevelSelection) {
  87788. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  87789. }
  87790. return this;
  87791. }
  87792. for (var index = 0; index < this._LODLevels.length; index++) {
  87793. var level = this._LODLevels[index];
  87794. if (level.distance < distanceToCamera) {
  87795. if (level.mesh) {
  87796. level.mesh._preActivate();
  87797. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  87798. }
  87799. if (this.onLODLevelSelection) {
  87800. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  87801. }
  87802. return level.mesh;
  87803. }
  87804. }
  87805. if (this.onLODLevelSelection) {
  87806. this.onLODLevelSelection(distanceToCamera, this, this);
  87807. }
  87808. return this;
  87809. };
  87810. Object.defineProperty(Mesh.prototype, "geometry", {
  87811. /**
  87812. * Gets the mesh internal Geometry object
  87813. */
  87814. get: function () {
  87815. return this._geometry;
  87816. },
  87817. enumerable: true,
  87818. configurable: true
  87819. });
  87820. /**
  87821. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  87822. * @returns the total number of vertices
  87823. */
  87824. Mesh.prototype.getTotalVertices = function () {
  87825. if (this._geometry === null || this._geometry === undefined) {
  87826. return 0;
  87827. }
  87828. return this._geometry.getTotalVertices();
  87829. };
  87830. /**
  87831. * Returns the content of an associated vertex buffer
  87832. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87833. * - VertexBuffer.PositionKind
  87834. * - VertexBuffer.UVKind
  87835. * - VertexBuffer.UV2Kind
  87836. * - VertexBuffer.UV3Kind
  87837. * - VertexBuffer.UV4Kind
  87838. * - VertexBuffer.UV5Kind
  87839. * - VertexBuffer.UV6Kind
  87840. * - VertexBuffer.ColorKind
  87841. * - VertexBuffer.MatricesIndicesKind
  87842. * - VertexBuffer.MatricesIndicesExtraKind
  87843. * - VertexBuffer.MatricesWeightsKind
  87844. * - VertexBuffer.MatricesWeightsExtraKind
  87845. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  87846. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  87847. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  87848. */
  87849. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  87850. if (!this._geometry) {
  87851. return null;
  87852. }
  87853. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  87854. };
  87855. /**
  87856. * Returns the mesh VertexBuffer object from the requested `kind`
  87857. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87858. * - VertexBuffer.PositionKind
  87859. * - VertexBuffer.UVKind
  87860. * - VertexBuffer.UV2Kind
  87861. * - VertexBuffer.UV3Kind
  87862. * - VertexBuffer.UV4Kind
  87863. * - VertexBuffer.UV5Kind
  87864. * - VertexBuffer.UV6Kind
  87865. * - VertexBuffer.ColorKind
  87866. * - VertexBuffer.MatricesIndicesKind
  87867. * - VertexBuffer.MatricesIndicesExtraKind
  87868. * - VertexBuffer.MatricesWeightsKind
  87869. * - VertexBuffer.MatricesWeightsExtraKind
  87870. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  87871. */
  87872. Mesh.prototype.getVertexBuffer = function (kind) {
  87873. if (!this._geometry) {
  87874. return null;
  87875. }
  87876. return this._geometry.getVertexBuffer(kind);
  87877. };
  87878. /**
  87879. * Tests if a specific vertex buffer is associated with this mesh
  87880. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87881. * - VertexBuffer.PositionKind
  87882. * - VertexBuffer.UVKind
  87883. * - VertexBuffer.UV2Kind
  87884. * - VertexBuffer.UV3Kind
  87885. * - VertexBuffer.UV4Kind
  87886. * - VertexBuffer.UV5Kind
  87887. * - VertexBuffer.UV6Kind
  87888. * - VertexBuffer.ColorKind
  87889. * - VertexBuffer.MatricesIndicesKind
  87890. * - VertexBuffer.MatricesIndicesExtraKind
  87891. * - VertexBuffer.MatricesWeightsKind
  87892. * - VertexBuffer.MatricesWeightsExtraKind
  87893. * @returns a boolean
  87894. */
  87895. Mesh.prototype.isVerticesDataPresent = function (kind) {
  87896. if (!this._geometry) {
  87897. if (this._delayInfo) {
  87898. return this._delayInfo.indexOf(kind) !== -1;
  87899. }
  87900. return false;
  87901. }
  87902. return this._geometry.isVerticesDataPresent(kind);
  87903. };
  87904. /**
  87905. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  87906. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87907. * - VertexBuffer.PositionKind
  87908. * - VertexBuffer.UVKind
  87909. * - VertexBuffer.UV2Kind
  87910. * - VertexBuffer.UV3Kind
  87911. * - VertexBuffer.UV4Kind
  87912. * - VertexBuffer.UV5Kind
  87913. * - VertexBuffer.UV6Kind
  87914. * - VertexBuffer.ColorKind
  87915. * - VertexBuffer.MatricesIndicesKind
  87916. * - VertexBuffer.MatricesIndicesExtraKind
  87917. * - VertexBuffer.MatricesWeightsKind
  87918. * - VertexBuffer.MatricesWeightsExtraKind
  87919. * @returns a boolean
  87920. */
  87921. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  87922. if (!this._geometry) {
  87923. if (this._delayInfo) {
  87924. return this._delayInfo.indexOf(kind) !== -1;
  87925. }
  87926. return false;
  87927. }
  87928. return this._geometry.isVertexBufferUpdatable(kind);
  87929. };
  87930. /**
  87931. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  87932. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87933. * - VertexBuffer.PositionKind
  87934. * - VertexBuffer.UVKind
  87935. * - VertexBuffer.UV2Kind
  87936. * - VertexBuffer.UV3Kind
  87937. * - VertexBuffer.UV4Kind
  87938. * - VertexBuffer.UV5Kind
  87939. * - VertexBuffer.UV6Kind
  87940. * - VertexBuffer.ColorKind
  87941. * - VertexBuffer.MatricesIndicesKind
  87942. * - VertexBuffer.MatricesIndicesExtraKind
  87943. * - VertexBuffer.MatricesWeightsKind
  87944. * - VertexBuffer.MatricesWeightsExtraKind
  87945. * @returns an array of strings
  87946. */
  87947. Mesh.prototype.getVerticesDataKinds = function () {
  87948. if (!this._geometry) {
  87949. var result = new Array();
  87950. if (this._delayInfo) {
  87951. this._delayInfo.forEach(function (kind) {
  87952. result.push(kind);
  87953. });
  87954. }
  87955. return result;
  87956. }
  87957. return this._geometry.getVerticesDataKinds();
  87958. };
  87959. /**
  87960. * Returns a positive integer : the total number of indices in this mesh geometry.
  87961. * @returns the numner of indices or zero if the mesh has no geometry.
  87962. */
  87963. Mesh.prototype.getTotalIndices = function () {
  87964. if (!this._geometry) {
  87965. return 0;
  87966. }
  87967. return this._geometry.getTotalIndices();
  87968. };
  87969. /**
  87970. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87971. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  87972. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87973. * @returns the indices array or an empty array if the mesh has no geometry
  87974. */
  87975. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  87976. if (!this._geometry) {
  87977. return [];
  87978. }
  87979. return this._geometry.getIndices(copyWhenShared, forceCopy);
  87980. };
  87981. Object.defineProperty(Mesh.prototype, "isBlocked", {
  87982. get: function () {
  87983. return this._masterMesh !== null && this._masterMesh !== undefined;
  87984. },
  87985. enumerable: true,
  87986. configurable: true
  87987. });
  87988. /**
  87989. * Determine if the current mesh is ready to be rendered
  87990. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87991. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  87992. * @returns true if all associated assets are ready (material, textures, shaders)
  87993. */
  87994. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  87995. if (completeCheck === void 0) { completeCheck = false; }
  87996. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  87997. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  87998. return false;
  87999. }
  88000. if (!_super.prototype.isReady.call(this, completeCheck)) {
  88001. return false;
  88002. }
  88003. if (!this.subMeshes || this.subMeshes.length === 0) {
  88004. return true;
  88005. }
  88006. if (!completeCheck) {
  88007. return true;
  88008. }
  88009. var engine = this.getEngine();
  88010. var scene = this.getScene();
  88011. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  88012. this.computeWorldMatrix();
  88013. var mat = this.material || scene.defaultMaterial;
  88014. if (mat) {
  88015. if (mat._storeEffectOnSubMeshes) {
  88016. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  88017. var subMesh = _a[_i];
  88018. var effectiveMaterial = subMesh.getMaterial();
  88019. if (effectiveMaterial) {
  88020. if (effectiveMaterial._storeEffectOnSubMeshes) {
  88021. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  88022. return false;
  88023. }
  88024. }
  88025. else {
  88026. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  88027. return false;
  88028. }
  88029. }
  88030. }
  88031. }
  88032. }
  88033. else {
  88034. if (!mat.isReady(this, hardwareInstancedRendering)) {
  88035. return false;
  88036. }
  88037. }
  88038. }
  88039. // Shadows
  88040. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  88041. var light = _c[_b];
  88042. var generator = light.getShadowGenerator();
  88043. if (generator) {
  88044. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  88045. var subMesh = _e[_d];
  88046. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  88047. return false;
  88048. }
  88049. }
  88050. }
  88051. }
  88052. // LOD
  88053. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  88054. var lod = _g[_f];
  88055. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  88056. return false;
  88057. }
  88058. }
  88059. return true;
  88060. };
  88061. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  88062. /**
  88063. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  88064. */
  88065. get: function () {
  88066. return this._areNormalsFrozen;
  88067. },
  88068. enumerable: true,
  88069. configurable: true
  88070. });
  88071. /**
  88072. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  88073. * @returns the current mesh
  88074. */
  88075. Mesh.prototype.freezeNormals = function () {
  88076. this._areNormalsFrozen = true;
  88077. return this;
  88078. };
  88079. /**
  88080. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  88081. * @returns the current mesh
  88082. */
  88083. Mesh.prototype.unfreezeNormals = function () {
  88084. this._areNormalsFrozen = false;
  88085. return this;
  88086. };
  88087. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  88088. /**
  88089. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  88090. */
  88091. set: function (count) {
  88092. this._instanceDataStorage.overridenInstanceCount = count;
  88093. },
  88094. enumerable: true,
  88095. configurable: true
  88096. });
  88097. // Methods
  88098. /** @hidden */
  88099. Mesh.prototype._preActivate = function () {
  88100. var sceneRenderId = this.getScene().getRenderId();
  88101. if (this._preActivateId === sceneRenderId) {
  88102. return this;
  88103. }
  88104. this._preActivateId = sceneRenderId;
  88105. this._instanceDataStorage.visibleInstances = null;
  88106. return this;
  88107. };
  88108. /** @hidden */
  88109. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  88110. if (this._instanceDataStorage.visibleInstances) {
  88111. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  88112. }
  88113. return this;
  88114. };
  88115. /** @hidden */
  88116. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  88117. if (!this._instanceDataStorage.visibleInstances) {
  88118. this._instanceDataStorage.visibleInstances = {
  88119. defaultRenderId: renderId,
  88120. selfDefaultRenderId: this._renderId
  88121. };
  88122. }
  88123. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  88124. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  88125. }
  88126. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  88127. return this;
  88128. };
  88129. /**
  88130. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88131. * This means the mesh underlying bounding box and sphere are recomputed.
  88132. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88133. * @returns the current mesh
  88134. */
  88135. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  88136. if (applySkeleton === void 0) { applySkeleton = false; }
  88137. if (this._boundingInfo && this._boundingInfo.isLocked) {
  88138. return this;
  88139. }
  88140. var bias = this.geometry ? this.geometry.boundingBias : null;
  88141. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  88142. return this;
  88143. };
  88144. /** @hidden */
  88145. Mesh.prototype._createGlobalSubMesh = function (force) {
  88146. var totalVertices = this.getTotalVertices();
  88147. if (!totalVertices || !this.getIndices()) {
  88148. return null;
  88149. }
  88150. // Check if we need to recreate the submeshes
  88151. if (this.subMeshes && this.subMeshes.length > 0) {
  88152. var ib = this.getIndices();
  88153. if (!ib) {
  88154. return null;
  88155. }
  88156. var totalIndices = ib.length;
  88157. var needToRecreate = false;
  88158. if (force) {
  88159. needToRecreate = true;
  88160. }
  88161. else {
  88162. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  88163. var submesh = _a[_i];
  88164. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  88165. needToRecreate = true;
  88166. break;
  88167. }
  88168. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  88169. needToRecreate = true;
  88170. break;
  88171. }
  88172. }
  88173. }
  88174. if (!needToRecreate) {
  88175. return this.subMeshes[0];
  88176. }
  88177. }
  88178. this.releaseSubMeshes();
  88179. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  88180. };
  88181. /**
  88182. * This function will subdivide the mesh into multiple submeshes
  88183. * @param count defines the expected number of submeshes
  88184. */
  88185. Mesh.prototype.subdivide = function (count) {
  88186. if (count < 1) {
  88187. return;
  88188. }
  88189. var totalIndices = this.getTotalIndices();
  88190. var subdivisionSize = (totalIndices / count) | 0;
  88191. var offset = 0;
  88192. // Ensure that subdivisionSize is a multiple of 3
  88193. while (subdivisionSize % 3 !== 0) {
  88194. subdivisionSize++;
  88195. }
  88196. this.releaseSubMeshes();
  88197. for (var index = 0; index < count; index++) {
  88198. if (offset >= totalIndices) {
  88199. break;
  88200. }
  88201. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  88202. offset += subdivisionSize;
  88203. }
  88204. this.synchronizeInstances();
  88205. };
  88206. /**
  88207. * Copy a FloatArray into a specific associated vertex buffer
  88208. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88209. * - VertexBuffer.PositionKind
  88210. * - VertexBuffer.UVKind
  88211. * - VertexBuffer.UV2Kind
  88212. * - VertexBuffer.UV3Kind
  88213. * - VertexBuffer.UV4Kind
  88214. * - VertexBuffer.UV5Kind
  88215. * - VertexBuffer.UV6Kind
  88216. * - VertexBuffer.ColorKind
  88217. * - VertexBuffer.MatricesIndicesKind
  88218. * - VertexBuffer.MatricesIndicesExtraKind
  88219. * - VertexBuffer.MatricesWeightsKind
  88220. * - VertexBuffer.MatricesWeightsExtraKind
  88221. * @param data defines the data source
  88222. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88223. * @param stride defines the data stride size (can be null)
  88224. * @returns the current mesh
  88225. */
  88226. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  88227. if (updatable === void 0) { updatable = false; }
  88228. if (!this._geometry) {
  88229. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  88230. vertexData.set(data, kind);
  88231. var scene = this.getScene();
  88232. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  88233. }
  88234. else {
  88235. this._geometry.setVerticesData(kind, data, updatable, stride);
  88236. }
  88237. return this;
  88238. };
  88239. /**
  88240. * Flags an associated vertex buffer as updatable
  88241. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  88242. * - VertexBuffer.PositionKind
  88243. * - VertexBuffer.UVKind
  88244. * - VertexBuffer.UV2Kind
  88245. * - VertexBuffer.UV3Kind
  88246. * - VertexBuffer.UV4Kind
  88247. * - VertexBuffer.UV5Kind
  88248. * - VertexBuffer.UV6Kind
  88249. * - VertexBuffer.ColorKind
  88250. * - VertexBuffer.MatricesIndicesKind
  88251. * - VertexBuffer.MatricesIndicesExtraKind
  88252. * - VertexBuffer.MatricesWeightsKind
  88253. * - VertexBuffer.MatricesWeightsExtraKind
  88254. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88255. */
  88256. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  88257. if (updatable === void 0) { updatable = true; }
  88258. var vb = this.getVertexBuffer(kind);
  88259. if (!vb || vb.isUpdatable() === updatable) {
  88260. return;
  88261. }
  88262. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  88263. };
  88264. /**
  88265. * Sets the mesh global Vertex Buffer
  88266. * @param buffer defines the buffer to use
  88267. * @returns the current mesh
  88268. */
  88269. Mesh.prototype.setVerticesBuffer = function (buffer) {
  88270. if (!this._geometry) {
  88271. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  88272. }
  88273. this._geometry.setVerticesBuffer(buffer);
  88274. return this;
  88275. };
  88276. /**
  88277. * Update a specific associated vertex buffer
  88278. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88279. * - VertexBuffer.PositionKind
  88280. * - VertexBuffer.UVKind
  88281. * - VertexBuffer.UV2Kind
  88282. * - VertexBuffer.UV3Kind
  88283. * - VertexBuffer.UV4Kind
  88284. * - VertexBuffer.UV5Kind
  88285. * - VertexBuffer.UV6Kind
  88286. * - VertexBuffer.ColorKind
  88287. * - VertexBuffer.MatricesIndicesKind
  88288. * - VertexBuffer.MatricesIndicesExtraKind
  88289. * - VertexBuffer.MatricesWeightsKind
  88290. * - VertexBuffer.MatricesWeightsExtraKind
  88291. * @param data defines the data source
  88292. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88293. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  88294. * @returns the current mesh
  88295. */
  88296. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  88297. if (!this._geometry) {
  88298. return this;
  88299. }
  88300. if (!makeItUnique) {
  88301. this._geometry.updateVerticesData(kind, data, updateExtends);
  88302. }
  88303. else {
  88304. this.makeGeometryUnique();
  88305. this.updateVerticesData(kind, data, updateExtends, false);
  88306. }
  88307. return this;
  88308. };
  88309. /**
  88310. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  88311. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  88312. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  88313. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  88314. * @returns the current mesh
  88315. */
  88316. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  88317. if (computeNormals === void 0) { computeNormals = true; }
  88318. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  88319. if (!positions) {
  88320. return this;
  88321. }
  88322. positionFunction(positions);
  88323. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  88324. if (computeNormals) {
  88325. var indices = this.getIndices();
  88326. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  88327. if (!normals) {
  88328. return this;
  88329. }
  88330. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  88331. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  88332. }
  88333. return this;
  88334. };
  88335. /**
  88336. * Creates a un-shared specific occurence of the geometry for the mesh.
  88337. * @returns the current mesh
  88338. */
  88339. Mesh.prototype.makeGeometryUnique = function () {
  88340. if (!this._geometry) {
  88341. return this;
  88342. }
  88343. var oldGeometry = this._geometry;
  88344. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  88345. oldGeometry.releaseForMesh(this, true);
  88346. geometry.applyToMesh(this);
  88347. return this;
  88348. };
  88349. /**
  88350. * Set the index buffer of this mesh
  88351. * @param indices defines the source data
  88352. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  88353. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  88354. * @returns the current mesh
  88355. */
  88356. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  88357. if (totalVertices === void 0) { totalVertices = null; }
  88358. if (updatable === void 0) { updatable = false; }
  88359. if (!this._geometry) {
  88360. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  88361. vertexData.indices = indices;
  88362. var scene = this.getScene();
  88363. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  88364. }
  88365. else {
  88366. this._geometry.setIndices(indices, totalVertices, updatable);
  88367. }
  88368. return this;
  88369. };
  88370. /**
  88371. * Update the current index buffer
  88372. * @param indices defines the source data
  88373. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88374. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  88375. * @returns the current mesh
  88376. */
  88377. Mesh.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  88378. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  88379. if (!this._geometry) {
  88380. return this;
  88381. }
  88382. this._geometry.updateIndices(indices, offset, gpuMemoryOnly);
  88383. return this;
  88384. };
  88385. /**
  88386. * Invert the geometry to move from a right handed system to a left handed one.
  88387. * @returns the current mesh
  88388. */
  88389. Mesh.prototype.toLeftHanded = function () {
  88390. if (!this._geometry) {
  88391. return this;
  88392. }
  88393. this._geometry.toLeftHanded();
  88394. return this;
  88395. };
  88396. /** @hidden */
  88397. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  88398. if (!this._geometry) {
  88399. return this;
  88400. }
  88401. var engine = this.getScene().getEngine();
  88402. // Wireframe
  88403. var indexToBind;
  88404. if (this._unIndexed) {
  88405. indexToBind = null;
  88406. }
  88407. else {
  88408. switch (fillMode) {
  88409. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  88410. indexToBind = null;
  88411. break;
  88412. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  88413. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  88414. break;
  88415. default:
  88416. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  88417. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  88418. break;
  88419. }
  88420. }
  88421. // VBOs
  88422. this._geometry._bind(effect, indexToBind);
  88423. return this;
  88424. };
  88425. /** @hidden */
  88426. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  88427. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  88428. return this;
  88429. }
  88430. if (this._onBeforeDrawObservable) {
  88431. this._onBeforeDrawObservable.notifyObservers(this);
  88432. }
  88433. var scene = this.getScene();
  88434. var engine = scene.getEngine();
  88435. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  88436. // or triangles as points
  88437. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  88438. }
  88439. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  88440. // Triangles as wireframe
  88441. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  88442. }
  88443. else {
  88444. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  88445. }
  88446. return this;
  88447. };
  88448. /**
  88449. * Registers for this mesh a javascript function called just before the rendering process
  88450. * @param func defines the function to call before rendering this mesh
  88451. * @returns the current mesh
  88452. */
  88453. Mesh.prototype.registerBeforeRender = function (func) {
  88454. this.onBeforeRenderObservable.add(func);
  88455. return this;
  88456. };
  88457. /**
  88458. * Disposes a previously registered javascript function called before the rendering
  88459. * @param func defines the function to remove
  88460. * @returns the current mesh
  88461. */
  88462. Mesh.prototype.unregisterBeforeRender = function (func) {
  88463. this.onBeforeRenderObservable.removeCallback(func);
  88464. return this;
  88465. };
  88466. /**
  88467. * Registers for this mesh a javascript function called just after the rendering is complete
  88468. * @param func defines the function to call after rendering this mesh
  88469. * @returns the current mesh
  88470. */
  88471. Mesh.prototype.registerAfterRender = function (func) {
  88472. this.onAfterRenderObservable.add(func);
  88473. return this;
  88474. };
  88475. /**
  88476. * Disposes a previously registered javascript function called after the rendering.
  88477. * @param func defines the function to remove
  88478. * @returns the current mesh
  88479. */
  88480. Mesh.prototype.unregisterAfterRender = function (func) {
  88481. this.onAfterRenderObservable.removeCallback(func);
  88482. return this;
  88483. };
  88484. /** @hidden */
  88485. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  88486. if (this._instanceDataStorage.isFrozen && this._instanceDataStorage.previousBatch) {
  88487. return this._instanceDataStorage.previousBatch;
  88488. }
  88489. var scene = this.getScene();
  88490. var batchCache = this._instanceDataStorage.batchCache;
  88491. batchCache.mustReturn = false;
  88492. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  88493. batchCache.visibleInstances[subMeshId] = null;
  88494. if (this._instanceDataStorage.visibleInstances) {
  88495. var visibleInstances = this._instanceDataStorage.visibleInstances;
  88496. var currentRenderId = scene.getRenderId();
  88497. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  88498. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  88499. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  88500. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  88501. }
  88502. }
  88503. batchCache.hardwareInstancedRendering[subMeshId] = this._instanceDataStorage.hardwareInstancedRendering && (batchCache.visibleInstances[subMeshId] !== null) && (batchCache.visibleInstances[subMeshId] !== undefined);
  88504. this._instanceDataStorage.previousBatch = batchCache;
  88505. return batchCache;
  88506. };
  88507. /** @hidden */
  88508. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  88509. var visibleInstances = batch.visibleInstances[subMesh._id];
  88510. if (!visibleInstances) {
  88511. return this;
  88512. }
  88513. var instanceStorage = this._instanceDataStorage;
  88514. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  88515. var instancesBuffer = instanceStorage.instancesBuffer;
  88516. if (!instanceStorage.isFrozen || !instanceStorage.instancesData) {
  88517. var matricesCount = visibleInstances.length + 1;
  88518. var bufferSize = matricesCount * 16 * 4;
  88519. while (instanceStorage.instancesBufferSize < bufferSize) {
  88520. instanceStorage.instancesBufferSize *= 2;
  88521. }
  88522. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  88523. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  88524. }
  88525. }
  88526. var offset = 0;
  88527. var instancesCount = 0;
  88528. var world = this._effectiveMesh.getWorldMatrix();
  88529. if (batch.renderSelf[subMesh._id]) {
  88530. world.copyToArray(instanceStorage.instancesData, offset);
  88531. offset += 16;
  88532. instancesCount++;
  88533. }
  88534. if (visibleInstances) {
  88535. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  88536. var instance = visibleInstances[instanceIndex];
  88537. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  88538. offset += 16;
  88539. instancesCount++;
  88540. }
  88541. }
  88542. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  88543. if (instancesBuffer) {
  88544. instancesBuffer.dispose();
  88545. }
  88546. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  88547. instanceStorage.instancesBuffer = instancesBuffer;
  88548. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  88549. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  88550. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  88551. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  88552. }
  88553. else {
  88554. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  88555. }
  88556. this._bind(subMesh, effect, fillMode);
  88557. this._draw(subMesh, fillMode, instancesCount);
  88558. engine.unbindInstanceAttributes();
  88559. return this;
  88560. };
  88561. /** @hidden */
  88562. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  88563. var scene = this.getScene();
  88564. var engine = scene.getEngine();
  88565. if (hardwareInstancedRendering) {
  88566. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  88567. }
  88568. else {
  88569. if (batch.renderSelf[subMesh._id]) {
  88570. // Draw
  88571. if (onBeforeDraw) {
  88572. onBeforeDraw(false, this._effectiveMesh.getWorldMatrix(), effectiveMaterial);
  88573. }
  88574. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  88575. }
  88576. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  88577. if (visibleInstancesForSubMesh) {
  88578. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  88579. var instance = visibleInstancesForSubMesh[instanceIndex];
  88580. // World
  88581. var world = instance.getWorldMatrix();
  88582. if (onBeforeDraw) {
  88583. onBeforeDraw(true, world, effectiveMaterial);
  88584. }
  88585. // Draw
  88586. this._draw(subMesh, fillMode);
  88587. }
  88588. }
  88589. }
  88590. return this;
  88591. };
  88592. /** @hidden */
  88593. Mesh.prototype._freeze = function () {
  88594. this._instanceDataStorage.isFrozen = true;
  88595. if (!this.subMeshes) {
  88596. return;
  88597. }
  88598. // Prepare batches
  88599. for (var index = 0; index < this.subMeshes.length; index++) {
  88600. this._getInstancesRenderList(index);
  88601. }
  88602. };
  88603. /** @hidden */
  88604. Mesh.prototype._unFreeze = function () {
  88605. this._instanceDataStorage.isFrozen = false;
  88606. };
  88607. /**
  88608. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  88609. * @param subMesh defines the subMesh to render
  88610. * @param enableAlphaMode defines if alpha mode can be changed
  88611. * @returns the current mesh
  88612. */
  88613. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  88614. if (this._checkOcclusionQuery()) {
  88615. return this;
  88616. }
  88617. var scene = this.getScene();
  88618. // Managing instances
  88619. var batch = this._getInstancesRenderList(subMesh._id);
  88620. if (batch.mustReturn) {
  88621. return this;
  88622. }
  88623. // Checking geometry state
  88624. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  88625. return this;
  88626. }
  88627. if (this._onBeforeRenderObservable) {
  88628. this._onBeforeRenderObservable.notifyObservers(this);
  88629. }
  88630. var engine = scene.getEngine();
  88631. var hardwareInstancedRendering = batch.hardwareInstancedRendering[subMesh._id];
  88632. var instanceDataStorage = this._instanceDataStorage;
  88633. // Material
  88634. if (!instanceDataStorage.isFrozen || !this._effectiveMaterial) {
  88635. var material = subMesh.getMaterial();
  88636. if (!material) {
  88637. return this;
  88638. }
  88639. this._effectiveMaterial = material;
  88640. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  88641. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  88642. return this;
  88643. }
  88644. }
  88645. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  88646. return this;
  88647. }
  88648. }
  88649. // Alpha mode
  88650. if (enableAlphaMode) {
  88651. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  88652. }
  88653. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  88654. var step = _a[_i];
  88655. step.action(this, subMesh, batch);
  88656. }
  88657. var effect;
  88658. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  88659. effect = subMesh.effect;
  88660. }
  88661. else {
  88662. effect = this._effectiveMaterial.getEffect();
  88663. }
  88664. if (!effect) {
  88665. return this;
  88666. }
  88667. var effectiveMesh = this._effectiveMesh;
  88668. var sideOrientation;
  88669. if (!instanceDataStorage.isFrozen) {
  88670. sideOrientation = this.overrideMaterialSideOrientation;
  88671. if (sideOrientation == null) {
  88672. sideOrientation = this._effectiveMaterial.sideOrientation;
  88673. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  88674. sideOrientation = (sideOrientation === _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].ClockWiseSideOrientation ? _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].CounterClockWiseSideOrientation : _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].ClockWiseSideOrientation);
  88675. }
  88676. }
  88677. instanceDataStorage.sideOrientation = sideOrientation;
  88678. }
  88679. else {
  88680. sideOrientation = instanceDataStorage.sideOrientation;
  88681. }
  88682. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  88683. if (this._effectiveMaterial.forceDepthWrite) {
  88684. engine.setDepthWrite(true);
  88685. }
  88686. // Bind
  88687. var fillMode = scene.forcePointsCloud ? _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode : (scene.forceWireframe ? _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode : this._effectiveMaterial.fillMode);
  88688. if (this._onBeforeBindObservable) {
  88689. this._onBeforeBindObservable.notifyObservers(this);
  88690. }
  88691. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  88692. this._bind(subMesh, effect, fillMode);
  88693. }
  88694. var world = effectiveMesh.getWorldMatrix();
  88695. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  88696. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  88697. }
  88698. else {
  88699. this._effectiveMaterial.bind(world, this);
  88700. }
  88701. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  88702. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  88703. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  88704. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  88705. }
  88706. // Draw
  88707. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  88708. // Unbind
  88709. this._effectiveMaterial.unbind();
  88710. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  88711. var step = _c[_b];
  88712. step.action(this, subMesh, batch);
  88713. }
  88714. if (this._onAfterRenderObservable) {
  88715. this._onAfterRenderObservable.notifyObservers(this);
  88716. }
  88717. return this;
  88718. };
  88719. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  88720. if (isInstance && effectiveMaterial) {
  88721. effectiveMaterial.bindOnlyWorldMatrix(world);
  88722. }
  88723. };
  88724. /**
  88725. * Renormalize the mesh and patch it up if there are no weights
  88726. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  88727. * However in the case of zero weights then we set just a single influence to 1.
  88728. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  88729. */
  88730. Mesh.prototype.cleanMatrixWeights = function () {
  88731. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  88732. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  88733. this.normalizeSkinWeightsAndExtra();
  88734. }
  88735. else {
  88736. this.normalizeSkinFourWeights();
  88737. }
  88738. }
  88739. };
  88740. // faster 4 weight version.
  88741. Mesh.prototype.normalizeSkinFourWeights = function () {
  88742. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  88743. var numWeights = matricesWeights.length;
  88744. for (var a = 0; a < numWeights; a += 4) {
  88745. // accumulate weights
  88746. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  88747. // check for invalid weight and just set it to 1.
  88748. if (t === 0) {
  88749. matricesWeights[a] = 1;
  88750. }
  88751. else {
  88752. // renormalize so everything adds to 1 use reciprical
  88753. var recip = 1 / t;
  88754. matricesWeights[a] *= recip;
  88755. matricesWeights[a + 1] *= recip;
  88756. matricesWeights[a + 2] *= recip;
  88757. matricesWeights[a + 3] *= recip;
  88758. }
  88759. }
  88760. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  88761. };
  88762. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  88763. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  88764. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  88765. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  88766. var numWeights = matricesWeights.length;
  88767. for (var a = 0; a < numWeights; a += 4) {
  88768. // accumulate weights
  88769. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  88770. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  88771. // check for invalid weight and just set it to 1.
  88772. if (t === 0) {
  88773. matricesWeights[a] = 1;
  88774. }
  88775. else {
  88776. // renormalize so everything adds to 1 use reciprical
  88777. var recip = 1 / t;
  88778. matricesWeights[a] *= recip;
  88779. matricesWeights[a + 1] *= recip;
  88780. matricesWeights[a + 2] *= recip;
  88781. matricesWeights[a + 3] *= recip;
  88782. // same goes for extras
  88783. matricesWeightsExtra[a] *= recip;
  88784. matricesWeightsExtra[a + 1] *= recip;
  88785. matricesWeightsExtra[a + 2] *= recip;
  88786. matricesWeightsExtra[a + 3] *= recip;
  88787. }
  88788. }
  88789. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  88790. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  88791. };
  88792. /**
  88793. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  88794. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  88795. * the user know there was an issue with importing the mesh
  88796. * @returns a validation object with skinned, valid and report string
  88797. */
  88798. Mesh.prototype.validateSkinning = function () {
  88799. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  88800. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  88801. if (matricesWeights === null || this.skeleton == null) {
  88802. return { skinned: false, valid: true, report: "not skinned" };
  88803. }
  88804. var numWeights = matricesWeights.length;
  88805. var numberNotSorted = 0;
  88806. var missingWeights = 0;
  88807. var maxUsedWeights = 0;
  88808. var numberNotNormalized = 0;
  88809. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  88810. var usedWeightCounts = new Array();
  88811. for (var a = 0; a <= numInfluences; a++) {
  88812. usedWeightCounts[a] = 0;
  88813. }
  88814. var toleranceEpsilon = 0.001;
  88815. for (var a = 0; a < numWeights; a += 4) {
  88816. var lastWeight = matricesWeights[a];
  88817. var t = lastWeight;
  88818. var usedWeights = t === 0 ? 0 : 1;
  88819. for (var b = 1; b < numInfluences; b++) {
  88820. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  88821. if (d > lastWeight) {
  88822. numberNotSorted++;
  88823. }
  88824. if (d !== 0) {
  88825. usedWeights++;
  88826. }
  88827. t += d;
  88828. lastWeight = d;
  88829. }
  88830. // count the buffer weights usage
  88831. usedWeightCounts[usedWeights]++;
  88832. // max influences
  88833. if (usedWeights > maxUsedWeights) {
  88834. maxUsedWeights = usedWeights;
  88835. }
  88836. // check for invalid weight and just set it to 1.
  88837. if (t === 0) {
  88838. missingWeights++;
  88839. }
  88840. else {
  88841. // renormalize so everything adds to 1 use reciprical
  88842. var recip = 1 / t;
  88843. var tolerance = 0;
  88844. for (b = 0; b < numInfluences; b++) {
  88845. if (b < 4) {
  88846. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  88847. }
  88848. else {
  88849. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  88850. }
  88851. }
  88852. // arbitary epsilon value for dicdating not normalized
  88853. if (tolerance > toleranceEpsilon) {
  88854. numberNotNormalized++;
  88855. }
  88856. }
  88857. }
  88858. // validate bone indices are in range of the skeleton
  88859. var numBones = this.skeleton.bones.length;
  88860. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  88861. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  88862. var numBadBoneIndices = 0;
  88863. for (var a = 0; a < numWeights; a++) {
  88864. for (var b = 0; b < numInfluences; b++) {
  88865. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  88866. if (index >= numBones || index < 0) {
  88867. numBadBoneIndices++;
  88868. }
  88869. }
  88870. }
  88871. // log mesh stats
  88872. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  88873. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  88874. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  88875. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  88876. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  88877. };
  88878. /** @hidden */
  88879. Mesh.prototype._checkDelayState = function () {
  88880. var scene = this.getScene();
  88881. if (this._geometry) {
  88882. this._geometry.load(scene);
  88883. }
  88884. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  88885. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING;
  88886. this._queueLoad(scene);
  88887. }
  88888. return this;
  88889. };
  88890. Mesh.prototype._queueLoad = function (scene) {
  88891. var _this = this;
  88892. scene._addPendingData(this);
  88893. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  88894. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  88895. if (data instanceof ArrayBuffer) {
  88896. _this._delayLoadingFunction(data, _this);
  88897. }
  88898. else {
  88899. _this._delayLoadingFunction(JSON.parse(data), _this);
  88900. }
  88901. _this.instances.forEach(function (instance) {
  88902. instance._syncSubMeshes();
  88903. });
  88904. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADED;
  88905. scene._removePendingData(_this);
  88906. }, function () { }, scene.offlineProvider, getBinaryData);
  88907. return this;
  88908. };
  88909. /**
  88910. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  88911. * A mesh is in the frustum if its bounding box intersects the frustum
  88912. * @param frustumPlanes defines the frustum to test
  88913. * @returns true if the mesh is in the frustum planes
  88914. */
  88915. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  88916. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  88917. return false;
  88918. }
  88919. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  88920. return false;
  88921. }
  88922. this._checkDelayState();
  88923. return true;
  88924. };
  88925. /**
  88926. * Sets the mesh material by the material or multiMaterial `id` property
  88927. * @param id is a string identifying the material or the multiMaterial
  88928. * @returns the current mesh
  88929. */
  88930. Mesh.prototype.setMaterialByID = function (id) {
  88931. var materials = this.getScene().materials;
  88932. var index;
  88933. for (index = materials.length - 1; index > -1; index--) {
  88934. if (materials[index].id === id) {
  88935. this.material = materials[index];
  88936. return this;
  88937. }
  88938. }
  88939. // Multi
  88940. var multiMaterials = this.getScene().multiMaterials;
  88941. for (index = multiMaterials.length - 1; index > -1; index--) {
  88942. if (multiMaterials[index].id === id) {
  88943. this.material = multiMaterials[index];
  88944. return this;
  88945. }
  88946. }
  88947. return this;
  88948. };
  88949. /**
  88950. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  88951. * @returns an array of IAnimatable
  88952. */
  88953. Mesh.prototype.getAnimatables = function () {
  88954. var results = new Array();
  88955. if (this.material) {
  88956. results.push(this.material);
  88957. }
  88958. if (this.skeleton) {
  88959. results.push(this.skeleton);
  88960. }
  88961. return results;
  88962. };
  88963. /**
  88964. * Modifies the mesh geometry according to the passed transformation matrix.
  88965. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  88966. * The mesh normals are modified using the same transformation.
  88967. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88968. * @param transform defines the transform matrix to use
  88969. * @see http://doc.babylonjs.com/resources/baking_transformations
  88970. * @returns the current mesh
  88971. */
  88972. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  88973. // Position
  88974. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  88975. return this;
  88976. }
  88977. var submeshes = this.subMeshes.splice(0);
  88978. this._resetPointsArrayCache();
  88979. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  88980. var temp = new Array();
  88981. var index;
  88982. for (index = 0; index < data.length; index += 3) {
  88983. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  88984. }
  88985. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  88986. // Normals
  88987. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  88988. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  88989. temp = [];
  88990. for (index = 0; index < data.length; index += 3) {
  88991. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  88992. }
  88993. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  88994. }
  88995. // flip faces?
  88996. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  88997. this.flipFaces();
  88998. }
  88999. // Restore submeshes
  89000. this.releaseSubMeshes();
  89001. this.subMeshes = submeshes;
  89002. return this;
  89003. };
  89004. /**
  89005. * Modifies the mesh geometry according to its own current World Matrix.
  89006. * The mesh World Matrix is then reset.
  89007. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  89008. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89009. * @see http://doc.babylonjs.com/resources/baking_transformations
  89010. * @returns the current mesh
  89011. */
  89012. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  89013. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  89014. this.scaling.copyFromFloats(1, 1, 1);
  89015. this.position.copyFromFloats(0, 0, 0);
  89016. this.rotation.copyFromFloats(0, 0, 0);
  89017. //only if quaternion is already set
  89018. if (this.rotationQuaternion) {
  89019. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  89020. }
  89021. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  89022. return this;
  89023. };
  89024. Object.defineProperty(Mesh.prototype, "_positions", {
  89025. // Cache
  89026. /** @hidden */
  89027. get: function () {
  89028. if (this._geometry) {
  89029. return this._geometry._positions;
  89030. }
  89031. return null;
  89032. },
  89033. enumerable: true,
  89034. configurable: true
  89035. });
  89036. /** @hidden */
  89037. Mesh.prototype._resetPointsArrayCache = function () {
  89038. if (this._geometry) {
  89039. this._geometry._resetPointsArrayCache();
  89040. }
  89041. return this;
  89042. };
  89043. /** @hidden */
  89044. Mesh.prototype._generatePointsArray = function () {
  89045. if (this._geometry) {
  89046. return this._geometry._generatePointsArray();
  89047. }
  89048. return false;
  89049. };
  89050. /**
  89051. * Returns a new Mesh object generated from the current mesh properties.
  89052. * This method must not get confused with createInstance()
  89053. * @param name is a string, the name given to the new mesh
  89054. * @param newParent can be any Node object (default `null`)
  89055. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  89056. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  89057. * @returns a new mesh
  89058. */
  89059. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  89060. if (name === void 0) { name = ""; }
  89061. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  89062. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  89063. };
  89064. /**
  89065. * Releases resources associated with this mesh.
  89066. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89067. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89068. */
  89069. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  89070. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  89071. this.morphTargetManager = null;
  89072. if (this._geometry) {
  89073. this._geometry.releaseForMesh(this, true);
  89074. }
  89075. if (this._onBeforeDrawObservable) {
  89076. this._onBeforeDrawObservable.clear();
  89077. }
  89078. if (this._onBeforeBindObservable) {
  89079. this._onBeforeBindObservable.clear();
  89080. }
  89081. if (this._onBeforeRenderObservable) {
  89082. this._onBeforeRenderObservable.clear();
  89083. }
  89084. if (this._onAfterRenderObservable) {
  89085. this._onAfterRenderObservable.clear();
  89086. }
  89087. // Sources
  89088. if (this._scene.useClonedMeshhMap) {
  89089. if (this.meshMap) {
  89090. for (var uniqueId in this.meshMap) {
  89091. var mesh = this.meshMap[uniqueId];
  89092. if (mesh) {
  89093. mesh._source = null;
  89094. this.meshMap[uniqueId] = undefined;
  89095. }
  89096. }
  89097. }
  89098. if (this._source && this._source.meshMap) {
  89099. this._source.meshMap[this.uniqueId] = undefined;
  89100. }
  89101. }
  89102. else {
  89103. var meshes = this.getScene().meshes;
  89104. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  89105. var abstractMesh = meshes_1[_i];
  89106. var mesh = abstractMesh;
  89107. if (mesh._source && mesh._source === this) {
  89108. mesh._source = null;
  89109. }
  89110. }
  89111. }
  89112. this._source = null;
  89113. // Instances
  89114. if (this._instanceDataStorage.instancesBuffer) {
  89115. this._instanceDataStorage.instancesBuffer.dispose();
  89116. this._instanceDataStorage.instancesBuffer = null;
  89117. }
  89118. while (this.instances.length) {
  89119. this.instances[0].dispose();
  89120. }
  89121. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  89122. };
  89123. /**
  89124. * Modifies the mesh geometry according to a displacement map.
  89125. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  89126. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89127. * @param url is a string, the URL from the image file is to be downloaded.
  89128. * @param minHeight is the lower limit of the displacement.
  89129. * @param maxHeight is the upper limit of the displacement.
  89130. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  89131. * @param uvOffset is an optional vector2 used to offset UV.
  89132. * @param uvScale is an optional vector2 used to scale UV.
  89133. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  89134. * @returns the Mesh.
  89135. */
  89136. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  89137. var _this = this;
  89138. if (forceUpdate === void 0) { forceUpdate = false; }
  89139. var scene = this.getScene();
  89140. var onload = function (img) {
  89141. // Getting height map data
  89142. var canvas = document.createElement("canvas");
  89143. var context = canvas.getContext("2d");
  89144. var heightMapWidth = img.width;
  89145. var heightMapHeight = img.height;
  89146. canvas.width = heightMapWidth;
  89147. canvas.height = heightMapHeight;
  89148. context.drawImage(img, 0, 0);
  89149. // Create VertexData from map data
  89150. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  89151. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  89152. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  89153. //execute success callback, if set
  89154. if (onSuccess) {
  89155. onSuccess(_this);
  89156. }
  89157. };
  89158. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  89159. return this;
  89160. };
  89161. /**
  89162. * Modifies the mesh geometry according to a displacementMap buffer.
  89163. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  89164. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89165. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89166. * @param heightMapWidth is the width of the buffer image.
  89167. * @param heightMapHeight is the height of the buffer image.
  89168. * @param minHeight is the lower limit of the displacement.
  89169. * @param maxHeight is the upper limit of the displacement.
  89170. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  89171. * @param uvOffset is an optional vector2 used to offset UV.
  89172. * @param uvScale is an optional vector2 used to scale UV.
  89173. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  89174. * @returns the Mesh.
  89175. */
  89176. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  89177. if (forceUpdate === void 0) { forceUpdate = false; }
  89178. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  89179. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  89180. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  89181. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  89182. return this;
  89183. }
  89184. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  89185. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  89186. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  89187. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  89188. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  89189. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  89190. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  89191. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  89192. for (var index = 0; index < positions.length; index += 3) {
  89193. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  89194. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  89195. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  89196. // Compute height
  89197. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  89198. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  89199. var pos = (u + v * heightMapWidth) * 4;
  89200. var r = buffer[pos] / 255.0;
  89201. var g = buffer[pos + 1] / 255.0;
  89202. var b = buffer[pos + 2] / 255.0;
  89203. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  89204. normal.normalize();
  89205. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  89206. position = position.add(normal);
  89207. position.toArray(positions, index);
  89208. }
  89209. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  89210. if (forceUpdate) {
  89211. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  89212. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  89213. }
  89214. else {
  89215. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  89216. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  89217. }
  89218. return this;
  89219. };
  89220. /**
  89221. * Modify the mesh to get a flat shading rendering.
  89222. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89223. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89224. * @returns current mesh
  89225. */
  89226. Mesh.prototype.convertToFlatShadedMesh = function () {
  89227. var kinds = this.getVerticesDataKinds();
  89228. var vbs = {};
  89229. var data = {};
  89230. var newdata = {};
  89231. var updatableNormals = false;
  89232. var kindIndex;
  89233. var kind;
  89234. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89235. kind = kinds[kindIndex];
  89236. var vertexBuffer = this.getVertexBuffer(kind);
  89237. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  89238. updatableNormals = vertexBuffer.isUpdatable();
  89239. kinds.splice(kindIndex, 1);
  89240. kindIndex--;
  89241. continue;
  89242. }
  89243. vbs[kind] = vertexBuffer;
  89244. data[kind] = vbs[kind].getData();
  89245. newdata[kind] = [];
  89246. }
  89247. // Save previous submeshes
  89248. var previousSubmeshes = this.subMeshes.slice(0);
  89249. var indices = this.getIndices();
  89250. var totalIndices = this.getTotalIndices();
  89251. // Generating unique vertices per face
  89252. var index;
  89253. for (index = 0; index < totalIndices; index++) {
  89254. var vertexIndex = indices[index];
  89255. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89256. kind = kinds[kindIndex];
  89257. var stride = vbs[kind].getStrideSize();
  89258. for (var offset = 0; offset < stride; offset++) {
  89259. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  89260. }
  89261. }
  89262. }
  89263. // Updating faces & normal
  89264. var normals = [];
  89265. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  89266. for (index = 0; index < totalIndices; index += 3) {
  89267. indices[index] = index;
  89268. indices[index + 1] = index + 1;
  89269. indices[index + 2] = index + 2;
  89270. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  89271. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  89272. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  89273. var p1p2 = p1.subtract(p2);
  89274. var p3p2 = p3.subtract(p2);
  89275. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  89276. // Store same normals for every vertex
  89277. for (var localIndex = 0; localIndex < 3; localIndex++) {
  89278. normals.push(normal.x);
  89279. normals.push(normal.y);
  89280. normals.push(normal.z);
  89281. }
  89282. }
  89283. this.setIndices(indices);
  89284. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  89285. // Updating vertex buffers
  89286. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89287. kind = kinds[kindIndex];
  89288. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  89289. }
  89290. // Updating submeshes
  89291. this.releaseSubMeshes();
  89292. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  89293. var previousOne = previousSubmeshes[submeshIndex];
  89294. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  89295. }
  89296. this.synchronizeInstances();
  89297. return this;
  89298. };
  89299. /**
  89300. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89301. * In other words, more vertices, no more indices and a single bigger VBO.
  89302. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  89303. * @returns current mesh
  89304. */
  89305. Mesh.prototype.convertToUnIndexedMesh = function () {
  89306. var kinds = this.getVerticesDataKinds();
  89307. var vbs = {};
  89308. var data = {};
  89309. var newdata = {};
  89310. var kindIndex;
  89311. var kind;
  89312. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89313. kind = kinds[kindIndex];
  89314. var vertexBuffer = this.getVertexBuffer(kind);
  89315. vbs[kind] = vertexBuffer;
  89316. data[kind] = vbs[kind].getData();
  89317. newdata[kind] = [];
  89318. }
  89319. // Save previous submeshes
  89320. var previousSubmeshes = this.subMeshes.slice(0);
  89321. var indices = this.getIndices();
  89322. var totalIndices = this.getTotalIndices();
  89323. // Generating unique vertices per face
  89324. var index;
  89325. for (index = 0; index < totalIndices; index++) {
  89326. var vertexIndex = indices[index];
  89327. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89328. kind = kinds[kindIndex];
  89329. var stride = vbs[kind].getStrideSize();
  89330. for (var offset = 0; offset < stride; offset++) {
  89331. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  89332. }
  89333. }
  89334. }
  89335. // Updating indices
  89336. for (index = 0; index < totalIndices; index += 3) {
  89337. indices[index] = index;
  89338. indices[index + 1] = index + 1;
  89339. indices[index + 2] = index + 2;
  89340. }
  89341. this.setIndices(indices);
  89342. // Updating vertex buffers
  89343. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89344. kind = kinds[kindIndex];
  89345. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  89346. }
  89347. // Updating submeshes
  89348. this.releaseSubMeshes();
  89349. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  89350. var previousOne = previousSubmeshes[submeshIndex];
  89351. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  89352. }
  89353. this._unIndexed = true;
  89354. this.synchronizeInstances();
  89355. return this;
  89356. };
  89357. /**
  89358. * Inverses facet orientations.
  89359. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89360. * @param flipNormals will also inverts the normals
  89361. * @returns current mesh
  89362. */
  89363. Mesh.prototype.flipFaces = function (flipNormals) {
  89364. if (flipNormals === void 0) { flipNormals = false; }
  89365. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  89366. var i;
  89367. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  89368. for (i = 0; i < vertex_data.normals.length; i++) {
  89369. vertex_data.normals[i] *= -1;
  89370. }
  89371. }
  89372. if (vertex_data.indices) {
  89373. var temp;
  89374. for (i = 0; i < vertex_data.indices.length; i += 3) {
  89375. // reassign indices
  89376. temp = vertex_data.indices[i + 1];
  89377. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  89378. vertex_data.indices[i + 2] = temp;
  89379. }
  89380. }
  89381. vertex_data.applyToMesh(this);
  89382. return this;
  89383. };
  89384. /**
  89385. * Increase the number of facets and hence vertices in a mesh
  89386. * Vertex normals are interpolated from existing vertex normals
  89387. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89388. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  89389. */
  89390. Mesh.prototype.increaseVertices = function (numberPerEdge) {
  89391. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  89392. var uvs = vertex_data.uvs;
  89393. var currentIndices = vertex_data.indices;
  89394. var positions = vertex_data.positions;
  89395. var normals = vertex_data.normals;
  89396. if (currentIndices === null || positions === null || normals === null || uvs === null) {
  89397. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("VertexData contains null entries");
  89398. }
  89399. else {
  89400. var segments = numberPerEdge + 1; //segments per current facet edge, become sides of new facets
  89401. var tempIndices = new Array();
  89402. for (var i = 0; i < segments + 1; i++) {
  89403. tempIndices[i] = new Array();
  89404. }
  89405. var a; //vertex index of one end of a side
  89406. var b; //vertex index of other end of the side
  89407. var deltaPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 0);
  89408. var deltaNormal = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 0);
  89409. var deltaUV = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](0, 0);
  89410. var indices = new Array();
  89411. var vertexIndex = new Array();
  89412. var side = new Array();
  89413. var len;
  89414. var positionPtr = positions.length;
  89415. var uvPtr = uvs.length;
  89416. for (var i = 0; i < currentIndices.length; i += 3) {
  89417. vertexIndex[0] = currentIndices[i];
  89418. vertexIndex[1] = currentIndices[i + 1];
  89419. vertexIndex[2] = currentIndices[i + 2];
  89420. for (var j = 0; j < 3; j++) {
  89421. a = vertexIndex[j];
  89422. b = vertexIndex[(j + 1) % 3];
  89423. if (side[a] === undefined && side[b] === undefined) {
  89424. side[a] = new Array();
  89425. side[b] = new Array();
  89426. }
  89427. else {
  89428. if (side[a] === undefined) {
  89429. side[a] = new Array();
  89430. }
  89431. if (side[b] === undefined) {
  89432. side[b] = new Array();
  89433. }
  89434. }
  89435. if (side[a][b] === undefined && side[b][a] === undefined) {
  89436. side[a][b] = [];
  89437. deltaPosition.x = (positions[3 * b] - positions[3 * a]) / segments;
  89438. deltaPosition.y = (positions[3 * b + 1] - positions[3 * a + 1]) / segments;
  89439. deltaPosition.z = (positions[3 * b + 2] - positions[3 * a + 2]) / segments;
  89440. deltaNormal.x = (normals[3 * b] - normals[3 * a]) / segments;
  89441. deltaNormal.y = (normals[3 * b + 1] - normals[3 * a + 1]) / segments;
  89442. deltaNormal.z = (normals[3 * b + 2] - normals[3 * a + 2]) / segments;
  89443. deltaUV.x = (uvs[2 * b] - uvs[2 * a]) / segments;
  89444. deltaUV.y = (uvs[2 * b + 1] - uvs[2 * a + 1]) / segments;
  89445. side[a][b].push(a);
  89446. for (var k = 1; k < segments; k++) {
  89447. side[a][b].push(positions.length / 3);
  89448. positions[positionPtr] = positions[3 * a] + k * deltaPosition.x;
  89449. normals[positionPtr++] = normals[3 * a] + k * deltaNormal.x;
  89450. positions[positionPtr] = positions[3 * a + 1] + k * deltaPosition.y;
  89451. normals[positionPtr++] = normals[3 * a + 1] + k * deltaNormal.y;
  89452. positions[positionPtr] = positions[3 * a + 2] + k * deltaPosition.z;
  89453. normals[positionPtr++] = normals[3 * a + 2] + k * deltaNormal.z;
  89454. uvs[uvPtr++] = uvs[2 * a] + k * deltaUV.x;
  89455. uvs[uvPtr++] = uvs[2 * a + 1] + k * deltaUV.y;
  89456. }
  89457. side[a][b].push(b);
  89458. side[b][a] = new Array();
  89459. len = side[a][b].length;
  89460. for (var idx = 0; idx < len; idx++) {
  89461. side[b][a][idx] = side[a][b][len - 1 - idx];
  89462. }
  89463. }
  89464. }
  89465. //Calculate positions, normals and uvs of new internal vertices
  89466. tempIndices[0][0] = currentIndices[i];
  89467. tempIndices[1][0] = side[currentIndices[i]][currentIndices[i + 1]][1];
  89468. tempIndices[1][1] = side[currentIndices[i]][currentIndices[i + 2]][1];
  89469. for (var k = 2; k < segments; k++) {
  89470. tempIndices[k][0] = side[currentIndices[i]][currentIndices[i + 1]][k];
  89471. tempIndices[k][k] = side[currentIndices[i]][currentIndices[i + 2]][k];
  89472. deltaPosition.x = (positions[3 * tempIndices[k][k]] - positions[3 * tempIndices[k][0]]) / k;
  89473. deltaPosition.y = (positions[3 * tempIndices[k][k] + 1] - positions[3 * tempIndices[k][0] + 1]) / k;
  89474. deltaPosition.z = (positions[3 * tempIndices[k][k] + 2] - positions[3 * tempIndices[k][0] + 2]) / k;
  89475. deltaNormal.x = (normals[3 * tempIndices[k][k]] - normals[3 * tempIndices[k][0]]) / k;
  89476. deltaNormal.y = (normals[3 * tempIndices[k][k] + 1] - normals[3 * tempIndices[k][0] + 1]) / k;
  89477. deltaNormal.z = (normals[3 * tempIndices[k][k] + 2] - normals[3 * tempIndices[k][0] + 2]) / k;
  89478. deltaUV.x = (uvs[2 * tempIndices[k][k]] - uvs[2 * tempIndices[k][0]]) / k;
  89479. deltaUV.y = (uvs[2 * tempIndices[k][k] + 1] - uvs[2 * tempIndices[k][0] + 1]) / k;
  89480. for (var j = 1; j < k; j++) {
  89481. tempIndices[k][j] = positions.length / 3;
  89482. positions[positionPtr] = positions[3 * tempIndices[k][0]] + j * deltaPosition.x;
  89483. normals[positionPtr++] = normals[3 * tempIndices[k][0]] + j * deltaNormal.x;
  89484. positions[positionPtr] = positions[3 * tempIndices[k][0] + 1] + j * deltaPosition.y;
  89485. normals[positionPtr++] = normals[3 * tempIndices[k][0] + 1] + j * deltaNormal.y;
  89486. positions[positionPtr] = positions[3 * tempIndices[k][0] + 2] + j * deltaPosition.z;
  89487. normals[positionPtr++] = normals[3 * tempIndices[k][0] + 2] + j * deltaNormal.z;
  89488. uvs[uvPtr++] = uvs[2 * tempIndices[k][0]] + j * deltaUV.x;
  89489. uvs[uvPtr++] = uvs[2 * tempIndices[k][0] + 1] + j * deltaUV.y;
  89490. }
  89491. }
  89492. tempIndices[segments] = side[currentIndices[i + 1]][currentIndices[i + 2]];
  89493. // reform indices
  89494. indices.push(tempIndices[0][0], tempIndices[1][0], tempIndices[1][1]);
  89495. for (var k = 1; k < segments; k++) {
  89496. for (var j = 0; j < k; j++) {
  89497. indices.push(tempIndices[k][j], tempIndices[k + 1][j], tempIndices[k + 1][j + 1]);
  89498. indices.push(tempIndices[k][j], tempIndices[k + 1][j + 1], tempIndices[k][j + 1]);
  89499. }
  89500. indices.push(tempIndices[k][j], tempIndices[k + 1][j], tempIndices[k + 1][j + 1]);
  89501. }
  89502. }
  89503. vertex_data.indices = indices;
  89504. vertex_data.applyToMesh(this);
  89505. }
  89506. };
  89507. /**
  89508. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  89509. * This will undo any application of covertToFlatShadedMesh
  89510. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89511. */
  89512. Mesh.prototype.forceSharedVertices = function () {
  89513. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  89514. var currentUVs = vertex_data.uvs;
  89515. var currentIndices = vertex_data.indices;
  89516. var currentPositions = vertex_data.positions;
  89517. var currentNormals = vertex_data.normals;
  89518. if (currentIndices === null || currentPositions === null || currentNormals === null || currentUVs === null) {
  89519. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("VertexData contains null entries");
  89520. }
  89521. else {
  89522. var positions = new Array();
  89523. var indices = new Array();
  89524. var uvs = new Array();
  89525. var pstring = new Array(); //lists facet vertex positions (a,b,c) as string "a|b|c"
  89526. var indexPtr = 0; // pointer to next available index value
  89527. var uniquePositions = new Array(); // unique vertex positions
  89528. var ptr; // pointer to element in uniquePositions
  89529. var facet;
  89530. for (var i = 0; i < currentIndices.length; i += 3) {
  89531. facet = [currentIndices[i], currentIndices[i + 1], currentIndices[i + 2]]; //facet vertex indices
  89532. pstring = new Array();
  89533. for (var j = 0; j < 3; j++) {
  89534. pstring[j] = "";
  89535. for (var k = 0; k < 3; k++) {
  89536. //small values make 0
  89537. if (Math.abs(currentPositions[3 * facet[j] + k]) < 0.00000001) {
  89538. currentPositions[3 * facet[j] + k] = 0;
  89539. }
  89540. pstring[j] += currentPositions[3 * facet[j] + k] + "|";
  89541. }
  89542. pstring[j] = pstring[j].slice(0, -1);
  89543. }
  89544. //check facet vertices to see that none are repeated
  89545. // do not process any facet that has a repeated vertex, ie is a line
  89546. if (!(pstring[0] == pstring[1] || pstring[0] == pstring[2] || pstring[1] == pstring[2])) {
  89547. //for each facet position check if already listed in uniquePositions
  89548. // if not listed add to uniquePositions and set index pointer
  89549. // if listed use its index in uniquePositions and new index pointer
  89550. for (var j = 0; j < 3; j++) {
  89551. ptr = uniquePositions.indexOf(pstring[j]);
  89552. if (ptr < 0) {
  89553. uniquePositions.push(pstring[j]);
  89554. ptr = indexPtr++;
  89555. //not listed so add individual x, y, z coordinates to positions
  89556. for (var k = 0; k < 3; k++) {
  89557. positions.push(currentPositions[3 * facet[j] + k]);
  89558. }
  89559. for (var k = 0; k < 2; k++) {
  89560. uvs.push(currentUVs[2 * facet[j] + k]);
  89561. }
  89562. }
  89563. // add new index pointer to indices array
  89564. indices.push(ptr);
  89565. }
  89566. }
  89567. }
  89568. var normals = new Array();
  89569. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  89570. //create new vertex data object and update
  89571. vertex_data.positions = positions;
  89572. vertex_data.indices = indices;
  89573. vertex_data.normals = normals;
  89574. vertex_data.uvs = uvs;
  89575. vertex_data.applyToMesh(this);
  89576. }
  89577. };
  89578. // Instances
  89579. /** @hidden */
  89580. Mesh._instancedMeshFactory = function (name, mesh) {
  89581. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("InstancedMesh");
  89582. };
  89583. /** @hidden */
  89584. Mesh._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  89585. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("PhysicsImpostor");
  89586. };
  89587. /**
  89588. * Creates a new InstancedMesh object from the mesh model.
  89589. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89590. * @param name defines the name of the new instance
  89591. * @returns a new InstancedMesh
  89592. */
  89593. Mesh.prototype.createInstance = function (name) {
  89594. return Mesh._instancedMeshFactory(name, this);
  89595. };
  89596. /**
  89597. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  89598. * After this call, all the mesh instances have the same submeshes than the current mesh.
  89599. * @returns the current mesh
  89600. */
  89601. Mesh.prototype.synchronizeInstances = function () {
  89602. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  89603. var instance = this.instances[instanceIndex];
  89604. instance._syncSubMeshes();
  89605. }
  89606. return this;
  89607. };
  89608. /**
  89609. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  89610. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  89611. * This should be used together with the simplification to avoid disappearing triangles.
  89612. * @param successCallback an optional success callback to be called after the optimization finished.
  89613. * @returns the current mesh
  89614. */
  89615. Mesh.prototype.optimizeIndices = function (successCallback) {
  89616. var _this = this;
  89617. var indices = this.getIndices();
  89618. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  89619. if (!positions || !indices) {
  89620. return this;
  89621. }
  89622. var vectorPositions = new Array();
  89623. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  89624. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  89625. }
  89626. var dupes = new Array();
  89627. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  89628. var realPos = vectorPositions.length - 1 - iteration;
  89629. var testedPosition = vectorPositions[realPos];
  89630. for (var j = 0; j < realPos; ++j) {
  89631. var againstPosition = vectorPositions[j];
  89632. if (testedPosition.equals(againstPosition)) {
  89633. dupes[realPos] = j;
  89634. break;
  89635. }
  89636. }
  89637. }, function () {
  89638. for (var i = 0; i < indices.length; ++i) {
  89639. indices[i] = dupes[indices[i]] || indices[i];
  89640. }
  89641. //indices are now reordered
  89642. var originalSubMeshes = _this.subMeshes.slice(0);
  89643. _this.setIndices(indices);
  89644. _this.subMeshes = originalSubMeshes;
  89645. if (successCallback) {
  89646. successCallback(_this);
  89647. }
  89648. });
  89649. return this;
  89650. };
  89651. /**
  89652. * Serialize current mesh
  89653. * @param serializationObject defines the object which will receive the serialization data
  89654. */
  89655. Mesh.prototype.serialize = function (serializationObject) {
  89656. serializationObject.name = this.name;
  89657. serializationObject.id = this.id;
  89658. serializationObject.type = this.getClassName();
  89659. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  89660. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  89661. }
  89662. serializationObject.position = this.position.asArray();
  89663. if (this.rotationQuaternion) {
  89664. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  89665. }
  89666. else if (this.rotation) {
  89667. serializationObject.rotation = this.rotation.asArray();
  89668. }
  89669. serializationObject.scaling = this.scaling.asArray();
  89670. if (this._postMultiplyPivotMatrix) {
  89671. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  89672. }
  89673. else {
  89674. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  89675. }
  89676. serializationObject.isEnabled = this.isEnabled(false);
  89677. serializationObject.isVisible = this.isVisible;
  89678. serializationObject.infiniteDistance = this.infiniteDistance;
  89679. serializationObject.pickable = this.isPickable;
  89680. serializationObject.receiveShadows = this.receiveShadows;
  89681. serializationObject.billboardMode = this.billboardMode;
  89682. serializationObject.visibility = this.visibility;
  89683. serializationObject.checkCollisions = this.checkCollisions;
  89684. serializationObject.isBlocker = this.isBlocker;
  89685. // Parent
  89686. if (this.parent) {
  89687. serializationObject.parentId = this.parent.id;
  89688. }
  89689. // Geometry
  89690. serializationObject.isUnIndexed = this.isUnIndexed;
  89691. var geometry = this._geometry;
  89692. if (geometry) {
  89693. var geometryId = geometry.id;
  89694. serializationObject.geometryId = geometryId;
  89695. // SubMeshes
  89696. serializationObject.subMeshes = [];
  89697. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  89698. var subMesh = this.subMeshes[subIndex];
  89699. serializationObject.subMeshes.push({
  89700. materialIndex: subMesh.materialIndex,
  89701. verticesStart: subMesh.verticesStart,
  89702. verticesCount: subMesh.verticesCount,
  89703. indexStart: subMesh.indexStart,
  89704. indexCount: subMesh.indexCount
  89705. });
  89706. }
  89707. }
  89708. // Material
  89709. if (this.material) {
  89710. serializationObject.materialId = this.material.id;
  89711. }
  89712. else {
  89713. this.material = null;
  89714. }
  89715. // Morph targets
  89716. if (this.morphTargetManager) {
  89717. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  89718. }
  89719. // Skeleton
  89720. if (this.skeleton) {
  89721. serializationObject.skeletonId = this.skeleton.id;
  89722. }
  89723. // Physics
  89724. //TODO implement correct serialization for physics impostors.
  89725. var impostor = this.getPhysicsImpostor();
  89726. if (impostor) {
  89727. serializationObject.physicsMass = impostor.getParam("mass");
  89728. serializationObject.physicsFriction = impostor.getParam("friction");
  89729. serializationObject.physicsRestitution = impostor.getParam("mass");
  89730. serializationObject.physicsImpostor = impostor.type;
  89731. }
  89732. // Metadata
  89733. if (this.metadata) {
  89734. serializationObject.metadata = this.metadata;
  89735. }
  89736. // Instances
  89737. serializationObject.instances = [];
  89738. for (var index = 0; index < this.instances.length; index++) {
  89739. var instance = this.instances[index];
  89740. if (instance.doNotSerialize) {
  89741. continue;
  89742. }
  89743. var serializationInstance = {
  89744. name: instance.name,
  89745. id: instance.id,
  89746. position: instance.position.asArray(),
  89747. scaling: instance.scaling.asArray()
  89748. };
  89749. if (instance.parent) {
  89750. serializationInstance.parentId = instance.parent.id;
  89751. }
  89752. if (instance.rotationQuaternion) {
  89753. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  89754. }
  89755. else if (instance.rotation) {
  89756. serializationInstance.rotation = instance.rotation.asArray();
  89757. }
  89758. serializationObject.instances.push(serializationInstance);
  89759. // Animations
  89760. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  89761. serializationInstance.ranges = instance.serializeAnimationRanges();
  89762. }
  89763. //
  89764. // Animations
  89765. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  89766. serializationObject.ranges = this.serializeAnimationRanges();
  89767. // Layer mask
  89768. serializationObject.layerMask = this.layerMask;
  89769. // Alpha
  89770. serializationObject.alphaIndex = this.alphaIndex;
  89771. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  89772. // Overlay
  89773. serializationObject.overlayAlpha = this.overlayAlpha;
  89774. serializationObject.overlayColor = this.overlayColor.asArray();
  89775. serializationObject.renderOverlay = this.renderOverlay;
  89776. // Fog
  89777. serializationObject.applyFog = this.applyFog;
  89778. // Action Manager
  89779. if (this.actionManager) {
  89780. serializationObject.actions = this.actionManager.serialize(this.name);
  89781. }
  89782. };
  89783. /** @hidden */
  89784. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  89785. if (!this.geometry) {
  89786. return;
  89787. }
  89788. this._markSubMeshesAsAttributesDirty();
  89789. var morphTargetManager = this._morphTargetManager;
  89790. if (morphTargetManager && morphTargetManager.vertexCount) {
  89791. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  89792. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  89793. this.morphTargetManager = null;
  89794. return;
  89795. }
  89796. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  89797. var morphTarget = morphTargetManager.getActiveTarget(index);
  89798. var positions = morphTarget.getPositions();
  89799. if (!positions) {
  89800. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Invalid morph target. Target must have positions.");
  89801. return;
  89802. }
  89803. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  89804. var normals = morphTarget.getNormals();
  89805. if (normals) {
  89806. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  89807. }
  89808. var tangents = morphTarget.getTangents();
  89809. if (tangents) {
  89810. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  89811. }
  89812. }
  89813. }
  89814. else {
  89815. var index = 0;
  89816. // Positions
  89817. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  89818. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  89819. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  89820. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  89821. }
  89822. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  89823. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  89824. }
  89825. index++;
  89826. }
  89827. }
  89828. };
  89829. /**
  89830. * Returns a new Mesh object parsed from the source provided.
  89831. * @param parsedMesh is the source
  89832. * @param scene defines the hosting scene
  89833. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  89834. * @returns a new Mesh
  89835. */
  89836. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  89837. var mesh;
  89838. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  89839. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  89840. }
  89841. else {
  89842. mesh = new Mesh(parsedMesh.name, scene);
  89843. }
  89844. mesh.id = parsedMesh.id;
  89845. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  89846. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  89847. }
  89848. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  89849. if (parsedMesh.metadata !== undefined) {
  89850. mesh.metadata = parsedMesh.metadata;
  89851. }
  89852. if (parsedMesh.rotationQuaternion) {
  89853. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  89854. }
  89855. else if (parsedMesh.rotation) {
  89856. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  89857. }
  89858. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  89859. if (parsedMesh.localMatrix) {
  89860. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  89861. }
  89862. else if (parsedMesh.pivotMatrix) {
  89863. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  89864. }
  89865. mesh.setEnabled(parsedMesh.isEnabled);
  89866. mesh.isVisible = parsedMesh.isVisible;
  89867. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  89868. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  89869. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  89870. if (parsedMesh.applyFog !== undefined) {
  89871. mesh.applyFog = parsedMesh.applyFog;
  89872. }
  89873. if (parsedMesh.pickable !== undefined) {
  89874. mesh.isPickable = parsedMesh.pickable;
  89875. }
  89876. if (parsedMesh.alphaIndex !== undefined) {
  89877. mesh.alphaIndex = parsedMesh.alphaIndex;
  89878. }
  89879. mesh.receiveShadows = parsedMesh.receiveShadows;
  89880. mesh.billboardMode = parsedMesh.billboardMode;
  89881. if (parsedMesh.visibility !== undefined) {
  89882. mesh.visibility = parsedMesh.visibility;
  89883. }
  89884. mesh.checkCollisions = parsedMesh.checkCollisions;
  89885. if (parsedMesh.isBlocker !== undefined) {
  89886. mesh.isBlocker = parsedMesh.isBlocker;
  89887. }
  89888. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  89889. // freezeWorldMatrix
  89890. if (parsedMesh.freezeWorldMatrix) {
  89891. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  89892. }
  89893. // Parent
  89894. if (parsedMesh.parentId) {
  89895. mesh._waitingParentId = parsedMesh.parentId;
  89896. }
  89897. // Actions
  89898. if (parsedMesh.actions !== undefined) {
  89899. mesh._waitingActions = parsedMesh.actions;
  89900. }
  89901. // Overlay
  89902. if (parsedMesh.overlayAlpha !== undefined) {
  89903. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  89904. }
  89905. if (parsedMesh.overlayColor !== undefined) {
  89906. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  89907. }
  89908. if (parsedMesh.renderOverlay !== undefined) {
  89909. mesh.renderOverlay = parsedMesh.renderOverlay;
  89910. }
  89911. // Geometry
  89912. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  89913. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  89914. if (parsedMesh.delayLoadingFile) {
  89915. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED;
  89916. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  89917. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__["BoundingInfo"](_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.boundingBoxMinimum), _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.boundingBoxMaximum));
  89918. if (parsedMesh._binaryInfo) {
  89919. mesh._binaryInfo = parsedMesh._binaryInfo;
  89920. }
  89921. mesh._delayInfo = [];
  89922. if (parsedMesh.hasUVs) {
  89923. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  89924. }
  89925. if (parsedMesh.hasUVs2) {
  89926. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  89927. }
  89928. if (parsedMesh.hasUVs3) {
  89929. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  89930. }
  89931. if (parsedMesh.hasUVs4) {
  89932. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  89933. }
  89934. if (parsedMesh.hasUVs5) {
  89935. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  89936. }
  89937. if (parsedMesh.hasUVs6) {
  89938. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  89939. }
  89940. if (parsedMesh.hasColors) {
  89941. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  89942. }
  89943. if (parsedMesh.hasMatricesIndices) {
  89944. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  89945. }
  89946. if (parsedMesh.hasMatricesWeights) {
  89947. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  89948. }
  89949. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  89950. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  89951. mesh._checkDelayState();
  89952. }
  89953. }
  89954. else {
  89955. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  89956. }
  89957. // Material
  89958. if (parsedMesh.materialId) {
  89959. mesh.setMaterialByID(parsedMesh.materialId);
  89960. }
  89961. else {
  89962. mesh.material = null;
  89963. }
  89964. // Morph targets
  89965. if (parsedMesh.morphTargetManagerId > -1) {
  89966. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  89967. }
  89968. // Skeleton
  89969. if (parsedMesh.skeletonId > -1) {
  89970. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  89971. if (parsedMesh.numBoneInfluencers) {
  89972. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  89973. }
  89974. }
  89975. // Animations
  89976. if (parsedMesh.animations) {
  89977. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  89978. var parsedAnimation = parsedMesh.animations[animationIndex];
  89979. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  89980. if (internalClass) {
  89981. mesh.animations.push(internalClass.Parse(parsedAnimation));
  89982. }
  89983. }
  89984. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  89985. }
  89986. if (parsedMesh.autoAnimate) {
  89987. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  89988. }
  89989. // Layer Mask
  89990. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  89991. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  89992. }
  89993. else {
  89994. mesh.layerMask = 0x0FFFFFFF;
  89995. }
  89996. // Physics
  89997. if (parsedMesh.physicsImpostor) {
  89998. Mesh._PhysicsImpostorParser(scene, mesh, parsedMesh);
  89999. }
  90000. // Instances
  90001. if (parsedMesh.instances) {
  90002. for (var index = 0; index < parsedMesh.instances.length; index++) {
  90003. var parsedInstance = parsedMesh.instances[index];
  90004. var instance = mesh.createInstance(parsedInstance.name);
  90005. if (parsedInstance.id) {
  90006. instance.id = parsedInstance.id;
  90007. }
  90008. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  90009. if (parsedInstance.tags) {
  90010. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  90011. }
  90012. else {
  90013. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  90014. }
  90015. }
  90016. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  90017. if (parsedInstance.parentId) {
  90018. instance._waitingParentId = parsedInstance.parentId;
  90019. }
  90020. if (parsedInstance.rotationQuaternion) {
  90021. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  90022. }
  90023. else if (parsedInstance.rotation) {
  90024. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  90025. }
  90026. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  90027. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  90028. instance.checkCollisions = parsedInstance.checkCollisions;
  90029. }
  90030. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  90031. instance.isPickable = parsedInstance.pickable;
  90032. }
  90033. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  90034. instance.showBoundingBox = parsedInstance.showBoundingBox;
  90035. }
  90036. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  90037. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  90038. }
  90039. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  90040. instance.alphaIndex = parsedInstance.alphaIndex;
  90041. }
  90042. // Physics
  90043. if (parsedInstance.physicsImpostor) {
  90044. Mesh._PhysicsImpostorParser(scene, instance, parsedInstance);
  90045. }
  90046. // Animation
  90047. if (parsedInstance.animations) {
  90048. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  90049. parsedAnimation = parsedInstance.animations[animationIndex];
  90050. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  90051. if (internalClass) {
  90052. instance.animations.push(internalClass.Parse(parsedAnimation));
  90053. }
  90054. }
  90055. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  90056. if (parsedInstance.autoAnimate) {
  90057. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  90058. }
  90059. }
  90060. }
  90061. }
  90062. return mesh;
  90063. };
  90064. /**
  90065. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  90066. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90067. * @param name defines the name of the mesh to create
  90068. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  90069. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  90070. * @param closePath creates a seam between the first and the last points of each path of the path array
  90071. * @param offset is taken in account only if the `pathArray` is containing a single path
  90072. * @param scene defines the hosting scene
  90073. * @param updatable defines if the mesh must be flagged as updatable
  90074. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90075. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  90076. * @returns a new Mesh
  90077. */
  90078. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  90079. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90080. };
  90081. /**
  90082. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  90083. * @param name defines the name of the mesh to create
  90084. * @param radius sets the radius size (float) of the polygon (default 0.5)
  90085. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  90086. * @param scene defines the hosting scene
  90087. * @param updatable defines if the mesh must be flagged as updatable
  90088. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90089. * @returns a new Mesh
  90090. */
  90091. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  90092. if (scene === void 0) { scene = null; }
  90093. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90094. };
  90095. /**
  90096. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  90097. * @param name defines the name of the mesh to create
  90098. * @param size sets the size (float) of each box side (default 1)
  90099. * @param scene defines the hosting scene
  90100. * @param updatable defines if the mesh must be flagged as updatable
  90101. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90102. * @returns a new Mesh
  90103. */
  90104. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  90105. if (scene === void 0) { scene = null; }
  90106. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90107. };
  90108. /**
  90109. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  90110. * @param name defines the name of the mesh to create
  90111. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90112. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90113. * @param scene defines the hosting scene
  90114. * @param updatable defines if the mesh must be flagged as updatable
  90115. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90116. * @returns a new Mesh
  90117. */
  90118. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  90119. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90120. };
  90121. /**
  90122. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  90123. * @param name defines the name of the mesh to create
  90124. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90125. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90126. * @param scene defines the hosting scene
  90127. * @returns a new Mesh
  90128. */
  90129. Mesh.CreateHemisphere = function (name, segments, diameter, scene) {
  90130. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90131. };
  90132. /**
  90133. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  90134. * @param name defines the name of the mesh to create
  90135. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  90136. * @param diameterTop set the top cap diameter (floats, default 1)
  90137. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  90138. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  90139. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  90140. * @param scene defines the hosting scene
  90141. * @param updatable defines if the mesh must be flagged as updatable
  90142. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90143. * @returns a new Mesh
  90144. */
  90145. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  90146. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90147. };
  90148. // Torus (Code from SharpDX.org)
  90149. /**
  90150. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  90151. * @param name defines the name of the mesh to create
  90152. * @param diameter sets the diameter size (float) of the torus (default 1)
  90153. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  90154. * @param tessellation sets the number of torus sides (postive integer, default 16)
  90155. * @param scene defines the hosting scene
  90156. * @param updatable defines if the mesh must be flagged as updatable
  90157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90158. * @returns a new Mesh
  90159. */
  90160. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  90161. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90162. };
  90163. /**
  90164. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  90165. * @param name defines the name of the mesh to create
  90166. * @param radius sets the global radius size (float) of the torus knot (default 2)
  90167. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  90168. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  90169. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  90170. * @param p the number of windings on X axis (positive integers, default 2)
  90171. * @param q the number of windings on Y axis (positive integers, default 3)
  90172. * @param scene defines the hosting scene
  90173. * @param updatable defines if the mesh must be flagged as updatable
  90174. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90175. * @returns a new Mesh
  90176. */
  90177. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  90178. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90179. };
  90180. /**
  90181. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  90182. * @param name defines the name of the mesh to create
  90183. * @param points is an array successive Vector3
  90184. * @param scene defines the hosting scene
  90185. * @param updatable defines if the mesh must be flagged as updatable
  90186. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  90187. * @returns a new Mesh
  90188. */
  90189. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  90190. if (scene === void 0) { scene = null; }
  90191. if (updatable === void 0) { updatable = false; }
  90192. if (instance === void 0) { instance = null; }
  90193. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90194. };
  90195. /**
  90196. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  90197. * @param name defines the name of the mesh to create
  90198. * @param points is an array successive Vector3
  90199. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  90200. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90201. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  90202. * @param scene defines the hosting scene
  90203. * @param updatable defines if the mesh must be flagged as updatable
  90204. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  90205. * @returns a new Mesh
  90206. */
  90207. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  90208. if (scene === void 0) { scene = null; }
  90209. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90210. };
  90211. /**
  90212. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  90213. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  90214. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  90215. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90216. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90217. * Remember you can only change the shape positions, not their number when updating a polygon.
  90218. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  90219. * @param name defines the name of the mesh to create
  90220. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  90221. * @param scene defines the hosting scene
  90222. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90223. * @param updatable defines if the mesh must be flagged as updatable
  90224. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90225. * @param earcutInjection can be used to inject your own earcut reference
  90226. * @returns a new Mesh
  90227. */
  90228. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  90229. if (earcutInjection === void 0) { earcutInjection = earcut; }
  90230. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90231. };
  90232. /**
  90233. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  90234. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  90235. * @param name defines the name of the mesh to create
  90236. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  90237. * @param depth defines the height of extrusion
  90238. * @param scene defines the hosting scene
  90239. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90240. * @param updatable defines if the mesh must be flagged as updatable
  90241. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90242. * @param earcutInjection can be used to inject your own earcut reference
  90243. * @returns a new Mesh
  90244. */
  90245. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  90246. if (earcutInjection === void 0) { earcutInjection = earcut; }
  90247. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90248. };
  90249. /**
  90250. * Creates an extruded shape mesh.
  90251. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  90252. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90253. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90254. * @param name defines the name of the mesh to create
  90255. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  90256. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90257. * @param scale is the value to scale the shape
  90258. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  90259. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  90260. * @param scene defines the hosting scene
  90261. * @param updatable defines if the mesh must be flagged as updatable
  90262. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90263. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  90264. * @returns a new Mesh
  90265. */
  90266. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  90267. if (scene === void 0) { scene = null; }
  90268. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90269. };
  90270. /**
  90271. * Creates an custom extruded shape mesh.
  90272. * The custom extrusion is a parametric shape.
  90273. * It has no predefined shape. Its final shape will depend on the input parameters.
  90274. * Please consider using the same method from the MeshBuilder class instead
  90275. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90276. * @param name defines the name of the mesh to create
  90277. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  90278. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90279. * @param scaleFunction is a custom Javascript function called on each path point
  90280. * @param rotationFunction is a custom Javascript function called on each path point
  90281. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90282. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  90283. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  90284. * @param scene defines the hosting scene
  90285. * @param updatable defines if the mesh must be flagged as updatable
  90286. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90287. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  90288. * @returns a new Mesh
  90289. */
  90290. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  90291. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90292. };
  90293. /**
  90294. * Creates lathe mesh.
  90295. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  90296. * Please consider using the same method from the MeshBuilder class instead
  90297. * @param name defines the name of the mesh to create
  90298. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  90299. * @param radius is the radius value of the lathe
  90300. * @param tessellation is the side number of the lathe.
  90301. * @param scene defines the hosting scene
  90302. * @param updatable defines if the mesh must be flagged as updatable
  90303. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90304. * @returns a new Mesh
  90305. */
  90306. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  90307. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90308. };
  90309. /**
  90310. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  90311. * @param name defines the name of the mesh to create
  90312. * @param size sets the size (float) of both sides of the plane at once (default 1)
  90313. * @param scene defines the hosting scene
  90314. * @param updatable defines if the mesh must be flagged as updatable
  90315. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90316. * @returns a new Mesh
  90317. */
  90318. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  90319. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90320. };
  90321. /**
  90322. * Creates a ground mesh.
  90323. * Please consider using the same method from the MeshBuilder class instead
  90324. * @param name defines the name of the mesh to create
  90325. * @param width set the width of the ground
  90326. * @param height set the height of the ground
  90327. * @param subdivisions sets the number of subdivisions per side
  90328. * @param scene defines the hosting scene
  90329. * @param updatable defines if the mesh must be flagged as updatable
  90330. * @returns a new Mesh
  90331. */
  90332. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  90333. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90334. };
  90335. /**
  90336. * Creates a tiled ground mesh.
  90337. * Please consider using the same method from the MeshBuilder class instead
  90338. * @param name defines the name of the mesh to create
  90339. * @param xmin set the ground minimum X coordinate
  90340. * @param zmin set the ground minimum Y coordinate
  90341. * @param xmax set the ground maximum X coordinate
  90342. * @param zmax set the ground maximum Z coordinate
  90343. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  90344. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  90345. * @param scene defines the hosting scene
  90346. * @param updatable defines if the mesh must be flagged as updatable
  90347. * @returns a new Mesh
  90348. */
  90349. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  90350. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90351. };
  90352. /**
  90353. * Creates a ground mesh from a height map.
  90354. * Please consider using the same method from the MeshBuilder class instead
  90355. * @see http://doc.babylonjs.com/babylon101/height_map
  90356. * @param name defines the name of the mesh to create
  90357. * @param url sets the URL of the height map image resource
  90358. * @param width set the ground width size
  90359. * @param height set the ground height size
  90360. * @param subdivisions sets the number of subdivision per side
  90361. * @param minHeight is the minimum altitude on the ground
  90362. * @param maxHeight is the maximum altitude on the ground
  90363. * @param scene defines the hosting scene
  90364. * @param updatable defines if the mesh must be flagged as updatable
  90365. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  90366. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90367. * @returns a new Mesh
  90368. */
  90369. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  90370. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90371. };
  90372. /**
  90373. * Creates a tube mesh.
  90374. * The tube is a parametric shape.
  90375. * It has no predefined shape. Its final shape will depend on the input parameters.
  90376. * Please consider using the same method from the MeshBuilder class instead
  90377. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90378. * @param name defines the name of the mesh to create
  90379. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  90380. * @param radius sets the tube radius size
  90381. * @param tessellation is the number of sides on the tubular surface
  90382. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  90383. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  90384. * @param scene defines the hosting scene
  90385. * @param updatable defines if the mesh must be flagged as updatable
  90386. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90387. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  90388. * @returns a new Mesh
  90389. */
  90390. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  90391. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90392. };
  90393. /**
  90394. * Creates a polyhedron mesh.
  90395. * Please consider using the same method from the MeshBuilder class instead.
  90396. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  90397. * * The parameter `size` (positive float, default 1) sets the polygon size
  90398. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90399. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  90400. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  90401. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  90402. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  90403. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  90404. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90407. * @param name defines the name of the mesh to create
  90408. * @param options defines the options used to create the mesh
  90409. * @param scene defines the hosting scene
  90410. * @returns a new Mesh
  90411. */
  90412. Mesh.CreatePolyhedron = function (name, options, scene) {
  90413. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90414. };
  90415. /**
  90416. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90417. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90418. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  90419. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90420. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  90421. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90424. * @param name defines the name of the mesh
  90425. * @param options defines the options used to create the mesh
  90426. * @param scene defines the hosting scene
  90427. * @returns a new Mesh
  90428. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90429. */
  90430. Mesh.CreateIcoSphere = function (name, options, scene) {
  90431. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90432. };
  90433. /**
  90434. * Creates a decal mesh.
  90435. * Please consider using the same method from the MeshBuilder class instead.
  90436. * A decal is a mesh usually applied as a model onto the surface of another mesh
  90437. * @param name defines the name of the mesh
  90438. * @param sourceMesh defines the mesh receiving the decal
  90439. * @param position sets the position of the decal in world coordinates
  90440. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  90441. * @param size sets the decal scaling
  90442. * @param angle sets the angle to rotate the decal
  90443. * @returns a new Mesh
  90444. */
  90445. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  90446. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90447. };
  90448. // Skeletons
  90449. /**
  90450. * Prepare internal position array for software CPU skinning
  90451. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  90452. */
  90453. Mesh.prototype.setPositionsForCPUSkinning = function () {
  90454. if (!this._sourcePositions) {
  90455. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  90456. if (!source) {
  90457. return this._sourcePositions;
  90458. }
  90459. this._sourcePositions = new Float32Array(source);
  90460. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  90461. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  90462. }
  90463. }
  90464. return this._sourcePositions;
  90465. };
  90466. /**
  90467. * Prepare internal normal array for software CPU skinning
  90468. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  90469. */
  90470. Mesh.prototype.setNormalsForCPUSkinning = function () {
  90471. if (!this._sourceNormals) {
  90472. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  90473. if (!source) {
  90474. return this._sourceNormals;
  90475. }
  90476. this._sourceNormals = new Float32Array(source);
  90477. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  90478. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  90479. }
  90480. }
  90481. return this._sourceNormals;
  90482. };
  90483. /**
  90484. * Updates the vertex buffer by applying transformation from the bones
  90485. * @param skeleton defines the skeleton to apply to current mesh
  90486. * @returns the current mesh
  90487. */
  90488. Mesh.prototype.applySkeleton = function (skeleton) {
  90489. if (!this.geometry) {
  90490. return this;
  90491. }
  90492. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  90493. return this;
  90494. }
  90495. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  90496. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  90497. return this;
  90498. }
  90499. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  90500. return this;
  90501. }
  90502. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  90503. return this;
  90504. }
  90505. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  90506. return this;
  90507. }
  90508. if (!this._sourcePositions) {
  90509. var submeshes = this.subMeshes.slice();
  90510. this.setPositionsForCPUSkinning();
  90511. this.subMeshes = submeshes;
  90512. }
  90513. if (!this._sourceNormals) {
  90514. this.setNormalsForCPUSkinning();
  90515. }
  90516. // positionsData checks for not being Float32Array will only pass at most once
  90517. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  90518. if (!positionsData) {
  90519. return this;
  90520. }
  90521. if (!(positionsData instanceof Float32Array)) {
  90522. positionsData = new Float32Array(positionsData);
  90523. }
  90524. // normalsData checks for not being Float32Array will only pass at most once
  90525. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  90526. if (!normalsData) {
  90527. return this;
  90528. }
  90529. if (!(normalsData instanceof Float32Array)) {
  90530. normalsData = new Float32Array(normalsData);
  90531. }
  90532. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  90533. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  90534. if (!matricesWeightsData || !matricesIndicesData) {
  90535. return this;
  90536. }
  90537. var needExtras = this.numBoneInfluencers > 4;
  90538. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  90539. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  90540. var skeletonMatrices = skeleton.getTransformMatrices(this);
  90541. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  90542. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  90543. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  90544. var matWeightIdx = 0;
  90545. var inf;
  90546. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  90547. var weight;
  90548. for (inf = 0; inf < 4; inf++) {
  90549. weight = matricesWeightsData[matWeightIdx + inf];
  90550. if (weight > 0) {
  90551. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  90552. finalMatrix.addToSelf(tempMatrix);
  90553. }
  90554. }
  90555. if (needExtras) {
  90556. for (inf = 0; inf < 4; inf++) {
  90557. weight = matricesWeightsExtraData[matWeightIdx + inf];
  90558. if (weight > 0) {
  90559. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  90560. finalMatrix.addToSelf(tempMatrix);
  90561. }
  90562. }
  90563. }
  90564. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  90565. tempVector3.toArray(positionsData, index);
  90566. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  90567. tempVector3.toArray(normalsData, index);
  90568. finalMatrix.reset();
  90569. }
  90570. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  90571. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  90572. return this;
  90573. };
  90574. // Tools
  90575. /**
  90576. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  90577. * @param meshes defines the list of meshes to scan
  90578. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  90579. */
  90580. Mesh.MinMax = function (meshes) {
  90581. var minVector = null;
  90582. var maxVector = null;
  90583. meshes.forEach(function (mesh) {
  90584. var boundingInfo = mesh.getBoundingInfo();
  90585. var boundingBox = boundingInfo.boundingBox;
  90586. if (!minVector || !maxVector) {
  90587. minVector = boundingBox.minimumWorld;
  90588. maxVector = boundingBox.maximumWorld;
  90589. }
  90590. else {
  90591. minVector.minimizeInPlace(boundingBox.minimumWorld);
  90592. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  90593. }
  90594. });
  90595. if (!minVector || !maxVector) {
  90596. return {
  90597. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  90598. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  90599. };
  90600. }
  90601. return {
  90602. min: minVector,
  90603. max: maxVector
  90604. };
  90605. };
  90606. /**
  90607. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  90608. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  90609. * @returns a vector3
  90610. */
  90611. Mesh.Center = function (meshesOrMinMaxVector) {
  90612. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  90613. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  90614. };
  90615. /**
  90616. * Merge the array of meshes into a single mesh for performance reasons.
  90617. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  90618. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  90619. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  90620. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  90621. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  90622. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  90623. * @returns a new mesh
  90624. */
  90625. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes, multiMultiMaterials) {
  90626. if (disposeSource === void 0) { disposeSource = true; }
  90627. var index;
  90628. if (!allow32BitsIndices) {
  90629. var totalVertices = 0;
  90630. // Counting vertices
  90631. for (index = 0; index < meshes.length; index++) {
  90632. if (meshes[index]) {
  90633. totalVertices += meshes[index].getTotalVertices();
  90634. if (totalVertices > 65536) {
  90635. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices");
  90636. return null;
  90637. }
  90638. }
  90639. }
  90640. }
  90641. if (multiMultiMaterials) {
  90642. var newMultiMaterial = null;
  90643. var subIndex;
  90644. var matIndex;
  90645. subdivideWithSubMeshes = false;
  90646. }
  90647. var materialArray = new Array();
  90648. var materialIndexArray = new Array();
  90649. // Merge
  90650. var vertexData = null;
  90651. var otherVertexData;
  90652. var indiceArray = new Array();
  90653. var source = null;
  90654. for (index = 0; index < meshes.length; index++) {
  90655. if (meshes[index]) {
  90656. var mesh = meshes[index];
  90657. var wm = mesh.computeWorldMatrix(true);
  90658. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(mesh, true, true);
  90659. otherVertexData.transform(wm);
  90660. if (vertexData) {
  90661. vertexData.merge(otherVertexData, allow32BitsIndices);
  90662. }
  90663. else {
  90664. vertexData = otherVertexData;
  90665. source = mesh;
  90666. }
  90667. if (subdivideWithSubMeshes) {
  90668. indiceArray.push(mesh.getTotalIndices());
  90669. }
  90670. if (multiMultiMaterials) {
  90671. if (mesh.material) {
  90672. var material = mesh.material;
  90673. if (material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"]) {
  90674. for (matIndex = 0; matIndex < material.subMaterials.length; matIndex++) {
  90675. if (materialArray.indexOf(material.subMaterials[matIndex]) < 0) {
  90676. materialArray.push(material.subMaterials[matIndex]);
  90677. }
  90678. }
  90679. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  90680. materialIndexArray.push(materialArray.indexOf(material.subMaterials[mesh.subMeshes[subIndex].materialIndex]));
  90681. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  90682. }
  90683. }
  90684. else {
  90685. if (materialArray.indexOf(material) < 0) {
  90686. materialArray.push(material);
  90687. }
  90688. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  90689. materialIndexArray.push(materialArray.indexOf(material));
  90690. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  90691. }
  90692. }
  90693. }
  90694. else {
  90695. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  90696. materialIndexArray.push(0);
  90697. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  90698. }
  90699. }
  90700. }
  90701. }
  90702. }
  90703. source = source;
  90704. if (!meshSubclass) {
  90705. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  90706. }
  90707. vertexData.applyToMesh(meshSubclass);
  90708. // Setting properties
  90709. meshSubclass.checkCollisions = source.checkCollisions;
  90710. // Cleaning
  90711. if (disposeSource) {
  90712. for (index = 0; index < meshes.length; index++) {
  90713. if (meshes[index]) {
  90714. meshes[index].dispose();
  90715. }
  90716. }
  90717. }
  90718. // Subdivide
  90719. if (subdivideWithSubMeshes || multiMultiMaterials) {
  90720. //-- removal of global submesh
  90721. meshSubclass.releaseSubMeshes();
  90722. index = 0;
  90723. var offset = 0;
  90724. //-- apply subdivision according to index table
  90725. while (index < indiceArray.length) {
  90726. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  90727. offset += indiceArray[index];
  90728. index++;
  90729. }
  90730. }
  90731. if (multiMultiMaterials) {
  90732. newMultiMaterial = new _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"](source.name + "_merged", source.getScene());
  90733. newMultiMaterial.subMaterials = materialArray;
  90734. for (subIndex = 0; subIndex < meshSubclass.subMeshes.length; subIndex++) {
  90735. meshSubclass.subMeshes[subIndex].materialIndex = materialIndexArray[subIndex];
  90736. }
  90737. meshSubclass.material = newMultiMaterial;
  90738. }
  90739. else {
  90740. meshSubclass.material = source.material;
  90741. }
  90742. return meshSubclass;
  90743. };
  90744. /** @hidden */
  90745. Mesh.prototype.addInstance = function (instance) {
  90746. instance._indexInSourceMeshInstanceArray = this.instances.length;
  90747. this.instances.push(instance);
  90748. };
  90749. /** @hidden */
  90750. Mesh.prototype.removeInstance = function (instance) {
  90751. // Remove from mesh
  90752. var index = instance._indexInSourceMeshInstanceArray;
  90753. if (index != -1) {
  90754. if (index !== this.instances.length - 1) {
  90755. var last = this.instances[this.instances.length - 1];
  90756. this.instances[index] = last;
  90757. last._indexInSourceMeshInstanceArray = index;
  90758. }
  90759. instance._indexInSourceMeshInstanceArray = -1;
  90760. this.instances.pop();
  90761. }
  90762. };
  90763. // Consts
  90764. /**
  90765. * Mesh side orientation : usually the external or front surface
  90766. */
  90767. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  90768. /**
  90769. * Mesh side orientation : usually the internal or back surface
  90770. */
  90771. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  90772. /**
  90773. * Mesh side orientation : both internal and external or front and back surfaces
  90774. */
  90775. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  90776. /**
  90777. * Mesh side orientation : by default, `FRONTSIDE`
  90778. */
  90779. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  90780. /**
  90781. * Mesh cap setting : no cap
  90782. */
  90783. Mesh.NO_CAP = 0;
  90784. /**
  90785. * Mesh cap setting : one cap at the beginning of the mesh
  90786. */
  90787. Mesh.CAP_START = 1;
  90788. /**
  90789. * Mesh cap setting : one cap at the end of the mesh
  90790. */
  90791. Mesh.CAP_END = 2;
  90792. /**
  90793. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90794. */
  90795. Mesh.CAP_ALL = 3;
  90796. // Statics
  90797. /** @hidden */
  90798. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  90799. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("GroundMesh");
  90800. };
  90801. return Mesh;
  90802. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  90803. /***/ }),
  90804. /***/ "./Meshes/mesh.vertexData.ts":
  90805. /*!***********************************!*\
  90806. !*** ./Meshes/mesh.vertexData.ts ***!
  90807. \***********************************/
  90808. /*! exports provided: VertexData */
  90809. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90810. "use strict";
  90811. __webpack_require__.r(__webpack_exports__);
  90812. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  90813. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  90814. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  90815. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  90816. /**
  90817. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  90818. */
  90819. var VertexData = /** @class */ (function () {
  90820. function VertexData() {
  90821. }
  90822. /**
  90823. * Uses the passed data array to set the set the values for the specified kind of data
  90824. * @param data a linear array of floating numbers
  90825. * @param kind the type of data that is being set, eg positions, colors etc
  90826. */
  90827. VertexData.prototype.set = function (data, kind) {
  90828. switch (kind) {
  90829. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  90830. this.positions = data;
  90831. break;
  90832. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  90833. this.normals = data;
  90834. break;
  90835. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  90836. this.tangents = data;
  90837. break;
  90838. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  90839. this.uvs = data;
  90840. break;
  90841. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  90842. this.uvs2 = data;
  90843. break;
  90844. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  90845. this.uvs3 = data;
  90846. break;
  90847. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  90848. this.uvs4 = data;
  90849. break;
  90850. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  90851. this.uvs5 = data;
  90852. break;
  90853. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  90854. this.uvs6 = data;
  90855. break;
  90856. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  90857. this.colors = data;
  90858. break;
  90859. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  90860. this.matricesIndices = data;
  90861. break;
  90862. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  90863. this.matricesWeights = data;
  90864. break;
  90865. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  90866. this.matricesIndicesExtra = data;
  90867. break;
  90868. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  90869. this.matricesWeightsExtra = data;
  90870. break;
  90871. }
  90872. };
  90873. /**
  90874. * Associates the vertexData to the passed Mesh.
  90875. * Sets it as updatable or not (default `false`)
  90876. * @param mesh the mesh the vertexData is applied to
  90877. * @param updatable when used and having the value true allows new data to update the vertexData
  90878. * @returns the VertexData
  90879. */
  90880. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  90881. this._applyTo(mesh, updatable);
  90882. return this;
  90883. };
  90884. /**
  90885. * Associates the vertexData to the passed Geometry.
  90886. * Sets it as updatable or not (default `false`)
  90887. * @param geometry the geometry the vertexData is applied to
  90888. * @param updatable when used and having the value true allows new data to update the vertexData
  90889. * @returns VertexData
  90890. */
  90891. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  90892. this._applyTo(geometry, updatable);
  90893. return this;
  90894. };
  90895. /**
  90896. * Updates the associated mesh
  90897. * @param mesh the mesh to be updated
  90898. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90899. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  90900. * @returns VertexData
  90901. */
  90902. VertexData.prototype.updateMesh = function (mesh) {
  90903. this._update(mesh);
  90904. return this;
  90905. };
  90906. /**
  90907. * Updates the associated geometry
  90908. * @param geometry the geometry to be updated
  90909. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90910. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  90911. * @returns VertexData.
  90912. */
  90913. VertexData.prototype.updateGeometry = function (geometry) {
  90914. this._update(geometry);
  90915. return this;
  90916. };
  90917. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  90918. if (updatable === void 0) { updatable = false; }
  90919. if (this.positions) {
  90920. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  90921. }
  90922. if (this.normals) {
  90923. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  90924. }
  90925. if (this.tangents) {
  90926. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  90927. }
  90928. if (this.uvs) {
  90929. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  90930. }
  90931. if (this.uvs2) {
  90932. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  90933. }
  90934. if (this.uvs3) {
  90935. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  90936. }
  90937. if (this.uvs4) {
  90938. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  90939. }
  90940. if (this.uvs5) {
  90941. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  90942. }
  90943. if (this.uvs6) {
  90944. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  90945. }
  90946. if (this.colors) {
  90947. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  90948. }
  90949. if (this.matricesIndices) {
  90950. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  90951. }
  90952. if (this.matricesWeights) {
  90953. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  90954. }
  90955. if (this.matricesIndicesExtra) {
  90956. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  90957. }
  90958. if (this.matricesWeightsExtra) {
  90959. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  90960. }
  90961. if (this.indices) {
  90962. meshOrGeometry.setIndices(this.indices, null, updatable);
  90963. }
  90964. else {
  90965. meshOrGeometry.setIndices([], null);
  90966. }
  90967. return this;
  90968. };
  90969. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  90970. if (this.positions) {
  90971. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  90972. }
  90973. if (this.normals) {
  90974. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  90975. }
  90976. if (this.tangents) {
  90977. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  90978. }
  90979. if (this.uvs) {
  90980. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  90981. }
  90982. if (this.uvs2) {
  90983. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  90984. }
  90985. if (this.uvs3) {
  90986. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  90987. }
  90988. if (this.uvs4) {
  90989. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  90990. }
  90991. if (this.uvs5) {
  90992. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  90993. }
  90994. if (this.uvs6) {
  90995. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  90996. }
  90997. if (this.colors) {
  90998. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  90999. }
  91000. if (this.matricesIndices) {
  91001. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  91002. }
  91003. if (this.matricesWeights) {
  91004. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  91005. }
  91006. if (this.matricesIndicesExtra) {
  91007. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  91008. }
  91009. if (this.matricesWeightsExtra) {
  91010. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  91011. }
  91012. if (this.indices) {
  91013. meshOrGeometry.setIndices(this.indices, null);
  91014. }
  91015. return this;
  91016. };
  91017. /**
  91018. * Transforms each position and each normal of the vertexData according to the passed Matrix
  91019. * @param matrix the transforming matrix
  91020. * @returns the VertexData
  91021. */
  91022. VertexData.prototype.transform = function (matrix) {
  91023. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  91024. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  91025. var index;
  91026. if (this.positions) {
  91027. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  91028. for (index = 0; index < this.positions.length; index += 3) {
  91029. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  91030. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  91031. this.positions[index] = transformed.x;
  91032. this.positions[index + 1] = transformed.y;
  91033. this.positions[index + 2] = transformed.z;
  91034. }
  91035. }
  91036. if (this.normals) {
  91037. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  91038. for (index = 0; index < this.normals.length; index += 3) {
  91039. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  91040. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  91041. this.normals[index] = transformed.x;
  91042. this.normals[index + 1] = transformed.y;
  91043. this.normals[index + 2] = transformed.z;
  91044. }
  91045. }
  91046. if (this.tangents) {
  91047. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  91048. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  91049. for (index = 0; index < this.tangents.length; index += 4) {
  91050. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  91051. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  91052. this.tangents[index] = tangentTransformed.x;
  91053. this.tangents[index + 1] = tangentTransformed.y;
  91054. this.tangents[index + 2] = tangentTransformed.z;
  91055. this.tangents[index + 3] = tangentTransformed.w;
  91056. }
  91057. }
  91058. if (flip && this.indices) {
  91059. for (index = 0; index < this.indices.length; index += 3) {
  91060. var tmp = this.indices[index + 1];
  91061. this.indices[index + 1] = this.indices[index + 2];
  91062. this.indices[index + 2] = tmp;
  91063. }
  91064. }
  91065. return this;
  91066. };
  91067. /**
  91068. * Merges the passed VertexData into the current one
  91069. * @param other the VertexData to be merged into the current one
  91070. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  91071. * @returns the modified VertexData
  91072. */
  91073. VertexData.prototype.merge = function (other, use32BitsIndices) {
  91074. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  91075. this._validate();
  91076. other._validate();
  91077. if (!this.normals !== !other.normals ||
  91078. !this.tangents !== !other.tangents ||
  91079. !this.uvs !== !other.uvs ||
  91080. !this.uvs2 !== !other.uvs2 ||
  91081. !this.uvs3 !== !other.uvs3 ||
  91082. !this.uvs4 !== !other.uvs4 ||
  91083. !this.uvs5 !== !other.uvs5 ||
  91084. !this.uvs6 !== !other.uvs6 ||
  91085. !this.colors !== !other.colors ||
  91086. !this.matricesIndices !== !other.matricesIndices ||
  91087. !this.matricesWeights !== !other.matricesWeights ||
  91088. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  91089. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  91090. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  91091. }
  91092. if (other.indices) {
  91093. if (!this.indices) {
  91094. this.indices = [];
  91095. }
  91096. var offset = this.positions ? this.positions.length / 3 : 0;
  91097. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  91098. if (isSrcTypedArray) {
  91099. var len = this.indices.length + other.indices.length;
  91100. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  91101. temp.set(this.indices);
  91102. var decal = this.indices.length;
  91103. for (var index = 0; index < other.indices.length; index++) {
  91104. temp[decal + index] = other.indices[index] + offset;
  91105. }
  91106. this.indices = temp;
  91107. }
  91108. else {
  91109. for (var index = 0; index < other.indices.length; index++) {
  91110. this.indices.push(other.indices[index] + offset);
  91111. }
  91112. }
  91113. }
  91114. this.positions = this._mergeElement(this.positions, other.positions);
  91115. this.normals = this._mergeElement(this.normals, other.normals);
  91116. this.tangents = this._mergeElement(this.tangents, other.tangents);
  91117. this.uvs = this._mergeElement(this.uvs, other.uvs);
  91118. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  91119. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  91120. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  91121. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  91122. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  91123. this.colors = this._mergeElement(this.colors, other.colors);
  91124. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  91125. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  91126. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  91127. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  91128. return this;
  91129. };
  91130. VertexData.prototype._mergeElement = function (source, other) {
  91131. if (!source) {
  91132. return other;
  91133. }
  91134. if (!other) {
  91135. return source;
  91136. }
  91137. var len = other.length + source.length;
  91138. var isSrcTypedArray = source instanceof Float32Array;
  91139. var isOthTypedArray = other instanceof Float32Array;
  91140. // use non-loop method when the source is Float32Array
  91141. if (isSrcTypedArray) {
  91142. var ret32 = new Float32Array(len);
  91143. ret32.set(source);
  91144. ret32.set(other, source.length);
  91145. return ret32;
  91146. // source is number[], when other is also use concat
  91147. }
  91148. else if (!isOthTypedArray) {
  91149. return source.concat(other);
  91150. // source is a number[], but other is a Float32Array, loop required
  91151. }
  91152. else {
  91153. var ret = source.slice(0); // copy source to a separate array
  91154. for (var i = 0, len = other.length; i < len; i++) {
  91155. ret.push(other[i]);
  91156. }
  91157. return ret;
  91158. }
  91159. };
  91160. VertexData.prototype._validate = function () {
  91161. if (!this.positions) {
  91162. throw new Error("Positions are required");
  91163. }
  91164. var getElementCount = function (kind, values) {
  91165. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  91166. if ((values.length % stride) !== 0) {
  91167. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  91168. }
  91169. return values.length / stride;
  91170. };
  91171. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  91172. var validateElementCount = function (kind, values) {
  91173. var elementCount = getElementCount(kind, values);
  91174. if (elementCount !== positionsElementCount) {
  91175. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  91176. }
  91177. };
  91178. if (this.normals) {
  91179. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  91180. }
  91181. if (this.tangents) {
  91182. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  91183. }
  91184. if (this.uvs) {
  91185. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  91186. }
  91187. if (this.uvs2) {
  91188. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  91189. }
  91190. if (this.uvs3) {
  91191. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  91192. }
  91193. if (this.uvs4) {
  91194. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  91195. }
  91196. if (this.uvs5) {
  91197. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  91198. }
  91199. if (this.uvs6) {
  91200. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  91201. }
  91202. if (this.colors) {
  91203. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  91204. }
  91205. if (this.matricesIndices) {
  91206. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  91207. }
  91208. if (this.matricesWeights) {
  91209. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  91210. }
  91211. if (this.matricesIndicesExtra) {
  91212. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  91213. }
  91214. if (this.matricesWeightsExtra) {
  91215. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  91216. }
  91217. };
  91218. /**
  91219. * Serializes the VertexData
  91220. * @returns a serialized object
  91221. */
  91222. VertexData.prototype.serialize = function () {
  91223. var serializationObject = this.serialize();
  91224. if (this.positions) {
  91225. serializationObject.positions = this.positions;
  91226. }
  91227. if (this.normals) {
  91228. serializationObject.normals = this.normals;
  91229. }
  91230. if (this.tangents) {
  91231. serializationObject.tangents = this.tangents;
  91232. }
  91233. if (this.uvs) {
  91234. serializationObject.uvs = this.uvs;
  91235. }
  91236. if (this.uvs2) {
  91237. serializationObject.uvs2 = this.uvs2;
  91238. }
  91239. if (this.uvs3) {
  91240. serializationObject.uvs3 = this.uvs3;
  91241. }
  91242. if (this.uvs4) {
  91243. serializationObject.uvs4 = this.uvs4;
  91244. }
  91245. if (this.uvs5) {
  91246. serializationObject.uvs5 = this.uvs5;
  91247. }
  91248. if (this.uvs6) {
  91249. serializationObject.uvs6 = this.uvs6;
  91250. }
  91251. if (this.colors) {
  91252. serializationObject.colors = this.colors;
  91253. }
  91254. if (this.matricesIndices) {
  91255. serializationObject.matricesIndices = this.matricesIndices;
  91256. serializationObject.matricesIndices._isExpanded = true;
  91257. }
  91258. if (this.matricesWeights) {
  91259. serializationObject.matricesWeights = this.matricesWeights;
  91260. }
  91261. if (this.matricesIndicesExtra) {
  91262. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  91263. serializationObject.matricesIndicesExtra._isExpanded = true;
  91264. }
  91265. if (this.matricesWeightsExtra) {
  91266. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  91267. }
  91268. serializationObject.indices = this.indices;
  91269. return serializationObject;
  91270. };
  91271. // Statics
  91272. /**
  91273. * Extracts the vertexData from a mesh
  91274. * @param mesh the mesh from which to extract the VertexData
  91275. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  91276. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  91277. * @returns the object VertexData associated to the passed mesh
  91278. */
  91279. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  91280. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  91281. };
  91282. /**
  91283. * Extracts the vertexData from the geometry
  91284. * @param geometry the geometry from which to extract the VertexData
  91285. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  91286. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  91287. * @returns the object VertexData associated to the passed mesh
  91288. */
  91289. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  91290. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  91291. };
  91292. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  91293. var result = new VertexData();
  91294. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  91295. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  91296. }
  91297. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  91298. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  91299. }
  91300. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  91301. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  91302. }
  91303. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  91304. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  91305. }
  91306. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  91307. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  91308. }
  91309. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  91310. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  91311. }
  91312. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  91313. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  91314. }
  91315. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  91316. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  91317. }
  91318. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  91319. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  91320. }
  91321. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  91322. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  91323. }
  91324. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  91325. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  91326. }
  91327. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  91328. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  91329. }
  91330. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  91331. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  91332. }
  91333. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  91334. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  91335. }
  91336. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  91337. return result;
  91338. };
  91339. /**
  91340. * Creates the VertexData for a Ribbon
  91341. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  91342. * * pathArray array of paths, each of which an array of successive Vector3
  91343. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  91344. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  91345. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  91346. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91347. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  91348. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  91349. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  91350. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  91351. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  91352. * @returns the VertexData of the ribbon
  91353. */
  91354. VertexData.CreateRibbon = function (options) {
  91355. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ribbonBuilder");
  91356. };
  91357. /**
  91358. * Creates the VertexData for a box
  91359. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91360. * * size sets the width, height and depth of the box to the value of size, optional default 1
  91361. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  91362. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  91363. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  91364. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  91365. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  91366. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91367. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  91368. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  91369. * @returns the VertexData of the box
  91370. */
  91371. VertexData.CreateBox = function (options) {
  91372. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("boxBuilder");
  91373. };
  91374. /**
  91375. * Creates the VertexData for an ellipsoid, defaults to a sphere
  91376. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91377. * * segments sets the number of horizontal strips optional, default 32
  91378. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  91379. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  91380. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  91381. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  91382. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  91383. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  91384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91385. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  91386. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  91387. * @returns the VertexData of the ellipsoid
  91388. */
  91389. VertexData.CreateSphere = function (options) {
  91390. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("sphereBuilder");
  91391. };
  91392. /**
  91393. * Creates the VertexData for a cylinder, cone or prism
  91394. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91395. * * height sets the height (y direction) of the cylinder, optional, default 2
  91396. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  91397. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  91398. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  91399. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  91400. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  91401. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  91402. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91403. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91404. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  91405. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  91406. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91407. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  91408. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  91409. * @returns the VertexData of the cylinder, cone or prism
  91410. */
  91411. VertexData.CreateCylinder = function (options) {
  91412. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("cylinderBuilder");
  91413. };
  91414. /**
  91415. * Creates the VertexData for a torus
  91416. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91417. * * diameter the diameter of the torus, optional default 1
  91418. * * thickness the diameter of the tube forming the torus, optional default 0.5
  91419. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  91420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91421. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  91422. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  91423. * @returns the VertexData of the torus
  91424. */
  91425. VertexData.CreateTorus = function (options) {
  91426. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusBuilder");
  91427. };
  91428. /**
  91429. * Creates the VertexData of the LineSystem
  91430. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  91431. * - lines an array of lines, each line being an array of successive Vector3
  91432. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  91433. * @returns the VertexData of the LineSystem
  91434. */
  91435. VertexData.CreateLineSystem = function (options) {
  91436. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  91437. };
  91438. /**
  91439. * Create the VertexData for a DashedLines
  91440. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  91441. * - points an array successive Vector3
  91442. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  91443. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  91444. * - dashNb the intended total number of dashes, optional, default 200
  91445. * @returns the VertexData for the DashedLines
  91446. */
  91447. VertexData.CreateDashedLines = function (options) {
  91448. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  91449. };
  91450. /**
  91451. * Creates the VertexData for a Ground
  91452. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  91453. * - width the width (x direction) of the ground, optional, default 1
  91454. * - height the height (z direction) of the ground, optional, default 1
  91455. * - subdivisions the number of subdivisions per side, optional, default 1
  91456. * @returns the VertexData of the Ground
  91457. */
  91458. VertexData.CreateGround = function (options) {
  91459. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  91460. };
  91461. /**
  91462. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  91463. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  91464. * * xmin the ground minimum X coordinate, optional, default -1
  91465. * * zmin the ground minimum Z coordinate, optional, default -1
  91466. * * xmax the ground maximum X coordinate, optional, default 1
  91467. * * zmax the ground maximum Z coordinate, optional, default 1
  91468. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  91469. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  91470. * @returns the VertexData of the TiledGround
  91471. */
  91472. VertexData.CreateTiledGround = function (options) {
  91473. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  91474. };
  91475. /**
  91476. * Creates the VertexData of the Ground designed from a heightmap
  91477. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  91478. * * width the width (x direction) of the ground
  91479. * * height the height (z direction) of the ground
  91480. * * subdivisions the number of subdivisions per side
  91481. * * minHeight the minimum altitude on the ground, optional, default 0
  91482. * * maxHeight the maximum altitude on the ground, optional default 1
  91483. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  91484. * * buffer the array holding the image color data
  91485. * * bufferWidth the width of image
  91486. * * bufferHeight the height of image
  91487. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  91488. * @returns the VertexData of the Ground designed from a heightmap
  91489. */
  91490. VertexData.CreateGroundFromHeightMap = function (options) {
  91491. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  91492. };
  91493. /**
  91494. * Creates the VertexData for a Plane
  91495. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  91496. * * size sets the width and height of the plane to the value of size, optional default 1
  91497. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  91498. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  91499. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91500. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  91501. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  91502. * @returns the VertexData of the box
  91503. */
  91504. VertexData.CreatePlane = function (options) {
  91505. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("planeBuilder");
  91506. };
  91507. /**
  91508. * Creates the VertexData of the Disc or regular Polygon
  91509. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  91510. * * radius the radius of the disc, optional default 0.5
  91511. * * tessellation the number of polygon sides, optional, default 64
  91512. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  91513. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91514. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  91515. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  91516. * @returns the VertexData of the box
  91517. */
  91518. VertexData.CreateDisc = function (options) {
  91519. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("discBuilder");
  91520. };
  91521. /**
  91522. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  91523. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  91524. * @param polygon a mesh built from polygonTriangulation.build()
  91525. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91526. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91527. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91528. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  91529. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  91530. * @returns the VertexData of the Polygon
  91531. */
  91532. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  91533. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polygonBuilder");
  91534. };
  91535. /**
  91536. * Creates the VertexData of the IcoSphere
  91537. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  91538. * * radius the radius of the IcoSphere, optional default 1
  91539. * * radiusX allows stretching in the x direction, optional, default radius
  91540. * * radiusY allows stretching in the y direction, optional, default radius
  91541. * * radiusZ allows stretching in the z direction, optional, default radius
  91542. * * flat when true creates a flat shaded mesh, optional, default true
  91543. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91544. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91545. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  91546. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  91547. * @returns the VertexData of the IcoSphere
  91548. */
  91549. VertexData.CreateIcoSphere = function (options) {
  91550. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("icoSphereBuilder");
  91551. };
  91552. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  91553. /**
  91554. * Creates the VertexData for a Polyhedron
  91555. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  91556. * * type provided types are:
  91557. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  91558. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  91559. * * size the size of the IcoSphere, optional default 1
  91560. * * sizeX allows stretching in the x direction, optional, default size
  91561. * * sizeY allows stretching in the y direction, optional, default size
  91562. * * sizeZ allows stretching in the z direction, optional, default size
  91563. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  91564. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91565. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91566. * * flat when true creates a flat shaded mesh, optional, default true
  91567. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91568. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91569. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  91570. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  91571. * @returns the VertexData of the Polyhedron
  91572. */
  91573. VertexData.CreatePolyhedron = function (options) {
  91574. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polyhedronBuilder");
  91575. };
  91576. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  91577. /**
  91578. * Creates the VertexData for a TorusKnot
  91579. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  91580. * * radius the radius of the torus knot, optional, default 2
  91581. * * tube the thickness of the tube, optional, default 0.5
  91582. * * radialSegments the number of sides on each tube segments, optional, default 32
  91583. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  91584. * * p the number of windings around the z axis, optional, default 2
  91585. * * q the number of windings around the x axis, optional, default 3
  91586. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91587. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  91588. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  91589. * @returns the VertexData of the Torus Knot
  91590. */
  91591. VertexData.CreateTorusKnot = function (options) {
  91592. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusKnotBuilder");
  91593. };
  91594. // Tools
  91595. /**
  91596. * Compute normals for given positions and indices
  91597. * @param positions an array of vertex positions, [...., x, y, z, ......]
  91598. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  91599. * @param normals an array of vertex normals, [...., x, y, z, ......]
  91600. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  91601. * * facetNormals : optional array of facet normals (vector3)
  91602. * * facetPositions : optional array of facet positions (vector3)
  91603. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  91604. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  91605. * * bInfo : optional bounding info, required for facetPartitioning computation
  91606. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  91607. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  91608. * * useRightHandedSystem: optional boolean to for right handed system computation
  91609. * * depthSort : optional boolean to enable the facet depth sort computation
  91610. * * distanceTo : optional Vector3 to compute the facet depth from this location
  91611. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  91612. */
  91613. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  91614. // temporary scalar variables
  91615. var index = 0; // facet index
  91616. var p1p2x = 0.0; // p1p2 vector x coordinate
  91617. var p1p2y = 0.0; // p1p2 vector y coordinate
  91618. var p1p2z = 0.0; // p1p2 vector z coordinate
  91619. var p3p2x = 0.0; // p3p2 vector x coordinate
  91620. var p3p2y = 0.0; // p3p2 vector y coordinate
  91621. var p3p2z = 0.0; // p3p2 vector z coordinate
  91622. var faceNormalx = 0.0; // facet normal x coordinate
  91623. var faceNormaly = 0.0; // facet normal y coordinate
  91624. var faceNormalz = 0.0; // facet normal z coordinate
  91625. var length = 0.0; // facet normal length before normalization
  91626. var v1x = 0; // vector1 x index in the positions array
  91627. var v1y = 0; // vector1 y index in the positions array
  91628. var v1z = 0; // vector1 z index in the positions array
  91629. var v2x = 0; // vector2 x index in the positions array
  91630. var v2y = 0; // vector2 y index in the positions array
  91631. var v2z = 0; // vector2 z index in the positions array
  91632. var v3x = 0; // vector3 x index in the positions array
  91633. var v3y = 0; // vector3 y index in the positions array
  91634. var v3z = 0; // vector3 z index in the positions array
  91635. var computeFacetNormals = false;
  91636. var computeFacetPositions = false;
  91637. var computeFacetPartitioning = false;
  91638. var computeDepthSort = false;
  91639. var faceNormalSign = 1;
  91640. var ratio = 0;
  91641. var distanceTo = null;
  91642. if (options) {
  91643. computeFacetNormals = (options.facetNormals) ? true : false;
  91644. computeFacetPositions = (options.facetPositions) ? true : false;
  91645. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  91646. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  91647. ratio = options.ratio || 0;
  91648. computeDepthSort = (options.depthSort) ? true : false;
  91649. distanceTo = (options.distanceTo);
  91650. if (computeDepthSort) {
  91651. if (distanceTo === undefined) {
  91652. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  91653. }
  91654. var depthSortedFacets = options.depthSortedFacets;
  91655. }
  91656. }
  91657. // facetPartitioning reinit if needed
  91658. var xSubRatio = 0;
  91659. var ySubRatio = 0;
  91660. var zSubRatio = 0;
  91661. var subSq = 0;
  91662. if (computeFacetPartitioning && options && options.bbSize) {
  91663. var ox = 0; // X partitioning index for facet position
  91664. var oy = 0; // Y partinioning index for facet position
  91665. var oz = 0; // Z partinioning index for facet position
  91666. var b1x = 0; // X partitioning index for facet v1 vertex
  91667. var b1y = 0; // Y partitioning index for facet v1 vertex
  91668. var b1z = 0; // z partitioning index for facet v1 vertex
  91669. var b2x = 0; // X partitioning index for facet v2 vertex
  91670. var b2y = 0; // Y partitioning index for facet v2 vertex
  91671. var b2z = 0; // Z partitioning index for facet v2 vertex
  91672. var b3x = 0; // X partitioning index for facet v3 vertex
  91673. var b3y = 0; // Y partitioning index for facet v3 vertex
  91674. var b3z = 0; // Z partitioning index for facet v3 vertex
  91675. var block_idx_o = 0; // facet barycenter block index
  91676. var block_idx_v1 = 0; // v1 vertex block index
  91677. var block_idx_v2 = 0; // v2 vertex block index
  91678. var block_idx_v3 = 0; // v3 vertex block index
  91679. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  91680. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  91681. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  91682. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  91683. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  91684. subSq = options.subDiv.max * options.subDiv.max;
  91685. options.facetPartitioning.length = 0;
  91686. }
  91687. // reset the normals
  91688. for (index = 0; index < positions.length; index++) {
  91689. normals[index] = 0.0;
  91690. }
  91691. // Loop : 1 indice triplet = 1 facet
  91692. var nbFaces = (indices.length / 3) | 0;
  91693. for (index = 0; index < nbFaces; index++) {
  91694. // get the indexes of the coordinates of each vertex of the facet
  91695. v1x = indices[index * 3] * 3;
  91696. v1y = v1x + 1;
  91697. v1z = v1x + 2;
  91698. v2x = indices[index * 3 + 1] * 3;
  91699. v2y = v2x + 1;
  91700. v2z = v2x + 2;
  91701. v3x = indices[index * 3 + 2] * 3;
  91702. v3y = v3x + 1;
  91703. v3z = v3x + 2;
  91704. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  91705. p1p2y = positions[v1y] - positions[v2y];
  91706. p1p2z = positions[v1z] - positions[v2z];
  91707. p3p2x = positions[v3x] - positions[v2x];
  91708. p3p2y = positions[v3y] - positions[v2y];
  91709. p3p2z = positions[v3z] - positions[v2z];
  91710. // compute the face normal with the cross product
  91711. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  91712. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  91713. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  91714. // normalize this normal and store it in the array facetData
  91715. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  91716. length = (length === 0) ? 1.0 : length;
  91717. faceNormalx /= length;
  91718. faceNormaly /= length;
  91719. faceNormalz /= length;
  91720. if (computeFacetNormals && options) {
  91721. options.facetNormals[index].x = faceNormalx;
  91722. options.facetNormals[index].y = faceNormaly;
  91723. options.facetNormals[index].z = faceNormalz;
  91724. }
  91725. if (computeFacetPositions && options) {
  91726. // compute and the facet barycenter coordinates in the array facetPositions
  91727. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  91728. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  91729. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  91730. }
  91731. if (computeFacetPartitioning && options) {
  91732. // store the facet indexes in arrays in the main facetPartitioning array :
  91733. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  91734. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  91735. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  91736. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  91737. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  91738. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  91739. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  91740. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  91741. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  91742. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  91743. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  91744. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  91745. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  91746. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  91747. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  91748. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  91749. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  91750. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  91751. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  91752. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  91753. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  91754. // push each facet index in each block containing the vertex
  91755. options.facetPartitioning[block_idx_v1].push(index);
  91756. if (block_idx_v2 != block_idx_v1) {
  91757. options.facetPartitioning[block_idx_v2].push(index);
  91758. }
  91759. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  91760. options.facetPartitioning[block_idx_v3].push(index);
  91761. }
  91762. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  91763. options.facetPartitioning[block_idx_o].push(index);
  91764. }
  91765. }
  91766. if (computeDepthSort && options && options.facetPositions) {
  91767. var dsf = depthSortedFacets[index];
  91768. dsf.ind = index * 3;
  91769. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  91770. }
  91771. // compute the normals anyway
  91772. normals[v1x] += faceNormalx; // accumulate all the normals per face
  91773. normals[v1y] += faceNormaly;
  91774. normals[v1z] += faceNormalz;
  91775. normals[v2x] += faceNormalx;
  91776. normals[v2y] += faceNormaly;
  91777. normals[v2z] += faceNormalz;
  91778. normals[v3x] += faceNormalx;
  91779. normals[v3y] += faceNormaly;
  91780. normals[v3z] += faceNormalz;
  91781. }
  91782. // last normalization of each normal
  91783. for (index = 0; index < normals.length / 3; index++) {
  91784. faceNormalx = normals[index * 3];
  91785. faceNormaly = normals[index * 3 + 1];
  91786. faceNormalz = normals[index * 3 + 2];
  91787. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  91788. length = (length === 0) ? 1.0 : length;
  91789. faceNormalx /= length;
  91790. faceNormaly /= length;
  91791. faceNormalz /= length;
  91792. normals[index * 3] = faceNormalx;
  91793. normals[index * 3 + 1] = faceNormaly;
  91794. normals[index * 3 + 2] = faceNormalz;
  91795. }
  91796. };
  91797. /** @hidden */
  91798. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  91799. var li = indices.length;
  91800. var ln = normals.length;
  91801. var i;
  91802. var n;
  91803. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  91804. switch (sideOrientation) {
  91805. case VertexData.FRONTSIDE:
  91806. // nothing changed
  91807. break;
  91808. case VertexData.BACKSIDE:
  91809. var tmp;
  91810. // indices
  91811. for (i = 0; i < li; i += 3) {
  91812. tmp = indices[i];
  91813. indices[i] = indices[i + 2];
  91814. indices[i + 2] = tmp;
  91815. }
  91816. // normals
  91817. for (n = 0; n < ln; n++) {
  91818. normals[n] = -normals[n];
  91819. }
  91820. break;
  91821. case VertexData.DOUBLESIDE:
  91822. // positions
  91823. var lp = positions.length;
  91824. var l = lp / 3;
  91825. for (var p = 0; p < lp; p++) {
  91826. positions[lp + p] = positions[p];
  91827. }
  91828. // indices
  91829. for (i = 0; i < li; i += 3) {
  91830. indices[i + li] = indices[i + 2] + l;
  91831. indices[i + 1 + li] = indices[i + 1] + l;
  91832. indices[i + 2 + li] = indices[i] + l;
  91833. }
  91834. // normals
  91835. for (n = 0; n < ln; n++) {
  91836. normals[ln + n] = -normals[n];
  91837. }
  91838. // uvs
  91839. var lu = uvs.length;
  91840. var u = 0;
  91841. for (u = 0; u < lu; u++) {
  91842. uvs[u + lu] = uvs[u];
  91843. }
  91844. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  91845. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  91846. u = 0;
  91847. for (i = 0; i < lu / 2; i++) {
  91848. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  91849. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  91850. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  91851. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  91852. u += 2;
  91853. }
  91854. break;
  91855. }
  91856. };
  91857. /**
  91858. * Applies VertexData created from the imported parameters to the geometry
  91859. * @param parsedVertexData the parsed data from an imported file
  91860. * @param geometry the geometry to apply the VertexData to
  91861. */
  91862. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  91863. var vertexData = new VertexData();
  91864. // positions
  91865. var positions = parsedVertexData.positions;
  91866. if (positions) {
  91867. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  91868. }
  91869. // normals
  91870. var normals = parsedVertexData.normals;
  91871. if (normals) {
  91872. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  91873. }
  91874. // tangents
  91875. var tangents = parsedVertexData.tangents;
  91876. if (tangents) {
  91877. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  91878. }
  91879. // uvs
  91880. var uvs = parsedVertexData.uvs;
  91881. if (uvs) {
  91882. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  91883. }
  91884. // uv2s
  91885. var uv2s = parsedVertexData.uv2s;
  91886. if (uv2s) {
  91887. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  91888. }
  91889. // uv3s
  91890. var uv3s = parsedVertexData.uv3s;
  91891. if (uv3s) {
  91892. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  91893. }
  91894. // uv4s
  91895. var uv4s = parsedVertexData.uv4s;
  91896. if (uv4s) {
  91897. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  91898. }
  91899. // uv5s
  91900. var uv5s = parsedVertexData.uv5s;
  91901. if (uv5s) {
  91902. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  91903. }
  91904. // uv6s
  91905. var uv6s = parsedVertexData.uv6s;
  91906. if (uv6s) {
  91907. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  91908. }
  91909. // colors
  91910. var colors = parsedVertexData.colors;
  91911. if (colors) {
  91912. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  91913. }
  91914. // matricesIndices
  91915. var matricesIndices = parsedVertexData.matricesIndices;
  91916. if (matricesIndices) {
  91917. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  91918. }
  91919. // matricesWeights
  91920. var matricesWeights = parsedVertexData.matricesWeights;
  91921. if (matricesWeights) {
  91922. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  91923. }
  91924. // indices
  91925. var indices = parsedVertexData.indices;
  91926. if (indices) {
  91927. vertexData.indices = indices;
  91928. }
  91929. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  91930. };
  91931. /**
  91932. * Mesh side orientation : usually the external or front surface
  91933. */
  91934. VertexData.FRONTSIDE = 0;
  91935. /**
  91936. * Mesh side orientation : usually the internal or back surface
  91937. */
  91938. VertexData.BACKSIDE = 1;
  91939. /**
  91940. * Mesh side orientation : both internal and external or front and back surfaces
  91941. */
  91942. VertexData.DOUBLESIDE = 2;
  91943. /**
  91944. * Mesh side orientation : by default, `FRONTSIDE`
  91945. */
  91946. VertexData.DEFAULTSIDE = 0;
  91947. return VertexData;
  91948. }());
  91949. /***/ }),
  91950. /***/ "./Meshes/meshBuilder.ts":
  91951. /*!*******************************!*\
  91952. !*** ./Meshes/meshBuilder.ts ***!
  91953. \*******************************/
  91954. /*! exports provided: MeshBuilder */
  91955. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91956. "use strict";
  91957. __webpack_require__.r(__webpack_exports__);
  91958. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  91959. /* harmony import */ var _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Builders/ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  91960. /* harmony import */ var _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  91961. /* harmony import */ var _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  91962. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  91963. /* harmony import */ var _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  91964. /* harmony import */ var _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  91965. /* harmony import */ var _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Builders/torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  91966. /* harmony import */ var _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  91967. /* harmony import */ var _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Builders/polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  91968. /* harmony import */ var _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  91969. /* harmony import */ var _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Builders/latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  91970. /* harmony import */ var _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  91971. /* harmony import */ var _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  91972. /* harmony import */ var _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Builders/tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  91973. /* harmony import */ var _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  91974. /* harmony import */ var _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Builders/icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  91975. /* harmony import */ var _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  91976. /**
  91977. * Class containing static functions to help procedurally build meshes
  91978. */
  91979. var MeshBuilder = /** @class */ (function () {
  91980. function MeshBuilder() {
  91981. }
  91982. /**
  91983. * Creates a box mesh
  91984. * * The parameter `size` sets the size (float) of each box side (default 1)
  91985. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  91986. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  91987. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  91988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91991. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  91992. * @param name defines the name of the mesh
  91993. * @param options defines the options used to create the mesh
  91994. * @param scene defines the hosting scene
  91995. * @returns the box mesh
  91996. */
  91997. MeshBuilder.CreateBox = function (name, options, scene) {
  91998. if (scene === void 0) { scene = null; }
  91999. return _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(name, options, scene);
  92000. };
  92001. /**
  92002. * Creates a sphere mesh
  92003. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  92004. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  92005. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  92006. * * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  92007. * * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude)
  92008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92011. * @param name defines the name of the mesh
  92012. * @param options defines the options used to create the mesh
  92013. * @param scene defines the hosting scene
  92014. * @returns the sphere mesh
  92015. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  92016. */
  92017. MeshBuilder.CreateSphere = function (name, options, scene) {
  92018. if (scene === void 0) { scene = null; }
  92019. return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
  92020. };
  92021. /**
  92022. * Creates a plane polygonal mesh. By default, this is a disc
  92023. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  92024. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  92025. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  92026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92027. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92029. * @param name defines the name of the mesh
  92030. * @param options defines the options used to create the mesh
  92031. * @param scene defines the hosting scene
  92032. * @returns the plane polygonal mesh
  92033. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  92034. */
  92035. MeshBuilder.CreateDisc = function (name, options, scene) {
  92036. if (scene === void 0) { scene = null; }
  92037. return _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"].CreateDisc(name, options, scene);
  92038. };
  92039. /**
  92040. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  92041. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  92042. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value of `radius`)
  92043. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  92044. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  92045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92046. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92048. * @param name defines the name of the mesh
  92049. * @param options defines the options used to create the mesh
  92050. * @param scene defines the hosting scene
  92051. * @returns the icosahedron mesh
  92052. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  92053. */
  92054. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  92055. if (scene === void 0) { scene = null; }
  92056. return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
  92057. };
  92058. /**
  92059. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  92060. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  92061. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  92062. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  92063. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  92064. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  92065. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  92066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92067. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92068. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  92069. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  92070. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  92071. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  92072. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  92073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92074. * @param name defines the name of the mesh
  92075. * @param options defines the options used to create the mesh
  92076. * @param scene defines the hosting scene
  92077. * @returns the ribbon mesh
  92078. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  92079. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  92080. */
  92081. MeshBuilder.CreateRibbon = function (name, options, scene) {
  92082. if (scene === void 0) { scene = null; }
  92083. return _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"].CreateRibbon(name, options, scene);
  92084. };
  92085. /**
  92086. * Creates a cylinder or a cone mesh
  92087. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  92088. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  92089. * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  92090. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  92091. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  92092. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  92093. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  92094. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  92095. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  92096. * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  92097. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  92098. * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  92099. * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  92100. * * If `enclose` is false, a ring surface is one element.
  92101. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  92102. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  92103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92106. * @param name defines the name of the mesh
  92107. * @param options defines the options used to create the mesh
  92108. * @param scene defines the hosting scene
  92109. * @returns the cylinder mesh
  92110. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  92111. */
  92112. MeshBuilder.CreateCylinder = function (name, options, scene) {
  92113. if (scene === void 0) { scene = null; }
  92114. return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
  92115. };
  92116. /**
  92117. * Creates a torus mesh
  92118. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  92119. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  92120. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  92121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92122. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92124. * @param name defines the name of the mesh
  92125. * @param options defines the options used to create the mesh
  92126. * @param scene defines the hosting scene
  92127. * @returns the torus mesh
  92128. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  92129. */
  92130. MeshBuilder.CreateTorus = function (name, options, scene) {
  92131. if (scene === void 0) { scene = null; }
  92132. return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
  92133. };
  92134. /**
  92135. * Creates a torus knot mesh
  92136. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  92137. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  92138. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  92139. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  92140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92143. * @param name defines the name of the mesh
  92144. * @param options defines the options used to create the mesh
  92145. * @param scene defines the hosting scene
  92146. * @returns the torus knot mesh
  92147. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  92148. */
  92149. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  92150. if (scene === void 0) { scene = null; }
  92151. return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
  92152. };
  92153. /**
  92154. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  92155. * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
  92156. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  92157. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  92158. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  92159. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  92160. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  92161. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  92162. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  92163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92164. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  92165. * @param name defines the name of the new line system
  92166. * @param options defines the options used to create the line system
  92167. * @param scene defines the hosting scene
  92168. * @returns a new line system mesh
  92169. */
  92170. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  92171. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLineSystem(name, options, scene);
  92172. };
  92173. /**
  92174. * Creates a line mesh
  92175. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  92176. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  92177. * * The parameter `points` is an array successive Vector3
  92178. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  92179. * * The optional parameter `colors` is an array of successive Color4, one per line point
  92180. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  92181. * * When updating an instance, remember that only point positions can change, not the number of points
  92182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92183. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  92184. * @param name defines the name of the new line system
  92185. * @param options defines the options used to create the line system
  92186. * @param scene defines the hosting scene
  92187. * @returns a new line mesh
  92188. */
  92189. MeshBuilder.CreateLines = function (name, options, scene) {
  92190. if (scene === void 0) { scene = null; }
  92191. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines(name, options, scene);
  92192. };
  92193. /**
  92194. * Creates a dashed line mesh
  92195. * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  92196. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  92197. * * The parameter `points` is an array successive Vector3
  92198. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  92199. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  92200. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  92201. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  92202. * * When updating an instance, remember that only point positions can change, not the number of points
  92203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92204. * @param name defines the name of the mesh
  92205. * @param options defines the options used to create the mesh
  92206. * @param scene defines the hosting scene
  92207. * @returns the dashed line mesh
  92208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  92209. */
  92210. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  92211. if (scene === void 0) { scene = null; }
  92212. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateDashedLines(name, options, scene);
  92213. };
  92214. /**
  92215. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  92216. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  92217. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  92218. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  92219. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  92220. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  92221. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  92222. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  92223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92225. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  92226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92227. * @param name defines the name of the mesh
  92228. * @param options defines the options used to create the mesh
  92229. * @param scene defines the hosting scene
  92230. * @returns the extruded shape mesh
  92231. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  92232. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92233. */
  92234. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  92235. if (scene === void 0) { scene = null; }
  92236. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShape(name, options, scene);
  92237. };
  92238. /**
  92239. * Creates an custom extruded shape mesh.
  92240. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  92241. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  92242. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  92243. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  92244. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  92245. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  92246. * * It must returns a float value that will be the scale value applied to the shape on each path point
  92247. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  92248. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  92249. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  92250. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  92251. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  92252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92253. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92254. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  92255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92256. * @param name defines the name of the mesh
  92257. * @param options defines the options used to create the mesh
  92258. * @param scene defines the hosting scene
  92259. * @returns the custom extruded shape mesh
  92260. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  92261. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  92262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92263. */
  92264. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  92265. if (scene === void 0) { scene = null; }
  92266. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
  92267. };
  92268. /**
  92269. * Creates lathe mesh.
  92270. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  92271. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  92272. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  92273. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  92274. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  92275. * * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape
  92276. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  92277. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  92278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92280. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  92281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92282. * @param name defines the name of the mesh
  92283. * @param options defines the options used to create the mesh
  92284. * @param scene defines the hosting scene
  92285. * @returns the lathe mesh
  92286. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  92287. */
  92288. MeshBuilder.CreateLathe = function (name, options, scene) {
  92289. if (scene === void 0) { scene = null; }
  92290. return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
  92291. };
  92292. /**
  92293. * Creates a plane mesh
  92294. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92295. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92296. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92300. * @param name defines the name of the mesh
  92301. * @param options defines the options used to create the mesh
  92302. * @param scene defines the hosting scene
  92303. * @returns the plane mesh
  92304. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92305. */
  92306. MeshBuilder.CreatePlane = function (name, options, scene) {
  92307. if (scene === void 0) { scene = null; }
  92308. return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
  92309. };
  92310. /**
  92311. * Creates a ground mesh
  92312. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  92313. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  92314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92315. * @param name defines the name of the mesh
  92316. * @param options defines the options used to create the mesh
  92317. * @param scene defines the hosting scene
  92318. * @returns the ground mesh
  92319. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  92320. */
  92321. MeshBuilder.CreateGround = function (name, options, scene) {
  92322. if (scene === void 0) { scene = null; }
  92323. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
  92324. };
  92325. /**
  92326. * Creates a tiled ground mesh
  92327. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  92328. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  92329. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  92330. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  92331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92332. * @param name defines the name of the mesh
  92333. * @param options defines the options used to create the mesh
  92334. * @param scene defines the hosting scene
  92335. * @returns the tiled ground mesh
  92336. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  92337. */
  92338. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  92339. if (scene === void 0) { scene = null; }
  92340. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
  92341. };
  92342. /**
  92343. * Creates a ground mesh from a height map
  92344. * * The parameter `url` sets the URL of the height map image resource.
  92345. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  92346. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  92347. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  92348. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  92349. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  92350. * * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  92351. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  92352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92353. * @param name defines the name of the mesh
  92354. * @param url defines the url to the height map
  92355. * @param options defines the options used to create the mesh
  92356. * @param scene defines the hosting scene
  92357. * @returns the ground mesh
  92358. * @see https://doc.babylonjs.com/babylon101/height_map
  92359. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  92360. */
  92361. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  92362. if (scene === void 0) { scene = null; }
  92363. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
  92364. };
  92365. /**
  92366. * Creates a polygon mesh
  92367. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  92368. * * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  92369. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  92372. * * Remember you can only change the shape positions, not their number when updating a polygon
  92373. * @param name defines the name of the mesh
  92374. * @param options defines the options used to create the mesh
  92375. * @param scene defines the hosting scene
  92376. * @param earcutInjection can be used to inject your own earcut reference
  92377. * @returns the polygon mesh
  92378. */
  92379. MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  92380. if (scene === void 0) { scene = null; }
  92381. if (earcutInjection === void 0) { earcutInjection = earcut; }
  92382. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
  92383. };
  92384. /**
  92385. * Creates an extruded polygon mesh, with depth in the Y direction.
  92386. * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
  92387. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  92388. * @param name defines the name of the mesh
  92389. * @param options defines the options used to create the mesh
  92390. * @param scene defines the hosting scene
  92391. * @param earcutInjection can be used to inject your own earcut reference
  92392. * @returns the polygon mesh
  92393. */
  92394. MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  92395. if (scene === void 0) { scene = null; }
  92396. if (earcutInjection === void 0) { earcutInjection = earcut; }
  92397. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
  92398. };
  92399. /**
  92400. * Creates a tube mesh.
  92401. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  92402. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  92403. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  92404. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  92405. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  92406. * * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float)
  92407. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  92408. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  92409. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  92410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92411. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92412. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  92413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92414. * @param name defines the name of the mesh
  92415. * @param options defines the options used to create the mesh
  92416. * @param scene defines the hosting scene
  92417. * @returns the tube mesh
  92418. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  92419. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  92420. */
  92421. MeshBuilder.CreateTube = function (name, options, scene) {
  92422. if (scene === void 0) { scene = null; }
  92423. return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
  92424. };
  92425. /**
  92426. * Creates a polyhedron mesh
  92427. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  92428. * * The parameter `size` (positive float, default 1) sets the polygon size
  92429. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92430. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  92431. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  92432. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  92433. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  92434. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  92435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92438. * @param name defines the name of the mesh
  92439. * @param options defines the options used to create the mesh
  92440. * @param scene defines the hosting scene
  92441. * @returns the polyhedron mesh
  92442. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  92443. */
  92444. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  92445. if (scene === void 0) { scene = null; }
  92446. return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
  92447. };
  92448. /**
  92449. * Creates a decal mesh.
  92450. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
  92451. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  92452. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  92453. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  92454. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  92455. * @param name defines the name of the mesh
  92456. * @param sourceMesh defines the mesh where the decal must be applied
  92457. * @param options defines the options used to create the mesh
  92458. * @param scene defines the hosting scene
  92459. * @returns the decal mesh
  92460. * @see https://doc.babylonjs.com/how_to/decals
  92461. */
  92462. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  92463. return _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"].CreateDecal(name, sourceMesh, options);
  92464. };
  92465. return MeshBuilder;
  92466. }());
  92467. /***/ }),
  92468. /***/ "./Meshes/meshSimplification.ts":
  92469. /*!**************************************!*\
  92470. !*** ./Meshes/meshSimplification.ts ***!
  92471. \**************************************/
  92472. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  92473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92474. "use strict";
  92475. __webpack_require__.r(__webpack_exports__);
  92476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  92477. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  92478. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  92479. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92480. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  92481. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  92482. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  92483. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  92484. /**
  92485. * Class used to specify simplification options
  92486. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  92487. */
  92488. var SimplificationSettings = /** @class */ (function () {
  92489. /**
  92490. * Creates a SimplificationSettings
  92491. * @param quality expected quality
  92492. * @param distance distance when this optimized version should be used
  92493. * @param optimizeMesh already optimized mesh
  92494. */
  92495. function SimplificationSettings(
  92496. /** expected quality */
  92497. quality,
  92498. /** distance when this optimized version should be used */
  92499. distance,
  92500. /** already optimized mesh */
  92501. optimizeMesh) {
  92502. this.quality = quality;
  92503. this.distance = distance;
  92504. this.optimizeMesh = optimizeMesh;
  92505. }
  92506. return SimplificationSettings;
  92507. }());
  92508. /**
  92509. * Queue used to order the simplification tasks
  92510. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  92511. */
  92512. var SimplificationQueue = /** @class */ (function () {
  92513. /**
  92514. * Creates a new queue
  92515. */
  92516. function SimplificationQueue() {
  92517. this.running = false;
  92518. this._simplificationArray = [];
  92519. }
  92520. /**
  92521. * Adds a new simplification task
  92522. * @param task defines a task to add
  92523. */
  92524. SimplificationQueue.prototype.addTask = function (task) {
  92525. this._simplificationArray.push(task);
  92526. };
  92527. /**
  92528. * Execute next task
  92529. */
  92530. SimplificationQueue.prototype.executeNext = function () {
  92531. var task = this._simplificationArray.pop();
  92532. if (task) {
  92533. this.running = true;
  92534. this.runSimplification(task);
  92535. }
  92536. else {
  92537. this.running = false;
  92538. }
  92539. };
  92540. /**
  92541. * Execute a simplification task
  92542. * @param task defines the task to run
  92543. */
  92544. SimplificationQueue.prototype.runSimplification = function (task) {
  92545. var _this = this;
  92546. if (task.parallelProcessing) {
  92547. //parallel simplifier
  92548. task.settings.forEach(function (setting) {
  92549. var simplifier = _this.getSimplifier(task);
  92550. simplifier.simplify(setting, function (newMesh) {
  92551. task.mesh.addLODLevel(setting.distance, newMesh);
  92552. newMesh.isVisible = true;
  92553. //check if it is the last
  92554. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  92555. //all done, run the success callback.
  92556. task.successCallback();
  92557. }
  92558. _this.executeNext();
  92559. });
  92560. });
  92561. }
  92562. else {
  92563. //single simplifier.
  92564. var simplifier = this.getSimplifier(task);
  92565. var runDecimation = function (setting, callback) {
  92566. simplifier.simplify(setting, function (newMesh) {
  92567. task.mesh.addLODLevel(setting.distance, newMesh);
  92568. newMesh.isVisible = true;
  92569. //run the next quality level
  92570. callback();
  92571. });
  92572. };
  92573. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  92574. runDecimation(task.settings[loop.index], function () {
  92575. loop.executeNext();
  92576. });
  92577. }, function () {
  92578. //execution ended, run the success callback.
  92579. if (task.successCallback) {
  92580. task.successCallback();
  92581. }
  92582. _this.executeNext();
  92583. });
  92584. }
  92585. };
  92586. SimplificationQueue.prototype.getSimplifier = function (task) {
  92587. switch (task.simplificationType) {
  92588. case SimplificationType.QUADRATIC:
  92589. default:
  92590. return new QuadraticErrorSimplification(task.mesh);
  92591. }
  92592. };
  92593. return SimplificationQueue;
  92594. }());
  92595. /**
  92596. * The implemented types of simplification
  92597. * At the moment only Quadratic Error Decimation is implemented
  92598. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  92599. */
  92600. var SimplificationType;
  92601. (function (SimplificationType) {
  92602. /** Quadratic error decimation */
  92603. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  92604. })(SimplificationType || (SimplificationType = {}));
  92605. var DecimationTriangle = /** @class */ (function () {
  92606. function DecimationTriangle(vertices) {
  92607. this.vertices = vertices;
  92608. this.error = new Array(4);
  92609. this.deleted = false;
  92610. this.isDirty = false;
  92611. this.deletePending = false;
  92612. this.borderFactor = 0;
  92613. }
  92614. return DecimationTriangle;
  92615. }());
  92616. var DecimationVertex = /** @class */ (function () {
  92617. function DecimationVertex(position, id) {
  92618. this.position = position;
  92619. this.id = id;
  92620. this.isBorder = true;
  92621. this.q = new QuadraticMatrix();
  92622. this.triangleCount = 0;
  92623. this.triangleStart = 0;
  92624. this.originalOffsets = [];
  92625. }
  92626. DecimationVertex.prototype.updatePosition = function (newPosition) {
  92627. this.position.copyFrom(newPosition);
  92628. };
  92629. return DecimationVertex;
  92630. }());
  92631. var QuadraticMatrix = /** @class */ (function () {
  92632. function QuadraticMatrix(data) {
  92633. this.data = new Array(10);
  92634. for (var i = 0; i < 10; ++i) {
  92635. if (data && data[i]) {
  92636. this.data[i] = data[i];
  92637. }
  92638. else {
  92639. this.data[i] = 0;
  92640. }
  92641. }
  92642. }
  92643. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  92644. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  92645. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  92646. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  92647. return det;
  92648. };
  92649. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  92650. for (var i = 0; i < 10; ++i) {
  92651. this.data[i] += matrix.data[i];
  92652. }
  92653. };
  92654. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  92655. for (var i = 0; i < 10; ++i) {
  92656. this.data[i] += data[i];
  92657. }
  92658. };
  92659. QuadraticMatrix.prototype.add = function (matrix) {
  92660. var m = new QuadraticMatrix();
  92661. for (var i = 0; i < 10; ++i) {
  92662. m.data[i] = this.data[i] + matrix.data[i];
  92663. }
  92664. return m;
  92665. };
  92666. QuadraticMatrix.FromData = function (a, b, c, d) {
  92667. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  92668. };
  92669. //returning an array to avoid garbage collection
  92670. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  92671. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  92672. };
  92673. return QuadraticMatrix;
  92674. }());
  92675. var Reference = /** @class */ (function () {
  92676. function Reference(vertexId, triangleId) {
  92677. this.vertexId = vertexId;
  92678. this.triangleId = triangleId;
  92679. }
  92680. return Reference;
  92681. }());
  92682. /**
  92683. * An implementation of the Quadratic Error simplification algorithm.
  92684. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  92685. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  92686. * @author RaananW
  92687. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  92688. */
  92689. var QuadraticErrorSimplification = /** @class */ (function () {
  92690. function QuadraticErrorSimplification(_mesh) {
  92691. this._mesh = _mesh;
  92692. this.syncIterations = 5000;
  92693. this.aggressiveness = 7;
  92694. this.decimationIterations = 100;
  92695. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  92696. }
  92697. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  92698. var _this = this;
  92699. this.initDecimatedMesh();
  92700. //iterating through the submeshes array, one after the other.
  92701. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  92702. _this.initWithMesh(loop.index, function () {
  92703. _this.runDecimation(settings, loop.index, function () {
  92704. loop.executeNext();
  92705. });
  92706. }, settings.optimizeMesh);
  92707. }, function () {
  92708. setTimeout(function () {
  92709. successCallback(_this._reconstructedMesh);
  92710. }, 0);
  92711. });
  92712. };
  92713. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  92714. var _this = this;
  92715. var targetCount = ~~(this.triangles.length * settings.quality);
  92716. var deletedTriangles = 0;
  92717. var triangleCount = this.triangles.length;
  92718. var iterationFunction = function (iteration, callback) {
  92719. setTimeout(function () {
  92720. if (iteration % 5 === 0) {
  92721. _this.updateMesh(iteration === 0);
  92722. }
  92723. for (var i = 0; i < _this.triangles.length; ++i) {
  92724. _this.triangles[i].isDirty = false;
  92725. }
  92726. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  92727. var trianglesIterator = function (i) {
  92728. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  92729. var t = _this.triangles[tIdx];
  92730. if (!t) {
  92731. return;
  92732. }
  92733. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  92734. return;
  92735. }
  92736. for (var j = 0; j < 3; ++j) {
  92737. if (t.error[j] < threshold) {
  92738. var deleted0 = [];
  92739. var deleted1 = [];
  92740. var v0 = t.vertices[j];
  92741. var v1 = t.vertices[(j + 1) % 3];
  92742. if (v0.isBorder || v1.isBorder) {
  92743. continue;
  92744. }
  92745. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  92746. // var n = Vector3.Zero();
  92747. // var uv = Vector2.Zero();
  92748. // var color = new Color4(0, 0, 0, 1);
  92749. _this.calculateError(v0, v1, p);
  92750. var delTr = new Array();
  92751. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  92752. continue;
  92753. }
  92754. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  92755. continue;
  92756. }
  92757. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  92758. continue;
  92759. }
  92760. var uniqueArray = new Array();
  92761. delTr.forEach(function (deletedT) {
  92762. if (uniqueArray.indexOf(deletedT) === -1) {
  92763. deletedT.deletePending = true;
  92764. uniqueArray.push(deletedT);
  92765. }
  92766. });
  92767. if (uniqueArray.length % 2 !== 0) {
  92768. continue;
  92769. }
  92770. v0.q = v1.q.add(v0.q);
  92771. v0.updatePosition(p);
  92772. var tStart = _this.references.length;
  92773. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  92774. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  92775. var tCount = _this.references.length - tStart;
  92776. if (tCount <= v0.triangleCount) {
  92777. if (tCount) {
  92778. for (var c = 0; c < tCount; c++) {
  92779. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  92780. }
  92781. }
  92782. }
  92783. else {
  92784. v0.triangleStart = tStart;
  92785. }
  92786. v0.triangleCount = tCount;
  92787. break;
  92788. }
  92789. }
  92790. };
  92791. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  92792. }, 0);
  92793. };
  92794. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  92795. if (triangleCount - deletedTriangles <= targetCount) {
  92796. loop.breakLoop();
  92797. }
  92798. else {
  92799. iterationFunction(loop.index, function () {
  92800. loop.executeNext();
  92801. });
  92802. }
  92803. }, function () {
  92804. setTimeout(function () {
  92805. //reconstruct this part of the mesh
  92806. _this.reconstructMesh(submeshIndex);
  92807. successCallback();
  92808. }, 0);
  92809. });
  92810. };
  92811. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  92812. var _this = this;
  92813. this.vertices = [];
  92814. this.triangles = [];
  92815. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  92816. var indices = this._mesh.getIndices();
  92817. var submesh = this._mesh.subMeshes[submeshIndex];
  92818. var findInVertices = function (positionToSearch) {
  92819. if (optimizeMesh) {
  92820. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  92821. if (_this.vertices[ii].position.equals(positionToSearch)) {
  92822. return _this.vertices[ii];
  92823. }
  92824. }
  92825. }
  92826. return null;
  92827. };
  92828. var vertexReferences = [];
  92829. var vertexInit = function (i) {
  92830. if (!positionData) {
  92831. return;
  92832. }
  92833. var offset = i + submesh.verticesStart;
  92834. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  92835. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  92836. vertex.originalOffsets.push(offset);
  92837. if (vertex.id === _this.vertices.length) {
  92838. _this.vertices.push(vertex);
  92839. }
  92840. vertexReferences.push(vertex.id);
  92841. };
  92842. //var totalVertices = mesh.getTotalVertices();
  92843. var totalVertices = submesh.verticesCount;
  92844. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  92845. var indicesInit = function (i) {
  92846. if (!indices) {
  92847. return;
  92848. }
  92849. var offset = (submesh.indexStart / 3) + i;
  92850. var pos = (offset * 3);
  92851. var i0 = indices[pos + 0];
  92852. var i1 = indices[pos + 1];
  92853. var i2 = indices[pos + 2];
  92854. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  92855. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  92856. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  92857. var triangle = new DecimationTriangle([v0, v1, v2]);
  92858. triangle.originalOffset = pos;
  92859. _this.triangles.push(triangle);
  92860. };
  92861. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  92862. _this.init(callback);
  92863. });
  92864. });
  92865. };
  92866. QuadraticErrorSimplification.prototype.init = function (callback) {
  92867. var _this = this;
  92868. var triangleInit1 = function (i) {
  92869. var t = _this.triangles[i];
  92870. t.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(t.vertices[1].position.subtract(t.vertices[0].position), t.vertices[2].position.subtract(t.vertices[0].position)).normalize();
  92871. for (var j = 0; j < 3; j++) {
  92872. t.vertices[j].q.addArrayInPlace(QuadraticMatrix.DataFromNumbers(t.normal.x, t.normal.y, t.normal.z, -(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(t.normal, t.vertices[0].position))));
  92873. }
  92874. };
  92875. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  92876. var triangleInit2 = function (i) {
  92877. var t = _this.triangles[i];
  92878. for (var j = 0; j < 3; ++j) {
  92879. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  92880. }
  92881. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  92882. };
  92883. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  92884. callback();
  92885. });
  92886. });
  92887. };
  92888. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  92889. var newTriangles = [];
  92890. var i;
  92891. for (i = 0; i < this.vertices.length; ++i) {
  92892. this.vertices[i].triangleCount = 0;
  92893. }
  92894. var t;
  92895. var j;
  92896. for (i = 0; i < this.triangles.length; ++i) {
  92897. if (!this.triangles[i].deleted) {
  92898. t = this.triangles[i];
  92899. for (j = 0; j < 3; ++j) {
  92900. t.vertices[j].triangleCount = 1;
  92901. }
  92902. newTriangles.push(t);
  92903. }
  92904. }
  92905. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  92906. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  92907. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  92908. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  92909. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  92910. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  92911. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  92912. var vertexCount = 0;
  92913. for (i = 0; i < this.vertices.length; ++i) {
  92914. var vertex = this.vertices[i];
  92915. vertex.id = vertexCount;
  92916. if (vertex.triangleCount) {
  92917. vertex.originalOffsets.forEach(function (originalOffset) {
  92918. if (!normalData) {
  92919. return;
  92920. }
  92921. newPositionData.push(vertex.position.x);
  92922. newPositionData.push(vertex.position.y);
  92923. newPositionData.push(vertex.position.z);
  92924. newNormalData.push(normalData[originalOffset * 3]);
  92925. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  92926. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  92927. if (uvs && uvs.length) {
  92928. newUVsData.push(uvs[(originalOffset * 2)]);
  92929. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  92930. }
  92931. if (colorsData && colorsData.length) {
  92932. newColorsData.push(colorsData[(originalOffset * 4)]);
  92933. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  92934. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  92935. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  92936. }
  92937. ++vertexCount;
  92938. });
  92939. }
  92940. }
  92941. var startingIndex = this._reconstructedMesh.getTotalIndices();
  92942. var startingVertex = this._reconstructedMesh.getTotalVertices();
  92943. var submeshesArray = this._reconstructedMesh.subMeshes;
  92944. this._reconstructedMesh.subMeshes = [];
  92945. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  92946. var originalIndices = this._mesh.getIndices();
  92947. for (i = 0; i < newTriangles.length; ++i) {
  92948. t = newTriangles[i]; //now get the new referencing point for each vertex
  92949. [0, 1, 2].forEach(function (idx) {
  92950. var id = originalIndices[t.originalOffset + idx];
  92951. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  92952. if (offset < 0) {
  92953. offset = 0;
  92954. }
  92955. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  92956. });
  92957. }
  92958. //overwriting the old vertex buffers and indices.
  92959. this._reconstructedMesh.setIndices(newIndicesArray);
  92960. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  92961. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  92962. if (newUVsData.length > 0) {
  92963. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  92964. }
  92965. if (newColorsData.length > 0) {
  92966. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  92967. }
  92968. //create submesh
  92969. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  92970. if (submeshIndex > 0) {
  92971. this._reconstructedMesh.subMeshes = [];
  92972. submeshesArray.forEach(function (submesh) {
  92973. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  92974. });
  92975. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  92976. }
  92977. };
  92978. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  92979. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  92980. this._reconstructedMesh.material = this._mesh.material;
  92981. this._reconstructedMesh.parent = this._mesh.parent;
  92982. this._reconstructedMesh.isVisible = false;
  92983. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  92984. };
  92985. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  92986. for (var i = 0; i < vertex1.triangleCount; ++i) {
  92987. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  92988. if (t.deleted) {
  92989. continue;
  92990. }
  92991. var s = this.references[vertex1.triangleStart + i].vertexId;
  92992. var v1 = t.vertices[(s + 1) % 3];
  92993. var v2 = t.vertices[(s + 2) % 3];
  92994. if ((v1 === vertex2 || v2 === vertex2)) {
  92995. deletedArray[i] = true;
  92996. delTr.push(t);
  92997. continue;
  92998. }
  92999. var d1 = v1.position.subtract(point);
  93000. d1 = d1.normalize();
  93001. var d2 = v2.position.subtract(point);
  93002. d2 = d2.normalize();
  93003. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  93004. return true;
  93005. }
  93006. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  93007. deletedArray[i] = false;
  93008. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  93009. return true;
  93010. }
  93011. }
  93012. return false;
  93013. };
  93014. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  93015. var newDeleted = deletedTriangles;
  93016. for (var i = 0; i < vertex.triangleCount; ++i) {
  93017. var ref = this.references[vertex.triangleStart + i];
  93018. var t = this.triangles[ref.triangleId];
  93019. if (t.deleted) {
  93020. continue;
  93021. }
  93022. if (deletedArray[i] && t.deletePending) {
  93023. t.deleted = true;
  93024. newDeleted++;
  93025. continue;
  93026. }
  93027. t.vertices[ref.vertexId] = origVertex;
  93028. t.isDirty = true;
  93029. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  93030. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  93031. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  93032. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  93033. this.references.push(ref);
  93034. }
  93035. return newDeleted;
  93036. };
  93037. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  93038. for (var i = 0; i < this.vertices.length; ++i) {
  93039. var vCount = [];
  93040. var vId = [];
  93041. var v = this.vertices[i];
  93042. var j;
  93043. for (j = 0; j < v.triangleCount; ++j) {
  93044. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  93045. for (var ii = 0; ii < 3; ii++) {
  93046. var ofs = 0;
  93047. var vv = triangle.vertices[ii];
  93048. while (ofs < vCount.length) {
  93049. if (vId[ofs] === vv.id) {
  93050. break;
  93051. }
  93052. ++ofs;
  93053. }
  93054. if (ofs === vCount.length) {
  93055. vCount.push(1);
  93056. vId.push(vv.id);
  93057. }
  93058. else {
  93059. vCount[ofs]++;
  93060. }
  93061. }
  93062. }
  93063. for (j = 0; j < vCount.length; ++j) {
  93064. if (vCount[j] === 1) {
  93065. this.vertices[vId[j]].isBorder = true;
  93066. }
  93067. else {
  93068. this.vertices[vId[j]].isBorder = false;
  93069. }
  93070. }
  93071. }
  93072. };
  93073. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  93074. if (identifyBorders === void 0) { identifyBorders = false; }
  93075. var i;
  93076. if (!identifyBorders) {
  93077. var newTrianglesVector = [];
  93078. for (i = 0; i < this.triangles.length; ++i) {
  93079. if (!this.triangles[i].deleted) {
  93080. newTrianglesVector.push(this.triangles[i]);
  93081. }
  93082. }
  93083. this.triangles = newTrianglesVector;
  93084. }
  93085. for (i = 0; i < this.vertices.length; ++i) {
  93086. this.vertices[i].triangleCount = 0;
  93087. this.vertices[i].triangleStart = 0;
  93088. }
  93089. var t;
  93090. var j;
  93091. var v;
  93092. for (i = 0; i < this.triangles.length; ++i) {
  93093. t = this.triangles[i];
  93094. for (j = 0; j < 3; ++j) {
  93095. v = t.vertices[j];
  93096. v.triangleCount++;
  93097. }
  93098. }
  93099. var tStart = 0;
  93100. for (i = 0; i < this.vertices.length; ++i) {
  93101. this.vertices[i].triangleStart = tStart;
  93102. tStart += this.vertices[i].triangleCount;
  93103. this.vertices[i].triangleCount = 0;
  93104. }
  93105. var newReferences = new Array(this.triangles.length * 3);
  93106. for (i = 0; i < this.triangles.length; ++i) {
  93107. t = this.triangles[i];
  93108. for (j = 0; j < 3; ++j) {
  93109. v = t.vertices[j];
  93110. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  93111. v.triangleCount++;
  93112. }
  93113. }
  93114. this.references = newReferences;
  93115. if (identifyBorders) {
  93116. this.identifyBorder();
  93117. }
  93118. };
  93119. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  93120. var x = point.x;
  93121. var y = point.y;
  93122. var z = point.z;
  93123. return q.data[0] * x * x + 2 * q.data[1] * x * y + 2 * q.data[2] * x * z + 2 * q.data[3] * x + q.data[4] * y * y
  93124. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  93125. };
  93126. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  93127. var q = vertex1.q.add(vertex2.q);
  93128. var border = vertex1.isBorder && vertex2.isBorder;
  93129. var error = 0;
  93130. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  93131. if (qDet !== 0 && !border) {
  93132. if (!pointResult) {
  93133. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  93134. }
  93135. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  93136. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  93137. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  93138. error = this.vertexError(q, pointResult);
  93139. }
  93140. else {
  93141. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  93142. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  93143. var error1 = this.vertexError(q, vertex1.position);
  93144. var error2 = this.vertexError(q, vertex2.position);
  93145. var error3 = this.vertexError(q, p3);
  93146. error = Math.min(error1, error2, error3);
  93147. if (error === error1) {
  93148. if (pointResult) {
  93149. pointResult.copyFrom(vertex1.position);
  93150. }
  93151. }
  93152. else if (error === error2) {
  93153. if (pointResult) {
  93154. pointResult.copyFrom(vertex2.position);
  93155. }
  93156. }
  93157. else {
  93158. if (pointResult) {
  93159. pointResult.copyFrom(p3);
  93160. }
  93161. }
  93162. }
  93163. return error;
  93164. };
  93165. return QuadraticErrorSimplification;
  93166. }());
  93167. /***/ }),
  93168. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  93169. /*!****************************************************!*\
  93170. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  93171. \****************************************************/
  93172. /*! exports provided: SimplicationQueueSceneComponent */
  93173. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93174. "use strict";
  93175. __webpack_require__.r(__webpack_exports__);
  93176. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  93177. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  93178. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  93179. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  93180. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  93181. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  93182. get: function () {
  93183. if (!this._simplificationQueue) {
  93184. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  93185. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  93186. if (!component) {
  93187. component = new SimplicationQueueSceneComponent(this);
  93188. this._addComponent(component);
  93189. }
  93190. }
  93191. return this._simplificationQueue;
  93192. },
  93193. set: function (value) {
  93194. this._simplificationQueue = value;
  93195. },
  93196. enumerable: true,
  93197. configurable: true
  93198. });
  93199. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  93200. if (parallelProcessing === void 0) { parallelProcessing = true; }
  93201. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  93202. this.getScene().simplificationQueue.addTask({
  93203. settings: settings,
  93204. parallelProcessing: parallelProcessing,
  93205. mesh: this,
  93206. simplificationType: simplificationType,
  93207. successCallback: successCallback
  93208. });
  93209. return this;
  93210. };
  93211. /**
  93212. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  93213. * created in a scene
  93214. */
  93215. var SimplicationQueueSceneComponent = /** @class */ (function () {
  93216. /**
  93217. * Creates a new instance of the component for the given scene
  93218. * @param scene Defines the scene to register the component in
  93219. */
  93220. function SimplicationQueueSceneComponent(scene) {
  93221. /**
  93222. * The component name helpfull to identify the component in the list of scene components.
  93223. */
  93224. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  93225. this.scene = scene;
  93226. }
  93227. /**
  93228. * Registers the component in a given scene
  93229. */
  93230. SimplicationQueueSceneComponent.prototype.register = function () {
  93231. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  93232. };
  93233. /**
  93234. * Rebuilds the elements related to this component in case of
  93235. * context lost for instance.
  93236. */
  93237. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  93238. // Nothing to do for this component
  93239. };
  93240. /**
  93241. * Disposes the component and the associated ressources
  93242. */
  93243. SimplicationQueueSceneComponent.prototype.dispose = function () {
  93244. // Nothing to do for this component
  93245. };
  93246. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  93247. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  93248. this.scene._simplificationQueue.executeNext();
  93249. }
  93250. };
  93251. return SimplicationQueueSceneComponent;
  93252. }());
  93253. /***/ }),
  93254. /***/ "./Meshes/polygonMesh.ts":
  93255. /*!*******************************!*\
  93256. !*** ./Meshes/polygonMesh.ts ***!
  93257. \*******************************/
  93258. /*! exports provided: Polygon, PolygonMeshBuilder */
  93259. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93260. "use strict";
  93261. __webpack_require__.r(__webpack_exports__);
  93262. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  93263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  93264. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  93265. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93266. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93267. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  93268. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  93269. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  93270. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  93271. /**
  93272. * Vector2 wth index property
  93273. */
  93274. var IndexedVector2 = /** @class */ (function (_super) {
  93275. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  93276. function IndexedVector2(original,
  93277. /** Index of the vector2 */
  93278. index) {
  93279. var _this = _super.call(this, original.x, original.y) || this;
  93280. _this.index = index;
  93281. return _this;
  93282. }
  93283. return IndexedVector2;
  93284. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  93285. /**
  93286. * Defines points to create a polygon
  93287. */
  93288. var PolygonPoints = /** @class */ (function () {
  93289. function PolygonPoints() {
  93290. this.elements = new Array();
  93291. }
  93292. PolygonPoints.prototype.add = function (originalPoints) {
  93293. var _this = this;
  93294. var result = new Array();
  93295. originalPoints.forEach(function (point) {
  93296. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  93297. var newPoint = new IndexedVector2(point, _this.elements.length);
  93298. result.push(newPoint);
  93299. _this.elements.push(newPoint);
  93300. }
  93301. });
  93302. return result;
  93303. };
  93304. PolygonPoints.prototype.computeBounds = function () {
  93305. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  93306. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  93307. this.elements.forEach(function (point) {
  93308. // x
  93309. if (point.x < lmin.x) {
  93310. lmin.x = point.x;
  93311. }
  93312. else if (point.x > lmax.x) {
  93313. lmax.x = point.x;
  93314. }
  93315. // y
  93316. if (point.y < lmin.y) {
  93317. lmin.y = point.y;
  93318. }
  93319. else if (point.y > lmax.y) {
  93320. lmax.y = point.y;
  93321. }
  93322. });
  93323. return {
  93324. min: lmin,
  93325. max: lmax,
  93326. width: lmax.x - lmin.x,
  93327. height: lmax.y - lmin.y
  93328. };
  93329. };
  93330. return PolygonPoints;
  93331. }());
  93332. /**
  93333. * Polygon
  93334. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  93335. */
  93336. var Polygon = /** @class */ (function () {
  93337. function Polygon() {
  93338. }
  93339. /**
  93340. * Creates a rectangle
  93341. * @param xmin bottom X coord
  93342. * @param ymin bottom Y coord
  93343. * @param xmax top X coord
  93344. * @param ymax top Y coord
  93345. * @returns points that make the resulting rectation
  93346. */
  93347. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  93348. return [
  93349. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  93350. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  93351. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  93352. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  93353. ];
  93354. };
  93355. /**
  93356. * Creates a circle
  93357. * @param radius radius of circle
  93358. * @param cx scale in x
  93359. * @param cy scale in y
  93360. * @param numberOfSides number of sides that make up the circle
  93361. * @returns points that make the resulting circle
  93362. */
  93363. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  93364. if (cx === void 0) { cx = 0; }
  93365. if (cy === void 0) { cy = 0; }
  93366. if (numberOfSides === void 0) { numberOfSides = 32; }
  93367. var result = new Array();
  93368. var angle = 0;
  93369. var increment = (Math.PI * 2) / numberOfSides;
  93370. for (var i = 0; i < numberOfSides; i++) {
  93371. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  93372. angle -= increment;
  93373. }
  93374. return result;
  93375. };
  93376. /**
  93377. * Creates a polygon from input string
  93378. * @param input Input polygon data
  93379. * @returns the parsed points
  93380. */
  93381. Polygon.Parse = function (input) {
  93382. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  93383. var i, result = [];
  93384. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  93385. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  93386. }
  93387. return result;
  93388. };
  93389. /**
  93390. * Starts building a polygon from x and y coordinates
  93391. * @param x x coordinate
  93392. * @param y y coordinate
  93393. * @returns the started path2
  93394. */
  93395. Polygon.StartingAt = function (x, y) {
  93396. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  93397. };
  93398. return Polygon;
  93399. }());
  93400. /**
  93401. * Builds a polygon
  93402. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  93403. */
  93404. var PolygonMeshBuilder = /** @class */ (function () {
  93405. /**
  93406. * Creates a PolygonMeshBuilder
  93407. * @param name name of the builder
  93408. * @param contours Path of the polygon
  93409. * @param scene scene to add to when creating the mesh
  93410. * @param earcutInjection can be used to inject your own earcut reference
  93411. */
  93412. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  93413. if (earcutInjection === void 0) { earcutInjection = earcut; }
  93414. this._points = new PolygonPoints();
  93415. this._outlinepoints = new PolygonPoints();
  93416. this._holes = new Array();
  93417. this._epoints = new Array();
  93418. this._eholes = new Array();
  93419. this.bjsEarcut = earcutInjection;
  93420. this._name = name;
  93421. this._scene = scene || _Engines_engine__WEBPACK_IMPORTED_MODULE_6__["Engine"].LastCreatedScene;
  93422. var points;
  93423. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  93424. points = contours.getPoints();
  93425. }
  93426. else {
  93427. points = contours;
  93428. }
  93429. this._addToepoint(points);
  93430. this._points.add(points);
  93431. this._outlinepoints.add(points);
  93432. if (typeof this.bjsEarcut === 'undefined') {
  93433. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  93434. }
  93435. }
  93436. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  93437. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  93438. var p = points_1[_i];
  93439. this._epoints.push(p.x, p.y);
  93440. }
  93441. };
  93442. /**
  93443. * Adds a whole within the polygon
  93444. * @param hole Array of points defining the hole
  93445. * @returns this
  93446. */
  93447. PolygonMeshBuilder.prototype.addHole = function (hole) {
  93448. this._points.add(hole);
  93449. var holepoints = new PolygonPoints();
  93450. holepoints.add(hole);
  93451. this._holes.push(holepoints);
  93452. this._eholes.push(this._epoints.length / 2);
  93453. this._addToepoint(hole);
  93454. return this;
  93455. };
  93456. /**
  93457. * Creates the polygon
  93458. * @param updatable If the mesh should be updatable
  93459. * @param depth The depth of the mesh created
  93460. * @returns the created mesh
  93461. */
  93462. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  93463. if (updatable === void 0) { updatable = false; }
  93464. if (depth === void 0) { depth = 0; }
  93465. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  93466. var vertexData = this.buildVertexData(depth);
  93467. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, vertexData.positions, updatable);
  93468. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, vertexData.normals, updatable);
  93469. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, vertexData.uvs, updatable);
  93470. result.setIndices(vertexData.indices);
  93471. return result;
  93472. };
  93473. /**
  93474. * Creates the polygon
  93475. * @param depth The depth of the mesh created
  93476. * @returns the created VertexData
  93477. */
  93478. PolygonMeshBuilder.prototype.buildVertexData = function (depth) {
  93479. var _this = this;
  93480. if (depth === void 0) { depth = 0; }
  93481. var result = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  93482. var normals = new Array();
  93483. var positions = new Array();
  93484. var uvs = new Array();
  93485. var bounds = this._points.computeBounds();
  93486. this._points.elements.forEach(function (p) {
  93487. normals.push(0, 1.0, 0);
  93488. positions.push(p.x, 0, p.y);
  93489. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  93490. });
  93491. var indices = new Array();
  93492. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  93493. for (var i = 0; i < res.length; i++) {
  93494. indices.push(res[i]);
  93495. }
  93496. if (depth > 0) {
  93497. var positionscount = (positions.length / 3); //get the current pointcount
  93498. this._points.elements.forEach(function (p) {
  93499. normals.push(0, -1.0, 0);
  93500. positions.push(p.x, -depth, p.y);
  93501. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  93502. });
  93503. var totalCount = indices.length;
  93504. for (var i = 0; i < totalCount; i += 3) {
  93505. var i0 = indices[i + 0];
  93506. var i1 = indices[i + 1];
  93507. var i2 = indices[i + 2];
  93508. indices.push(i2 + positionscount);
  93509. indices.push(i1 + positionscount);
  93510. indices.push(i0 + positionscount);
  93511. }
  93512. //Add the sides
  93513. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  93514. this._holes.forEach(function (hole) {
  93515. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  93516. });
  93517. }
  93518. result.indices = indices;
  93519. result.positions = positions;
  93520. result.normals = normals;
  93521. result.uvs = uvs;
  93522. return result;
  93523. };
  93524. /**
  93525. * Adds a side to the polygon
  93526. * @param positions points that make the polygon
  93527. * @param normals normals of the polygon
  93528. * @param uvs uvs of the polygon
  93529. * @param indices indices of the polygon
  93530. * @param bounds bounds of the polygon
  93531. * @param points points of the polygon
  93532. * @param depth depth of the polygon
  93533. * @param flip flip of the polygon
  93534. */
  93535. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  93536. var StartIndex = positions.length / 3;
  93537. var ulength = 0;
  93538. for (var i = 0; i < points.elements.length; i++) {
  93539. var p = points.elements[i];
  93540. var p1;
  93541. if ((i + 1) > points.elements.length - 1) {
  93542. p1 = points.elements[0];
  93543. }
  93544. else {
  93545. p1 = points.elements[i + 1];
  93546. }
  93547. positions.push(p.x, 0, p.y);
  93548. positions.push(p.x, -depth, p.y);
  93549. positions.push(p1.x, 0, p1.y);
  93550. positions.push(p1.x, -depth, p1.y);
  93551. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  93552. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  93553. var v3 = v2.subtract(v1);
  93554. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  93555. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  93556. vn = vn.normalize();
  93557. uvs.push(ulength / bounds.width, 0);
  93558. uvs.push(ulength / bounds.width, 1);
  93559. ulength += v3.length();
  93560. uvs.push((ulength / bounds.width), 0);
  93561. uvs.push((ulength / bounds.width), 1);
  93562. if (!flip) {
  93563. normals.push(-vn.x, -vn.y, -vn.z);
  93564. normals.push(-vn.x, -vn.y, -vn.z);
  93565. normals.push(-vn.x, -vn.y, -vn.z);
  93566. normals.push(-vn.x, -vn.y, -vn.z);
  93567. indices.push(StartIndex);
  93568. indices.push(StartIndex + 1);
  93569. indices.push(StartIndex + 2);
  93570. indices.push(StartIndex + 1);
  93571. indices.push(StartIndex + 3);
  93572. indices.push(StartIndex + 2);
  93573. }
  93574. else {
  93575. normals.push(vn.x, vn.y, vn.z);
  93576. normals.push(vn.x, vn.y, vn.z);
  93577. normals.push(vn.x, vn.y, vn.z);
  93578. normals.push(vn.x, vn.y, vn.z);
  93579. indices.push(StartIndex);
  93580. indices.push(StartIndex + 2);
  93581. indices.push(StartIndex + 1);
  93582. indices.push(StartIndex + 1);
  93583. indices.push(StartIndex + 2);
  93584. indices.push(StartIndex + 3);
  93585. }
  93586. StartIndex += 4;
  93587. }
  93588. };
  93589. return PolygonMeshBuilder;
  93590. }());
  93591. /***/ }),
  93592. /***/ "./Meshes/subMesh.ts":
  93593. /*!***************************!*\
  93594. !*** ./Meshes/subMesh.ts ***!
  93595. \***************************/
  93596. /*! exports provided: BaseSubMesh, SubMesh */
  93597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93598. "use strict";
  93599. __webpack_require__.r(__webpack_exports__);
  93600. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  93601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  93602. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  93603. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  93604. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  93605. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  93606. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  93607. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  93608. /**
  93609. * Base class for submeshes
  93610. */
  93611. var BaseSubMesh = /** @class */ (function () {
  93612. function BaseSubMesh() {
  93613. }
  93614. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  93615. /**
  93616. * Gets associated effect
  93617. */
  93618. get: function () {
  93619. return this._materialEffect;
  93620. },
  93621. enumerable: true,
  93622. configurable: true
  93623. });
  93624. /**
  93625. * Sets associated effect (effect used to render this submesh)
  93626. * @param effect defines the effect to associate with
  93627. * @param defines defines the set of defines used to compile this effect
  93628. */
  93629. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  93630. if (defines === void 0) { defines = null; }
  93631. if (this._materialEffect === effect) {
  93632. if (!effect) {
  93633. this._materialDefines = null;
  93634. }
  93635. return;
  93636. }
  93637. this._materialDefines = defines;
  93638. this._materialEffect = effect;
  93639. };
  93640. return BaseSubMesh;
  93641. }());
  93642. /**
  93643. * Defines a subdivision inside a mesh
  93644. */
  93645. var SubMesh = /** @class */ (function (_super) {
  93646. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  93647. /**
  93648. * Creates a new submesh
  93649. * @param materialIndex defines the material index to use
  93650. * @param verticesStart defines vertex index start
  93651. * @param verticesCount defines vertices count
  93652. * @param indexStart defines index start
  93653. * @param indexCount defines indices count
  93654. * @param mesh defines the parent mesh
  93655. * @param renderingMesh defines an optional rendering mesh
  93656. * @param createBoundingBox defines if bounding box should be created for this submesh
  93657. */
  93658. function SubMesh(
  93659. /** the material index to use */
  93660. materialIndex,
  93661. /** vertex index start */
  93662. verticesStart,
  93663. /** vertices count */
  93664. verticesCount,
  93665. /** index start */
  93666. indexStart,
  93667. /** indices count */
  93668. indexCount, mesh, renderingMesh, createBoundingBox) {
  93669. if (createBoundingBox === void 0) { createBoundingBox = true; }
  93670. var _this = _super.call(this) || this;
  93671. _this.materialIndex = materialIndex;
  93672. _this.verticesStart = verticesStart;
  93673. _this.verticesCount = verticesCount;
  93674. _this.indexStart = indexStart;
  93675. _this.indexCount = indexCount;
  93676. /** @hidden */
  93677. _this._renderId = 0;
  93678. _this._mesh = mesh;
  93679. _this._renderingMesh = renderingMesh || mesh;
  93680. mesh.subMeshes.push(_this);
  93681. _this._trianglePlanes = [];
  93682. _this._id = mesh.subMeshes.length - 1;
  93683. if (createBoundingBox) {
  93684. _this.refreshBoundingInfo();
  93685. mesh.computeWorldMatrix(true);
  93686. }
  93687. return _this;
  93688. }
  93689. /**
  93690. * Add a new submesh to a mesh
  93691. * @param materialIndex defines the material index to use
  93692. * @param verticesStart defines vertex index start
  93693. * @param verticesCount defines vertices count
  93694. * @param indexStart defines index start
  93695. * @param indexCount defines indices count
  93696. * @param mesh defines the parent mesh
  93697. * @param renderingMesh defines an optional rendering mesh
  93698. * @param createBoundingBox defines if bounding box should be created for this submesh
  93699. * @returns the new submesh
  93700. */
  93701. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  93702. if (createBoundingBox === void 0) { createBoundingBox = true; }
  93703. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  93704. };
  93705. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  93706. /**
  93707. * Returns true if this submesh covers the entire parent mesh
  93708. * @ignorenaming
  93709. */
  93710. get: function () {
  93711. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  93712. },
  93713. enumerable: true,
  93714. configurable: true
  93715. });
  93716. /**
  93717. * Returns the submesh BoudingInfo object
  93718. * @returns current bounding info (or mesh's one if the submesh is global)
  93719. */
  93720. SubMesh.prototype.getBoundingInfo = function () {
  93721. if (this.IsGlobal) {
  93722. return this._mesh.getBoundingInfo();
  93723. }
  93724. return this._boundingInfo;
  93725. };
  93726. /**
  93727. * Sets the submesh BoundingInfo
  93728. * @param boundingInfo defines the new bounding info to use
  93729. * @returns the SubMesh
  93730. */
  93731. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  93732. this._boundingInfo = boundingInfo;
  93733. return this;
  93734. };
  93735. /**
  93736. * Returns the mesh of the current submesh
  93737. * @return the parent mesh
  93738. */
  93739. SubMesh.prototype.getMesh = function () {
  93740. return this._mesh;
  93741. };
  93742. /**
  93743. * Returns the rendering mesh of the submesh
  93744. * @returns the rendering mesh (could be different from parent mesh)
  93745. */
  93746. SubMesh.prototype.getRenderingMesh = function () {
  93747. return this._renderingMesh;
  93748. };
  93749. /**
  93750. * Returns the submesh material
  93751. * @returns null or the current material
  93752. */
  93753. SubMesh.prototype.getMaterial = function () {
  93754. var rootMaterial = this._renderingMesh.material;
  93755. if (rootMaterial === null || rootMaterial === undefined) {
  93756. return this._mesh.getScene().defaultMaterial;
  93757. }
  93758. else if (rootMaterial.getSubMaterial) {
  93759. var multiMaterial = rootMaterial;
  93760. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  93761. if (this._currentMaterial !== effectiveMaterial) {
  93762. this._currentMaterial = effectiveMaterial;
  93763. this._materialDefines = null;
  93764. }
  93765. return effectiveMaterial;
  93766. }
  93767. return rootMaterial;
  93768. };
  93769. // Methods
  93770. /**
  93771. * Sets a new updated BoundingInfo object to the submesh
  93772. * @returns the SubMesh
  93773. */
  93774. SubMesh.prototype.refreshBoundingInfo = function () {
  93775. this._lastColliderWorldVertices = null;
  93776. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  93777. return this;
  93778. }
  93779. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  93780. if (!data) {
  93781. this._boundingInfo = this._mesh.getBoundingInfo();
  93782. return this;
  93783. }
  93784. var indices = this._renderingMesh.getIndices();
  93785. var extend;
  93786. //is this the only submesh?
  93787. if (this.indexStart === 0 && this.indexCount === indices.length) {
  93788. var boundingInfo = this._renderingMesh.getBoundingInfo();
  93789. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  93790. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  93791. }
  93792. else {
  93793. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  93794. }
  93795. if (this._boundingInfo) {
  93796. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  93797. }
  93798. else {
  93799. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  93800. }
  93801. return this;
  93802. };
  93803. /** @hidden */
  93804. SubMesh.prototype._checkCollision = function (collider) {
  93805. var boundingInfo = this.getBoundingInfo();
  93806. return boundingInfo._checkCollision(collider);
  93807. };
  93808. /**
  93809. * Updates the submesh BoundingInfo
  93810. * @param world defines the world matrix to use to update the bounding info
  93811. * @returns the submesh
  93812. */
  93813. SubMesh.prototype.updateBoundingInfo = function (world) {
  93814. var boundingInfo = this.getBoundingInfo();
  93815. if (!boundingInfo) {
  93816. this.refreshBoundingInfo();
  93817. boundingInfo = this.getBoundingInfo();
  93818. }
  93819. boundingInfo.update(world);
  93820. return this;
  93821. };
  93822. /**
  93823. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  93824. * @param frustumPlanes defines the frustum planes
  93825. * @returns true if the submesh is intersecting with the frustum
  93826. */
  93827. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  93828. var boundingInfo = this.getBoundingInfo();
  93829. if (!boundingInfo) {
  93830. return false;
  93831. }
  93832. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  93833. };
  93834. /**
  93835. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  93836. * @param frustumPlanes defines the frustum planes
  93837. * @returns true if the submesh is inside the frustum
  93838. */
  93839. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  93840. var boundingInfo = this.getBoundingInfo();
  93841. if (!boundingInfo) {
  93842. return false;
  93843. }
  93844. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  93845. };
  93846. /**
  93847. * Renders the submesh
  93848. * @param enableAlphaMode defines if alpha needs to be used
  93849. * @returns the submesh
  93850. */
  93851. SubMesh.prototype.render = function (enableAlphaMode) {
  93852. this._renderingMesh.render(this, enableAlphaMode);
  93853. return this;
  93854. };
  93855. /**
  93856. * @hidden
  93857. */
  93858. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  93859. if (!this._linesIndexBuffer) {
  93860. var linesIndices = [];
  93861. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  93862. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  93863. }
  93864. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  93865. this._linesIndexCount = linesIndices.length;
  93866. }
  93867. return this._linesIndexBuffer;
  93868. };
  93869. /**
  93870. * Checks if the submesh intersects with a ray
  93871. * @param ray defines the ray to test
  93872. * @returns true is the passed ray intersects the submesh bounding box
  93873. */
  93874. SubMesh.prototype.canIntersects = function (ray) {
  93875. var boundingInfo = this.getBoundingInfo();
  93876. if (!boundingInfo) {
  93877. return false;
  93878. }
  93879. return ray.intersectsBox(boundingInfo.boundingBox);
  93880. };
  93881. /**
  93882. * Intersects current submesh with a ray
  93883. * @param ray defines the ray to test
  93884. * @param positions defines mesh's positions array
  93885. * @param indices defines mesh's indices array
  93886. * @param fastCheck defines if only bounding info should be used
  93887. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93888. * @returns intersection info or null if no intersection
  93889. */
  93890. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck, trianglePredicate) {
  93891. var material = this.getMaterial();
  93892. if (!material) {
  93893. return null;
  93894. }
  93895. switch (material.fillMode) {
  93896. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  93897. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  93898. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  93899. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  93900. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  93901. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  93902. return null;
  93903. }
  93904. // LineMesh first as it's also a Mesh...
  93905. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  93906. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  93907. }
  93908. return this._intersectTriangles(ray, positions, indices, fastCheck, trianglePredicate);
  93909. };
  93910. /** @hidden */
  93911. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  93912. var intersectInfo = null;
  93913. // Line test
  93914. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  93915. var p0 = positions[indices[index]];
  93916. var p1 = positions[indices[index + 1]];
  93917. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  93918. if (length < 0) {
  93919. continue;
  93920. }
  93921. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  93922. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  93923. intersectInfo.faceId = index / 2;
  93924. if (fastCheck) {
  93925. break;
  93926. }
  93927. }
  93928. }
  93929. return intersectInfo;
  93930. };
  93931. /** @hidden */
  93932. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck, trianglePredicate) {
  93933. var intersectInfo = null;
  93934. // Triangles test
  93935. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  93936. var p0 = positions[indices[index]];
  93937. var p1 = positions[indices[index + 1]];
  93938. var p2 = positions[indices[index + 2]];
  93939. if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {
  93940. continue;
  93941. }
  93942. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  93943. if (currentIntersectInfo) {
  93944. if (currentIntersectInfo.distance < 0) {
  93945. continue;
  93946. }
  93947. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  93948. intersectInfo = currentIntersectInfo;
  93949. intersectInfo.faceId = index / 3;
  93950. if (fastCheck) {
  93951. break;
  93952. }
  93953. }
  93954. }
  93955. }
  93956. return intersectInfo;
  93957. };
  93958. /** @hidden */
  93959. SubMesh.prototype._rebuild = function () {
  93960. if (this._linesIndexBuffer) {
  93961. this._linesIndexBuffer = null;
  93962. }
  93963. };
  93964. // Clone
  93965. /**
  93966. * Creates a new submesh from the passed mesh
  93967. * @param newMesh defines the new hosting mesh
  93968. * @param newRenderingMesh defines an optional rendering mesh
  93969. * @returns the new submesh
  93970. */
  93971. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  93972. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  93973. if (!this.IsGlobal) {
  93974. var boundingInfo = this.getBoundingInfo();
  93975. if (!boundingInfo) {
  93976. return result;
  93977. }
  93978. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  93979. }
  93980. return result;
  93981. };
  93982. // Dispose
  93983. /**
  93984. * Release associated resources
  93985. */
  93986. SubMesh.prototype.dispose = function () {
  93987. if (this._linesIndexBuffer) {
  93988. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  93989. this._linesIndexBuffer = null;
  93990. }
  93991. // Remove from mesh
  93992. var index = this._mesh.subMeshes.indexOf(this);
  93993. this._mesh.subMeshes.splice(index, 1);
  93994. };
  93995. /**
  93996. * Gets the class name
  93997. * @returns the string "SubMesh".
  93998. */
  93999. SubMesh.prototype.getClassName = function () {
  94000. return "SubMesh";
  94001. };
  94002. // Statics
  94003. /**
  94004. * Creates a new submesh from indices data
  94005. * @param materialIndex the index of the main mesh material
  94006. * @param startIndex the index where to start the copy in the mesh indices array
  94007. * @param indexCount the number of indices to copy then from the startIndex
  94008. * @param mesh the main mesh to create the submesh from
  94009. * @param renderingMesh the optional rendering mesh
  94010. * @returns a new submesh
  94011. */
  94012. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  94013. var minVertexIndex = Number.MAX_VALUE;
  94014. var maxVertexIndex = -Number.MAX_VALUE;
  94015. var whatWillRender = (renderingMesh || mesh);
  94016. var indices = whatWillRender.getIndices();
  94017. for (var index = startIndex; index < startIndex + indexCount; index++) {
  94018. var vertexIndex = indices[index];
  94019. if (vertexIndex < minVertexIndex) {
  94020. minVertexIndex = vertexIndex;
  94021. }
  94022. if (vertexIndex > maxVertexIndex) {
  94023. maxVertexIndex = vertexIndex;
  94024. }
  94025. }
  94026. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  94027. };
  94028. return SubMesh;
  94029. }(BaseSubMesh));
  94030. /***/ }),
  94031. /***/ "./Meshes/trailMesh.ts":
  94032. /*!*****************************!*\
  94033. !*** ./Meshes/trailMesh.ts ***!
  94034. \*****************************/
  94035. /*! exports provided: TrailMesh */
  94036. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94037. "use strict";
  94038. __webpack_require__.r(__webpack_exports__);
  94039. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return TrailMesh; });
  94040. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  94041. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  94042. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  94043. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  94044. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  94045. /**
  94046. * Class used to create a trail following a mesh
  94047. */
  94048. var TrailMesh = /** @class */ (function (_super) {
  94049. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TrailMesh, _super);
  94050. /**
  94051. * @constructor
  94052. * @param name The value used by scene.getMeshByName() to do a lookup.
  94053. * @param generator The mesh to generate a trail.
  94054. * @param scene The scene to add this mesh to.
  94055. * @param diameter Diameter of trailing mesh. Default is 1.
  94056. * @param length Length of trailing mesh. Default is 60.
  94057. * @param autoStart Automatically start trailing mesh. Default true.
  94058. */
  94059. function TrailMesh(name, generator, scene, diameter, length, autoStart) {
  94060. if (diameter === void 0) { diameter = 1; }
  94061. if (length === void 0) { length = 60; }
  94062. if (autoStart === void 0) { autoStart = true; }
  94063. var _this = _super.call(this, name, scene) || this;
  94064. _this._sectionPolygonPointsCount = 4;
  94065. _this._running = false;
  94066. _this._autoStart = autoStart;
  94067. _this._generator = generator;
  94068. _this._diameter = diameter;
  94069. _this._length = length;
  94070. _this._sectionVectors = [];
  94071. _this._sectionNormalVectors = [];
  94072. for (var i = 0; i < _this._sectionPolygonPointsCount; i++) {
  94073. _this._sectionVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  94074. _this._sectionNormalVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  94075. }
  94076. _this._createMesh();
  94077. return _this;
  94078. }
  94079. /**
  94080. * "TrailMesh"
  94081. * @returns "TrailMesh"
  94082. */
  94083. TrailMesh.prototype.getClassName = function () {
  94084. return "TrailMesh";
  94085. };
  94086. TrailMesh.prototype._createMesh = function () {
  94087. var data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"]();
  94088. var positions = [];
  94089. var normals = [];
  94090. var indices = [];
  94091. var meshCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  94092. if (this._generator._boundingInfo) {
  94093. meshCenter = this._generator._boundingInfo.boundingBox.centerWorld;
  94094. }
  94095. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  94096. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  94097. positions.push(meshCenter.x + Math.cos(i * alpha) * this._diameter, meshCenter.y + Math.sin(i * alpha) * this._diameter, meshCenter.z);
  94098. }
  94099. for (var i = 1; i <= this._length; i++) {
  94100. for (var j = 0; j < this._sectionPolygonPointsCount; j++) {
  94101. positions.push(meshCenter.x + Math.cos(j * alpha) * this._diameter, meshCenter.y + Math.sin(j * alpha) * this._diameter, meshCenter.z);
  94102. }
  94103. var l = positions.length / 3 - 2 * this._sectionPolygonPointsCount;
  94104. for (var j = 0; j < this._sectionPolygonPointsCount - 1; j++) {
  94105. indices.push(l + j, l + j + this._sectionPolygonPointsCount, l + j + this._sectionPolygonPointsCount + 1);
  94106. indices.push(l + j, l + j + this._sectionPolygonPointsCount + 1, l + j + 1);
  94107. }
  94108. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount);
  94109. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l);
  94110. }
  94111. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"].ComputeNormals(positions, indices, normals);
  94112. data.positions = positions;
  94113. data.normals = normals;
  94114. data.indices = indices;
  94115. data.applyToMesh(this, true);
  94116. if (this._autoStart) {
  94117. this.start();
  94118. }
  94119. };
  94120. /**
  94121. * Start trailing mesh.
  94122. */
  94123. TrailMesh.prototype.start = function () {
  94124. var _this = this;
  94125. if (!this._running) {
  94126. this._running = true;
  94127. this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add(function () {
  94128. _this.update();
  94129. });
  94130. }
  94131. };
  94132. /**
  94133. * Stop trailing mesh.
  94134. */
  94135. TrailMesh.prototype.stop = function () {
  94136. if (this._beforeRenderObserver && this._running) {
  94137. this._running = false;
  94138. this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver);
  94139. }
  94140. };
  94141. /**
  94142. * Update trailing mesh geometry.
  94143. */
  94144. TrailMesh.prototype.update = function () {
  94145. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  94146. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind);
  94147. var wm = this._generator.getWorldMatrix();
  94148. if (positions && normals) {
  94149. for (var i = 3 * this._sectionPolygonPointsCount; i < positions.length; i++) {
  94150. positions[i - 3 * this._sectionPolygonPointsCount] = positions[i] - normals[i] / this._length * this._diameter;
  94151. }
  94152. for (var i = 3 * this._sectionPolygonPointsCount; i < normals.length; i++) {
  94153. normals[i - 3 * this._sectionPolygonPointsCount] = normals[i];
  94154. }
  94155. var l = positions.length - 3 * this._sectionPolygonPointsCount;
  94156. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  94157. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  94158. this._sectionVectors[i].copyFromFloats(Math.cos(i * alpha) * this._diameter, Math.sin(i * alpha) * this._diameter, 0);
  94159. this._sectionNormalVectors[i].copyFromFloats(Math.cos(i * alpha), Math.sin(i * alpha), 0);
  94160. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._sectionVectors[i], wm, this._sectionVectors[i]);
  94161. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this._sectionNormalVectors[i], wm, this._sectionNormalVectors[i]);
  94162. }
  94163. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  94164. positions[l + 3 * i] = this._sectionVectors[i].x;
  94165. positions[l + 3 * i + 1] = this._sectionVectors[i].y;
  94166. positions[l + 3 * i + 2] = this._sectionVectors[i].z;
  94167. normals[l + 3 * i] = this._sectionNormalVectors[i].x;
  94168. normals[l + 3 * i + 1] = this._sectionNormalVectors[i].y;
  94169. normals[l + 3 * i + 2] = this._sectionNormalVectors[i].z;
  94170. }
  94171. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, true, false);
  94172. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, true, false);
  94173. }
  94174. };
  94175. /**
  94176. * Returns a new TrailMesh object.
  94177. * @param name is a string, the name given to the new mesh
  94178. * @param newGenerator use new generator object for cloned trail mesh
  94179. * @returns a new mesh
  94180. */
  94181. TrailMesh.prototype.clone = function (name, newGenerator) {
  94182. if (name === void 0) { name = ""; }
  94183. return new TrailMesh(name, (newGenerator === undefined ? this._generator : newGenerator), this.getScene(), this._diameter, this._length, this._autoStart);
  94184. };
  94185. /**
  94186. * Serializes this trail mesh
  94187. * @param serializationObject object to write serialization to
  94188. */
  94189. TrailMesh.prototype.serialize = function (serializationObject) {
  94190. _super.prototype.serialize.call(this, serializationObject);
  94191. };
  94192. /**
  94193. * Parses a serialized trail mesh
  94194. * @param parsedMesh the serialized mesh
  94195. * @param scene the scene to create the trail mesh in
  94196. * @returns the created trail mesh
  94197. */
  94198. TrailMesh.Parse = function (parsedMesh, scene) {
  94199. return new TrailMesh(parsedMesh.name, parsedMesh._generator, scene, parsedMesh._diameter, parsedMesh._length, parsedMesh._autoStart);
  94200. };
  94201. return TrailMesh;
  94202. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]));
  94203. /***/ }),
  94204. /***/ "./Meshes/transformNode.ts":
  94205. /*!*********************************!*\
  94206. !*** ./Meshes/transformNode.ts ***!
  94207. \*********************************/
  94208. /*! exports provided: TransformNode */
  94209. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94210. "use strict";
  94211. __webpack_require__.r(__webpack_exports__);
  94212. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  94213. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  94214. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  94215. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  94216. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  94217. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  94218. /**
  94219. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  94220. * @see https://doc.babylonjs.com/how_to/transformnode
  94221. */
  94222. var TransformNode = /** @class */ (function (_super) {
  94223. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  94224. function TransformNode(name, scene, isPure) {
  94225. if (scene === void 0) { scene = null; }
  94226. if (isPure === void 0) { isPure = true; }
  94227. var _this = _super.call(this, name, scene) || this;
  94228. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  94229. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  94230. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0);
  94231. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  94232. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-1, 0, 0);
  94233. // Properties
  94234. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94235. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94236. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].One();
  94237. _this._isDirty = false;
  94238. _this._billboardMode = TransformNode.BILLBOARDMODE_NONE;
  94239. _this._preserveParentRotationForBillboard = false;
  94240. /**
  94241. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  94242. */
  94243. _this.scalingDeterminant = 1;
  94244. _this._infiniteDistance = false;
  94245. /**
  94246. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  94247. * By default the system will update normals to compensate
  94248. */
  94249. _this.ignoreNonUniformScaling = false;
  94250. /**
  94251. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  94252. */
  94253. _this.reIntegrateRotationIntoRotationQuaternion = false;
  94254. /** @hidden */
  94255. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  94256. _this._usePivotMatrix = false;
  94257. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94258. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  94259. _this._postMultiplyPivotMatrix = false;
  94260. _this._isWorldMatrixFrozen = false;
  94261. /** @hidden */
  94262. _this._indexInSceneTransformNodesArray = -1;
  94263. /**
  94264. * An event triggered after the world matrix is updated
  94265. */
  94266. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  94267. _this._nonUniformScaling = false;
  94268. if (isPure) {
  94269. _this.getScene().addTransformNode(_this);
  94270. }
  94271. return _this;
  94272. }
  94273. Object.defineProperty(TransformNode.prototype, "billboardMode", {
  94274. /**
  94275. * Gets or sets the billboard mode. Default is 0.
  94276. *
  94277. * | Value | Type | Description |
  94278. * | --- | --- | --- |
  94279. * | 0 | BILLBOARDMODE_NONE | |
  94280. * | 1 | BILLBOARDMODE_X | |
  94281. * | 2 | BILLBOARDMODE_Y | |
  94282. * | 4 | BILLBOARDMODE_Z | |
  94283. * | 7 | BILLBOARDMODE_ALL | |
  94284. *
  94285. */
  94286. get: function () {
  94287. return this._billboardMode;
  94288. },
  94289. set: function (value) {
  94290. if (this._billboardMode === value) {
  94291. return;
  94292. }
  94293. this._billboardMode = value;
  94294. },
  94295. enumerable: true,
  94296. configurable: true
  94297. });
  94298. Object.defineProperty(TransformNode.prototype, "preserveParentRotationForBillboard", {
  94299. /**
  94300. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  94301. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  94302. */
  94303. get: function () {
  94304. return this._preserveParentRotationForBillboard;
  94305. },
  94306. set: function (value) {
  94307. if (value === this._preserveParentRotationForBillboard) {
  94308. return;
  94309. }
  94310. this._preserveParentRotationForBillboard = value;
  94311. },
  94312. enumerable: true,
  94313. configurable: true
  94314. });
  94315. Object.defineProperty(TransformNode.prototype, "infiniteDistance", {
  94316. /**
  94317. * Gets or sets the distance of the object to max, often used by skybox
  94318. */
  94319. get: function () {
  94320. return this._infiniteDistance;
  94321. },
  94322. set: function (value) {
  94323. if (this._infiniteDistance === value) {
  94324. return;
  94325. }
  94326. this._infiniteDistance = value;
  94327. },
  94328. enumerable: true,
  94329. configurable: true
  94330. });
  94331. /**
  94332. * Gets a string identifying the name of the class
  94333. * @returns "TransformNode" string
  94334. */
  94335. TransformNode.prototype.getClassName = function () {
  94336. return "TransformNode";
  94337. };
  94338. Object.defineProperty(TransformNode.prototype, "position", {
  94339. /**
  94340. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  94341. */
  94342. get: function () {
  94343. return this._position;
  94344. },
  94345. set: function (newPosition) {
  94346. this._position = newPosition;
  94347. this._isDirty = true;
  94348. },
  94349. enumerable: true,
  94350. configurable: true
  94351. });
  94352. Object.defineProperty(TransformNode.prototype, "rotation", {
  94353. /**
  94354. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  94355. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  94356. */
  94357. get: function () {
  94358. return this._rotation;
  94359. },
  94360. set: function (newRotation) {
  94361. this._rotation = newRotation;
  94362. this._rotationQuaternion = null;
  94363. this._isDirty = true;
  94364. },
  94365. enumerable: true,
  94366. configurable: true
  94367. });
  94368. Object.defineProperty(TransformNode.prototype, "scaling", {
  94369. /**
  94370. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  94371. */
  94372. get: function () {
  94373. return this._scaling;
  94374. },
  94375. set: function (newScaling) {
  94376. this._scaling = newScaling;
  94377. this._isDirty = true;
  94378. },
  94379. enumerable: true,
  94380. configurable: true
  94381. });
  94382. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  94383. /**
  94384. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  94385. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  94386. */
  94387. get: function () {
  94388. return this._rotationQuaternion;
  94389. },
  94390. set: function (quaternion) {
  94391. this._rotationQuaternion = quaternion;
  94392. //reset the rotation vector.
  94393. if (quaternion) {
  94394. this._rotation.setAll(0.0);
  94395. }
  94396. this._isDirty = true;
  94397. },
  94398. enumerable: true,
  94399. configurable: true
  94400. });
  94401. Object.defineProperty(TransformNode.prototype, "forward", {
  94402. /**
  94403. * The forward direction of that transform in world space.
  94404. */
  94405. get: function () {
  94406. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.getScene().useRightHandedSystem ? this._forwardInverted : this._forward, this.getWorldMatrix()));
  94407. },
  94408. enumerable: true,
  94409. configurable: true
  94410. });
  94411. Object.defineProperty(TransformNode.prototype, "up", {
  94412. /**
  94413. * The up direction of that transform in world space.
  94414. */
  94415. get: function () {
  94416. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  94417. },
  94418. enumerable: true,
  94419. configurable: true
  94420. });
  94421. Object.defineProperty(TransformNode.prototype, "right", {
  94422. /**
  94423. * The right direction of that transform in world space.
  94424. */
  94425. get: function () {
  94426. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.getScene().useRightHandedSystem ? this._rightInverted : this._right, this.getWorldMatrix()));
  94427. },
  94428. enumerable: true,
  94429. configurable: true
  94430. });
  94431. /**
  94432. * Copies the parameter passed Matrix into the mesh Pose matrix.
  94433. * @param matrix the matrix to copy the pose from
  94434. * @returns this TransformNode.
  94435. */
  94436. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  94437. this._poseMatrix.copyFrom(matrix);
  94438. return this;
  94439. };
  94440. /**
  94441. * Returns the mesh Pose matrix.
  94442. * @returns the pose matrix
  94443. */
  94444. TransformNode.prototype.getPoseMatrix = function () {
  94445. return this._poseMatrix;
  94446. };
  94447. /** @hidden */
  94448. TransformNode.prototype._isSynchronized = function () {
  94449. var cache = this._cache;
  94450. if (this.billboardMode !== cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  94451. return false;
  94452. }
  94453. if (cache.pivotMatrixUpdated) {
  94454. return false;
  94455. }
  94456. if (this.infiniteDistance) {
  94457. return false;
  94458. }
  94459. if (!cache.position.equals(this._position)) {
  94460. return false;
  94461. }
  94462. if (this._rotationQuaternion) {
  94463. if (!cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  94464. return false;
  94465. }
  94466. }
  94467. else if (!cache.rotation.equals(this._rotation)) {
  94468. return false;
  94469. }
  94470. if (!cache.scaling.equals(this._scaling)) {
  94471. return false;
  94472. }
  94473. return true;
  94474. };
  94475. /** @hidden */
  94476. TransformNode.prototype._initCache = function () {
  94477. _super.prototype._initCache.call(this);
  94478. var cache = this._cache;
  94479. cache.localMatrixUpdated = false;
  94480. cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94481. cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94482. cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94483. cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](0, 0, 0, 0);
  94484. cache.billboardMode = -1;
  94485. cache.infiniteDistance = false;
  94486. };
  94487. /**
  94488. * Flag the transform node as dirty (Forcing it to update everything)
  94489. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  94490. * @returns this transform node
  94491. */
  94492. TransformNode.prototype.markAsDirty = function (property) {
  94493. this._currentRenderId = Number.MAX_VALUE;
  94494. this._isDirty = true;
  94495. return this;
  94496. };
  94497. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  94498. /**
  94499. * Returns the current mesh absolute position.
  94500. * Returns a Vector3.
  94501. */
  94502. get: function () {
  94503. return this._absolutePosition;
  94504. },
  94505. enumerable: true,
  94506. configurable: true
  94507. });
  94508. /**
  94509. * Sets a new matrix to apply before all other transformation
  94510. * @param matrix defines the transform matrix
  94511. * @returns the current TransformNode
  94512. */
  94513. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  94514. return this.setPivotMatrix(matrix, false);
  94515. };
  94516. /**
  94517. * Sets a new pivot matrix to the current node
  94518. * @param matrix defines the new pivot matrix to use
  94519. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  94520. * @returns the current TransformNode
  94521. */
  94522. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  94523. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  94524. this._pivotMatrix.copyFrom(matrix);
  94525. this._usePivotMatrix = !this._pivotMatrix.isIdentity();
  94526. this._cache.pivotMatrixUpdated = true;
  94527. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  94528. if (this._postMultiplyPivotMatrix) {
  94529. if (!this._pivotMatrixInverse) {
  94530. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._pivotMatrix);
  94531. }
  94532. else {
  94533. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  94534. }
  94535. }
  94536. return this;
  94537. };
  94538. /**
  94539. * Returns the mesh pivot matrix.
  94540. * Default : Identity.
  94541. * @returns the matrix
  94542. */
  94543. TransformNode.prototype.getPivotMatrix = function () {
  94544. return this._pivotMatrix;
  94545. };
  94546. /**
  94547. * Prevents the World matrix to be computed any longer.
  94548. * @returns the TransformNode.
  94549. */
  94550. TransformNode.prototype.freezeWorldMatrix = function () {
  94551. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  94552. this.computeWorldMatrix(true);
  94553. this._isWorldMatrixFrozen = true;
  94554. return this;
  94555. };
  94556. /**
  94557. * Allows back the World matrix computation.
  94558. * @returns the TransformNode.
  94559. */
  94560. TransformNode.prototype.unfreezeWorldMatrix = function () {
  94561. this._isWorldMatrixFrozen = false;
  94562. this.computeWorldMatrix(true);
  94563. return this;
  94564. };
  94565. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  94566. /**
  94567. * True if the World matrix has been frozen.
  94568. */
  94569. get: function () {
  94570. return this._isWorldMatrixFrozen;
  94571. },
  94572. enumerable: true,
  94573. configurable: true
  94574. });
  94575. /**
  94576. * Retuns the mesh absolute position in the World.
  94577. * @returns a Vector3.
  94578. */
  94579. TransformNode.prototype.getAbsolutePosition = function () {
  94580. this.computeWorldMatrix();
  94581. return this._absolutePosition;
  94582. };
  94583. /**
  94584. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  94585. * @param absolutePosition the absolute position to set
  94586. * @returns the TransformNode.
  94587. */
  94588. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  94589. if (!absolutePosition) {
  94590. return this;
  94591. }
  94592. var absolutePositionX;
  94593. var absolutePositionY;
  94594. var absolutePositionZ;
  94595. if (absolutePosition.x === undefined) {
  94596. if (arguments.length < 3) {
  94597. return this;
  94598. }
  94599. absolutePositionX = arguments[0];
  94600. absolutePositionY = arguments[1];
  94601. absolutePositionZ = arguments[2];
  94602. }
  94603. else {
  94604. absolutePositionX = absolutePosition.x;
  94605. absolutePositionY = absolutePosition.y;
  94606. absolutePositionZ = absolutePosition.z;
  94607. }
  94608. if (this.parent) {
  94609. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94610. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  94611. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  94612. }
  94613. else {
  94614. this.position.x = absolutePositionX;
  94615. this.position.y = absolutePositionY;
  94616. this.position.z = absolutePositionZ;
  94617. }
  94618. return this;
  94619. };
  94620. /**
  94621. * Sets the mesh position in its local space.
  94622. * @param vector3 the position to set in localspace
  94623. * @returns the TransformNode.
  94624. */
  94625. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  94626. this.computeWorldMatrix();
  94627. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(vector3, this._localMatrix);
  94628. return this;
  94629. };
  94630. /**
  94631. * Returns the mesh position in the local space from the current World matrix values.
  94632. * @returns a new Vector3.
  94633. */
  94634. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  94635. this.computeWorldMatrix();
  94636. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94637. this._localMatrix.invertToRef(invLocalWorldMatrix);
  94638. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  94639. };
  94640. /**
  94641. * Translates the mesh along the passed Vector3 in its local space.
  94642. * @param vector3 the distance to translate in localspace
  94643. * @returns the TransformNode.
  94644. */
  94645. TransformNode.prototype.locallyTranslate = function (vector3) {
  94646. this.computeWorldMatrix(true);
  94647. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  94648. return this;
  94649. };
  94650. /**
  94651. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  94652. * @param targetPoint the position (must be in same space as current mesh) to look at
  94653. * @param yawCor optional yaw (y-axis) correction in radians
  94654. * @param pitchCor optional pitch (x-axis) correction in radians
  94655. * @param rollCor optional roll (z-axis) correction in radians
  94656. * @param space the choosen space of the target
  94657. * @returns the TransformNode.
  94658. */
  94659. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  94660. if (yawCor === void 0) { yawCor = 0; }
  94661. if (pitchCor === void 0) { pitchCor = 0; }
  94662. if (rollCor === void 0) { rollCor = 0; }
  94663. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  94664. var dv = TransformNode._lookAtVectorCache;
  94665. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  94666. targetPoint.subtractToRef(pos, dv);
  94667. this.setDirection(dv, yawCor, pitchCor, rollCor);
  94668. // Correct for parent's rotation offset
  94669. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD && this.parent) {
  94670. if (this.rotationQuaternion) {
  94671. // Get local rotation matrix of the looking object
  94672. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94673. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  94674. // Offset rotation by parent's inverted rotation matrix to correct in world space
  94675. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  94676. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  94677. parentRotationMatrix.invert();
  94678. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  94679. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  94680. }
  94681. else {
  94682. // Get local rotation matrix of the looking object
  94683. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  94684. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  94685. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94686. quaternionRotation.toRotationMatrix(rotationMatrix);
  94687. // Offset rotation by parent's inverted rotation matrix to correct in world space
  94688. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  94689. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  94690. parentRotationMatrix.invert();
  94691. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  94692. quaternionRotation.fromRotationMatrix(rotationMatrix);
  94693. quaternionRotation.toEulerAnglesToRef(this.rotation);
  94694. }
  94695. }
  94696. return this;
  94697. };
  94698. /**
  94699. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94700. * This Vector3 is expressed in the World space.
  94701. * @param localAxis axis to rotate
  94702. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94703. */
  94704. TransformNode.prototype.getDirection = function (localAxis) {
  94705. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94706. this.getDirectionToRef(localAxis, result);
  94707. return result;
  94708. };
  94709. /**
  94710. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  94711. * localAxis is expressed in the mesh local space.
  94712. * result is computed in the Wordl space from the mesh World matrix.
  94713. * @param localAxis axis to rotate
  94714. * @param result the resulting transformnode
  94715. * @returns this TransformNode.
  94716. */
  94717. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  94718. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  94719. return this;
  94720. };
  94721. /**
  94722. * Sets this transform node rotation to the given local axis.
  94723. * @param localAxis the axis in local space
  94724. * @param yawCor optional yaw (y-axis) correction in radians
  94725. * @param pitchCor optional pitch (x-axis) correction in radians
  94726. * @param rollCor optional roll (z-axis) correction in radians
  94727. * @returns this TransformNode
  94728. */
  94729. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  94730. if (yawCor === void 0) { yawCor = 0; }
  94731. if (pitchCor === void 0) { pitchCor = 0; }
  94732. if (rollCor === void 0) { rollCor = 0; }
  94733. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  94734. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  94735. var pitch = -Math.atan2(localAxis.y, len);
  94736. if (this.rotationQuaternion) {
  94737. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  94738. }
  94739. else {
  94740. this.rotation.x = pitch + pitchCor;
  94741. this.rotation.y = yaw + yawCor;
  94742. this.rotation.z = rollCor;
  94743. }
  94744. return this;
  94745. };
  94746. /**
  94747. * Sets a new pivot point to the current node
  94748. * @param point defines the new pivot point to use
  94749. * @param space defines if the point is in world or local space (local by default)
  94750. * @returns the current TransformNode
  94751. */
  94752. TransformNode.prototype.setPivotPoint = function (point, space) {
  94753. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  94754. if (this.getScene().getRenderId() == 0) {
  94755. this.computeWorldMatrix(true);
  94756. }
  94757. var wm = this.getWorldMatrix();
  94758. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD) {
  94759. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94760. wm.invertToRef(tmat);
  94761. point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(point, tmat);
  94762. }
  94763. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  94764. };
  94765. /**
  94766. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  94767. * @returns the pivot point
  94768. */
  94769. TransformNode.prototype.getPivotPoint = function () {
  94770. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94771. this.getPivotPointToRef(point);
  94772. return point;
  94773. };
  94774. /**
  94775. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  94776. * @param result the vector3 to store the result
  94777. * @returns this TransformNode.
  94778. */
  94779. TransformNode.prototype.getPivotPointToRef = function (result) {
  94780. result.x = -this._pivotMatrix.m[12];
  94781. result.y = -this._pivotMatrix.m[13];
  94782. result.z = -this._pivotMatrix.m[14];
  94783. return this;
  94784. };
  94785. /**
  94786. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  94787. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  94788. */
  94789. TransformNode.prototype.getAbsolutePivotPoint = function () {
  94790. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94791. this.getAbsolutePivotPointToRef(point);
  94792. return point;
  94793. };
  94794. /**
  94795. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  94796. * @param result vector3 to store the result
  94797. * @returns this TransformNode.
  94798. */
  94799. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  94800. result.x = this._pivotMatrix.m[12];
  94801. result.y = this._pivotMatrix.m[13];
  94802. result.z = this._pivotMatrix.m[14];
  94803. this.getPivotPointToRef(result);
  94804. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  94805. return this;
  94806. };
  94807. /**
  94808. * Defines the passed node as the parent of the current node.
  94809. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  94810. * @see https://doc.babylonjs.com/how_to/parenting
  94811. * @param node the node ot set as the parent
  94812. * @returns this TransformNode.
  94813. */
  94814. TransformNode.prototype.setParent = function (node) {
  94815. if (!node && !this.parent) {
  94816. return this;
  94817. }
  94818. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  94819. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  94820. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  94821. if (!node) {
  94822. if (this.parent && this.parent.computeWorldMatrix) {
  94823. this.parent.computeWorldMatrix(true);
  94824. }
  94825. this.computeWorldMatrix(true);
  94826. this.getWorldMatrix().decompose(scale, quatRotation, position);
  94827. }
  94828. else {
  94829. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94830. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  94831. this.computeWorldMatrix(true);
  94832. node.computeWorldMatrix(true);
  94833. node.getWorldMatrix().invertToRef(invParentMatrix);
  94834. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  94835. diffMatrix.decompose(scale, quatRotation, position);
  94836. }
  94837. if (this.rotationQuaternion) {
  94838. this.rotationQuaternion.copyFrom(quatRotation);
  94839. }
  94840. else {
  94841. quatRotation.toEulerAnglesToRef(this.rotation);
  94842. }
  94843. this.scaling.copyFrom(scale);
  94844. this.position.copyFrom(position);
  94845. this.parent = node;
  94846. return this;
  94847. };
  94848. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  94849. /**
  94850. * True if the scaling property of this object is non uniform eg. (1,2,1)
  94851. */
  94852. get: function () {
  94853. return this._nonUniformScaling;
  94854. },
  94855. enumerable: true,
  94856. configurable: true
  94857. });
  94858. /** @hidden */
  94859. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  94860. if (this._nonUniformScaling === value) {
  94861. return false;
  94862. }
  94863. this._nonUniformScaling = value;
  94864. return true;
  94865. };
  94866. /**
  94867. * Attach the current TransformNode to another TransformNode associated with a bone
  94868. * @param bone Bone affecting the TransformNode
  94869. * @param affectedTransformNode TransformNode associated with the bone
  94870. * @returns this object
  94871. */
  94872. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  94873. this._transformToBoneReferal = affectedTransformNode;
  94874. this.parent = bone;
  94875. if (bone.getWorldMatrix().determinant() < 0) {
  94876. this.scalingDeterminant *= -1;
  94877. }
  94878. return this;
  94879. };
  94880. /**
  94881. * Detach the transform node if its associated with a bone
  94882. * @returns this object
  94883. */
  94884. TransformNode.prototype.detachFromBone = function () {
  94885. if (!this.parent) {
  94886. return this;
  94887. }
  94888. if (this.parent.getWorldMatrix().determinant() < 0) {
  94889. this.scalingDeterminant *= -1;
  94890. }
  94891. this._transformToBoneReferal = null;
  94892. this.parent = null;
  94893. return this;
  94894. };
  94895. /**
  94896. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  94897. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94898. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94899. * The passed axis is also normalized.
  94900. * @param axis the axis to rotate around
  94901. * @param amount the amount to rotate in radians
  94902. * @param space Space to rotate in (Default: local)
  94903. * @returns the TransformNode.
  94904. */
  94905. TransformNode.prototype.rotate = function (axis, amount, space) {
  94906. axis.normalize();
  94907. if (!this.rotationQuaternion) {
  94908. this.rotationQuaternion = this.rotation.toQuaternion();
  94909. this.rotation.setAll(0);
  94910. }
  94911. var rotationQuaternion;
  94912. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  94913. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  94914. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  94915. }
  94916. else {
  94917. if (this.parent) {
  94918. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94919. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  94920. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  94921. }
  94922. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  94923. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  94924. }
  94925. return this;
  94926. };
  94927. /**
  94928. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  94929. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94930. * The passed axis is also normalized. .
  94931. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  94932. * @param point the point to rotate around
  94933. * @param axis the axis to rotate around
  94934. * @param amount the amount to rotate in radians
  94935. * @returns the TransformNode
  94936. */
  94937. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  94938. axis.normalize();
  94939. if (!this.rotationQuaternion) {
  94940. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  94941. this.rotation.setAll(0);
  94942. }
  94943. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  94944. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  94945. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[2];
  94946. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  94947. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]; // T
  94948. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]; // T'
  94949. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]; // R
  94950. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[3]; // T' x R x T
  94951. point.subtractToRef(this.position, tmpVector);
  94952. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  94953. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  94954. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  94955. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  94956. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  94957. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  94958. this.position.addInPlace(finalTranslation);
  94959. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  94960. return this;
  94961. };
  94962. /**
  94963. * Translates the mesh along the axis vector for the passed distance in the given space.
  94964. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94965. * @param axis the axis to translate in
  94966. * @param distance the distance to translate
  94967. * @param space Space to rotate in (Default: local)
  94968. * @returns the TransformNode.
  94969. */
  94970. TransformNode.prototype.translate = function (axis, distance, space) {
  94971. var displacementVector = axis.scale(distance);
  94972. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  94973. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  94974. this.setPositionWithLocalVector(tempV3);
  94975. }
  94976. else {
  94977. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  94978. }
  94979. return this;
  94980. };
  94981. /**
  94982. * Adds a rotation step to the mesh current rotation.
  94983. * x, y, z are Euler angles expressed in radians.
  94984. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  94985. * This means this rotation is made in the mesh local space only.
  94986. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  94987. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  94988. * ```javascript
  94989. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  94990. * ```
  94991. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  94992. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  94993. * @param x Rotation to add
  94994. * @param y Rotation to add
  94995. * @param z Rotation to add
  94996. * @returns the TransformNode.
  94997. */
  94998. TransformNode.prototype.addRotation = function (x, y, z) {
  94999. var rotationQuaternion;
  95000. if (this.rotationQuaternion) {
  95001. rotationQuaternion = this.rotationQuaternion;
  95002. }
  95003. else {
  95004. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[1];
  95005. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  95006. }
  95007. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  95008. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  95009. rotationQuaternion.multiplyInPlace(accumulation);
  95010. if (!this.rotationQuaternion) {
  95011. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  95012. }
  95013. return this;
  95014. };
  95015. /**
  95016. * @hidden
  95017. */
  95018. TransformNode.prototype._getEffectiveParent = function () {
  95019. return this.parent;
  95020. };
  95021. /**
  95022. * Computes the world matrix of the node
  95023. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95024. * @returns the world matrix
  95025. */
  95026. TransformNode.prototype.computeWorldMatrix = function (force) {
  95027. var currentRenderId = this.getScene().getRenderId();
  95028. if (this._isWorldMatrixFrozen && !this._isDirty) {
  95029. return this._worldMatrix;
  95030. }
  95031. if (!this._isDirty && !force && this.isSynchronized()) {
  95032. this._currentRenderId = currentRenderId;
  95033. return this._worldMatrix;
  95034. }
  95035. this._updateCache();
  95036. var cache = this._cache;
  95037. cache.pivotMatrixUpdated = false;
  95038. cache.billboardMode = this.billboardMode;
  95039. cache.infiniteDistance = this.infiniteDistance;
  95040. this._currentRenderId = currentRenderId;
  95041. this._childUpdateId++;
  95042. this._isDirty = false;
  95043. var parent = this._getEffectiveParent();
  95044. var useBillboardPath = this._billboardMode !== TransformNode.BILLBOARDMODE_NONE && !this.preserveParentRotationForBillboard;
  95045. var camera = this.getScene().activeCamera;
  95046. // Scaling
  95047. var scaling = cache.scaling;
  95048. var translation = cache.position;
  95049. // Translation
  95050. if (this._infiniteDistance) {
  95051. if (!this.parent && camera) {
  95052. var cameraWorldMatrix = camera.getWorldMatrix();
  95053. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  95054. translation.copyFromFloats(this._position.x + cameraGlobalPosition.x, this._position.y + cameraGlobalPosition.y, this._position.z + cameraGlobalPosition.z);
  95055. }
  95056. else {
  95057. translation.copyFrom(this._position);
  95058. }
  95059. }
  95060. else {
  95061. translation.copyFrom(this._position);
  95062. }
  95063. // Scaling
  95064. scaling.copyFromFloats(this._scaling.x * this.scalingDeterminant, this._scaling.y * this.scalingDeterminant, this._scaling.z * this.scalingDeterminant);
  95065. // Rotation
  95066. var rotation = cache.rotationQuaternion;
  95067. if (this._rotationQuaternion) {
  95068. if (this.reIntegrateRotationIntoRotationQuaternion) {
  95069. var len = this.rotation.lengthSquared();
  95070. if (len) {
  95071. this._rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z));
  95072. this._rotation.copyFromFloats(0, 0, 0);
  95073. }
  95074. }
  95075. rotation.copyFrom(this._rotationQuaternion);
  95076. }
  95077. else {
  95078. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, rotation);
  95079. cache.rotation.copyFrom(this._rotation);
  95080. }
  95081. // Compose
  95082. if (this._usePivotMatrix) {
  95083. var scaleMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  95084. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(scaling.x, scaling.y, scaling.z, scaleMatrix);
  95085. // Rotation
  95086. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  95087. rotation.toRotationMatrix(rotationMatrix);
  95088. // Composing transformations
  95089. this._pivotMatrix.multiplyToRef(scaleMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4]);
  95090. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4].multiplyToRef(rotationMatrix, this._localMatrix);
  95091. // Post multiply inverse of pivotMatrix
  95092. if (this._postMultiplyPivotMatrix) {
  95093. this._localMatrix.multiplyToRef(this._pivotMatrixInverse, this._localMatrix);
  95094. }
  95095. this._localMatrix.addTranslationFromFloats(translation.x, translation.y, translation.z);
  95096. }
  95097. else {
  95098. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ComposeToRef(scaling, rotation, translation, this._localMatrix);
  95099. }
  95100. // Parent
  95101. if (parent && parent.getWorldMatrix) {
  95102. if (useBillboardPath) {
  95103. if (this._transformToBoneReferal) {
  95104. parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7]);
  95105. }
  95106. else {
  95107. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].copyFrom(parent.getWorldMatrix());
  95108. }
  95109. // Extract scaling and translation from parent
  95110. var translation_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5];
  95111. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[6];
  95112. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].decompose(scale, undefined, translation_1);
  95113. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(scale.x, scale.y, scale.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7]);
  95114. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].setTranslation(translation_1);
  95115. this._localMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7], this._worldMatrix);
  95116. }
  95117. else {
  95118. if (this._transformToBoneReferal) {
  95119. this._localMatrix.multiplyToRef(parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  95120. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  95121. }
  95122. else {
  95123. this._localMatrix.multiplyToRef(parent.getWorldMatrix(), this._worldMatrix);
  95124. }
  95125. }
  95126. this._markSyncedWithParent();
  95127. }
  95128. else {
  95129. this._worldMatrix.copyFrom(this._localMatrix);
  95130. }
  95131. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  95132. if (useBillboardPath && camera) {
  95133. var storedTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  95134. this._worldMatrix.getTranslationToRef(storedTranslation); // Save translation
  95135. // Cancel camera rotation
  95136. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  95137. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  95138. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  95139. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  95140. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0].decompose(undefined, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0], undefined);
  95141. var eulerAngles = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  95142. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0].toEulerAnglesToRef(eulerAngles);
  95143. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) !== TransformNode.BILLBOARDMODE_X) {
  95144. eulerAngles.x = 0;
  95145. }
  95146. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) !== TransformNode.BILLBOARDMODE_Y) {
  95147. eulerAngles.y = 0;
  95148. }
  95149. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) !== TransformNode.BILLBOARDMODE_Z) {
  95150. eulerAngles.z = 0;
  95151. }
  95152. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(eulerAngles.y, eulerAngles.x, eulerAngles.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  95153. }
  95154. this._worldMatrix.setTranslationFromFloats(0, 0, 0);
  95155. this._worldMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], this._worldMatrix);
  95156. // Restore translation
  95157. this._worldMatrix.setTranslation(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  95158. }
  95159. // Normal matrix
  95160. if (!this.ignoreNonUniformScaling) {
  95161. if (this._scaling.isNonUniform) {
  95162. this._updateNonUniformScalingState(true);
  95163. }
  95164. else if (parent && parent._nonUniformScaling) {
  95165. this._updateNonUniformScalingState(parent._nonUniformScaling);
  95166. }
  95167. else {
  95168. this._updateNonUniformScalingState(false);
  95169. }
  95170. }
  95171. else {
  95172. this._updateNonUniformScalingState(false);
  95173. }
  95174. this._afterComputeWorldMatrix();
  95175. // Absolute position
  95176. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  95177. // Callbacks
  95178. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  95179. if (!this._poseMatrix) {
  95180. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._worldMatrix);
  95181. }
  95182. // Cache the determinant
  95183. this._worldMatrixDeterminantIsDirty = true;
  95184. return this._worldMatrix;
  95185. };
  95186. TransformNode.prototype._afterComputeWorldMatrix = function () {
  95187. };
  95188. /**
  95189. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95190. * @param func callback function to add
  95191. *
  95192. * @returns the TransformNode.
  95193. */
  95194. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  95195. this.onAfterWorldMatrixUpdateObservable.add(func);
  95196. return this;
  95197. };
  95198. /**
  95199. * Removes a registered callback function.
  95200. * @param func callback function to remove
  95201. * @returns the TransformNode.
  95202. */
  95203. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  95204. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  95205. return this;
  95206. };
  95207. /**
  95208. * Gets the position of the current mesh in camera space
  95209. * @param camera defines the camera to use
  95210. * @returns a position
  95211. */
  95212. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  95213. if (camera === void 0) { camera = null; }
  95214. if (!camera) {
  95215. camera = this.getScene().activeCamera;
  95216. }
  95217. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  95218. };
  95219. /**
  95220. * Returns the distance from the mesh to the active camera
  95221. * @param camera defines the camera to use
  95222. * @returns the distance
  95223. */
  95224. TransformNode.prototype.getDistanceToCamera = function (camera) {
  95225. if (camera === void 0) { camera = null; }
  95226. if (!camera) {
  95227. camera = this.getScene().activeCamera;
  95228. }
  95229. return this.absolutePosition.subtract(camera.globalPosition).length();
  95230. };
  95231. /**
  95232. * Clone the current transform node
  95233. * @param name Name of the new clone
  95234. * @param newParent New parent for the clone
  95235. * @param doNotCloneChildren Do not clone children hierarchy
  95236. * @returns the new transform node
  95237. */
  95238. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  95239. var _this = this;
  95240. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  95241. result.name = name;
  95242. result.id = name;
  95243. if (newParent) {
  95244. result.parent = newParent;
  95245. }
  95246. if (!doNotCloneChildren) {
  95247. // Children
  95248. var directDescendants = this.getDescendants(true);
  95249. for (var index = 0; index < directDescendants.length; index++) {
  95250. var child = directDescendants[index];
  95251. if (child.clone) {
  95252. child.clone(name + "." + child.name, result);
  95253. }
  95254. }
  95255. }
  95256. return result;
  95257. };
  95258. /**
  95259. * Serializes the objects information.
  95260. * @param currentSerializationObject defines the object to serialize in
  95261. * @returns the serialized object
  95262. */
  95263. TransformNode.prototype.serialize = function (currentSerializationObject) {
  95264. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  95265. serializationObject.type = this.getClassName();
  95266. // Parent
  95267. if (this.parent) {
  95268. serializationObject.parentId = this.parent.id;
  95269. }
  95270. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  95271. serializationObject.isEnabled = this.isEnabled();
  95272. // Parent
  95273. if (this.parent) {
  95274. serializationObject.parentId = this.parent.id;
  95275. }
  95276. return serializationObject;
  95277. };
  95278. // Statics
  95279. /**
  95280. * Returns a new TransformNode object parsed from the source provided.
  95281. * @param parsedTransformNode is the source.
  95282. * @param scene the scne the object belongs to
  95283. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95284. * @returns a new TransformNode object parsed from the source provided.
  95285. */
  95286. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  95287. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  95288. if (parsedTransformNode.localMatrix) {
  95289. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  95290. }
  95291. else if (parsedTransformNode.pivotMatrix) {
  95292. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  95293. }
  95294. transformNode.setEnabled(parsedTransformNode.isEnabled);
  95295. // Parent
  95296. if (parsedTransformNode.parentId) {
  95297. transformNode._waitingParentId = parsedTransformNode.parentId;
  95298. }
  95299. return transformNode;
  95300. };
  95301. /**
  95302. * Get all child-transformNodes of this node
  95303. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  95304. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  95305. * @returns an array of TransformNode
  95306. */
  95307. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  95308. var results = [];
  95309. this._getDescendants(results, directDescendantsOnly, function (node) {
  95310. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  95311. });
  95312. return results;
  95313. };
  95314. /**
  95315. * Releases resources associated with this transform node.
  95316. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95317. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95318. */
  95319. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  95320. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  95321. // Animations
  95322. this.getScene().stopAnimation(this);
  95323. // Remove from scene
  95324. this.getScene().removeTransformNode(this);
  95325. this.onAfterWorldMatrixUpdateObservable.clear();
  95326. if (doNotRecurse) {
  95327. var transformNodes = this.getChildTransformNodes(true);
  95328. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  95329. var transformNode = transformNodes_1[_i];
  95330. transformNode.parent = null;
  95331. transformNode.computeWorldMatrix(true);
  95332. }
  95333. }
  95334. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  95335. };
  95336. // Statics
  95337. /**
  95338. * Object will not rotate to face the camera
  95339. */
  95340. TransformNode.BILLBOARDMODE_NONE = 0;
  95341. /**
  95342. * Object will rotate to face the camera but only on the x axis
  95343. */
  95344. TransformNode.BILLBOARDMODE_X = 1;
  95345. /**
  95346. * Object will rotate to face the camera but only on the y axis
  95347. */
  95348. TransformNode.BILLBOARDMODE_Y = 2;
  95349. /**
  95350. * Object will rotate to face the camera but only on the z axis
  95351. */
  95352. TransformNode.BILLBOARDMODE_Z = 4;
  95353. /**
  95354. * Object will rotate to face the camera
  95355. */
  95356. TransformNode.BILLBOARDMODE_ALL = 7;
  95357. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  95358. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  95359. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95360. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  95361. ], TransformNode.prototype, "_position", void 0);
  95362. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95363. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  95364. ], TransformNode.prototype, "_rotation", void 0);
  95365. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95366. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  95367. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  95368. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95369. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  95370. ], TransformNode.prototype, "_scaling", void 0);
  95371. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95372. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("billboardMode")
  95373. ], TransformNode.prototype, "_billboardMode", void 0);
  95374. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95375. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  95376. ], TransformNode.prototype, "scalingDeterminant", void 0);
  95377. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95378. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("infiniteDistance")
  95379. ], TransformNode.prototype, "_infiniteDistance", void 0);
  95380. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95381. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  95382. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  95383. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95384. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  95385. ], TransformNode.prototype, "reIntegrateRotationIntoRotationQuaternion", void 0);
  95386. return TransformNode;
  95387. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  95388. /***/ }),
  95389. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  95390. /*!***************************************************************!*\
  95391. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  95392. \***************************************************************/
  95393. /*! exports provided: CubeMapToSphericalPolynomialTools */
  95394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95395. "use strict";
  95396. __webpack_require__.r(__webpack_exports__);
  95397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  95398. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  95399. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  95400. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  95401. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  95402. var FileFaceOrientation = /** @class */ (function () {
  95403. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  95404. this.name = name;
  95405. this.worldAxisForNormal = worldAxisForNormal;
  95406. this.worldAxisForFileX = worldAxisForFileX;
  95407. this.worldAxisForFileY = worldAxisForFileY;
  95408. }
  95409. return FileFaceOrientation;
  95410. }());
  95411. /**
  95412. * Helper class dealing with the extraction of spherical polynomial dataArray
  95413. * from a cube map.
  95414. */
  95415. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  95416. function CubeMapToSphericalPolynomialTools() {
  95417. }
  95418. /**
  95419. * Converts a texture to the according Spherical Polynomial data.
  95420. * This extracts the first 3 orders only as they are the only one used in the lighting.
  95421. *
  95422. * @param texture The texture to extract the information from.
  95423. * @return The Spherical Polynomial data.
  95424. */
  95425. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  95426. if (!texture.isCube) {
  95427. // Only supports cube Textures currently.
  95428. return null;
  95429. }
  95430. var size = texture.getSize().width;
  95431. var right = texture.readPixels(0);
  95432. var left = texture.readPixels(1);
  95433. var up;
  95434. var down;
  95435. if (texture.isRenderTarget) {
  95436. up = texture.readPixels(3);
  95437. down = texture.readPixels(2);
  95438. }
  95439. else {
  95440. up = texture.readPixels(2);
  95441. down = texture.readPixels(3);
  95442. }
  95443. var front = texture.readPixels(4);
  95444. var back = texture.readPixels(5);
  95445. var gammaSpace = texture.gammaSpace;
  95446. // Always read as RGBA.
  95447. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  95448. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  95449. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  95450. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  95451. }
  95452. var cubeInfo = {
  95453. size: size,
  95454. right: right,
  95455. left: left,
  95456. up: up,
  95457. down: down,
  95458. front: front,
  95459. back: back,
  95460. format: format,
  95461. type: type,
  95462. gammaSpace: gammaSpace,
  95463. };
  95464. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  95465. };
  95466. /**
  95467. * Converts a cubemap to the according Spherical Polynomial data.
  95468. * This extracts the first 3 orders only as they are the only one used in the lighting.
  95469. *
  95470. * @param cubeInfo The Cube map to extract the information from.
  95471. * @return The Spherical Polynomial data.
  95472. */
  95473. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  95474. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  95475. var totalSolidAngle = 0.0;
  95476. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  95477. var du = 2.0 / cubeInfo.size;
  95478. var dv = du;
  95479. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  95480. var minUV = du * 0.5 - 1.0;
  95481. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  95482. var fileFace = this.FileFaces[faceIndex];
  95483. var dataArray = cubeInfo[fileFace.name];
  95484. var v = minUV;
  95485. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  95486. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  95487. // Because SP is still linear, so summation is fine in that basis.
  95488. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  95489. for (var y = 0; y < cubeInfo.size; y++) {
  95490. var u = minUV;
  95491. for (var x = 0; x < cubeInfo.size; x++) {
  95492. // World direction (not normalised)
  95493. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  95494. worldDirection.normalize();
  95495. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  95496. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  95497. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  95498. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  95499. // Handle Integer types.
  95500. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  95501. r /= 255;
  95502. g /= 255;
  95503. b /= 255;
  95504. }
  95505. // Handle Gamma space textures.
  95506. if (cubeInfo.gammaSpace) {
  95507. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  95508. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  95509. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  95510. }
  95511. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  95512. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  95513. totalSolidAngle += deltaSolidAngle;
  95514. u += du;
  95515. }
  95516. v += dv;
  95517. }
  95518. }
  95519. // Solid angle for entire sphere is 4*pi
  95520. var sphereSolidAngle = 4.0 * Math.PI;
  95521. // Adjust the solid angle to allow for how many faces we processed.
  95522. var facesProcessed = 6.0;
  95523. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  95524. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  95525. // This is needed because the numerical integration over the cube uses a
  95526. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  95527. // and also to compensate for accumulative error due to float precision in the summation.
  95528. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  95529. sphericalHarmonics.scale(correctionFactor);
  95530. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  95531. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  95532. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  95533. };
  95534. CubeMapToSphericalPolynomialTools.FileFaces = [
  95535. new FileFaceOrientation("right", new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)),
  95536. new FileFaceOrientation("left", new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)),
  95537. new FileFaceOrientation("up", new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1)),
  95538. new FileFaceOrientation("down", new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1)),
  95539. new FileFaceOrientation("front", new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)),
  95540. new FileFaceOrientation("back", new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)) // -Z bottom
  95541. ];
  95542. return CubeMapToSphericalPolynomialTools;
  95543. }());
  95544. /***/ }),
  95545. /***/ "./Misc/HighDynamicRange/hdr.ts":
  95546. /*!**************************************!*\
  95547. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  95548. \**************************************/
  95549. /*! exports provided: HDRTools */
  95550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95551. "use strict";
  95552. __webpack_require__.r(__webpack_exports__);
  95553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  95554. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  95555. /**
  95556. * This groups tools to convert HDR texture to native colors array.
  95557. */
  95558. var HDRTools = /** @class */ (function () {
  95559. function HDRTools() {
  95560. }
  95561. HDRTools.Ldexp = function (mantissa, exponent) {
  95562. if (exponent > 1023) {
  95563. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  95564. }
  95565. if (exponent < -1074) {
  95566. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  95567. }
  95568. return mantissa * Math.pow(2, exponent);
  95569. };
  95570. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  95571. if (exponent > 0) { /*nonzero pixel*/
  95572. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  95573. float32array[index + 0] = red * exponent;
  95574. float32array[index + 1] = green * exponent;
  95575. float32array[index + 2] = blue * exponent;
  95576. }
  95577. else {
  95578. float32array[index + 0] = 0;
  95579. float32array[index + 1] = 0;
  95580. float32array[index + 2] = 0;
  95581. }
  95582. };
  95583. HDRTools.readStringLine = function (uint8array, startIndex) {
  95584. var line = "";
  95585. var character = "";
  95586. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  95587. character = String.fromCharCode(uint8array[i]);
  95588. if (character == "\n") {
  95589. break;
  95590. }
  95591. line += character;
  95592. }
  95593. return line;
  95594. };
  95595. /**
  95596. * Reads header information from an RGBE texture stored in a native array.
  95597. * More information on this format are available here:
  95598. * https://en.wikipedia.org/wiki/RGBE_image_format
  95599. *
  95600. * @param uint8array The binary file stored in native array.
  95601. * @return The header information.
  95602. */
  95603. HDRTools.RGBE_ReadHeader = function (uint8array) {
  95604. var height = 0;
  95605. var width = 0;
  95606. var line = this.readStringLine(uint8array, 0);
  95607. if (line[0] != '#' || line[1] != '?') {
  95608. throw "Bad HDR Format.";
  95609. }
  95610. var endOfHeader = false;
  95611. var findFormat = false;
  95612. var lineIndex = 0;
  95613. do {
  95614. lineIndex += (line.length + 1);
  95615. line = this.readStringLine(uint8array, lineIndex);
  95616. if (line == "FORMAT=32-bit_rle_rgbe") {
  95617. findFormat = true;
  95618. }
  95619. else if (line.length == 0) {
  95620. endOfHeader = true;
  95621. }
  95622. } while (!endOfHeader);
  95623. if (!findFormat) {
  95624. throw "HDR Bad header format, unsupported FORMAT";
  95625. }
  95626. lineIndex += (line.length + 1);
  95627. line = this.readStringLine(uint8array, lineIndex);
  95628. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  95629. var match = sizeRegexp.exec(line);
  95630. // TODO. Support +Y and -X if needed.
  95631. if (!match || match.length < 3) {
  95632. throw "HDR Bad header format, no size";
  95633. }
  95634. width = parseInt(match[2]);
  95635. height = parseInt(match[1]);
  95636. if (width < 8 || width > 0x7fff) {
  95637. throw "HDR Bad header format, unsupported size";
  95638. }
  95639. lineIndex += (line.length + 1);
  95640. return {
  95641. height: height,
  95642. width: width,
  95643. dataPosition: lineIndex
  95644. };
  95645. };
  95646. /**
  95647. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  95648. * This RGBE texture needs to store the information as a panorama.
  95649. *
  95650. * More information on this format are available here:
  95651. * https://en.wikipedia.org/wiki/RGBE_image_format
  95652. *
  95653. * @param buffer The binary file stored in an array buffer.
  95654. * @param size The expected size of the extracted cubemap.
  95655. * @return The Cube Map information.
  95656. */
  95657. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  95658. var uint8array = new Uint8Array(buffer);
  95659. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  95660. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  95661. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  95662. return cubeMapData;
  95663. };
  95664. /**
  95665. * Returns the pixels data extracted from an RGBE texture.
  95666. * This pixels will be stored left to right up to down in the R G B order in one array.
  95667. *
  95668. * More information on this format are available here:
  95669. * https://en.wikipedia.org/wiki/RGBE_image_format
  95670. *
  95671. * @param uint8array The binary file stored in an array buffer.
  95672. * @param hdrInfo The header information of the file.
  95673. * @return The pixels data in RGB right to left up to down order.
  95674. */
  95675. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  95676. // Keep for multi format supports.
  95677. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  95678. };
  95679. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  95680. var num_scanlines = hdrInfo.height;
  95681. var scanline_width = hdrInfo.width;
  95682. var a, b, c, d, count;
  95683. var dataIndex = hdrInfo.dataPosition;
  95684. var index = 0, endIndex = 0, i = 0;
  95685. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  95686. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  95687. // 3 channels of 4 bytes per pixel in float.
  95688. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  95689. var resultArray = new Float32Array(resultBuffer);
  95690. // read in each successive scanline
  95691. while (num_scanlines > 0) {
  95692. a = uint8array[dataIndex++];
  95693. b = uint8array[dataIndex++];
  95694. c = uint8array[dataIndex++];
  95695. d = uint8array[dataIndex++];
  95696. if (a != 2 || b != 2 || (c & 0x80)) {
  95697. // this file is not run length encoded
  95698. throw "HDR Bad header format, not RLE";
  95699. }
  95700. if (((c << 8) | d) != scanline_width) {
  95701. throw "HDR Bad header format, wrong scan line width";
  95702. }
  95703. index = 0;
  95704. // read each of the four channels for the scanline into the buffer
  95705. for (i = 0; i < 4; i++) {
  95706. endIndex = (i + 1) * scanline_width;
  95707. while (index < endIndex) {
  95708. a = uint8array[dataIndex++];
  95709. b = uint8array[dataIndex++];
  95710. if (a > 128) {
  95711. // a run of the same value
  95712. count = a - 128;
  95713. if ((count == 0) || (count > endIndex - index)) {
  95714. throw "HDR Bad Format, bad scanline data (run)";
  95715. }
  95716. while (count-- > 0) {
  95717. scanLineArray[index++] = b;
  95718. }
  95719. }
  95720. else {
  95721. // a non-run
  95722. count = a;
  95723. if ((count == 0) || (count > endIndex - index)) {
  95724. throw "HDR Bad Format, bad scanline data (non-run)";
  95725. }
  95726. scanLineArray[index++] = b;
  95727. if (--count > 0) {
  95728. for (var j = 0; j < count; j++) {
  95729. scanLineArray[index++] = uint8array[dataIndex++];
  95730. }
  95731. }
  95732. }
  95733. }
  95734. }
  95735. // now convert data from buffer into floats
  95736. for (i = 0; i < scanline_width; i++) {
  95737. a = scanLineArray[i];
  95738. b = scanLineArray[i + scanline_width];
  95739. c = scanLineArray[i + 2 * scanline_width];
  95740. d = scanLineArray[i + 3 * scanline_width];
  95741. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  95742. }
  95743. num_scanlines--;
  95744. }
  95745. return resultArray;
  95746. };
  95747. return HDRTools;
  95748. }());
  95749. /***/ }),
  95750. /***/ "./Misc/HighDynamicRange/index.ts":
  95751. /*!****************************************!*\
  95752. !*** ./Misc/HighDynamicRange/index.ts ***!
  95753. \****************************************/
  95754. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  95755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95756. "use strict";
  95757. __webpack_require__.r(__webpack_exports__);
  95758. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  95759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  95760. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  95761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  95762. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  95763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  95764. /***/ }),
  95765. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  95766. /*!****************************************************!*\
  95767. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  95768. \****************************************************/
  95769. /*! exports provided: PanoramaToCubeMapTools */
  95770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95771. "use strict";
  95772. __webpack_require__.r(__webpack_exports__);
  95773. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  95774. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  95775. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  95776. /**
  95777. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  95778. */
  95779. var PanoramaToCubeMapTools = /** @class */ (function () {
  95780. function PanoramaToCubeMapTools() {
  95781. }
  95782. /**
  95783. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  95784. *
  95785. * @param float32Array The source data.
  95786. * @param inputWidth The width of the input panorama.
  95787. * @param inputHeight The height of the input panorama.
  95788. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  95789. * @return The cubemap data
  95790. */
  95791. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  95792. if (!float32Array) {
  95793. throw "ConvertPanoramaToCubemap: input cannot be null";
  95794. }
  95795. if (float32Array.length != inputWidth * inputHeight * 3) {
  95796. throw "ConvertPanoramaToCubemap: input size is wrong";
  95797. }
  95798. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  95799. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  95800. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  95801. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  95802. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  95803. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  95804. return {
  95805. front: textureFront,
  95806. back: textureBack,
  95807. left: textureLeft,
  95808. right: textureRight,
  95809. up: textureUp,
  95810. down: textureDown,
  95811. size: size,
  95812. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  95813. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  95814. gammaSpace: false,
  95815. };
  95816. };
  95817. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  95818. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  95819. var textureArray = new Float32Array(buffer);
  95820. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  95821. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  95822. var dy = 1 / texSize;
  95823. var fy = 0;
  95824. for (var y = 0; y < texSize; y++) {
  95825. var xv1 = faceData[0];
  95826. var xv2 = faceData[2];
  95827. for (var x = 0; x < texSize; x++) {
  95828. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  95829. v.normalize();
  95830. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  95831. // 3 channels per pixels
  95832. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  95833. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  95834. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  95835. xv1 = xv1.add(rotDX1);
  95836. xv2 = xv2.add(rotDX2);
  95837. }
  95838. fy += dy;
  95839. }
  95840. return textureArray;
  95841. };
  95842. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  95843. var theta = Math.atan2(vDir.z, vDir.x);
  95844. var phi = Math.acos(vDir.y);
  95845. while (theta < -Math.PI) {
  95846. theta += 2 * Math.PI;
  95847. }
  95848. while (theta > Math.PI) {
  95849. theta -= 2 * Math.PI;
  95850. }
  95851. var dx = theta / Math.PI;
  95852. var dy = phi / Math.PI;
  95853. // recenter.
  95854. dx = dx * 0.5 + 0.5;
  95855. var px = Math.round(dx * inputWidth);
  95856. if (px < 0) {
  95857. px = 0;
  95858. }
  95859. else if (px >= inputWidth) {
  95860. px = inputWidth - 1;
  95861. }
  95862. var py = Math.round(dy * inputHeight);
  95863. if (py < 0) {
  95864. py = 0;
  95865. }
  95866. else if (py >= inputHeight) {
  95867. py = inputHeight - 1;
  95868. }
  95869. var inputY = (inputHeight - py - 1);
  95870. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  95871. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  95872. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  95873. return {
  95874. r: r,
  95875. g: g,
  95876. b: b
  95877. };
  95878. };
  95879. PanoramaToCubeMapTools.FACE_FRONT = [
  95880. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  95881. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  95882. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  95883. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  95884. ];
  95885. PanoramaToCubeMapTools.FACE_BACK = [
  95886. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  95887. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  95888. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  95889. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  95890. ];
  95891. PanoramaToCubeMapTools.FACE_RIGHT = [
  95892. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  95893. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  95894. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  95895. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  95896. ];
  95897. PanoramaToCubeMapTools.FACE_LEFT = [
  95898. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  95899. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  95900. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  95901. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  95902. ];
  95903. PanoramaToCubeMapTools.FACE_DOWN = [
  95904. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  95905. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  95906. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  95907. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  95908. ];
  95909. PanoramaToCubeMapTools.FACE_UP = [
  95910. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  95911. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  95912. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  95913. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  95914. ];
  95915. return PanoramaToCubeMapTools;
  95916. }());
  95917. /***/ }),
  95918. /***/ "./Misc/andOrNotEvaluator.ts":
  95919. /*!***********************************!*\
  95920. !*** ./Misc/andOrNotEvaluator.ts ***!
  95921. \***********************************/
  95922. /*! exports provided: AndOrNotEvaluator */
  95923. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95924. "use strict";
  95925. __webpack_require__.r(__webpack_exports__);
  95926. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  95927. /**
  95928. * Class used to evalaute queries containing `and` and `or` operators
  95929. */
  95930. var AndOrNotEvaluator = /** @class */ (function () {
  95931. function AndOrNotEvaluator() {
  95932. }
  95933. /**
  95934. * Evaluate a query
  95935. * @param query defines the query to evaluate
  95936. * @param evaluateCallback defines the callback used to filter result
  95937. * @returns true if the query matches
  95938. */
  95939. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  95940. if (!query.match(/\([^\(\)]*\)/g)) {
  95941. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  95942. }
  95943. else {
  95944. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  95945. // remove parenthesis
  95946. r = r.slice(1, r.length - 1);
  95947. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  95948. });
  95949. }
  95950. if (query === "true") {
  95951. return true;
  95952. }
  95953. if (query === "false") {
  95954. return false;
  95955. }
  95956. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  95957. };
  95958. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  95959. evaluateCallback = evaluateCallback || (function (r) {
  95960. return r === "true" ? true : false;
  95961. });
  95962. var result;
  95963. var or = parenthesisContent.split("||");
  95964. for (var i in or) {
  95965. if (or.hasOwnProperty(i)) {
  95966. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  95967. var and = ori.split("&&");
  95968. if (and.length > 1) {
  95969. for (var j = 0; j < and.length; ++j) {
  95970. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  95971. if (andj !== "true" && andj !== "false") {
  95972. if (andj[0] === "!") {
  95973. result = !evaluateCallback(andj.substring(1));
  95974. }
  95975. else {
  95976. result = evaluateCallback(andj);
  95977. }
  95978. }
  95979. else {
  95980. result = andj === "true" ? true : false;
  95981. }
  95982. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  95983. ori = "false";
  95984. break;
  95985. }
  95986. }
  95987. }
  95988. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  95989. result = true;
  95990. break;
  95991. }
  95992. // result equals false (or undefined)
  95993. if (ori !== "true" && ori !== "false") {
  95994. if (ori[0] === "!") {
  95995. result = !evaluateCallback(ori.substring(1));
  95996. }
  95997. else {
  95998. result = evaluateCallback(ori);
  95999. }
  96000. }
  96001. else {
  96002. result = ori === "true" ? true : false;
  96003. }
  96004. }
  96005. }
  96006. // the whole parenthesis scope is replaced by 'true' or 'false'
  96007. return result ? "true" : "false";
  96008. };
  96009. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  96010. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  96011. // remove whitespaces
  96012. r = r.replace(/[\s]/g, function () { return ""; });
  96013. return r.length % 2 ? "!" : "";
  96014. });
  96015. booleanString = booleanString.trim();
  96016. if (booleanString === "!true") {
  96017. booleanString = "false";
  96018. }
  96019. else if (booleanString === "!false") {
  96020. booleanString = "true";
  96021. }
  96022. return booleanString;
  96023. };
  96024. return AndOrNotEvaluator;
  96025. }());
  96026. /***/ }),
  96027. /***/ "./Misc/arrayTools.ts":
  96028. /*!****************************!*\
  96029. !*** ./Misc/arrayTools.ts ***!
  96030. \****************************/
  96031. /*! exports provided: ArrayTools */
  96032. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96033. "use strict";
  96034. __webpack_require__.r(__webpack_exports__);
  96035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  96036. /**
  96037. * Class containing a set of static utilities functions for arrays.
  96038. */
  96039. var ArrayTools = /** @class */ (function () {
  96040. function ArrayTools() {
  96041. }
  96042. /**
  96043. * Returns an array of the given size filled with element built from the given constructor and the paramters
  96044. * @param size the number of element to construct and put in the array
  96045. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  96046. * @returns a new array filled with new objects
  96047. */
  96048. ArrayTools.BuildArray = function (size, itemBuilder) {
  96049. var a = [];
  96050. for (var i = 0; i < size; ++i) {
  96051. a.push(itemBuilder());
  96052. }
  96053. return a;
  96054. };
  96055. return ArrayTools;
  96056. }());
  96057. /***/ }),
  96058. /***/ "./Misc/assetsManager.ts":
  96059. /*!*******************************!*\
  96060. !*** ./Misc/assetsManager.ts ***!
  96061. \*******************************/
  96062. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, EquiRectangularCubeTextureAssetTask, AssetsManager */
  96063. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96064. "use strict";
  96065. __webpack_require__.r(__webpack_exports__);
  96066. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  96067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  96068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  96069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  96070. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  96071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  96072. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  96073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  96074. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  96075. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  96076. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return EquiRectangularCubeTextureAssetTask; });
  96077. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  96078. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  96079. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  96080. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  96081. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  96082. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  96083. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  96084. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  96085. /* harmony import */ var _Materials_Textures_equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/equiRectangularCubeTexture */ "./Materials/Textures/equiRectangularCubeTexture.ts");
  96086. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  96087. /**
  96088. * Defines the list of states available for a task inside a AssetsManager
  96089. */
  96090. var AssetTaskState;
  96091. (function (AssetTaskState) {
  96092. /**
  96093. * Initialization
  96094. */
  96095. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  96096. /**
  96097. * Running
  96098. */
  96099. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  96100. /**
  96101. * Done
  96102. */
  96103. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  96104. /**
  96105. * Error
  96106. */
  96107. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  96108. })(AssetTaskState || (AssetTaskState = {}));
  96109. /**
  96110. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  96111. */
  96112. var AbstractAssetTask = /** @class */ (function () {
  96113. /**
  96114. * Creates a new AssetsManager
  96115. * @param name defines the name of the task
  96116. */
  96117. function AbstractAssetTask(
  96118. /**
  96119. * Task name
  96120. */ name) {
  96121. this.name = name;
  96122. this._isCompleted = false;
  96123. this._taskState = AssetTaskState.INIT;
  96124. }
  96125. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  96126. /**
  96127. * Get if the task is completed
  96128. */
  96129. get: function () {
  96130. return this._isCompleted;
  96131. },
  96132. enumerable: true,
  96133. configurable: true
  96134. });
  96135. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  96136. /**
  96137. * Gets the current state of the task
  96138. */
  96139. get: function () {
  96140. return this._taskState;
  96141. },
  96142. enumerable: true,
  96143. configurable: true
  96144. });
  96145. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  96146. /**
  96147. * Gets the current error object (if task is in error)
  96148. */
  96149. get: function () {
  96150. return this._errorObject;
  96151. },
  96152. enumerable: true,
  96153. configurable: true
  96154. });
  96155. /**
  96156. * Internal only
  96157. * @hidden
  96158. */
  96159. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  96160. if (this._errorObject) {
  96161. return;
  96162. }
  96163. this._errorObject = {
  96164. message: message,
  96165. exception: exception
  96166. };
  96167. };
  96168. /**
  96169. * Execute the current task
  96170. * @param scene defines the scene where you want your assets to be loaded
  96171. * @param onSuccess is a callback called when the task is successfully executed
  96172. * @param onError is a callback called if an error occurs
  96173. */
  96174. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  96175. var _this = this;
  96176. this._taskState = AssetTaskState.RUNNING;
  96177. this.runTask(scene, function () {
  96178. _this.onDoneCallback(onSuccess, onError);
  96179. }, function (msg, exception) {
  96180. _this.onErrorCallback(onError, msg, exception);
  96181. });
  96182. };
  96183. /**
  96184. * Execute the current task
  96185. * @param scene defines the scene where you want your assets to be loaded
  96186. * @param onSuccess is a callback called when the task is successfully executed
  96187. * @param onError is a callback called if an error occurs
  96188. */
  96189. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96190. throw new Error("runTask is not implemented");
  96191. };
  96192. /**
  96193. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  96194. * This can be used with failed tasks that have the reason for failure fixed.
  96195. */
  96196. AbstractAssetTask.prototype.reset = function () {
  96197. this._taskState = AssetTaskState.INIT;
  96198. };
  96199. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  96200. this._taskState = AssetTaskState.ERROR;
  96201. this._errorObject = {
  96202. message: message,
  96203. exception: exception
  96204. };
  96205. if (this.onError) {
  96206. this.onError(this, message, exception);
  96207. }
  96208. onError();
  96209. };
  96210. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  96211. try {
  96212. this._taskState = AssetTaskState.DONE;
  96213. this._isCompleted = true;
  96214. if (this.onSuccess) {
  96215. this.onSuccess(this);
  96216. }
  96217. onSuccess();
  96218. }
  96219. catch (e) {
  96220. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  96221. }
  96222. };
  96223. return AbstractAssetTask;
  96224. }());
  96225. /**
  96226. * Class used to share progress information about assets loading
  96227. */
  96228. var AssetsProgressEvent = /** @class */ (function () {
  96229. /**
  96230. * Creates a AssetsProgressEvent
  96231. * @param remainingCount defines the number of remaining tasks to process
  96232. * @param totalCount defines the total number of tasks
  96233. * @param task defines the task that was just processed
  96234. */
  96235. function AssetsProgressEvent(remainingCount, totalCount, task) {
  96236. this.remainingCount = remainingCount;
  96237. this.totalCount = totalCount;
  96238. this.task = task;
  96239. }
  96240. return AssetsProgressEvent;
  96241. }());
  96242. /**
  96243. * Define a task used by AssetsManager to load meshes
  96244. */
  96245. var MeshAssetTask = /** @class */ (function (_super) {
  96246. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  96247. /**
  96248. * Creates a new MeshAssetTask
  96249. * @param name defines the name of the task
  96250. * @param meshesNames defines the list of mesh's names you want to load
  96251. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  96252. * @param sceneFilename defines the filename of the scene to load from
  96253. */
  96254. function MeshAssetTask(
  96255. /**
  96256. * Defines the name of the task
  96257. */
  96258. name,
  96259. /**
  96260. * Defines the list of mesh's names you want to load
  96261. */
  96262. meshesNames,
  96263. /**
  96264. * Defines the root url to use as a base to load your meshes and associated resources
  96265. */
  96266. rootUrl,
  96267. /**
  96268. * Defines the filename of the scene to load from
  96269. */
  96270. sceneFilename) {
  96271. var _this = _super.call(this, name) || this;
  96272. _this.name = name;
  96273. _this.meshesNames = meshesNames;
  96274. _this.rootUrl = rootUrl;
  96275. _this.sceneFilename = sceneFilename;
  96276. return _this;
  96277. }
  96278. /**
  96279. * Execute the current task
  96280. * @param scene defines the scene where you want your assets to be loaded
  96281. * @param onSuccess is a callback called when the task is successfully executed
  96282. * @param onError is a callback called if an error occurs
  96283. */
  96284. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96285. var _this = this;
  96286. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  96287. _this.loadedMeshes = meshes;
  96288. _this.loadedParticleSystems = particleSystems;
  96289. _this.loadedSkeletons = skeletons;
  96290. _this.loadedAnimationGroups = animationGroups;
  96291. onSuccess();
  96292. }, null, function (scene, message, exception) {
  96293. onError(message, exception);
  96294. });
  96295. };
  96296. return MeshAssetTask;
  96297. }(AbstractAssetTask));
  96298. /**
  96299. * Define a task used by AssetsManager to load text content
  96300. */
  96301. var TextFileAssetTask = /** @class */ (function (_super) {
  96302. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  96303. /**
  96304. * Creates a new TextFileAssetTask object
  96305. * @param name defines the name of the task
  96306. * @param url defines the location of the file to load
  96307. */
  96308. function TextFileAssetTask(
  96309. /**
  96310. * Defines the name of the task
  96311. */
  96312. name,
  96313. /**
  96314. * Defines the location of the file to load
  96315. */
  96316. url) {
  96317. var _this = _super.call(this, name) || this;
  96318. _this.name = name;
  96319. _this.url = url;
  96320. return _this;
  96321. }
  96322. /**
  96323. * Execute the current task
  96324. * @param scene defines the scene where you want your assets to be loaded
  96325. * @param onSuccess is a callback called when the task is successfully executed
  96326. * @param onError is a callback called if an error occurs
  96327. */
  96328. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96329. var _this = this;
  96330. scene._loadFile(this.url, function (data) {
  96331. _this.text = data;
  96332. onSuccess();
  96333. }, undefined, false, false, function (request, exception) {
  96334. if (request) {
  96335. onError(request.status + " " + request.statusText, exception);
  96336. }
  96337. });
  96338. };
  96339. return TextFileAssetTask;
  96340. }(AbstractAssetTask));
  96341. /**
  96342. * Define a task used by AssetsManager to load binary data
  96343. */
  96344. var BinaryFileAssetTask = /** @class */ (function (_super) {
  96345. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  96346. /**
  96347. * Creates a new BinaryFileAssetTask object
  96348. * @param name defines the name of the new task
  96349. * @param url defines the location of the file to load
  96350. */
  96351. function BinaryFileAssetTask(
  96352. /**
  96353. * Defines the name of the task
  96354. */
  96355. name,
  96356. /**
  96357. * Defines the location of the file to load
  96358. */
  96359. url) {
  96360. var _this = _super.call(this, name) || this;
  96361. _this.name = name;
  96362. _this.url = url;
  96363. return _this;
  96364. }
  96365. /**
  96366. * Execute the current task
  96367. * @param scene defines the scene where you want your assets to be loaded
  96368. * @param onSuccess is a callback called when the task is successfully executed
  96369. * @param onError is a callback called if an error occurs
  96370. */
  96371. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96372. var _this = this;
  96373. scene._loadFile(this.url, function (data) {
  96374. _this.data = data;
  96375. onSuccess();
  96376. }, undefined, true, true, function (request, exception) {
  96377. if (request) {
  96378. onError(request.status + " " + request.statusText, exception);
  96379. }
  96380. });
  96381. };
  96382. return BinaryFileAssetTask;
  96383. }(AbstractAssetTask));
  96384. /**
  96385. * Define a task used by AssetsManager to load images
  96386. */
  96387. var ImageAssetTask = /** @class */ (function (_super) {
  96388. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  96389. /**
  96390. * Creates a new ImageAssetTask
  96391. * @param name defines the name of the task
  96392. * @param url defines the location of the image to load
  96393. */
  96394. function ImageAssetTask(
  96395. /**
  96396. * Defines the name of the task
  96397. */
  96398. name,
  96399. /**
  96400. * Defines the location of the image to load
  96401. */
  96402. url) {
  96403. var _this = _super.call(this, name) || this;
  96404. _this.name = name;
  96405. _this.url = url;
  96406. return _this;
  96407. }
  96408. /**
  96409. * Execute the current task
  96410. * @param scene defines the scene where you want your assets to be loaded
  96411. * @param onSuccess is a callback called when the task is successfully executed
  96412. * @param onError is a callback called if an error occurs
  96413. */
  96414. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96415. var _this = this;
  96416. var img = new Image();
  96417. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  96418. img.onload = function () {
  96419. _this.image = img;
  96420. onSuccess();
  96421. };
  96422. img.onerror = function (err) {
  96423. onError("Error loading image", err);
  96424. };
  96425. img.src = this.url;
  96426. };
  96427. return ImageAssetTask;
  96428. }(AbstractAssetTask));
  96429. /**
  96430. * Define a task used by AssetsManager to load 2D textures
  96431. */
  96432. var TextureAssetTask = /** @class */ (function (_super) {
  96433. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  96434. /**
  96435. * Creates a new TextureAssetTask object
  96436. * @param name defines the name of the task
  96437. * @param url defines the location of the file to load
  96438. * @param noMipmap defines if mipmap should not be generated (default is false)
  96439. * @param invertY defines if texture must be inverted on Y axis (default is false)
  96440. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  96441. */
  96442. function TextureAssetTask(
  96443. /**
  96444. * Defines the name of the task
  96445. */
  96446. name,
  96447. /**
  96448. * Defines the location of the file to load
  96449. */
  96450. url,
  96451. /**
  96452. * Defines if mipmap should not be generated (default is false)
  96453. */
  96454. noMipmap,
  96455. /**
  96456. * Defines if texture must be inverted on Y axis (default is false)
  96457. */
  96458. invertY,
  96459. /**
  96460. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  96461. */
  96462. samplingMode) {
  96463. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  96464. var _this = _super.call(this, name) || this;
  96465. _this.name = name;
  96466. _this.url = url;
  96467. _this.noMipmap = noMipmap;
  96468. _this.invertY = invertY;
  96469. _this.samplingMode = samplingMode;
  96470. return _this;
  96471. }
  96472. /**
  96473. * Execute the current task
  96474. * @param scene defines the scene where you want your assets to be loaded
  96475. * @param onSuccess is a callback called when the task is successfully executed
  96476. * @param onError is a callback called if an error occurs
  96477. */
  96478. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96479. var onload = function () {
  96480. onSuccess();
  96481. };
  96482. var onerror = function (message, exception) {
  96483. onError(message, exception);
  96484. };
  96485. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  96486. };
  96487. return TextureAssetTask;
  96488. }(AbstractAssetTask));
  96489. /**
  96490. * Define a task used by AssetsManager to load cube textures
  96491. */
  96492. var CubeTextureAssetTask = /** @class */ (function (_super) {
  96493. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  96494. /**
  96495. * Creates a new CubeTextureAssetTask
  96496. * @param name defines the name of the task
  96497. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  96498. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  96499. * @param noMipmap defines if mipmaps should not be generated (default is false)
  96500. * @param files defines the explicit list of files (undefined by default)
  96501. */
  96502. function CubeTextureAssetTask(
  96503. /**
  96504. * Defines the name of the task
  96505. */
  96506. name,
  96507. /**
  96508. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  96509. */
  96510. url,
  96511. /**
  96512. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  96513. */
  96514. extensions,
  96515. /**
  96516. * Defines if mipmaps should not be generated (default is false)
  96517. */
  96518. noMipmap,
  96519. /**
  96520. * Defines the explicit list of files (undefined by default)
  96521. */
  96522. files) {
  96523. var _this = _super.call(this, name) || this;
  96524. _this.name = name;
  96525. _this.url = url;
  96526. _this.extensions = extensions;
  96527. _this.noMipmap = noMipmap;
  96528. _this.files = files;
  96529. return _this;
  96530. }
  96531. /**
  96532. * Execute the current task
  96533. * @param scene defines the scene where you want your assets to be loaded
  96534. * @param onSuccess is a callback called when the task is successfully executed
  96535. * @param onError is a callback called if an error occurs
  96536. */
  96537. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96538. var onload = function () {
  96539. onSuccess();
  96540. };
  96541. var onerror = function (message, exception) {
  96542. onError(message, exception);
  96543. };
  96544. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  96545. };
  96546. return CubeTextureAssetTask;
  96547. }(AbstractAssetTask));
  96548. /**
  96549. * Define a task used by AssetsManager to load HDR cube textures
  96550. */
  96551. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  96552. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  96553. /**
  96554. * Creates a new HDRCubeTextureAssetTask object
  96555. * @param name defines the name of the task
  96556. * @param url defines the location of the file to load
  96557. * @param size defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
  96558. * @param noMipmap defines if mipmaps should not be generated (default is false)
  96559. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  96560. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  96561. * @param reserved Internal use only
  96562. */
  96563. function HDRCubeTextureAssetTask(
  96564. /**
  96565. * Defines the name of the task
  96566. */
  96567. name,
  96568. /**
  96569. * Defines the location of the file to load
  96570. */
  96571. url,
  96572. /**
  96573. * Defines the desired size (the more it increases the longer the generation will be)
  96574. */
  96575. size,
  96576. /**
  96577. * Defines if mipmaps should not be generated (default is false)
  96578. */
  96579. noMipmap,
  96580. /**
  96581. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  96582. */
  96583. generateHarmonics,
  96584. /**
  96585. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  96586. */
  96587. gammaSpace,
  96588. /**
  96589. * Internal Use Only
  96590. */
  96591. reserved) {
  96592. if (noMipmap === void 0) { noMipmap = false; }
  96593. if (generateHarmonics === void 0) { generateHarmonics = true; }
  96594. if (gammaSpace === void 0) { gammaSpace = false; }
  96595. if (reserved === void 0) { reserved = false; }
  96596. var _this = _super.call(this, name) || this;
  96597. _this.name = name;
  96598. _this.url = url;
  96599. _this.size = size;
  96600. _this.noMipmap = noMipmap;
  96601. _this.generateHarmonics = generateHarmonics;
  96602. _this.gammaSpace = gammaSpace;
  96603. _this.reserved = reserved;
  96604. return _this;
  96605. }
  96606. /**
  96607. * Execute the current task
  96608. * @param scene defines the scene where you want your assets to be loaded
  96609. * @param onSuccess is a callback called when the task is successfully executed
  96610. * @param onError is a callback called if an error occurs
  96611. */
  96612. HDRCubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96613. var onload = function () {
  96614. onSuccess();
  96615. };
  96616. var onerror = function (message, exception) {
  96617. onError(message, exception);
  96618. };
  96619. this.texture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__["HDRCubeTexture"](this.url, scene, this.size, this.noMipmap, this.generateHarmonics, this.gammaSpace, this.reserved, onload, onerror);
  96620. };
  96621. return HDRCubeTextureAssetTask;
  96622. }(AbstractAssetTask));
  96623. /**
  96624. * Define a task used by AssetsManager to load Equirectangular cube textures
  96625. */
  96626. var EquiRectangularCubeTextureAssetTask = /** @class */ (function (_super) {
  96627. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](EquiRectangularCubeTextureAssetTask, _super);
  96628. /**
  96629. * Creates a new EquiRectangularCubeTextureAssetTask object
  96630. * @param name defines the name of the task
  96631. * @param url defines the location of the file to load
  96632. * @param size defines the desired size (the more it increases the longer the generation will be)
  96633. * If the size is omitted this implies you are using a preprocessed cubemap.
  96634. * @param noMipmap defines if mipmaps should not be generated (default is false)
  96635. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  96636. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  96637. * (default is true)
  96638. */
  96639. function EquiRectangularCubeTextureAssetTask(
  96640. /**
  96641. * Defines the name of the task
  96642. */
  96643. name,
  96644. /**
  96645. * Defines the location of the file to load
  96646. */
  96647. url,
  96648. /**
  96649. * Defines the desired size (the more it increases the longer the generation will be)
  96650. */
  96651. size,
  96652. /**
  96653. * Defines if mipmaps should not be generated (default is false)
  96654. */
  96655. noMipmap,
  96656. /**
  96657. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  96658. * but the standard material would require them in Gamma space) (default is true)
  96659. */
  96660. gammaSpace) {
  96661. if (noMipmap === void 0) { noMipmap = false; }
  96662. if (gammaSpace === void 0) { gammaSpace = true; }
  96663. var _this = _super.call(this, name) || this;
  96664. _this.name = name;
  96665. _this.url = url;
  96666. _this.size = size;
  96667. _this.noMipmap = noMipmap;
  96668. _this.gammaSpace = gammaSpace;
  96669. return _this;
  96670. }
  96671. /**
  96672. * Execute the current task
  96673. * @param scene defines the scene where you want your assets to be loaded
  96674. * @param onSuccess is a callback called when the task is successfully executed
  96675. * @param onError is a callback called if an error occurs
  96676. */
  96677. EquiRectangularCubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96678. var onload = function () {
  96679. onSuccess();
  96680. };
  96681. var onerror = function (message, exception) {
  96682. onError(message, exception);
  96683. };
  96684. this.texture = new _Materials_Textures_equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_7__["EquiRectangularCubeTexture"](this.url, scene, this.size, this.noMipmap, this.gammaSpace, onload, onerror);
  96685. };
  96686. return EquiRectangularCubeTextureAssetTask;
  96687. }(AbstractAssetTask));
  96688. /**
  96689. * This class can be used to easily import assets into a scene
  96690. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  96691. */
  96692. var AssetsManager = /** @class */ (function () {
  96693. /**
  96694. * Creates a new AssetsManager
  96695. * @param scene defines the scene to work on
  96696. */
  96697. function AssetsManager(scene) {
  96698. this._isLoading = false;
  96699. this._tasks = new Array();
  96700. this._waitingTasksCount = 0;
  96701. this._totalTasksCount = 0;
  96702. /**
  96703. * Observable called when all tasks are processed
  96704. */
  96705. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96706. /**
  96707. * Observable called when a task had an error
  96708. */
  96709. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96710. /**
  96711. * Observable called when all tasks were executed
  96712. */
  96713. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96714. /**
  96715. * Observable called when a task is done (whatever the result is)
  96716. */
  96717. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96718. /**
  96719. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  96720. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96721. */
  96722. this.useDefaultLoadingScreen = true;
  96723. this._scene = scene;
  96724. }
  96725. /**
  96726. * Add a MeshAssetTask to the list of active tasks
  96727. * @param taskName defines the name of the new task
  96728. * @param meshesNames defines the name of meshes to load
  96729. * @param rootUrl defines the root url to use to locate files
  96730. * @param sceneFilename defines the filename of the scene file
  96731. * @returns a new MeshAssetTask object
  96732. */
  96733. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  96734. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  96735. this._tasks.push(task);
  96736. return task;
  96737. };
  96738. /**
  96739. * Add a TextFileAssetTask to the list of active tasks
  96740. * @param taskName defines the name of the new task
  96741. * @param url defines the url of the file to load
  96742. * @returns a new TextFileAssetTask object
  96743. */
  96744. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  96745. var task = new TextFileAssetTask(taskName, url);
  96746. this._tasks.push(task);
  96747. return task;
  96748. };
  96749. /**
  96750. * Add a BinaryFileAssetTask to the list of active tasks
  96751. * @param taskName defines the name of the new task
  96752. * @param url defines the url of the file to load
  96753. * @returns a new BinaryFileAssetTask object
  96754. */
  96755. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  96756. var task = new BinaryFileAssetTask(taskName, url);
  96757. this._tasks.push(task);
  96758. return task;
  96759. };
  96760. /**
  96761. * Add a ImageAssetTask to the list of active tasks
  96762. * @param taskName defines the name of the new task
  96763. * @param url defines the url of the file to load
  96764. * @returns a new ImageAssetTask object
  96765. */
  96766. AssetsManager.prototype.addImageTask = function (taskName, url) {
  96767. var task = new ImageAssetTask(taskName, url);
  96768. this._tasks.push(task);
  96769. return task;
  96770. };
  96771. /**
  96772. * Add a TextureAssetTask to the list of active tasks
  96773. * @param taskName defines the name of the new task
  96774. * @param url defines the url of the file to load
  96775. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  96776. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  96777. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  96778. * @returns a new TextureAssetTask object
  96779. */
  96780. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  96781. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  96782. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  96783. this._tasks.push(task);
  96784. return task;
  96785. };
  96786. /**
  96787. * Add a CubeTextureAssetTask to the list of active tasks
  96788. * @param taskName defines the name of the new task
  96789. * @param url defines the url of the file to load
  96790. * @param extensions defines the extension to use to load the cube map (can be null)
  96791. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  96792. * @param files defines the list of files to load (can be null)
  96793. * @returns a new CubeTextureAssetTask object
  96794. */
  96795. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  96796. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  96797. this._tasks.push(task);
  96798. return task;
  96799. };
  96800. /**
  96801. *
  96802. * Add a HDRCubeTextureAssetTask to the list of active tasks
  96803. * @param taskName defines the name of the new task
  96804. * @param url defines the url of the file to load
  96805. * @param size defines the size you want for the cubemap (can be null)
  96806. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  96807. * @param generateHarmonics defines if you want to automatically generate (true by default)
  96808. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  96809. * @param reserved Internal use only
  96810. * @returns a new HDRCubeTextureAssetTask object
  96811. */
  96812. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  96813. if (noMipmap === void 0) { noMipmap = false; }
  96814. if (generateHarmonics === void 0) { generateHarmonics = true; }
  96815. if (gammaSpace === void 0) { gammaSpace = false; }
  96816. if (reserved === void 0) { reserved = false; }
  96817. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  96818. this._tasks.push(task);
  96819. return task;
  96820. };
  96821. /**
  96822. *
  96823. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  96824. * @param taskName defines the name of the new task
  96825. * @param url defines the url of the file to load
  96826. * @param size defines the size you want for the cubemap (can be null)
  96827. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  96828. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  96829. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  96830. * @returns a new EquiRectangularCubeTextureAssetTask object
  96831. */
  96832. AssetsManager.prototype.addEquiRectangularCubeTextureAssetTask = function (taskName, url, size, noMipmap, gammaSpace) {
  96833. if (noMipmap === void 0) { noMipmap = false; }
  96834. if (gammaSpace === void 0) { gammaSpace = true; }
  96835. var task = new EquiRectangularCubeTextureAssetTask(taskName, url, size, noMipmap, gammaSpace);
  96836. this._tasks.push(task);
  96837. return task;
  96838. };
  96839. /**
  96840. * Remove a task from the assets manager.
  96841. * @param task the task to remove
  96842. */
  96843. AssetsManager.prototype.removeTask = function (task) {
  96844. var index = this._tasks.indexOf(task);
  96845. if (index > -1) {
  96846. this._tasks.splice(index, 1);
  96847. }
  96848. };
  96849. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  96850. this._waitingTasksCount--;
  96851. try {
  96852. if (this.onProgress) {
  96853. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  96854. }
  96855. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  96856. }
  96857. catch (e) {
  96858. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Error("Error running progress callbacks.");
  96859. console.log(e);
  96860. }
  96861. if (this._waitingTasksCount === 0) {
  96862. try {
  96863. if (this.onFinish) {
  96864. this.onFinish(this._tasks);
  96865. }
  96866. // Let's remove successfull tasks
  96867. var currentTasks = this._tasks.slice();
  96868. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  96869. var task = currentTasks_1[_i];
  96870. if (task.taskState === AssetTaskState.DONE) {
  96871. var index = this._tasks.indexOf(task);
  96872. if (index > -1) {
  96873. this._tasks.splice(index, 1);
  96874. }
  96875. }
  96876. }
  96877. this.onTasksDoneObservable.notifyObservers(this._tasks);
  96878. }
  96879. catch (e) {
  96880. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Error("Error running tasks-done callbacks.");
  96881. console.log(e);
  96882. }
  96883. this._isLoading = false;
  96884. this._scene.getEngine().hideLoadingUI();
  96885. }
  96886. };
  96887. AssetsManager.prototype._runTask = function (task) {
  96888. var _this = this;
  96889. var done = function () {
  96890. try {
  96891. if (_this.onTaskSuccess) {
  96892. _this.onTaskSuccess(task);
  96893. }
  96894. _this.onTaskSuccessObservable.notifyObservers(task);
  96895. _this._decreaseWaitingTasksCount(task);
  96896. }
  96897. catch (e) {
  96898. error("Error executing task success callbacks", e);
  96899. }
  96900. };
  96901. var error = function (message, exception) {
  96902. task._setErrorObject(message, exception);
  96903. if (_this.onTaskError) {
  96904. _this.onTaskError(task);
  96905. }
  96906. _this.onTaskErrorObservable.notifyObservers(task);
  96907. _this._decreaseWaitingTasksCount(task);
  96908. };
  96909. task.run(this._scene, done, error);
  96910. };
  96911. /**
  96912. * Reset the AssetsManager and remove all tasks
  96913. * @return the current instance of the AssetsManager
  96914. */
  96915. AssetsManager.prototype.reset = function () {
  96916. this._isLoading = false;
  96917. this._tasks = new Array();
  96918. return this;
  96919. };
  96920. /**
  96921. * Start the loading process
  96922. * @return the current instance of the AssetsManager
  96923. */
  96924. AssetsManager.prototype.load = function () {
  96925. if (this._isLoading) {
  96926. return this;
  96927. }
  96928. this._isLoading = true;
  96929. this._waitingTasksCount = this._tasks.length;
  96930. this._totalTasksCount = this._tasks.length;
  96931. if (this._waitingTasksCount === 0) {
  96932. this._isLoading = false;
  96933. if (this.onFinish) {
  96934. this.onFinish(this._tasks);
  96935. }
  96936. this.onTasksDoneObservable.notifyObservers(this._tasks);
  96937. return this;
  96938. }
  96939. if (this.useDefaultLoadingScreen) {
  96940. this._scene.getEngine().displayLoadingUI();
  96941. }
  96942. for (var index = 0; index < this._tasks.length; index++) {
  96943. var task = this._tasks[index];
  96944. if (task.taskState === AssetTaskState.INIT) {
  96945. this._runTask(task);
  96946. }
  96947. }
  96948. return this;
  96949. };
  96950. /**
  96951. * Start the loading process as an async operation
  96952. * @return a promise returning the list of failed tasks
  96953. */
  96954. AssetsManager.prototype.loadAsync = function () {
  96955. var _this = this;
  96956. return new Promise(function (resolve, reject) {
  96957. _this.onTasksDoneObservable.addOnce(function (remainingTasks) {
  96958. if (remainingTasks && remainingTasks.length) {
  96959. reject(remainingTasks);
  96960. }
  96961. else {
  96962. resolve();
  96963. }
  96964. });
  96965. });
  96966. };
  96967. return AssetsManager;
  96968. }());
  96969. /***/ }),
  96970. /***/ "./Misc/brdfTextureTools.ts":
  96971. /*!**********************************!*\
  96972. !*** ./Misc/brdfTextureTools.ts ***!
  96973. \**********************************/
  96974. /*! exports provided: BRDFTextureTools */
  96975. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96976. "use strict";
  96977. __webpack_require__.r(__webpack_exports__);
  96978. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BRDFTextureTools", function() { return BRDFTextureTools; });
  96979. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  96980. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96981. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  96982. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  96983. /**
  96984. * Class used to host texture specific utilities
  96985. */
  96986. var BRDFTextureTools = /** @class */ (function () {
  96987. function BRDFTextureTools() {
  96988. }
  96989. /**
  96990. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  96991. * @param texture the texture to expand.
  96992. */
  96993. BRDFTextureTools._ExpandDefaultBRDFTexture = function (texture) {
  96994. // Gets everything ready.
  96995. var engine = texture.getEngine();
  96996. var caps = engine.getCaps();
  96997. var expandTexture = false;
  96998. // If half float available we can uncompress the texture
  96999. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  97000. expandTexture = true;
  97001. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_HALF_FLOAT;
  97002. }
  97003. // If full float available we can uncompress the texture
  97004. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  97005. expandTexture = true;
  97006. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT;
  97007. }
  97008. // Expand the texture if possible
  97009. if (expandTexture) {
  97010. // Do not use during decode.
  97011. texture.isReady = false;
  97012. // Simply run through the decode PP.
  97013. var rgbdPostProcess_1 = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]("rgbdDecode", "rgbdDecode", null, null, 1, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, engine, false, undefined, texture.type, undefined, null, false);
  97014. texture._isRGBD = false;
  97015. texture.invertY = false;
  97016. // Hold the output of the decoding.
  97017. var expandedTexture_1 = engine.createRenderTargetTexture(texture.width, {
  97018. generateDepthBuffer: false,
  97019. generateMipMaps: false,
  97020. generateStencilBuffer: false,
  97021. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  97022. type: texture.type,
  97023. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA
  97024. });
  97025. rgbdPostProcess_1.getEffect().executeWhenCompiled(function () {
  97026. // PP Render Pass
  97027. rgbdPostProcess_1.onApply = function (effect) {
  97028. effect._bindTexture("textureSampler", texture);
  97029. effect.setFloat2("scale", 1, 1);
  97030. };
  97031. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess_1], expandedTexture_1, true);
  97032. // Cleanup
  97033. engine.restoreDefaultFramebuffer();
  97034. engine._releaseTexture(texture);
  97035. engine._releaseFramebufferObjects(expandedTexture_1);
  97036. if (rgbdPostProcess_1) {
  97037. rgbdPostProcess_1.dispose();
  97038. }
  97039. // Internal Swap
  97040. expandedTexture_1._swapAndDie(texture);
  97041. // Ready to get rolling again.
  97042. texture.isReady = true;
  97043. });
  97044. }
  97045. };
  97046. /**
  97047. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  97048. * @param scene defines the hosting scene
  97049. * @returns the environment BRDF texture
  97050. */
  97051. BRDFTextureTools.GetEnvironmentBRDFTexture = function (scene) {
  97052. var _this = this;
  97053. if (!scene.environmentBRDFTexture) {
  97054. // Forces Delayed Texture Loading to prevent undefined error whilst setting RGBD values.
  97055. var useDelayedTextureLoading = scene.useDelayedTextureLoading;
  97056. scene.useDelayedTextureLoading = false;
  97057. var texture = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CreateFromBase64String(this._environmentBRDFBase64Texture, "EnvironmentBRDFTexture", scene, true, true, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].BILINEAR_SAMPLINGMODE);
  97058. texture._texture._isRGBD = true;
  97059. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97060. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97061. scene.environmentBRDFTexture = texture;
  97062. scene.useDelayedTextureLoading = useDelayedTextureLoading;
  97063. texture.onLoadObservable.addOnce(function () {
  97064. _this._ExpandDefaultBRDFTexture(texture._texture);
  97065. });
  97066. }
  97067. return scene.environmentBRDFTexture;
  97068. };
  97069. BRDFTextureTools._environmentBRDFBase64Texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR4Xuy9Ccx261oW9q5v/r7/33ufgalSbWtiTJsmTZOmSdOkpVKsWhxAxIJFQaCKUkpFiiBFKjKPh3PO7hjb2LmNnYxtjbGtbY21rQGkgCgiIKPMM5x99ruatZ7puq/7up/nWd/3bzzABjb/9675Xeu5hnt41rv8s+evW9fz+ZT+W9N/63o6re3v+nlfvq2CbdZT2hbW7dukDbf/a/9uS3G7E69Ln9PifK50sHSMvD2ur3+XY/E2++dyPelDPoU7Jm9XTm2uab86vJ56gvSd80dzXflA+Zul74PHwGuGv/MXLv+kL4Lfp56r3DM8ef6utE10Xnu97fra7uWi2/etZ8BV/F3F+fdni/8Dn9O4KSvt/cxPMa+HY5Qx024OHF3cM7zHdcsy3uAeuu3wPve3S2OVthHH09v5e9BuCT0HHgPlHsjz+3uxNALYAJ9JgAigALyBmQGPQEcAxwRQgVhIogwcIoAG2HYsM1gR3IokEDD5biMBhMeSoLXkweCoAxsGcDoX3Xi3nkCFACnfiQaPARECgPaVAMZjEuAsNttAjIBZSY8HXHkuFctt4Npj2e8+B/ImFOnwEcg9SPEqcNdyDBSZemwipBkwmvMwocG9Gm6nCDUisHpb+iSRTp+2kQTQAJ9cACt8cwRN/Ss5IJBJ7a2qC0AHYK4gUkpuQE2uoTiJfMPw4epjeqdRXYE5Rhu0me7aGCwIKtfFD0sAmklCgWBmG3utbfCrfdtlBUpK6qUIpwCkkUYDIg4yp4QhAeW9GDBwLR6glgysC8PvZq6o2MJMT3jdhtKqI0WiMfeTCMhs54BqzwNPyLueclxzS/3+XQI0jtSSQrmly4ecv249Z+U/gQOoNj+HBKj+yhGEtn9/2C10qLaWLH5Tz6KykeI3FTb7wM0uRJMWlZtmQwgXFgAr23VwDGRjADoPOgMIQ1pigNdnCrbviaqvFMopuDpvHjB8/RXoeI8ydGp4RAM2x13NzQtr74BkQoFZlceBDQTugIlaixa7kbn5nl3wNgVNpxGKi2OvQxJmjOJ24riNB/sKX0VJPS/zjNfTTgAp9s95AIj9K9DPqPQc22+nS6C0eYAGZJMLyF+sPPwGVggXypcH8HggA5gwbCjHhy9v1Z7yDIY4Gie3nIMGrQHUUNVBVeq14rnyOeiBvWjVl8QgQoZ6NajErESk0n0wx4CLFLuXJ5gOE4J8gtV4cW2RlYbvrO5lVWMk10KU6lpwrHbBr8cHn8+EMdH5YPl2H4gANhCmPEABLTsBp/5k+Y1TwGReWlGTgqiy6WFrxXcEQQTilLw8mUP5AIh1pbJnTgUrOiYIVBZKMAXqW7GISigAyjbYgkWfyyqyTTI5ZckLokEehQNxAs8TYMHF8X3w+3kSrcc1qozPAsAUqbfLX8B5AKgyFGBidOcIiB8JAMdZWV4fGak/nU+Sd0BC266CANbTqdp+zPZHmX9Uf1Txju1HxS6DbeeAZtOtavtKAILAhw9B1aCNjhyJELDZrldlFwRB1YT2nJtUNnVTBPJ41Y+dAQwOE2eD6+EBWZ4FDDRUFmUn7ZiLzjkgGbgOTTTintG1y2QiuKh2ZSKrLoDDVt4RI90jc28CMunnC/AK27iBhEB+FHgme78rtk2w5b+vcguSAKLyH5YCfT6ghAgFeAh+H9PXBxcBPiKICjo4fnEE+ODLk1NJQ7M9PACXK2iqgTa1DTpPHo59FYGgNZuM9T1AoBphFMIPIhXPMzG1Q/jBVYceAobVqCElHYo+uzwBPKvGyXBuY1O9YjZBQzOP312TK4PAVjDw/Hn/p5CEJKI2puq15C/jXFz7kiZB2CPLckzzzIPjlMtbPuT89WtK/rUSoOkFMDV/KvflEp6pCnCtH614yRPU0AAScxjvlwGABFFGlgQ12MJD+QCt7HX88bEE2aRFFnhGOdBO5hWsLDOx/mzZT6meSgAa9cLrYnA6O0yqxSDpbG/uFRAXwDWPYUsG1s2Le91Yp8CJsK5VM6wYUJyMGLLqjESsCcykC80XsddknltlRSC/fL+GBFAdXXw97fDrafnnzl+fG4FyIrAAPggD9nsTNQIhsLfziwqAVX+r5IcqAQKMxZlYUBaSQVUog4jWgXJhCGKah1QlQIUDZlDSQCm804n1+6rfQOAqEALA0SCMcwdeqZyqONKIQBsAVoBWKlcvRKnq6YHSKmAa/LJKUZFBJMf3tEdeJvmGY05cIx1XkXIlH8re8/J0SeK6I3LMvQCSAHQYULL8OhfApT6X2BN2v4YSRxW/Hivf4ALcScuPAx9JxxIHwKY6AXiIfC5+mHBNj63rW2cAwyMiDiQnygJ3AQzEZ+6BG+iCGBQ4BqD1cTHlKFTJUA3kyi0RyHF8EAAVWOg+vBCSqLeMFFnct64jOXAcW6SM8wHbLcgEUNT/3BKA2BJsWnoFAahKgGv79V2Bs5WAWkbkHAAMirgnoA1ajN8REKHay/IesCzkDdrzfMR6/B5moHuLORMu1PtKipbG9wGldsSgQVSpqdkWECRtRcPyn1DQGTVvl+rPh7pYOA2tvKxE8DOBJJuq+4/i7rj0SKpN9zA9QpFQbV9EtBxbZ1uPUcYDuAlDAEn5z83i7yRgld91AXZiftMXkG9oAartCqQKQOgIhOKHMX8elsbWF8mgdRSnm0QfJry4SoCEhAwND9EMjFE+wCXXJlS/o7ZK9RXwDhNDl0jsgJ2r81cpz8a0MpfrkJNA53sQqWsHXI8mCXZdCDImRAHmuvljjiO+Z+0FUG5GCMLy6/YcAAB/B30igdOZ4/2dDRJBIKCNQyggxfheNfn4kh8qsSGKei6v5l7VDyQEcSBzWIEKgDeTtkubWQvKg5StfBsXI4DDd2ky2EBirkt3pw3BXbFnQdjGVqSoj9weBi3fB1QqHyaIe0FEZMmmnigfNqoYwDOge4zg1AovQhcCmflOgjgbX4jrCLavWzpCa8/EOQ5xXds2y687f0ObDchdgC4M2E4wqAQYYsiDcrcRDSjVRRiQlQds/5WzAE3mHSoJlJGfIoeW8jezBDON+R7/URIQE4IyJvcJQT5XSzqCLhHJtOFN9pBVh0iil5U+5BhUnM6qw3G2UOCo4w/hkNUGtDWIa3mOgVC8CsjhtVhSN/c7ALl0J0Aqs6BkUkASUWMFiapFKoLwRCgBBJCUf9wE1MCswoEKdOcSChlQf76y8PlOGkeAeYZCMkwg+SlJ4PfIQal9uQZULKW4sAxVi2N1rr2zMusyXx/cKtZXqtrtFJxQ5C4xKBWeARc7D6F2GlAQLu4j3zoRoEwXPqRTkKMBMJt9pWLWAZbX2mON8gDTyTl4Jgbc7lrFd8HxiPdH3N9tkSGAU24DtmU+7gYsTT8lHGjlPhPz13gZFV01BWUbpWr+tazYyMOoI8TkCKg4ISgUtRIQcDwk9xhQ0u4jIQHL6m0bqDn5xANopvZ/vMZfvpGoYbscRNWbLEITA55VGMhAkZMrsfYAqQa3JBsgBiKJUTKuOg9x3PBa8ZljsjCqZojlqPIy/CFCMg6pfEe6ZvNdA+JbPrSGAG0egO36C8p+KTtYe/ttGZBzBKz+uv5fzotMPQLz/r3YRbhqAYDOgdvnDDzJIPNb4BxK8kX5AnQghqk74cJAubXqB7aWBodSMnU8Qw8MdHPMdv/cwOUEnhvEvnLRxnusgD0n0AM5CgmCMp1T2epj9ffu8XuJQFLwEZH5Z9OIH11FJoACfnohSNDwo63/DBnkyyo5gTDbv329AtpokhAOKtq23shiD21ZxIUW9VBwHACYsdomk5+HEiiTGSQ4uCsggqYg/L547mJyMZ5mNqdKRc0Eq0HDAMNrZyJS5SfaXlpqvEfRwOXjRKrIcxoitWUSI8WcUth8TYY81LPoJQs75+2SSM9F0DUYcHfcRLvFgijzdyAC2DL/rQyIQEdXYGYE1jKgz/Tbkh/Z/5QsqH3jBpQqL4AM3Fmv3QOFEDgoe9l/tZ1RAuEsROLPKo6v0VpVoGx34bBDYBxUD14EMQwciGp+CgGggMeOgq45Lnd13MZR8gjAFfYNDBUcoYturN7MmtMwTolJOoN35Ca6oUS+1uVDz38tVQFKAhBagBvQC1gpHJDgB3vPiUAX00MG38TzXtGl1e/lDdJoM5l9vGH4EF03IA+UMkBRPY0TgAcrcgpISra7TOUDhKswpBN1zen9npIAVANdDjrOHQycROMOr0xy0KrjT4C5FwO3R6nU8RHJwgN5AKPgh8EN/iRKaIJDafeAvmf+uBNAUn07GagP/jLYIkIoNzB2BVb9i8x5R+DsugFj277adAYrzcjzFQIkCkhYssIpYKtOQUkedI4qUlXeoQFmPkloQhPhPIrtVVZQgpsHY5DQi4A1TRiVw/ygNMqnnErPDgsw9TLz7lwHbPhIofsE411geVYtgtDEhFUPXVZUY8o7jMQR62n556sDaM1AUSlw2ASkbH3JI1T1hwRhecBQMTAqraw+EYCNz2dife4baDfHJRyNks3affEAYGCyIk8lEVlRZdKunVcBVA1YNUiniIE7INmhUIwMmmVKcxFIFGGNMvDTYMZcSrnO7BbbRzxae+6ufViQUZR/wX2738WFVoIICgYKW8jvQd8Bt4Xx6Aggeh9AHPejamN23ycF7Qs/mouoFrmC264z+yEYOKPP5ABZ9y64VYJOOYfIFaBSSVeAmWKRA0DlEqpbH2XFePkjHqj9TH65v6gMKfw0lpHPpxS5objAaP5FmjOhQ5PEdnyRhFMEV3cdJe3w/uNZguVpk6AiIPMABGJ1X0ffyZDUCNwgavB9SviJbiMTQGkCyglA1QFI8bypBHAuAOcHRK6g2K1uHK8tvrTx0/kAn2TD47Ux7sOB+shrdn8yhqfKASufBbi2h2FPQX7WXdUPiCPt6hUujXs7aB9VGmTnMhrkADgmPaO+Qez72CafOfdQb6JO1Kl7xgpNhDIq5Y3W1+cXOJiZ9cuH7SEA9gCUeQC5538v2aVLUZWApt4JrOkhROqPDoG2LczZrQBwchCYeBjrk+pB0rFlrGEosLswrD/OFdT7AgqGg5oVy5NLRXZ+vAKoA5C6hBreI3YzNIja9Qg1AdVvY7oRRpQl1wAVDUk9hVXKq4gDvh9/g6LgziGMQExuxwBMuIUeifVast11dZJ9LCYu1IDxh8pf/l4+7PyNtQpgfxUoE0EH/GWAaTdQ1EWECFV1RO8ArwubeoISotjfgFGp8UDRe3G6BK4KKYq5xhgUH6wAJ6s6D6gQpBznsvLwgAqsOEK68YO3s5bMhD09AlACWQQi5VIM0COwiuWjmDx0FjzvgxW/13pcSnnm2dC9jZKl5WGIHhFNACqPkc7lCGCU/TcuwLmCMeiNQzDg7gPa234RHqBysJPAhxG6hbhfwKgpxfkxMAHCgmTUwJtOEiqVrC61/EFg7Ci3AppXF9Atdh+kuFUdFaCFojm3IgECEBeK60kKAHUoZhfuS4B7lAcwKh8kHHUmH0u9nhSqkjviFgRiXI1fXwmA3wWgG39aP0BR1aPqnwY9WGhX/89DsRsKiPZfyAHg4EOlaOAC8jDEAKZOuQJUdraYUtl9vkFZP6tmgyShUB0GD37PSLldTG8SgA0AQ3VXRAT3xrgIJiiy3CoB6UDEJNa+YIYoJeciRxERlrPMMCaCZKLKvxSQmu/vzhkkEtnBgeIj+PHK6nLcNpOkeYZ0rOXX1xCAXgZi2oCx3s+WPq8zbiBfmgE6lP/KhWGcXZfBvji4iBAkmA2ZEIvS8QuBpfthldqqIZUWYdA64OLgRIUS2fUjrgEJLSozuUQmgUu6jXAbqxSOLAJra++HJ1McpC9K8Q8fRyQ9DVgDZ6G+W+WKSgxarVWoJglCnHtEIJVTpkuB9hozAeQkYGc6sCkD7oABN5AHeHUDBVTlC5mWX6X+jRwQmCVcqOUpTtzV4zfrjsAyYQMCV8XonbLfbPa/PT/rYurDDkkBO8/INeQnzOpolZlUipXWKEE9IDQf2az/oQSgIRGtvt0KRUURfiMYpNWJtaGO5SyrblSVKcfu9SWMzl9DEQ3uci09lY2Sn4ZAQDzqZZdzd8qY+OQrwdKxdJiR7tXy68//X2sF3kCArwTLLiCe/PMY9S+jEx2BBYyr2e+DQOQITJ2/Dex54Jfz0r4DV8AAQXWwyq7sPHK6Tc6MrHy8Pg8DVhAR9w5bgyN1V+oULkOw4rXZ5bpa4O/ZSKGZeJ26qnzFvlGrKjk1N+sZZoqgAoLo5R4UuTNpmVKtPgcLVCWC/B2ciwDS3gmgtgLvBJB7Ajrgt/kBTPwBkKlvIJ0zWF8v6A1KBIaVgTYgfaNQ0C8gyMEMD6oy1DME+QPnGsiiIrnU8wDDj9aPzh+pUDsFERYMHv7eJjwZqa5UdgzbiEQiIA2TewFoRCIyJhrhToj8nMqO1rcHA+a9XKslGA9g+508AYr1GCLAd1/+BXAAGwjw58AR6M3ed6x/vhKb5KOcQQXQRE9A7ari+j8QyUR2P3QEMJhVlaGJQL6hLkywKoKgsU7AZs8ZXHbboHKgBgwmKqMBxZliBbyZBKDscAs64jjnkVlGWWG+T45EgOwiwmF9xiYmDUzqeETVVSVRhKgkDiCIgFh0olCQaxl0ZmwSGdbrKTgYrBfHLGQHBFC6AakBCJOBEPcnV065AEwEFqA/QvVVCIBKZ5xE/nLVHnNVARUbB7/L8nMeQrgDAQKfjGykYHQDHEAT+UIsvgUX93XlJgFqoxKiPDSTyFMJNbmfcikiuabAzddpwTtSvn4LrrpWbvIqAx+eLiwSSt9UwOZMRNLNPDNa71UaQatzJ6b7kUBfL1qRNwIer9q4knS1mQC2o9gZgbIfQCT+ynYtUUd5AdMViKQRdAIa1dfJQZkPeArw4cZgXBqWDYGd8VraYhjmLuGo1mUYmAdkE4M8gJAQq2ry/hTj2n3QlSAcGilFaqxUVS/zyuSB0FfPIYmMlLKj6JbwgHxgRgS3RHviCPaTBGG3rcajNolZUnDrAxvfnqQ6vsqptO2W33D+pjVNBW4EMAX+mpgTicCB+isAO1U3vf0+BHCKT0qPA8e4B8wH4OCJYvSIHBhcYP10M0+5IpX4U27DNiXVLfA8Nc4m5arPt8AyyI5z9yHeQ1CR2BmIwa9IyBCmrezX17mRarXsugaNTiBqUnMuw90fIiqZVwDiFm6nKLJ1AUF1xXzXvAfdt6b+9GzpXsq8C7uPzrGJAHJ8nysBhgjodeCqDFjdgAoFirJHGf2q4FAdEACtpcEg9m84toM/zgMwucBwCcOE3ja4DocenKehOQ8FAdD80FgBR+VAsz5oJXXVBGnpo9IgAaHIlEzqiZJm+cYAQgsee96oEUiXtqicWiV0UFkogIzICwEb5DdGuQv3Pei+heszmKOKST2MChGUWBA5VAIwrwI7l5Bgu6HnWoKzbcDQHASKb+P3fqJPdwQWRmTF7FQIuurPwLPHxRIK21NPGn3gcznGOQ8kNBp0DQ8+HuQEEqtMz3HUKzZOJjOQUsIjQBYOQg1Uc71MbF0CadfplLXadOuompaDc+BkKbkNXaf3eZlCVPIc7CzpHI0g8nUJVVbfsQ2T8n2UI6IxI1xCdOzlN9YQoDQDbe8FhERgbt1V4J9OBAbqb/IGBGIdJsCtL+xmQgUcMAeB784/ytzT8XF/UFRHMNW22wHGCSwNavH9m4fQvw6rADeZ9T+UAKyXpgajzrp3yWKkxhVHHhBIvDqRZgmQXZMBemCfdVYfBIJzAJnoXJs2EIUF6YjY7Pdmp9gNIeDaMgHAj4PWXoDtkEFFQM73L3YvhxGh5QeFB9uf8EPqn8MFta5lxicnBWFyUYAVb6AELSaTEECsmAQu88B761JbCoDY21a53rgKqy5tiMCzKYqr5hQAOcnYUtnfIAutEmxqkJprNM+lkV0BZEhITSYLzGCIE1BCQNP5Bq6Bk7+Pdwd4B5Q7EOsFuTwqRNheCZYcQHkbcHshSCnxuV4A/jFQfBlIeYBmYk405dfH+sZyF+UqD2yg9N7Kl+FGg79Ty4+B3x7MlKJTEonBgAPZgjpI/HUdxcgV4MAOSKVnXwXo+ZpN/MrJVACnsqHqWPCNAFeQ0wESa7dGOQEPKHUNVbfrIQJ1LeeVYZK4z4bQ8Vv5a023KfiO+R46sgzcZL09kBeI9l1+4/mbN/mHFuD9F0HbLwTz36jsuQ/AN/6gkkfvA9BqX8Dis/xC6UmJnYpPrEfTZh6A3Nc/JLTqbO8Q+EhubVwASdXxYZOX5vqGMwEVwPuuQCWfZJKQBvMoL1GPaxQX9pIJqpjMKvakSxGACpxJlFTUSTigC7heF88XkgOCiIiGn2fbFfco32eOiKYqAeIat0XLbzp/M5QBs33fQR8QAai8aQTC5aYKgKFBUThUf87Ccx8BgM6oNzkItPjFPTCrKhuP24ZhAgGfVLGr6KyIImRQg9JE0nCMxhNtkDThEoNoYj5AwyjqBAxCvG+gvjFRdNQuOpZQS6da/KzwWkid00ehqJ0SnwPtTBhQgEXuISYARYLBfYfvh3c0x4p57ey+QCYwnoAASuafp/4CKewAwex/+Zxv9nZgUb8vpbum7pFDyF8TcgNVI8sorevK47UEg8ozCgvatqzEVoWdsyiDC9RNq71NJFq34bPMdtAUxwN7KdVUdlTZ9oESm3MH/fXOxaCq9MDZBUd5fm2IF/AmTrAqaIBAoDeupJbP2pgyxz2YpHNkVMVCX3ev7DdFDkFZ77H78rMrrmEngPYyEHgNGAK9/G1e/rkdEsGnGoJoPbkESRZGhZV7sIBI4w4AjAPRxfvgNsR+mA02gEbwUJwW2XxUZSQQHhhORTtq37Xdw1jdKw8PJhfCCHWzRDGX3VfgmU3oKVDX6hESEDXq7gPckJIFKj7rxgXGdxmFtc8Qj6X2IfdBBBiSQyUtrdae/Cw5soBUA6Fe457PtfyL529JIUDOA4zj/5wfcFl+Uv8Cyv1fPyGIXUF9qJzsK/sX8kDgvmjg98Dds/ITNp8HHD4sV/Iz5ASDbdrOm6Nn4dMDdQR6c91RYxERhVbi6v1LvcNodK8jEMm0qLgnlQw643SM56rnLeQQqam7/nwyvhfhtcgkYQ+s+Iw1qfq8g3JGR4ljPVUCaD8NHrgAUv9qz8yEoPIQAPR1fRz/s5NA6yfXdeL9+sghVJBWf+QUCv8juGFwNUs1b/OtW4hLfiOVta7BJv6G+wK5WHgoK56PRqDqkZkFhQU9g3Zs7wfhwahsicXAA0k8b5c7RIJ0NqX0mpyNWpOzKeDvJSoRM7h9OW5EXjsB+IlA7QdCqyPA+B+TfEgARaWd+peBVKgUwoVyXKfwvvMvjUNyFEYto3xAuek+BEBr13IGloVtOFCecgA8zj47V4EwaPfD2Ds+hrBwOEhZyXqOYgz6QtRsOK26uHNWMIrvlwd0e35+WNZB28s/IDDEPZKKPKveKvSiONw5BnZ+AriRy9AvFBXkQLmK8TV4Z9AjjuXDawiQmoF8CHDOoZRN/tX+gEoMj1P/FB5YgnDhgWgSUvuZUEMQAzqBpwMfHoXLFtsEHrNzE1TKUsvqAgEK1NgMF1I4BttItbsJPpOMixVMkgJcL+totbXDRF/sBBQg8I4VUmA6a+cG+w0AlrkHcR+c46lSHt+n0T49wKLzZKW398ITgXcB62n58PNf33MAthcAMv9VcYNqAMf3rgowjv+bwgrVL4MDlLRsL/cbAL8OQgSb+duCMp4S3Oxtcw68Lw675j56au9jcmWjtV1HYnFgm+jbj52EGsyjBKBSsyISFnSPyhlIex+7D3zuSArOEWUAPzpJSC6l3aUeIPF+BC6g7k6iYVzH8XXLb84E0H4dWLgAsP9NnSnpp0KEieRf2P4ryn3KiiuAovo5q6wqA5k0pCsg++1i/4w6va+107gNDzzMitvtKHlH1rer3NyRWAZLHkyjBJ9TjKjSMJNxD5yLUUPlYtQAN66C7g8DePaYBrgBCB05WOAyAbfEnQd4RDwtQekJwycCJ4jDuBrafnspKBIA/zYAv/EnBH+YB4jVv5f1d4pq1L+M3sZ2lRhggCrga/UH1uxYcEM09T6O9oXH7MIEP3XVkQsA1g7J2BU4YglBP1JjbbuVMjoiyYRqwG2A7PMMChBMmH01zQ8lJJrYkdiyYgOJDgM8Idvv+QSlB7JSdj3zD7yuZMbmw/ehPMd2PysBpNh/awkusX6uBvCEIIj504AtMTyDfWYOACblbAKvHtuAAFwHVQKUDe8n7wLwhkk7aEWmiTvTIYBxGp4cTOynLLtLOlUpd4PCVhzsQEG3YYGn+9Hx+yE8HMA7A5hdzWOPo67XLVP19OmQge4VEddjkncezNS7wudQHYyQkORQbVglMC7VuoDlt+whQJkKfLZTgWuv/xYW4Cu8EPTb0Rns21dGQOdbMFEStIm8OKtvjm+ARUAVZTwXItD+VhGA2CoF21jLuwOKRTlMoHp6D2BmrgFl2lmhXJkRtscrMoAR12bXazvMdtcOSriyTqZ8hhQcUYgwpKfATHZRgo3vT7PiFjBehe36CJz6nQMqfKGxY8ihF5rkdRQelXujCHdbtvyW87fWRqBUDoQ3A7vaP0wSUrMAwzxAuTj8t5MczIBM/2SCQZCinQ5i+sO5ASQsJhS8HnYk+bNT3CrO5YECmeVR5MKUolz0EC1h0YCr46UMjo4rgO+hgBCGIK7WPUsKSk1F/wMMcme7a7QD95FaiUys3S3nIQzstT0pDDDXb7+fJwx1T+haypgSzkCRswW5vU/9dWsigNoHkJ1AfSFIN/lX7H++pAN5gJpbQIAXJar/ti/Ssv4wyFG5wFnIUh+WETlhxbF5RCiGBArIyAmoZBiHFHUbfJR9cjAPvVeSU/0DHdAjafE58D5GgxiJqausQGgqrjbLZB+AVso5dRfVisBFSKse2DVzzl4AACAASURBVHG+d6MEnXQYBuiW2I1iK0Ew5ABYKQ+Lehii/MnyW8EBtLn/KRdQau2+5l/WlWQOhwQ2XDBKzgB3YUG5VF8StOEBxFHkCOpgDpJ6VlExD5Fvu0wmwkDq5QmUWyDQtudJqk3TfavOItnhoAnsdQxs0Z+AjSZRqRAVbjAY0UVEg85+L0sdEZAs2RB5wqBHb5IuOyCPACh2//yJvvNjVT0kGHN85VK8Q5gjq57bSOsyAWwjPs8HKEm9Eg5so8kk+loizlcFOO4/lgdw6l3IAQEkljkrLVW8PMzYRbC9MrxqQMiKzQnC4hCs+sgYPSqtuapByaPoARIm9vi62T4LgLSchAKaB5QlHLG+5iLmgcv9ENahoJ62p1R4augyOknCI7F6pOrq/E28OkpPqv441+DJwpNqu2fLbzv/jTYZKHoHwP6EN4IojCqmBHPSrwzgEsO7z+WR6ux/U3FMILJCU4LOOAGt2D5WR863wI6Se2HWP6iHz+QHQhC5EKLdA1ZY7Rj89xvF/3PHVUQEy6AioJyAUbDJON8AonIsEYCZFdghiumuPrp/oduAc1EeIu1iw8WyLCI2v/1YzfWxjIzBhKi0tSGAWgoE1Vf2Pylu3/bXLH0lgDI4JjoDEUhVwRQ4SdXREncU+wiw02EC11CTdnST6/YKEDZDbodXGdWBiprvBI8bwMbWUFYReslGHqwB0PouwcfdTE5IHxYgvKaFaGqf4bJ8z4bbgfriMzEJRoyrxbOIvscbkx8YKD187/A7bCHA5gCO2H9j++nloHZdnAdwTUC9+QAVgOQEjM1v7GrUtpPg06oMLC3zAHo95ibMQOMchCGTHjkUYmvbGEUgxeyp6UhpjUaaQROAOMg7WPUZ9BNUC26/X8uPsmqp+yAciAG7B4iKm8NldC+G+QxwBvOqLr4D5mTYNXTufQG5cnfdEOAj9hAg9QHUMmD9bFXeuYFi+00F4EAeAKoAM6RQkpL1BiPAVL4AW5FZyWViDpR+Yj2/xBETYDiwHNnk5262EdeH3zO00ex08kB0eRFshJnpDyhOgJQECcMM9N51sLrOkoiK1UWi8gg4jboLp9ZTyylnYBwUEVxQTj0GWrzrjSgr/7hQIwoB0vLlI85/s00Gyom/NiMwzwswNf9W/quhANf/XYiQL9pYaVR0tPciJyCBPJcbSLiKLfzICYzW4/HNgxxVCgTAYtLQbsG4jV55sESgFb02HmV7bgc6JTLrSS1ZpgHIce6g6jAJ8BnlDsFJ8fiTEoSkzvI7B0QYq3AP0D4UHIUT2n3g3bGksRMAhgDoAvS7AEQzkLPwg/ZgtX1WwHT/tv9PBIFAzuvH4A6AT6HBKCfg1nPTkJswVAgPIZpvfJR1FwMndBRFUUXyDMHMoIjtfpBzEE7FDjD41MtDRLa23BKqWc8obTsdK5xV3dCxKEcULQuIs+cWIiDy9TyOGHx45kOAdqZuCPCR2QHYtwDTjEByAHPlP1b4WPGLylqlbtvXmwmq2pTZVwIsCJAELCF0bToBshET3PygycfyregzMGpNCpvPa9WlQyiVKAXZwAwBk8jMfvFQwrCQDhJ1B0QGxL1SY+Qc8jWq645UkJ1LlEnnigs7qX4Y0AOWIh+7vSK3uRDAHvuo0kf3YvnI87eBA8DXgQEJgKV3th/yAC1Gty/5aPsE6l5jefE+AFNa65TpyOa3LDUkCKW7gMfvYlNR31dKzfup5J9yDfXUbMkHbkGA0JCOs73aiaiBb1xCvV+s+0CkSCZAXmy1GZyj5GR8be4KTWkLcx+VQ5zDmAPxTOhhibq5EXP9ktRniGFG6Y8Qg72+7ejLbz9/m58LUMuA29uAfMlPZvupFdgTReshwISfU3eXzFOTe1T874EunYABq2jogUFfj+gAzgBosW7XVRS1M0DpE1C6nHiwzIQJrDASjILYlMpE5xsCNmp4AnAitJlyMCQsoBsRmAYnHnkMQnYysVvokcr4PHMu4MhxPNj5/hoCaLG/sv+cDMyXS9n/Rgz5JpdYvgwu+bkdS5MBHkttC+Ymyg2QYvrEnlBgAoTO5ItkWtj7H51DJdkEwVQ5E4m2TCyNu/z+zWx01nFSTrmdXpmKWpm9b2CFFAO6Q3YKJP2kHsIXzh02Hr1IZzCTwDsC6Mcovd3HEn/6tHwUOIBU5qMXgir7X4G8HSQnBct2FWylZbjTDgxlQB3Ti31Nwo2n6qJb8Ouq8whKfO0GCYeh9qm23qvKVOKwALdT17fEg/qjcwus2tH+JibsJRO5dZgSnu58QEbSQYD78XGpt7w8aNm9pPGHA13bZqV+0gkNrj9SanVd6vu/cUpPY8N8D036uwP4qPPfCsqA4oUgNXtvW4Fr8k4QQ+KDTBQYBxelFJbf7IMq1N22uANOqtGXl4lEdhHl0c2FCO1644TeODRo18/AwLgWB7LVNyYEPSA4e26uq7iMKF+BTiOy7k+y+qTYxoHEA1wp2ygHESYIu8DxRL8nDPND8TkD7QLU9U4Rw3LEMVi3FX3fnQBaGZDtP/1GQFX5pu7JNeiQwAI5f20OA5RzYLU1CT6I9SvzdyoBhoCorTdQ9XGIQMnMPGjS5YzDiTqMxACvgyNKJPYqCAjQUd4gg50n3dghawdRS6wqpY4HpwQjXB8Dpw/eHqg6KiiJyV6zVuzHO4oIdMr5jLdFlxMreuQ6zPJKJOtp+R3GAaSOQN//r5KBAejrHAFeT5+F/S9K1xKI+UsL1TbbFgBGlQDTSOStcwGu4feZikAH8F5ZAzdR4u4AEOraWC1kfgJLgNBTkXCvYN7Abs85r7zRfi/C6jfy4cGvVXnG8s9c1xGw9p3IWL29gwgch3mGkdLPEcbyO87fLhyABbyu+2+XyxOCbPkvxWfZ/le16+UEUMlVyY9cBAMQiUKBs4YiwgmYcmO+8dVhRCFCISgcJgAksX+6JxpUbTG4HLbdxjXgMB+dN1DtvJskrIgsHDnOgdCdI7gPeHcUYc0q9VyCsOcCYgDOHLvEBnPEgFsFzmuinDl2EvbYy0efv92XAXcwxMnAAuym1CUkwFJfIgi0xLpKgM6gAC8CehmtCBBSVswTqFhWEREO9GELbz43uo3qQPyA8fE7KRiTVs3Ee5JyuYEpG23bce0w44HmCW2kknZwl2epCO5Y2KBiYh8qtOsdXedTiOTFuwAdxmhio22X2JE1wvGuIDr2TgCuFbh2/gEJkNrLWYHG1mflr0osSAKteRjnA2CgYahl9J9QCSCCqjdJxd8E+C6wjzQCkT2PYvC+zS+E2bPr5BaEk+jF3gZ8naoFq3cIWraxg0qEGsCjXIHdp6fm1i4zqUWqOusCZo93hGimlR7ifeVElt95/tvZAbye1Vr9OCiEBJAI7CYATdyeyQAAzJWDxBOKNMpXpfCALD5P+EkPB50EaIpRXbtN3WoimVdvaAD4ELTC+hp7bNYLUKtrG9h1b/GDMCQ4t3MfnX6AFq8HjijJsZ48BOseA3qkOa16PSdCJJmvcfY4RwDs4/04BBgT0NGQoW2/E4CpAuyqHGT/tynDGaje/mPdv9lkkyfougEIHyIywAlBmYjaw+lVAgY9AZksfPbfDpbqRQSAo9h+FALIfgFM01EfvbTwISHo68d+CAXEkCx6lQkAyxGyGFn9XtmS3UYMlL7CKzDOqLZSVL1MWPLFZggeY9+Z7I4dI+29/EvVAWzgxrhf2P8cX2v7rxOAwzyAidPbMfybg0WugBN3w/gfwgl2EC4bD3kGpdiiStBczAzwMI8xEe/n62U1miOEQO2NwrVr6AHYW/o2uM2A7JBF7zv0VV+rJIO1d42KNOw5tTOZdQFHlH1MPLEjOS1t/BQSj1xVb/lOANUBqOTf5gagGzAp3a7rOWTAfxGkUAFQyj+qEDhiKI+gUx3gpCOBHFVa2fcSNijrrpQ68QKRipnGHAAvE4oE76hKcCRJCDZ96DQOlQbnrHLPjo+sepQLMUCs9/7pCu/A6ADmQ4exNdfPvwdI5SDG5xEhACQLe85g+Zjzd7QqQHUAnYYgWfrLj0V0AjbbvP0FLkFWCHzXYPry+SiDRKGN3wGYrEYMWpGJnwX8Uy3+FDCVA0Fwl7+HuYFAQaOQJo3UTqzuj+fUd7ZSAefqu4Dx9TzdRcw4DSb+Adi7gOzvq92HF57DDmA5nXYCaA4AgS+mA1eHYJXe/IhojadtHkD/GAiCFC23XV5vgEss+gSh3HbGCXB+IcjOK8ArN4Gs/dT1ZshHoUcGKg+WrkuZArdudWWlUlSggRgPdm/dZ7Z9MYQwQxqjfMVRZZ8KATJxvDBnAONk+z7LxxoHwAlAOx/A2X9WfBMWZO2umX3RMhx2A3oyqE4A1FxWDcqgrjb7gBMwHYNlSASdg9RjYBJnXcXWjUAu8abKjgKwsQPR4DFA7XUf1lCD7eX4uAYoHVeCR5oBYJ90WlChLLPdd4Y0bBCy33oRdytg6mX2Pka2fjaRWckmdBZz51s+9vyd5AC4AUi0BocdgPhCD8oTjHoEhpl/DAPIXRSTKpt4fDKvPSBRHTjiBMhZWBXsEAea6lDR2wMsOQl3/IgQzHX5we7IxoEdIPxIAGuw9q+FCSFORs5ZdAb905KDkeX2uQFzno6CI8WUOP1R8T6puiOg3AugHMfyu87f2c0BVNXfS4DzCcBi+f1rvrbLs0RhbXsf6N08Qh34Cjx4XPvQzDU6BwFOoAf4KBk4kdSbDhEq0R0H9egcfQWm+wUDzpNJxyG4ezRDCLGyx4Cm40oQziX1RiQyC1gFdgXI014enFPv2XPbJKA99k4AugrQeSNw+ZWgrhPIQDfKfqAbsJMwNO3FBPpWnYCBaAaeUn3RTVgGOTYvuWUCGIFi1oc6Wt/LPUwpfnM8DOoGpcE2gsx6dr3vTMYhA4PjxVl9/p7tWiwo1DXqMKEuHbTk4r2udp2UWpHuNKg7qq5CEH3c9bT8y+fvSg7gVH4XAC1/8HLQrhPI1p8sf3oUrPzCyqucgVHR3j75lu53oF2HOW/UHciE45pxvAXsWfOwioB2m65TWfM6kCYy/BKIw/2OuwlvzS2wuoSQv7MmJ22z6/GEkvcShzO5gHFYMFLjScU+oOwvxAHMlgE3AtgdwK7qBfD8MpBm/znj75qCMDnGrwwzai0ah0I1t2FBHTzRNGHOJ0jQvwAnAJY8Bi/1LYC9g+xEFiStzDJmh975vgIL4lIW3hHFEeWOlbYHMHvdcyRiieNpIURIENA/z85nTCqaxKaTe9NEcew88vxbGfDjzn9nXdfXoQsQSAAagJK17lQFVJJPqLl8O5DJvqsZhPnyzSD1cwNMVYCPWewzq65JwsFNxWoDgvZgrG9BHoPRgEEkBkcg1/uPY3dJLuh+ZhqERMUgAvc8ITQTPU4GWpWeCyHaPnb7QVKP7k2196S4fMxpa9+6XtKhg2rMvrySBX9/71qicGMnAOsAsAXYVgBUC3CLuVVnIAx/IAP3CrFu1x9CCDPr1hUkXEP4YVTfAs8RRd633SQMM1hl/Dq7BU1PxkYmQyT+4YYuokc6wSBRhFGXdXv6NTDGRBGTTQzgx+zDJHocsGsXrNbNzCt+7GAkiKeqAxFJ9Zbn6ycXExHQ8rt3B1DmARTAp/ZffEloiqMzwNjaiw7AekLeJytzywmg6or8QRAW2ONDzC+Sdq21FwnJ5gkSkellRsUphu9Zf3negf3WwA1A2SEGR0rFAUnCKHdT6fYkIYTXQgQqLG5MLo8JCxjAjyAIysKzo1CZ+lEu4VEO4JFz/1UOwTmAfOzl95y/ew8BUhIQGoHMxKDtkFQVoAqAcQIq2VcdACp1IZV8ea7VV6g8txCze5CEwQNcH7e4CHxYlZ6IHMw2eZ0CXSG6dJmsXrwEr0sfbRrYT1D5GUCOHUH8XTmujo41tv6xRXaADOfFjwlixgU4ktiGucsleGsu95stAwYTguqYA7IPHUAiAHQADejmrUDGAaj3A3AfP7kFGeejXe6QAWTo0xeh/Qag5/DAgpfCg8gJiAYhCUY1r8Ak/goBHggBqOtQEdQ0MZATcI6jEp0Gl3IoCKEeaKN99zM5gHLo5T/3VLdALYqhR4q9r+8o8Gh/vidOgctzmOzkm1J1fLaGfDwZ75turcAfnwmglQGTC6iWv1QGqvLie/62A9vP1tqryT+4T75NGLsPyoBVM9FRuBKeSBASaZjhxMcqzCnBbHMN0i1kQmrnsLbUOYHwtWBKRWlZ2FdQANyGzog4HgPePiHw9Vu1ndl3fE0BUb3QOH/gEiYz949S+x3IHNbosEyTXWfbrQrw8efvyUnA103M30ICSwiVGIAQWvJN5AlkC7BX/gqWiAxEac928E1UBSowvfXmbsCedW8kF6u4sbUHk3i2h2AybBhm4uPwgtWJPZFdfxzEw3DBNbXMnSO67qJuXcfB9viJhKEU3qh2kPQ7Tgo2jGCnosmi4wA+4fw9YQhQ+wJqQnCQCzCkUMy6qA5E3YFSyeHijVJSuZCy/nWvamnxOOVx4Y1R3YDAnmSNDYW4dWxXYeu8bWzZGX75GgYuYaTuQxC6DEVMPD3gKb8xVvH5c3VBX2Pip4UPXTAf6MCbAbez9t24vrk6RXJRuLNNYgpzAJ9w/t71lJOADfA0LbjE/y7bn3MBocqneF3P2ustB4CarP5M7I/QRNUj1Q9sf+gEoklCZM9kiZHUWZPH05W+VR20gipFPEIMx5yCDnscGUwm554aLjhQD6oRI3fRV/y8dqIUN0MS5p5VpxKruj9mxwH83vP3ZgeQQoAW/4uWYOMEMqtEbwdyuYF8U0yMj8oILFXDgLy+FxbMVAWiNl855RbPaZ1CfRCq34A7/Caz/u1h+fPGLsErXA1LkjSYVmh3joCQIqU+ThI+NHrDXAApJitqPwwQdhpCA7bw/tgH9q/PBFR8MnegyCapPeUGOu4kCg2WT8wEYJKAriRY1Do3Can4P4PCdvpZAO+fENxoz3v2fpjwIyu/37HkPurNU/0BJuPPoBFuwwCnM4GI7XTXvmulVKDzcw/I1bxgYB8H/ryVr8AkEPQBOyaWHtHUsTAZj7OSDj8P8gixawiIZPBK7xJkF8KPwwJ4LnSNyyeev0+GAKkJKMX87e8GYKwU+EpApPYtbq+KNZP1f0zsP1MqrByqwV5vm0ziKXIpw88CwcE0aj+WLbhIEMcBnzhWX8+U4otS2GOJ4UW6gIhARtb9kCMY1PGPOoK5F4qQqovkLgI+lU97TqStU6HB8knn7/NJwN0yY9//4M1ATtmz+hq1Dyz+TAmwC2YRJhR7hA6jTtxRIIqO0QBdgOQHEB0Pvo9KzDUo0oN5gkuQbkFYWQ3c46TSAxkfbRr0gdpFZOOPq92BudbBG30soD0QnQM4WDmIHUC79kQSFtBzZcAA6EAQ/P22sy6fdP7+9XTa4n+YDYghQAF3dgNzswHTl4gn/hQyUBN/qjewNh6dggTzZFVAhQczoQJGXEMFR0LxAxO+oZvsYQHUcxk4nOxgnTn+U6sGDpgi/ozU9oUtDxp1elZ9qNod2z0MASrpEhgPHLM91Y6quxBm7AAUqWxjYPnk8/evKf73SUAVAiRQ92YFauD73EAmAaPSqnEIVNhYWdq28KZL0EVNQX1rHVUDjJmOKglRLN5JHlpAWcvecxL9dX7t44DfdwlToUSQXIus/FNIYr7SMKHyT0gKqhg9VHdJEj37bis9NQwwLqdv/3cH8K+cf2BdswOwbwYSFYGw/790DuaLktYf8wc4wDtOga0/5wK4n0A1C0X9AWa5SACa1mW1HuJ9l/H3gGkDWoUM9vhzoD5u3Xvhi/ITI7II1x+w848G+uDlINFxu0nCAxOVlC1nh+AnDXnCGYcFOO0XQgVTATjoAOD57ASQFD2FAV718fXgOE9A2fx4WUsUZl505cB8+9jqT3xm2+w6BDOLy3f/qfxCmW9QQw3KBZgsv4rlrYK76wvj8w6ooYqhzb9ne76KEaD3sxOwFJBKiPFCcwFvVAhx4LjKfjvbf2B+gCYJAOuwGnHAAUw7CEsWy+/bHQC8DkyWAHkmIIQA5Aoa0OfzAL6lF4ZuryegJvvIUQRx/h50ZELBh52ikJZ84Ri6Hr3XN0CM3PbpuYf+ul5Y4GLwHikNuvz0sWJCiYDvyKKj0uqcDMDuNgccQFf1C8kPwehdmlTvQ5UDH+q5Y051HioHIJZRE9GeA/j9579rQ4BcAeg7Aazni94AbLwZhAP14ZQ+AtnYg8ookn0qNFDHiZKHUA7kWrtU7+h8WFY0bRo79bTMQGIcyBT01NsPEu8vZtSf9b/nUoTH6ChpA761uOxnekCsVzOR2IuIwR4frqXTazBFDsWxhSFCrNTOQeyBdxoPikCUa9DLIAQNqxHqusgBbATQQoBtZaoGtLf/2L/r6757zUCiLFicQVVXmdArrgHZlpN44rNRcCYLZd+jun9+KHxt9VEJ0AzJoJ8/iGCoHUqLAUOXguGFAe08OJ2Sc7uzGLz8PZxLCBU7JrhhiHHABWjSyOfuqLYEMJTp3PqDDoD3r9/5UMvvGOiqX2B3AJ9y/sHdAfifB8MfBcXpwZkkAOTqxaBx1r89cL2NTSTWrcNcAADMgTGoAIQVAyKLmbDgsd2BnGcQjiGO9ftgZtcynzOInYQ6Bja2PNUFOIBKx6GV9miooFV/cOzAiuO5p3II1QHokOKwA5CEY1U+Z912aSjOI/27npY/sBNASgKmdwPm7L/rAlRvBAp+LIR6AHqTgcaOIN8o19orYvZIuXuKHrUIy7BA6bW38i5s2HdToGWTzN+p7YUPUe1VHm60zoIkUF0oIb0hLiAP/n78r+lKuoEDJNENPzoW+pADECU4TRAFiHZMmLBgygEooLdjV8DLGYZp3+UPnH/INgLhLwQbMpidD7CRCCbV4B0BrjnIDng5j6Ao5UDd661UDUOmpIeDH+AyY/tFt54Dew0X5qx/ulXBNdVjxTbZAV5kg8FzmatTVQEFTk8GTEz5u3bOHdl5RTT7toNS4gyJtOPMhxn+OjPIDjmAGOD+haQ9EA+IImwDHjmAdj+WP3j+IWgEKra/JPbaewJNDJ+dgv35rwzmcFJQshz1xaIOlLYfwJEIk4or33FogXY+r3ONOwS8qtQRIGH50Dmo3EOfFLT25fsWEIsGsT3PU7fB109PkwHYTc5XcH2cfVUIQpVkPZwHiN1Pc1EFeOzcvGIbhyBbjS0YRyFDPeOjHYAHv52D0NZvfy2fev5hqgLYNwPX9wLugIO3BRd34EDdgF5sa6jspsSHlQXOAzCAEYg6FLCq9xSln1TnQ12BY+s/tvz+GG249gIBGADDmn/vHJ3wZHhcva+06cPZghPqPkhA9sIDQ0YvwOK/OAewnvhYUf4Ax0UNCzKZ7gRgGoGq7Uewi98KQOBXIENJ0PQHgBoai06qbxSYXhiSQwH3wg2p6jb558hgVum7jiGoLqjynzzfUYfQcw/FMj+OFHrE4VxJMP9ehw5WbRzQuk06KmeiQw/vKPx5oxCkqv5kv75VcOEIXD6h5wAemwPwpGfyB9V9ebLHJOB29uVfPf+IqQLYMiDW+LneL5KCWBmISoFH8gBBmNAHNKs9gsL+naKIYrE7tl/afQXIkbKP1h8lBTbP6vMBUiCFi47uQxW95f5tOuo7G07wL+DwN+om+ErJbmomoAIWkM6LcADbzTNk4y17uy+KyGgZ5QFm9y3favm0nQDKZCDMAcDfBbQy9uewAADlmntUeIBAGuUBuH5f8g4dIHeSe0mYRQjBpb0af+P5Rw5gBPbR+qNkwLAkUOaBwlBVYI63EWQCFt2u7ZAC5wcOuAq2s1WRBxUMFd8710L3aLSPstwjiz9yEOb7Bd2Jj7H6qPyFgHYH8K+df1TkAGhOAP5ISDf2D0IA5wx0SLDfnKDcZwYXtwebPEQv+RerfOsALAR2QOEflRCcU2sdzcPSOkh6bqC/rgv4YTw/mSeAee46XCiJt471f2ozEc21Vw7Egss7gmMAb2PRkQk9N2vN273g0GVs9ZWjwGXoIDIB2BxAifdLjd9WBvavxO8GkPmAuPwXNgkpyy9aev2LN9FZlPQZAdk5AU8GjYDIlaADwP6AunxEFu1c6i8cdHq9dwNHEn6szGbgB92CR1xAPR78WKUClwW+AFe2x37fY26iF++XkC/cRsy1j4iC3YghjwDghxwAjS8bOliSsMRgAd+u35LDVmpdPv38Y6IT0DcEpZ8N2y5fTAxSXYGz+YCw979Yc9X6q94F4MODBstCEPPADknmEWQQAXAW7EMXwAMF5xlMOoRpwB/OEwhFd2FDQAZB8xQm/ZSb6OcEWi/+GNiW2F8EwBmMGMIoQnn0snC+ATmAf30nAOwE5CnBQAZF6eGXg6re8otCgmSftfn562OugPfLjTKFueu/+/dIJNHWUQOSAWveKqoaCGDXoRs1F02Qgbm2eq2s+QhxpXad9UMF18dDBXQEFdp+TUXlORibK2PymXAhX+9khSAC8aiRSF4z9vhDHX5MFAiqosxEHvScXEhAY4mz9WX7/d/wtWFW+f05vDNY/tD5x3UOIMf6+AYg/LWgFAqU3wUAu29m/+WuwB4ZOMBj6BDlCvLNFcCMbTzo7UQ4gIFEGyyWsLQNVyDx4QYOQOkQRMzsyUSFHpPJQ2HXvQsYAD6o0fNeKsTZlw2nCw+s/zCxGTuL/c51ZuVZZ3EU4M2eI3mM8gt4TxrgrYNKxDBa5q0+EgqGCzsByBxAfUfAdjJ6EYgDvnhRiCgDGhWnacJ2HcfxPjlonQQO+uwIuiW+/FgmKwDWfSiAeYDPgfWY8ns4DNyCULH5sAM8wjCB1wFqdxrxhPXvZvdji74fWWT1LbDngNqO1aAXxdxo8SX4B2U7vD57Dhvz1+0ciVnws9Ph614+4/wTYQ7AvSLMvAtQ/UKwfVGInDrsGnrgVWFovdC3NQAAIABJREFUg6hL0PfLZyZUcwT2e1WCA8uYypLPVAD6Vt4CWYNsDuyHiaMb44/cCJCZs/1e9brkMcg1xI7HWloFUAUqY8uFks8ouNsmfBfBhAMopeNOjb88W7TzDHj8rvx2JhsWWELwQFfkBt8jX+fyh3cCiHIAXA4E218Ayu3BJiGYKwkl9pUvB6GfFVcEUSyPA3XQF2Be/MHA058r8Lp9AzNWHiEcgV4vlwAzCjhQfJmTIMfy1OMNEniWcqxVLZbbgJfeLYAgMccKCIZtdXzsvKY7yUgBXX2HA85BvjvAX8tY7fW1yVBB5i/QGbTvtHzm+SeDHIAvB6a4f9tZTw22IKIyYK8qwOsoL1CHPcT8ZnBQX0CDoH97kB+gDGrYQuQKZtR9ZptqsDMg+w5Dx/Xdfbox/gSRBDVz5SlcjD9dKfBHm5t41Ak5trF0sPvQqafLbcw5AKPeNKMR80W95Jw7Ro75K9DhuSL4IWDLc/7tuNbbrqflM88/lacD55eClqYfyAGU14DLEmB1AtvD3E4avCLsQCJwP46c/lvOYRU03B6z7oY8MHYcOAKjqvPq3gf0/HHYOjtyCRJhkRLr/ScThzzPYTLTzzC3CUALZksmcRjSTyKqY9Iy2X044QBA0fmXftC9qERduQ9R/oATk5Gtt8fx39WGCqD8IjxZ/o1KAPmHQcorwdyPg/jJQdIRmORf3BlomoGqsyBg8mzB3ChkFN6EFzYZaId1MLlIALylIL07aFfYW9cjGExwjhKKsK1U9FjJPQHpWFtup8qVYUJNeQK4rkBNmaBQwcw6SiLi4Ld/BwlBUX6ThITABqLjkptWaH9upcj7vodyBO1KpdUPypajbZGcls86/3ROAuZfB6r23v5SkP9BEJsErL8VOGgAqgMumApswM2JQEjuWZDmG6VyBKZzz27nCMLNAdDuwEN4e7TsSuygUI5AhgqPCAnmwD4Aarn+x+YIDs0JsAN7/9TtIhTb47sBDjQWuXCFzq3seQN9GzF+u7xO5hi0SuNxvdpbEk2qHtl6f13xtvYYyx/ZCcAmAfEnws1rwrD2X1/80V4Lli4jeGX4IAfgHIFqCFI9AwQ8m/2fcQR2GwtKtupe9RWIY/ud17iy2hPIQyokE1dAT1Phg3Apg8qDV3MinzC/EKh4cSQHKhVswRPJKMfUU+8gPAn6B0YWP3QPzl3pUKSRDth6SvwiUaQwCbfF4yZCWT77/DM5CUjvBDRvB6Y3BO1gFu8LKE0KNd6eJAOX9MuKCkk45Qw80LYlUeIvr4P+QYZFyTuYc3W2l0DPg1uqe6lw0ENjmnHXlRNKSsPlthMWfvpYj+w0LHaX70N0vSZJdtBNGMIJwZm2ksQgGmvapB/lPjRAu4oukneaECy4y9iQtv5Atr84gnYP0nmWzz7/rEgC4lTg9lqwBK4A+KU6UOP5BuI6wCNiMHkDNNg8PRiJQalzAnm6TlZ2pd5+mY3xWZmPOACtwkN3AKw9RQwO7L7DTp0Tj11BMdV9qFR0dE5rUc31TCYSnXUPKg1IJAhIBFJVahHuKOuMym7/bqQy8zNgY4dAyu5afi0Z9cMC3Na6ALyO5XMqAagkYPCWYJfph7IgkkSvG5BLejJ+F6XEzNYyZCCGN+8fhPjp8QrPoFYkhARm7bM6b8kke0CidjLxAE0FtrgSoZy9aH9vrn9uymUcDBsqICfKkpHzYeurANlddpAsyhN0cf6BygEnASX4yZ53HQT1Szirb5KYMF5cCGCJYfmj558TSUCcAGTfEdjyA9uBsB+gNf3YDsB8rB4ZhLE9tgDTkHY9ATzk2YE8zhFYCzsCPDsGBE9SSQW2OFygHEbef257OPfwvJ2E5aGkYL6yg2FDBZxI5ikVD5cF5zXhBWb4RagUtw9b58MkIc8RTCjy+/pj21BFhxyt38EqvM4VJDzwdS6fe/75gABK/I6/FORzAUgI6aJ7cb8nA6OKwgVYpR+FBwrkmRj2757+9hrdW0YgFDkB8x0qSMsxbVCBD79RFjuLNFEFlyovIY81BHtg4feA0PsGPoe24pFDUcSiJ+F4YvQxe70fopQ2dgV0vPDlIH2gN/LJZwzKergduwEFbusQkEhtWFDuk8wJkAuw14Ak0v5e/s1MAOmXgV8HAGNIQD8V7nIBfmbg3hDEyT2cvWfAXrZFsDRQ+r5+VnelzGUw8+C0/QAGvEafLQANcZgsOJ+bv0McBhglJ+Da6+qEFc6S41E7wBwmK01qLT3L6XkHcN7J8p4lu3zPBhWOUby/X8WwD2CsvvgWIAQgg1Y5ExdGoAp3SoazLoEVvYUG7Y7uy4KE4fJ55/dQFYCAL2cF0u8F1sQf/VIQlg1Vpr/zHgADOH6TMCq5nAw0o/QMlAjwipR6roBcSjVdcHwA7TTQcxlLw1t9FwDwNNgBho8oL9qfCnucK1AgMkQZWfhJV6DyDHWZKMfh9YS5AVVFKGosGqgUuPk8cQhgHcG+HVQ+GgG0MYpuwRLGelr+2Pm1DgFsyhxVARDsOgm4X4J7PwDYbfGKcGvRm9I3WMH+BVxhPkCoPyQK5bkUYE3YoMEWA7kX+3uQmOOYcCJyEiLEAPCqMEKGQMPQgex8x3koZWb7Hln+npXf1z3KFYAaDhwJ2/UplXe/GkzqS6Q1EwIY+y5fL6YtfSKAGPwYBu8GaSOA02nrAsS5ALYMmMKD7UthXmA7kX9V+P7Vq7IzMYAyY9mwlu7QtvO2AvjkBDxJsFLj8VmpESp4rp66otNottXuMSIMALBLYtlrUkqYQDEmB0MTQ7AL9Z7qUCQj3214UvmBfuhgyUHnF+oA707o8bZfHdsAlSoAPTfAAIxJJIOYqhQRgA0pgFCxwkfhA4N/I9Pl88/vDQhgAy+WAfnVYNgKjIk/9U4AahvmrsBKAOkNQumGlb+L0+iBOQM7mi1YuwMGJOLUvxBGENdXaz0CuSIX+2Meo1DAQKtj6ZXi8zTcQls4UIwiT4cMlniwb36k8Hy+rmsQquavNx3BWny/rLs+zBd4wrAq7hXXEYprUEIrj47BEtvI0itSSGFB++7FFShiWP6t8+umClB/GKTG/uwGUPlFGbBafpoIlPMB9SIGGX8LCN8PgOvd37IJiN2FJRSvtZG6M3zaoItBnNdU28xn64cCKvnmgQ5LgtKdIgef+e9dCwzOQV1fuRU7MIk8REnOkYhImvF3Qgtf9ne2vpMY9MqOVlsRir0nHmR9cmAiYRKT4B2QCcf56BAsYayn5Y+fz+t6em9S+1wFSMqP9f+SGMQXgkQdgfyeQHgpSK8TUCUJUbkVYbjYXABL7seKDkpvVD0CuwIwDtd8PIjduoClwV/6t9tVeXrCAKYpL1/D8fyAV+5jIYZRWFk1sN9FAXYfpJ3wQbsF4QA6hNGz8AiS9nf+ZoI8LIhRzUfOIYjXZduwdQwF1Og0PFn4fRoppnXLF+wEsM0DwNmAhQAoDDDvCtgOZasB+8FLrsDZ/M7U4GL53ew/tOyYW2jLGxCUDUcVF4ruQgPlCgSwndXMxxY9AOgKujB2MXYnrOjE4+4cE/kBp9aySuFjbkdqjwX8cD9l73W+QJGDXoZAtSodvSwUwWaBR/vn8dFAinbcEomy5Ug6PUfAxFMIAJ0PhhD1XECMy584r+f19PpiCWDrB8i1f3QD9V0BOCdgXA2oIIjmC8gkIDiJMEkYATYCfk/RRwQShAxVqSKiQK2GbUSc3XUJZOsjMkk2O6Ya4QlEA9BEGDBVafCk8fhSYb6mQSsyAkoBFsFhXx2OVn9k+2PyaCDT4YICJ8fxM9so4kiS3sY4g1/ts/yJ19fXT8v5YrP/rRFoAzV3APZyAWKSULX04tXh3B/QqQI4BZ0OBY6qP4OG3EfpAOzG8R0S6BIFhyTYCcjHZCLCh97bFvYbgBePUghFEgfUv5la9+0fWyoUPQ+spp4slUvIy4JJP9rqd5wBKPu+FZUklVprcCty0ATkVP0FzABsxLCeli987/ra6eJ8lQgArH8lgEIG21fmkIBfEhpXA8y8ARUedHIAxuYfJAAkEA+dNGw1bPLyUKnbnjYMgTMGDT9en7lXQJEROIlBqOHASvG0AzgBuZQVI5DNgj1MBO5ohqNMEoWO/W0o4B2AdzPKKhtnEHbrHXMJeL06Zrehw35doiQYqb1yCvacNgfACcDdMHzha+vPL5frjSWA11uNf/8VoOwGaguw7QfYL4SnCZMDaD39oiRYYFh+cciAUij5QRJAE+7BiiTAysvntkqtgRw5CR9CYHZfHgtn8k2GAEWZOKCx35vuyCDmd0RgkpvC5vecwcSsQEVQBkCdY5S7zKDh79CAkvc4UBnAc9i/PaDLeas7gFePK2CzYwitPhAoKroiHU94jRiWL3pt/dnl8nQXhwD4I6FRI5BtFEpfGpN+/ZJgfeBYJaAMPyp5IhxWb0EUJsmHgx72hay/BiEeNzqGWh6QhQkFPFlU4HZU296LfJ4hQcC5ujkChF/eZ6IvQIJ2IgE5VvV23RbcmnhGCT/1k2EIUvu3tuq9mD0RcGzxWbUdQWR3VAiPyUa5l0YAREC1XGhdEB57+aL3rD+zXJ5uT6fzhc4BQDtwdgL7acqvA2GzEMf26heEqtqXGDvIERgXIBKCQYnQEQUafFHi4+2tcto8gIGryQXwXmW/pi5IV96F8HbsFo7kCDyN7UcLymoRmcQxvz2+2W744lJBLtOhAA5ivD+WCKpiypZfJBN/jFllTyDXoLKAtoBk8HtwewehtsHviODXboHDFhsWLF/88+tP7QSwbHkATP6h9S+xP1t/3SKcvmjPAdCUYdoeByWCpS0fEAKAXhOCdwt+aCJkG4A81AnshZjIVkugCWDyddTPZkCX60fnQS7Eba8gnY9zcCZiUTml+jbufzpZRKDEI3PcHOUetDuIQeqBHpBNVW0kGPs3hhwFtF27P905yHG+/WxzD7xuPS1f/HPrT1xcnu5OF+t1IoDcD2BifwQ6hgSqHEgtwjXDD+8CiKoAveWDvMBxoEckAEBy4UEhBVboTAIuOeeBWgaVpY12XOMO4HgxQWEIwJG/3kt1/yngmr3B8cTuQJOMeuOvpYZ2N6zNJ5WddBgMMFRlQxwZuHPlQFTS46GBU+fJZh/lGiJX0F/uwb8nAb/kZ9cf23IAmwvoE4B/S1DL7HtnoJN+yu4zMRTQ0HITz5M6C3LoEcJwXQBkVvEGZrweUuLqCFROQOj9QOnrAB6UFflaG+iZJIJwYxgyRGD3pIODX7kGSShh6c6SwiG1f3Q5MFb2puLevvMbeXu5A23f50MCD352Bo20EkGmzxsB/OjFxel2J4AtD+DKfyUHoNqDtxsTOYIcBuwAoFmBJjwo4ImqA327PwRzQBxuP6P2EVjztXbtPWiMSPjxeROJ2EDHAqK5g1ZXLyTJZMPuJQC3y9Lba2AV5rDHWOlQlSeJ4EBFoecODBEEnYU6BEBw4/2aVPmOVUfAd+0+dZYiQNG9lOXaFSBZ2EQkfm889k4AX/oz6w8vmQBOy3rVCKCUAqEBKOoK7LUI5zcDmRZhsPoWEEwUTVkr0TwhFHDgo0SeU00gDwaf0O5UtAv6Bpx7cOdWpNPKkh5OjRjseZ8SBoz31ZOHYrC70GLY9gsEOjULUDuCbihB8+XZlVg1Va8wo9CkhBKgrAxcrf6oysJBwPFKWFPBDO28fWLga7XOYPnSn15/cFP/zQWcLk43iQD43QA5CVjfCcDNQUnl9y/NVYEM9qZNrPTqF4S1/U/H8I7giAuIgdzIxuhqlySyEstYnQBqEn6ODmzBslOaNPCgrsQ+gVmC8S4jDgX62+rjJlLyispgw+9jtyYioJh55jgFNBwmoN2uahoc36qnBWkP5Eftvtn+ES8Aad+JY31yBpCw3B3Al/3U+gN7DuDidLP9l9qCg1eEj+YFmJ8Vy+BAd1CHuQgJXFlvZP0tcXRJYAbEodozMDKwpxS87wgYzKGrCEuZjarkvmKCUWTn6/7d6oFXW3NekSj0oB7E8J1ZgAg4RRwS2CbcKe8I9C4D933q30wafLxCjk7VSfFnwoa++jdyZutfPi9f9pPr919cphzAaTldLxfrXg7slQTxp8NMIpAcQB0ctR8AlB1mDbZBpPIAbR8P8njdvm2YxS/k1FRfba90mo/J17Q/tEH1oIGtnZ8DAEM7gwlHFVKmz8H4GNNWZUAZtjrr/cu+KqnYA7sHbL5q0QYcJfZiJfeA9jP67BU0d9AUM4rZjy7HqscMGaht6n12Mwu9wiuCQcCzU0HiWb78J9fvLTmAZSOAy9NNIgDIAVA7cCOH7dBifgCrPr/+y7T8stJbd5AufqYikI/zQkEPRAFq6kGftwMw9bdhcBUiAAgFYHZK3w0DWO91so+JDn1FJaZwXgOqjCcNXMLvLVCKvV0xfke9DbgIasiJyGOcAHyEK4C23nLNM4AfhQcR+PvLNTGE5JCvffnyn1i/u1QBdgdwuecB9jAgqgi0Xwr2MwRdVYAbgvacQCYODAnQgqOTMNoVxP8VLOP8gFJfBdZk08gh1GuEYU3bKEcwk0C0DiQmCL6urnMwLshvKYFe7nenXdhCpUG2B3YNan+kLuCDSUMRkfDgZxcSxfdG8YO23h6IkQwUAI8RAFYjJtSfkoNa/dsxl6/48fW7qgNIeYDrrRqQXgQqZge6dmDbJFQV2839L+CkDsGa1Rd2viQUiQQ8CBCoPjdgQOlKc2jD899By7DR6Qm1t8BHZYPrFSVFVuR964HSGyhRHC38Bfy8Sd5zInwwAK/PLS8NHIJNINp7wKpsSILCnmMgt1Bnu+/UGsiOVXZs/9t32vNrcF/aeY9m+/0x05i3x9HHtyRhyYYJZD0tX/Fj63dsnYA1CXhxut5CgfV0XhoBbOFA6f/nBKHN/PccgF+XnIAdoD4k8KraTwByydADSIDeZekD9Q/JgYHQcQ9dEgJdFrG/vVcAmWEfA+q9CgVYjW34gNDVnYR6e00a9lx2+jGtOxASDElioj9gnPW3ScyR5WcF7ib2yOEUQomIZLScySxtjySyEcCPrt+OBJAcwO4CLuPJQQX0pUkoA7mqPvyEmKv50zpZ2hN5AQoRFMjtEM8kMcgJ7A9I2HjlGjwRAZEQAB1QJXEQKKmPIDofxuXKLfBRrWPiUEABl8gA4mxUaT43A1Bu24nZrW73iMCC0MT9gz4DBAWC07kCqB5YIHmV98dB2w6Ae0L7ryKOEcBH6r+tX77yR9ZvUw7gtBFB/akwGw7YFuCcKwCHYJt+GuDrgBBVAQ9oVnml+p0qwKLzARGwJdg6Sj1PHKiB1hXUc1KC0V9LftQy3yBIJHh7kTqu3TsPmW7VwRKItfgxcWgngL7iEYDvJgA7JCGsOpPPY5xAIVpU2VG8zw5BOQoP9IBgSN0j0ihOYDv38lU/vP7NrQRYQoDiAPaegNN5SS/+VAQArcG7jQdlr7G7bRNuIUB2DC7Dz4Duf5YuwIAkIIEXAmxQf3Yn3RxCDGZWzP0M7lpjQtmHhXM8HYIIE36iemBy883f1KM7MDKgvR9ojsF/c84P6LcEz4Mcz6Cs8zQBdBqGGKgj8CtgoxMp1xmRgl3uE4T6WG27RAA/tH7r3glY+wC2XoDTzZYH2MKARgDtRaGt9MevC6eqgJnm65OADcAIVJ0TaEMuIAUJOjrWKGO/r49Ljggu1i6/zqu9qga0HDps3ykBWhXXbzCSx4S2WksqilBilW+uxd4B5QTwWu36jvJT9cESQR/w6nyodhFAUYWTs5u3+W5fUOERATxV/XvEgOTKcX/5nAjgB9dvKY1Aex9AqQSUZOCu5vZ9gb72314ZZhuDIgeAICt/RySgbD4s25XHbtMGQl4+yOonYPpjaAUmYIsuQ+MNOuuNNlMYwNbcaG6Y14jcgW9OYo33kIQzdisEVun5E8fcRmnhO7cBq4mFj+M/434xgBuBWSVEUPDfqKSsqk8jAEzI+Wtm8mIgxxa/3QuzjygRLl/9d9dvIgewlwJrMnDrCajNPr5F2PYE0OvDTD2fHYACPMb5A1fgQC1IgBS9Den8Vz2GIJkDiUHW+hILCg9gGlPZrlt1h6vtkoinivr4O4lH3otTgz4zr4DerhipB49djytr+Lw/gsCebx7wvJ+ezIPgsX+jy5hxAkgkcWzOxPFC7b8oD6rz2dxEuu7lq39g/caeA7AzBEvWv8T8+bPp/MOkH/QI5Gx/+uJcCVCOIG3XBlNT83oMnD+ACm4GvlB2E1fT+l7VYBRCiOahmHSMT/BvQAxdS6TyrU4sCQnupAV/HoqdsMNqq/EiVMLlY+lQgtUeaSByAibTb0qDGYD1mUZOQIcPiljwGmb/ZkC/MPs/VfufcRI2R1Cub/ma71+/YZsMdLF1AEIIAMnA6z0ZmOcHsBtIIBVvDS6Ah4RgetAZcK4SoBW/kgCouSKAemwHUjhusG7fN1D8fbhLwtiuwocYVsUBao8gD2uGmTDaD4A4kjHEGDgE+dITdUYGMak2Ac9ruicMBh1q9pAcnpD5b6roXcIs0Mueve1n1D2NuQLco/a/PScbFlgHpdZte+L1LV/zfevX7WXAy5T44xzATgSnkgzcEoHcIQgNQjgvIFcGsCRokn6mHbjlAbziCxdQv4TNBcgGoO06egnCHjCDEKJCsRv/91qJUaPVnH/WcAA/5Qo0+AWQBVDtvspZcGDwxAai2iXHNCHUWTgSr9YM5PZZKTvaYiTqNyT+ly3Ex0KEXpIPv0sBtfoeaR06BHuvl6/53vWvKgJAB5A6A/07Asx8AaP4AGjpAJoLYMBXh5Dr+MY1uKYhC275rgA4ToORbhJCYGM1wKh6zykU5R0RA4UKXqM9QfS2kU5BTFe27iSdw0Pc1hCsMxq4AXFEa8j9Of1PhU2QAxFJFDYwIPDIrIT9UMCCZr8L+f72yKOAj8GKLiLaRrkIdc0N3EguviSIJIFOaHnH96z/TyOA9Xq5WNJ8gFwFyAnBm6012AJeJATxfQDmBSGo8JT1VwRByTmboYd8gVTofq5gH4JEChVcPcUfWXhJNKTkzol0YG3CDuUICPYyd2GPrz7xFfjXk0U+wZIH+gc8JlIGg50BydAfK769B6iYNmfwhPgfMucI3OhvBdzHEUD7bmzlX5T670nAd3z3+leGDmB/Uch6KRuCavyPCcLtEoPPoOLcB+A/l+NQmS50Bx7cJiyIAC6qAZYUCgjihKKCaB3QM65hMBeh6LKBozyu0vSivN4D9BTeazFexYQbCFqIFUEoAvkFIYAXUPNnRY8qDJFFb9vbZF4E9McTgM81LO/4O+tf3gjgYgP5xem6/Lsrf8oJ7HMDttxAi//FT4nnVuCk1qU6gPmBAmKO98v2ZZBah9BsPdp9BCLkCCJHEGX9DYB61YBRJUHAP0w4kuYOld67CO8bED6aioptxbVqL+cIZPXABx1zZUN/RqvaBUqWsHoWHyktdAA5b8IWeqToCLTob7w2/nvGDURxflTjj8iiHx5wBaB9Xr72u9a/BHMBahKQcwDpdWHr/ivCtTtwSv079r+ShVJ6ArkDNxCFiXftfrbWzknDomh+eRqC/RJhA5OuBoSuYNYRhDkFHTrIpeatu/aKPIytz2AvYeBLOQZj9aE4GIYDlC/QDkBbfHQmFXTTLwZhkrGqOAP6WTKICSBOBvaBHIcFinw4dFDbLF/7nev/ERFAcQAJ/LsL2H9FuE8ATdHrdOL6Ik9Ue5hEVIFW1JxcgJnYw+ssUFsSUQCYKgIG5NNuwB+3W0IEEFv4CVcB/fZ+DkBEJ6iW9h2EZQ9FDHHyr+3FYRAThgItghPV2cLOlqL4jKz4BvDGMSF454CtVP8poMd9+27A229FEB6ko7BgTCaVCMgJbedavvY71r9YQoCS8MNOwLpsOV3ltwa3ZCA6gPIGIQwBTIKPAa/ATstMYq2/rsJDkkUBBoOOqwgE7h4pyKaf4zkCA+uZ6gFPPKo9DAdcgcz9Z1BCmbEXDlhwT+QDqOKAgz8kAPEz6A0gDHhPAArYjyGAXlPPvBvQ6q2s/iH7P3iDcHIUMUks7/zb6/8qHUCO/wsBZAeQJgjV14VlN4C9AbXjrzQHgSMAckg3DtU8/b0vM3Zf5AyicEAtFwm+qvwZcNsZ0uOxVj4tP/tZAuEx81AOLX4jCFbXvr7TWvHrQWp/TwnGxCcq6VQm5ghABRK6QuDDBFgyOZvwRRHASPWjRF4vwddzAyrWRzJCoOo3/4zsv3UKJZTogX93AO/89vUvcBLQxP9pXsDWJHS1hwIXJ/sbgibbjwlAagl28T4qegGeDgssYCnGd2U9jOfFtqIMiMdvQIri/8i6Ry5DQPNoDuBQ30A6nwUvfDowr4CP4Qmhnam3LVIEvxgUr9UnBHX5Ds8aE4IlJs7Aa3eglXKGDBjgngwAoFK1VYgwsvfz66Nk4/LOv7X++cv2SrCWBPQOYCOAXA1YL+qPiJpWYCYA/FwUNi1riouKH+QAyBUY5zCt+lEVQZcOK2xB7SX0Z+r/IekMdN+p87xPaA6j5wPweD4rcIQAmHRGVQFDCrWxxzsUJgX7uZ8DiMhFHQNDkkYqHpRdMoDmoC4BQAjWFHqWALzSWycROwHlOJZ3fdv65zAEqGVAJID29+4AlvzSUFvrL2Cn9wcWglD2v4JHhQmZMIJwwE7hRetOScKOQ9hed+Iy/a6/P1D8EPht+/2vrtprl+EhOw/8/SHTLxVZmOtgQZ2T4Rg6AFHK9Ha/DD90KKzS3lFEBKBdANpkPp+10EwOCHrlDup1POItwUwuWo2Vxe+TQnM1CvRzRLG862+s/9PFVeoDSLX/9Xq5XMq8gNIDsPcD1HkC28tCytuC9vi/5QLs5KCi9hTrLz4hmIYFLBfk0GJ0BrlS97hvoIGylxT0wN+zARLQUbigCEYAMDzmNig6IUcx+wecQuQHpglgMmesYnE4AAAgAElEQVQwRwAWpPiJATln+z3oFbBRCc3flIfo2XpW03FuwAKSHUI7lwJuDPCx+isSgT6Ad33r+mcvLtfbi8tley1YIoDcDmyagbBJCN4WJMHP/QGo/jv4CzCa8pvmoR38CuQR8CfzAlRVaFBMwCbthnx7v1rQlH4EViCEx+QBwpIiqmrfLRwigHqNVqnLGXgpHntEAArQPZCzYs8RgnAE1a1YYHRVHyoY2xE1McTxeEwWihReBAHMHmM9Le/66+uf2QlgdwBpHkBxAzQfwDiAbTvzpqDa/beBYOsU3L52Dgd25aT8gKsAJJC1TkIgCRcGFMvfs/u0jux+ze2HDUY2NxCSwyAUMJTgQD9DGBluA8KYCRv0NgBjOsdcCIBQbOSjYnzW+xmV77kCre7t7Uc+ro9A384ykx/oOYPY7iuC6C/zrmAW2GW7cQixvPtb1v9+I4AN/DUMKOEAtgOXv9u04ev6Q6JV4fPPiYEDSGW9Bn6XACz7ZiA6AqgABUB3l5VBaEnCFvM64cHmPXq5garCojyo7Lo4loa9WDrhEmaAbxWbCUWrOypu8Rc6BzAmAKXe9vg4UNvVNoBb6vAzCDmXYOkHjzMCOKp1/Hds52fUXrXz+mVj8NpzWdAXp2IJyRPI8u5vXv/b/Y1AFycggBwG2EpAmhvQXhySkoEK/MYNMPjt5/1xZ4Iw4HdhgOoPiJzAWYCYty0Oo1j/mBQqNAfE0LaLlD1W/P45WFnb59m/+t2KaNijc4228etHLkCFDHWZKZURAcg2Yq3u7CBeDAG0GFo3CcXKrkAbAbmQ5B5zmIYe9Aap5Bttw26Ft13e/U3rn94IIKt/TQRe5ETgHgbYqcHmpSEpGQjKf4gQGvh9ApDyAFL1rc1vtr6fK0hrAYwm4QiEYGJuDgIYzDZP4M5hOvjw3D0IHwgRuEMwtPP6fAreKl8QuwDb/BMpPPoF+wvD3klYsKrmInYOXjWZAJSqI9D83/ExMQRRuQGlvscJwKv2TGhQCCFyFuV6l3d/4/m/urhachVgvb7Y8gDpZ8JdMrCSAYQI6dXhSAD5rUGm7JfAjDMFfViACg3g7zqBArPYCZSuQgvIsj26AASbdQMWhna7FC6U/43MPS2H3oKxgk+SwBNyBFEQoMIL3tYTAmcOyu8aiuVZ2SKyQACV+xSRAm87H/+3bzRyB0pNLaGo0MCqtyaA4yDv2/92TruddwrLu//a+b+4vFzqK8G2dwPCJKCwMajOF9hfGVbKgBH4ySGYnEAC4YnyBPsD5+2IDLTiN/W3sbxX/BbF23Ws9WnwAYW4xB/rvQBt3sevmQF4sM1EjsCCK1J/XK6A2tbzWukIRKvyk8IBRxRzdh89Ayu0KttFYNYlPkscTDhepZsXQbseATRW7nYmbf1VeKJDiG3p8u5vWP+z1AmY1Z8SgIUQQP3NlOE0UzD/glAmgqT0ojdAJAQl+I3dz25gL9OBM6jHauCs+Yi6La2LlrvEH1KAJ450VBECZCdg6KDjEDTRKJCiYxl7Bt5CKbmGvN1zJiyI3yCk5wNwoKCIQS+z3kOpdSM7TRDxPvM2PyIDDgdmE30vngAi9dcksLz69et/kjoBKwHUMqAMBUpOoBDFnhRMYUCz+Qr8eRlXBEKVL2AvNXr7uSUfM8irwjYHgI1DKgSwjT3gHNzEINybQgCO7QHwqk6gGnv0dthFOOMSZtQ9Jo/Y7mdYiW4/BFyz6DGJNJDoPe36ppga2Lx+liDG5IDqXc7tY2qr6PF2nlxG8bklBQ/c0frR8dGBLK9+3fqnLi72RqAtAdj6AEwFgPIB0BW4v0249ARI5Qcy6ILflwtLCNDgV7Ypys7uAJenEMLsWxXaVxQcQdTGICQUkSDM3YGxmjO8IzDn7WY6DTnh1/k8Un8J3ADsFnIN6HgOdg0YMtjt/NGOKP/j1R4beR4f/7Nys+L3qwOWYhCQNpR4DPjt9/Nhgj3m8upfXf+jWgW4PN1cqARg7hDMJGHbgrfGocvTzbqcL6z157jfuoINnL2koAO/yBskgJPi5/DBx/cFYAxo+kwVAWv3AeZBV6ElkkJICSx+XQZRt1fgMeqf9pkFf5l+yv4g2t9qrT9PHO8r5ecZf33lx7VouyNC6G2DYENA279bgg5B/kYRQE/de3mBBvRRjiDRTdl+efX/Xf9kKwO2MABDgpoUzGpvXhxSl209AQjyQgCvu0agdeklBZsTqIDhBKEBOQBYKv7WE2BB3iJ4sP3UbahDBp45iOqOHoBBaz+360HIaaCH4UFUVoTlEsBB4lCDXWUBFODt3pEjeIwbUMfywO2FAx7ACuwxAeikGlp+Bu0oHPAJwrm43RJAnNhr1xNvU0hgefX/Pv/7rQzY2oA30LuKABBA7RosyzYXANWA6gYMeBMZaOXHHEGGqKsMCHKAZCAnCS3wMRzIeiwSi2zlW55AATzODRjtF1UDooTAxIeewaQbWbmN+j+xUqCgzWTB23ir75U/dgneXzQV7wGdnUSc2GO3gMlBlSj0gG3XocD8YglgjhyKrvsQokMCy+m0vPpXzv9ucQCp+SfF+xd7nO9j/50URA4gdQjmHxItRLBQebACWiQEAewJdDm+r63C6XMDuX2PgLH8wgnU/VwlwBNDcx42AMAJSirmN2ptyn7aEcR5Axs6FID3t1dv91HUoJf17b7dB5XckE2d11+2ZzDrygD6DFb3Y5b/qBMYuQMGn46v58OBPph7Ci/tP/20GB7d5hUUCaRly6v/1/pvp8lAbS4AzAnYSWBvDirZ/0wAygGcLtar2hMgwc8JQV0ZSMoN/+XPFvwFpna7ppmFMJraNwIpwLahAfcVcB6B5xM4fa7EYwHM+1njr6x/FPfTGYOE4XTsPwoXur8cxKTAtNDWe4AzUBthxJY/VngmCaXidhvrDlCxEcz9+r93GLEbsADUYG5nbvE8hx8xkAvgyx7+GLhv+3t59S+v764OAN4JUBN+OSnYEoDrdf07kcHNcpneFbAnA43659LgDmAEf/D3pu8j8LNTyFl46w4A4KY8yKSRt4O+A4799ecGcBvPxyFBrN4zVQL9HoIoQHixBBA5hjjut/DGnAFSQVluXYIKDRjQ6Dp6YG+hgz1qAUc7zljpfQIwcAPwS0KKELxFt0e2yt1b58kgdhAa/NvS5dW/tL5zJ4C9AuDtfwoF0iSgPFW4/r0t253ARgCZDPYwIKu/dAMYBiDY8z7NqlsXwGEBbseVgLatbx6KQoFY7YMQARKLHtzHk4MGzBPtxZ2aAmX/Izfhge2Jw1t4a+61ytuwQIGeKUJVArzizwLfA5v1P123Vc1GSAxS5xDAelv73/a0JNOz/kgT7ZryxZlf8sVl/m/lIGLgl+++vPp/nr/m4nKbC9A6AQvoMRSA2H8H+77NBnpIAu4/MX5RqgE504+hADoB9/cGmrmQAMnAhAW7gyjqjPkCIAKT+LPgdklEU7yzvQOeMND2H3QCtaphgwMP0RjMeMbHOAALWntmdTwLa64MzIIeodqoJUr6WRhbEjnmBBqxWfi1n+zWBNEHOFt7ZfURphFJoAtQ21uXYH1Gs/498LdAYXn1f1+/quYA9nkA2eLnRqCNGPZXhOV6P/67EwEQQCGENDloy/hDEtAAXocACdi2X4BDAvyM4Hfb1ap7dhKUGEQAa/XHDsQcKphZhFHyEMID0y6MPkH/qnEvTNBGfFbd57bTxMFQL+rJVxSBXqm9Bz7uPU4Etq17wPdOIB95J1xW3raMrXtU/x8BXhOAsu4NkBy7z9j6mW20e9hCgL+4fgX3Aeygh0qAj/8TKezgL6HB1f5Ogevl6nS7TxHegZz/k+DH/oDXIfZvLsCqO24D6l6bgXxSUIcCZd8gPDBqTIlEMwcAzxeDviozzQDU8ftkPiDs/JsDuiYTVvG2lXYA3jNwVsAm9LzCe0VXZOHjdwZ2epOUpQ0mEQ9qH8PPxPkRGaDJ96FFpNL9GP9p6s8OQH3eCOB/W78M3gewzwPY7X1xAqD8Tf2zSygOIOUA9jzCXg68OF+mGLW4gALq2BE0sCdiMOBfXjefffxfgNryBiU5Z1wCTCay7oEVHtXdA72XKDRuIoOeHQaercGMHMJEo4+aV2DBfYwQeqGDygbw9r2wQCm8pRBUdeEQzAxDezSV7POE0LH9zg+o/MAR+++3xSVo0zHUYJWeVXZLFHPALyS1vPt/OX/xNh24qT5MCqLEX4n767/FATQiSI7gct3fF2hDAAX+5gJs/A+A38mghQUq/o9CgbIcY3u/bYGjrxD4/YrSi9wBdBIyQXjAxzmC5iXsX4oongL2tK8nCG34tTtoBKCThR706axuOU0fVvD2YcEoDChA8HYfQedDAQvex9l/RQCjZRa4x9X/GPAL2Szv/gvrF17CZKCdCPYuwNwMlBN+JdY3/17lHEAmghoSXJ5ubQiA4PdEwLH/Dvha+wfwQwXBgZtcA69vVty6iwb7AgZcj9N+W+iwLx20DmuXgKCL7T6v0Uofqfsx1edwIHIBfrmmCmPY3VuJmCjsMWLgM2mosEARgl5mCWAmFLB+Ymz3lVtggPJ5ewQQ7VtgjDmE3jJPEsu7//z6Ba0PwKp/6QYsOYC9VHjZ4n8AfM0HXGy5gDo5KLmApOAF1P7vZNcT0JEMjPLzNnVbtP8cKoC6S4LAPAABHCYZVUC6RGIDNNt8b/sR1n0HoEOEo44g2p4hbz/3CQDWyhmDDOhy7Dngo6NgW2913PoIb/e96nOGAD/j/seXj8jBry/2u8HWJwF76xrEHw/86gDe9efOn3+5vRIsx/yl9FfLgpdpTgDY/jRHAGx//Xy1L98JYLk4XzUXsCkmJgWbC2jgx9i/kIFalgEP1QKv9pwLaKpucwJo/znhV8godgE8qWhEAjo0YKBiLkCBWCn8jOrPbFMsOpCC+4XeiDBmw4CYDKyu+2DBx/rKCaiEIFPEnOr3E34I0ZYz8O7A0ouO/4+ovz4DHreAu/2riCKtXd71P58/73J/KWhpBU4u4GLv7kvJvp0M9lLgen1xlbL/hgQgFNjfMLy7gJwHgERgIgGbHEygKUAvJJHj/qra1h342L4pf10nOgY1UQgSEFOKo3wAgr6XHLTvEMJwowAKAWqP5EOAx5IAgpeOUe26tvYJjt498Na9vIC1+O2IHviPt/x4VKX63i2oJRFBIPgUAWi1j+J5u1wBm4GrfEEM7j4ppLXLu/7H9XN3AoAeAGgKSuqPLiCDvZIAgj/b/0ICpgpgQoEE9Jb4KwDOy43dj8BPicE9LodtYeKQJwx0BFllIUSwoFbOoCizTQaOHIGfhmxpwQLdhwwWfk/IATzyBaIzeQCv7wz04jKU4S8kY6nCAlkpvLf8SCHHQK9AjlBt59JW3G57xBH40KCdAVXdVwdY83ukYH3B8q4/u35OygFk5S9lwKL+l+ACWP0t+Hf7X3IAez/A8voFkkBK7rVQAO1/IQN0CW1ZcgnFLVhAc3/AHAlURYeXitjwgKsCCPbob9VbYG38TG4gQYRTgQz4SQKYnA7M2j6bC7Db+TDAq35s7RVoLbTVpxj8WtubXe9XAGwiz+v9yAEw9C0oj6u/phsL/TngY8CxvPPPnD+LQ4BL6PzbYv+LDejl31zm2x3A1ZLmEOTYH/7dw4DTcr5sgH8v5AFsTqARQ7b+Bey1/s/gz58hRHCkALMJnfWn2YWzwPdhAJOEzRdYGOO2ESnY5TpsUCFDXpbbnCPwegMfL5klABsa9JN9EfRV7O+tfE/TZ+J+b8+tlvdtf0QArMYM7Nj+27i/D28mD+8H2AOMPpcjLu/8H9bPvLg43V5yCACx/5b533MBu+LveYDkGK6WDegpJ1Dsf/p3dwKnPQ/w3toQ1KoBrTKArqApfKkeKOUvio9xP6u+cAHO4rcwAGcSHksS6lAgyhcoQvBaD8oeTC8uDkHBdzv3G0sAKhBQNIAQLleqrL2lhb7510D3ZNEDu03t4ZY6VEAnEG0dq72y62P119bfUsa82isyqATwtf/d+hnJAUAIsMX8HALkEmAigaT6xQHsFYGrbP+3f1siME0PXt4LpUAsCxIRbMqf4/9CFsb2jxxBjfuBHKifQCcCmQwKLLHEGKn9yAX08wSVANyPhRxPBJY9tiFbaOSxZKD3Q3g2+uGl4zxArPk+M9CjBIasNvX9UMCnCvswR+AhlL0XiAAbxfCj2N4Tx0jn9Xr8Bss7/pvzp5cQ4HJ/H8B6vYUALfGHmX/4+2qFECD9vdn+Av6Lq9P2YyO3G/j3+H2P/fPfORfQQN5yAwh8QwI1iVjCBPVvBjK0Dtc8Qg4JIgJQLqDvBmy8H6t+QAD0UlGGu53uOxf/c9YAHcJRIogIwGp9OsOYAHRtYOQHGhBHGt9zBlbB8XoTPBqsLJx1jM+WPqIDPnaDooLxGPqWTB4HfHWM5R1/ev20y4v2PgAs+212fyeDZv139b/cY/715rKEADvwKwnc5XBgCwPu1uX1BR3AeSOBnAisAOfPuXFoW28dAeUIcq5AJwuRIFDJRckwIAd8g5DKE+j16B7y37MvHDVvOEajPyIATx8cHjQIquRhZOv1UcbVAEsJI6BHQUDbr6fhDOkZiD8e9Ec0nwMDa+x7cb2H6tMMf6EjTxzLO/7r9VMvLtb9xR4p+ZdBn2v+W24gx/07Eeyfd/ufbX+J/3MIkEOBXf2Xq9Pd6SJVAgrw939LCXBXavhcS4MW+Coc8O4A8wUJ/E3to8qAXm7dgA0HEPS4XbXy+SfNMNvf4IlAbb0AZl/q0beq3q//67pAWzrnAlitPQkcI4Aj8Lehgf7kLbungFnTr91BPwRQsJ6L9DmbgHCc8wAvTvnLkZav+S/Pn9KqACkPsCl8TvLt4C8uYF9ecwA5BChEUJJ/16e7vay4hQA7AZwvE/ghD3BKFQEJfugXSCAuPQMF4HkZTBJqYA+qBSo34FRfkYFqFS75AiCGmdeO8ctF5LsF0jEb5BD+fRdg10Ylwm2YMaDVZ47ibTBxlADQwHPIwFDVbmDGAfSIIYb0nO3XoD9a2Ovp+kjhR+tH1BDtv3z1f77+vpYETC6gZP0vU8a/qn4lgBQS7HH/5fXe9ZeTgEuy/1en7d9CAFc1D1DUvuQFQP1LjgDzAiZHsIO45BIQ6Br0NvZ/ihtoJGDCAAd6jPXt31bhdTlwPgcQ6XwM+jgc6JOBNfJlW7XUqjwDPgK9zR54kI/MfboiG20rQLfjMJBx6yhXYHW6F/Nj1kDF20xD3gFoGL9R4N/OtnzVf3r+pEQAGfw1CZjBX23/9nmL/5dN3W8urlIOoGT/M/B35c9/329/ny7Peykwlfu2f4vlb9b/XAmhdQgmABfXkPoGPDnYnEADPcwlyOofE0LJDwzCAflGIeEGahMPWvxRJSBS+p4DsG5hZP81CYz9wBwJHCEAFRJo9e4X/Y7bfF8AHIGeCcLCegR4Xh+TQl+/31gC+I/Pv/fyMjf0bBOCNsXfSGDr+tvBX4Cfkn+76m9JQEEAF9e76hcSuN+cwOYOdiDvIE8EUMGdKwPJwvtcQMsbtLZhGxY0oCP4PRH08gN2XZuR2EqDXDmwLb24XQHlUx1Ag7PP7D/dATSFHnsDHQwwLfiynrbyVtNHdl85gEjxLVlYrWUHoFRc5/yZIHpuYBzRR0DuAfyp4I9Ip+YAvvJPrR+/JQG3EuBWAUhJv9P1BvIN/JUIdvXPyn+9EcZ6c7H925J/dxdX6+3+K0OJCHYHsFyttwncRf0TGaDCa1fQHEAUFiRwJHLAvxNAo3wAVwG4q3AEfKwolL8R+E35dSIQAwLc1iq6LQPyOv95PgAoxrln/1UiEN3CDAGMlT4igHnlV87BG+1jBBCB3roB9gIMVAXcX2gCmCGP5Sv+w/PHpclAadbfRgAb6Av4S9y/EwISwN4HcLq9vC5xfwZ/jv8vrncCuC8EUElAOQF0AJAsbG6hgJxDBFxeQI/235JAI4lMHKYleFwe1B2DnCjULsDG+FFI4ElgnNzz2YMetHFdL9VX0oVRTcBSgHIADYjNcVjAItARpEr5C+AiMB8BOULZO4ftGjlXUPIMRTd7ZMDbNmdwhBTamfrhQbR2Bvx7DuDL/+T5d+0hwNLAv2f+r5abqwb668vrZP1r7H992j43B7Bl/wH8ORG4EcBdCQHQCdi/W7cguoGm/MkxDBOEUDFQpcPUkMT9AQr4Nh+gm4RY9TG5x87gMZOEElRnQgCv/rxEx/rj6j9TBNKBdQRWzeesvncA5ZjewjNQLeCRWHhfD2ZPALHVH5OBBvws2EdAHa1XBHBkn+XL/oP1Yy63PoBN+bcQIMf/l9c5BNj+zUSwkcCeF7hOwK8EUMDf/t3Vf3MBy+V6l+L/13L8j7mAMkGo5AZagjAGfysncpkwrhog6DFv0EsANmIYKX+rDkRuICKApvhRvd8TwNPtf3MBbOWbVuttojDAK7tWfQVw3DKpr1LzPgE0SPvtFAGoMAGVWqXvijOYA/yLIIAjQPYZiDnnsHzpv3f+6MuLZZ8MtIcAxf5fn26utr8LAVyXrP96k4ng9iK5gBT7b+C/Xva4v9j/i+vTQ3UAmQBqInB5rWb5k9UvxIAJwaL8UDHA0iF2DKL6Q2ehs/01b9CSf3YbjPHjsKCpc8sZ+OQgAzyO+Y8RgCWB+fg/0nxebj83mjhKAB7wiVgKiNjs4/aWCGLrrxW/ncPb9t46G9vHoB/F/KP1Mxb/MQRwdJ/lS/6d9aNKErCAf7f+1zkEqARQlD8TwfVa4/8M+rvLFPdvBPCQHcBOAOdTAftrOQFYwL65ggL45gJ8GNBCAKwWmJDAgF41D2G2nxOEHBaozyr5p2y/Ajluh8ZeZfs56u/BexT/a+tfQOj13tt6Ze0biO0RME7n+N5+5vxAi7uTA4hCALVOEQC7CAYyGnuv6J4g4m0iIP+iIYAvevf5I65yGXC3/0X5r9brqwz+q5sU/yfrvzmAlvzblf/qtIF/+3e3/fm/jQQeLjIBbCTAoUAjBgR/yf7bngEuFba+gig3gD0CbPuf0jGYiMCHBQXYZT2/G8Am/ljxkQqa/VY5AFxb8gR+WbzEqz3rPdr/eQLwYUDLIKh1s2rP2x0DPOcKUOERpBb0niBOp6U6l55LmCWEN8oB8LWNAoHli951/q0XS+rxb4m/BP6dAKoD2EgAwL+TQLL/l2j9r9f7y+vlYXcBWwhweb47Lyn+T3mAkgsoroCVH/MBLQTA3gFdHeBEoSaA8mahca8AOgZfGozmBDRN7vUCMDkUILPa6wwAg3scAign0JbZTIB3AQ3IqPhWxVm5vUvA7Xt/s/Wfs/gYViiQz4JdbZeOt/8iaP2faLsIgLM5gegcIyDPEIo6xvKFX7v+5hQCbHMA1uvN/l9t9j+DP7mAFPdf7nmA0+3lzVb6yyHA9a7+95vSZ+BvDmAH/+X16dnp6nzbgJ8IIOUBGhFwdcDmBHjeAPcQ2H4BmwhMSi+TgyIXUPoHxlODZ8KBkQOwcbzX+pG9n1H/PvBbwo2Dgaa62u57RVexPapv/DeTwQwBRKFAs/ps41vmwW8zcgW/WAjgaPy/fa/lC776/JtSG/CW9MvgL/Z/cwGb/U9uYLf/V1vdP6t/tv07AewkkP7bgP9wcXN6dnF9erZcvn6TwF7Ab11AcwboBF6rk4dUglA3EcVlQqv2SAqqOjCr/Dr5Z5t/Wj4AI38Ldjb/nAPo2/tY/b3Vt0eyII9UfkwAfJwEMEUIzWm0mNoSg1d7tuYe2O1YDcgN7iqeP7rs7wUBHAXz0e2LG1j++Feuv2F3AJdb0q9Z/+QCNsCfbi5vltuNAPbYf6v97wnATfmXDfBIAA+XN7v6P9vU//Lm9Hy9eO9VUv1GApYQwA3UUMGGBVwh0L0Ctp247wSwAuDnDbQXkPas/wwBoMpzDmDkAFDhEeYW2J4A5lS/ALQHcAtka/85qacdwMjqK7W36t4HfLkmb81HRMFWvUcK7+sE8Fjw7w7g87/s/GEbAWwlv80BXN8k+7//d7PlAHbVT+Df/0vWPxHAupf+LnPcv4F/A/6m/pkAXlqX1y4S4N9TXYAjhL37D/MEcV7gMRWC+XbhXva/vIY8mB0oJgFZE68IwJKASgRqhW8gt+t7qu9j+z7AOd73YYEigQKsFl4UR6Cs/hjsvdg+AnkvBxDnAqyT8ATRcgCjDP9svN8D7hFQH9mW8wDLH/uS84duIcBOADvw1+vrDP5EAgn81QEU9b9Z7i+v1ruLm9P91fWSlX99uLxeduXP/72UgF/An/7d3cCu9vY/mxtIpNAmENFEIpxUVLsEsVyIvz3gW4b5NeN2tmBMBOplIT4hiIafy4I2GIh0vtj1eQKYAb8CcTPhSAjNIbBKN9XluB4BaR0Bxt3Wntt9RiGAjd/fJIB2P2aThI4APvcLX/+Qq8uL2633//pmcwA5D7D/u+4EgODfcgCXN9n236TYf4v5i/pf3qzPLm+WlzYCuLhen51PP5+Bnohg3YFv3UDLDxQnwF2D+DlZfTOrsJJBATo2DuH8gWL92farvoCS6OMfIFEOwHb6aa2PC389sM8RgFJ3tuz9zz4HgGRh1RvJoSm+B7aP72fcwBzIE1mp+F8ve1zcj6HF4x1ApNBHlyuQP0X99xDgj37B+Z/ZZgJuan+9xf03hQh24G9hADiA9XYD/9Vm+wv4N9t/c3q4SjF/Uv/b00YALy2Xr9/toN8AvxQnYN2ATw5ymbCBn+cP6O7BXi4gKbt6bwB3A7b2Xp8HKOt0yQ/7ARG+jyWAfkxvXwLOCh+BfmTnrcqzSs8TQM/2Ixn0/44s/S93Angq+HcC+OzPf/2fvry8uN0SgDebA7jNZLA5gE39b5r9v0rKf3dVwb/eX93sln8jgedXxfrfnl66uj29clpeuzovmwNA8AchgUsS2vkDLUegmoZ8+3CL++EVUykAAAroSURBVDkUwLIgZ/zbJKAxAWjVj+DPZT6l7PGyWOHbPrG954SftfqYsUfgq2y+dQUjy+/t/Tzoe0m8Iwm+IyQRJQY5CXg0B3BU6WeBPbtdLzxYPuvzzv/U5gA2639zs+z/7mHAzbolBHcCKMm/jQCutth/j/vX7d+HTADPrm63uH99fnW7vHx1e9r+eyXZ//KfJ4HdGVTg49++aUj1CpQ3BtlwoCi8bwyypBCVAIvi4zyAErdj/d/W+THhZ0OAluizfqAY//ZvWm8V3y+zQI8dgFZ5TQYc51vwzzkAb917BKCAGW3PDuCXAgG8LyQAdwfwhz/n9X/y+uridkv+3dxuJHC6ubrdqwHbsj0EuLpZNtW/u7peGwHs4F835X92dbs8v9pU/2ZX/pev7k6vXFy/nuN/JADrBhIBaBJoCcG4cxAJoLx5WLYM0wtD5roA2fpz7K8IwCb4uJVHE0ADvFfz7RxK/Ru4LUGwQnMI4IFdYmmO171LaLF128cvs1UAuz5ah8vV30cJAMH1S9kBsGN5TCJw+Yw/cv4ntiagHfy3y04A1zc78HfwX+/gT7H/dVb/6xL3327gT9b/6nZ96fpueWVT/qvb01tOl++5bur/cxnojQwa+I/mBLhV2L9dKH5vQNQEZBN+HOPrz9zO44t43MiLYFXlO2XnRxY/EUSk9t6y2+x+ZPObVe+B3TuDPiG8SQAWokdDgzckCfjpn/n6P745gOub8/XtXQoBbm4365/UPxHAHvfvsf/VzXp/fbs829Q/Kf/6/Pou2f7ru9MrV3ent17drq+cTxvoy38YCvx8Sgru/xVHgJWBLWmI5cFSDrTJQPdCkVwJ4NmC/sUgUcZ/3vIfaemJQK+s/XiZBWzbPlJ2julVjK/jcgR++ZsBrAhg1va/kSHALwYH8CJCgBeSA/i0P3T+x7YGoNu7083t7XJzfbvF/nseYI//r28T+K9vlx38V7fLw/Vu+9dn13fLS9cp4ffy9d36yvX98tbru9PblqvX7hL4fzaDfPt7A74lAp8cTETguwYxIahLghgCqAQgZvltzV/N+ceY36f1UNl1lb/E9Sd6y7+N8dneKzvvFR7t/yzwtaIzyBXAjzqAxxDAiAx+KYYA7zME8Ac/7fV/9Ob24vbm9ny9EcDN3XK7hQBIAJv1v7o93V/fnh6ub9eH6xTzP7++O710fXd6+ebu9Jbr7b/709uu79e3J+AXAkguYN0/RwRAvQKibbg1BJWOQZwp2HthCJf+et1+JRTAWL7pfQ/sNr7nuD599m5AJfSsbbcqbxXcO4A5oCt1j9T8TQIoYc2L7QN4nyGAT/nU8z+yxf27A7jL1YDbXflvr2+T/b/ewL9Z/7vl2fXt6dn13en5zQ7+9eWbu2UD/ltv7k9vu3k4vd9y9Z77jQDWnQTKfxgKIBFgGJAbhUTbsJowZDsES6mPXxdWynyo8tFbfjDJx8k8m85TyTyM1ft/FzKYA3oP5M0dPA34PYv/JgH8EieAT/797/21m/Lf3adE4O3mAG53F7Db/5vbZVP+++u79eHmdrHgv1/ecvNweuvt/entG/hv7s9vP59+5tT+804guQAmgVYitKVBnEWIU4jt68PGrw23qt+SegXY0b/JynNZT8X1aOf93x70bZsE3gjoPZC/SQD9rr+ogagk0zj0+IXsA3ifcQCf+MnnX3N3d0oEcJcSgDe7+q+3O/jvNuu/3t/cnZ7d3C278t/cry/fFvA/rG+/fVje/+756YNOFz97fT79NBHARgg2HIhDgdw1OJwjYF8eqgmgB3rM67eIXgO9WHf+19p6SwocpyfrjqBn8EZgfpMAPMij0l4P0DPrflkSwO/5hPf+6vv75ADu7vdqwM3N3cXdzd2m/uvdzd3ycLOp/93p+e39ksD/sLzl9uH0trtnp7ffPjt9wN2z0wdd3b7n5fPpp06JAJgEOBTQYUBT/1IaxAlBJfmH7xDEST6+xIdKz5F8qfKrd/O0WL84gAJg/JeXqdq8An16tdSbBKB7BHp9ALPAf7MKMN8RsHzc7z7/g/cPp5v73QGsexLw9m7J4D/d394vz27u1me3D8tLt/fry3cPy1vunu3gf7+75+sH3L+0/Irbh9c/4Hz6yVMigB4JRKXBEv+rSUL0GnE38Qd7+5Xql7l6GMe3Rt+WnPMKX1Q9+jft6y08gtv//SYBqJzDTKb/KAEcJYJflg7gYz72vb/y4dmm/psLWG5v7k63t3enu9u7Dfynh9v707O7DfwPp5fvHk5vuX++vu3++fL+98/XD3x4efngh5dPv+p8+vFTIgAmAZUP4N6AKP7HdwTYdwNibb/9BFjSdGXum9pbkFulb3G4BbwHuQJ4H/SFJLZ/33cJYFQJeKP6AGbLgL8YCEDF9rPLODcx0vEX0gfw0b/z/MHPn59ubvcQYFP/9fb2frm/vV/v7+5Pz+6fLS/dPZxevn92esv9S6e3Pzw/vf/Dy6e/79nLp7//+VtO/9B68RNXiQCYBEoYsP0bhQB2fkD78RCeAdisPv/mXwx6m7zzoG5ttiU2t/82m95UHoFs/36TAHRD0Wxr8C8VBzAL9veZJOBH/vb3ftBGAPfPLm/v7k63dw+nu7v70/3tw/pw/3B6fv/s9PLDS8tbH146vf3ZS+sHPH/L8sHPX1l/1ctvW37N6fLHb86nHz2dTz8mCGALBdABYGMQTxDCl4Xa2X42wccqz026kcK3hhwEeQTs2eUYy79JAG8SQNSbP0sKf08cwG/7iPMHJAew3jw8XNzd3Z/v7p8tD/fPTs8fXjq9/Oyl5a3PXz693/NX1g986a3Lr3zlbadf/cr7nf7h08WPXJ9PP3w6n34ECOAnIAwoyUDVC8CTgLi5BxW/NOew1iewl/9KLI9Kj0BWoJ4F+psOIIH7zRDAViQUYGfB/j7jAD78w197+7Pny83Ds+X2/tly9/Cw3j97aXn+7KXl5ecvn976/JX1/V552/IrXnnb+g+89f2XX/u2D/z/2zuXnYSBMAqf0YhAW1pKuQVUVDRqCG5MUBN0oRt3bnwMX8c38EmMD+DGxBgX3qKocUc0mk5NkQk/ZWw1bozMgnBpWJ5zvv8yrbfM0QLHIzieiAH4FED7ACL9xS4APQlI7wxM7+4jOvm9pKejObng+1H9K9ErA/jeslDYOrAygH9oADs7PK3piCU1b1wzWEI3mKYZnmFazDZt5KwMypkcqtki6pbzuuTiFhz34HgIGIBIf5r8YtxHEz+I+PLmXb/YP0VOXwK/xW/0e9Rn2XUZzkcRgioBoqlA9QB69ESben+GALa231O67sV0YyRupJA00yMpy2a27aDg5FHJl7xaucKaca1V4LiEi5uuAfgEQPGf1vy0xqcNPXnCy0QcJvZgyn8n9RUBKAKQbQaGj/56kqVPBgqKVzZujBL7nzGAZrOtpczYuGmxhGUzw8myTK6IUmkSi5Uqa05Mt7c4TsFxAY4ruLjr4r8vfj/1hfBF2gu8F3W8OIwzmOJRqR5mDIoABpeJxHz9N++qBKCiHwIDaKy+JWx7LO5kPb1QhDM1g9mFGttYWfP2OY7BcQKOc3Bcd7Df7XT9/VpfHPWlgo8WeVD0UUkvS3tFAIPjyN+Inv5XGcCQGUC9/hwrlQ1tbn602FjH5u7eywHHIVwcgeOsi/v+jN9v6vn1O+AG6vEwUf/kWjDVFQGEpzwdPSoD6J9UfIX2wWWiYS8BPgCAPOYxoDrtqQAAAABJRU5ErkJggg==";
  97070. return BRDFTextureTools;
  97071. }());
  97072. /***/ }),
  97073. /***/ "./Misc/dds.ts":
  97074. /*!*********************!*\
  97075. !*** ./Misc/dds.ts ***!
  97076. \*********************/
  97077. /*! exports provided: DDSTools */
  97078. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97079. "use strict";
  97080. __webpack_require__.r(__webpack_exports__);
  97081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  97082. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  97083. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  97084. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97085. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  97086. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  97087. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  97088. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  97089. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  97090. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  97091. // All values and structures referenced from:
  97092. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  97093. var DDS_MAGIC = 0x20534444;
  97094. var
  97095. //DDSD_CAPS = 0x1,
  97096. //DDSD_HEIGHT = 0x2,
  97097. //DDSD_WIDTH = 0x4,
  97098. //DDSD_PITCH = 0x8,
  97099. //DDSD_PIXELFORMAT = 0x1000,
  97100. DDSD_MIPMAPCOUNT = 0x20000;
  97101. //DDSD_LINEARSIZE = 0x80000,
  97102. //DDSD_DEPTH = 0x800000;
  97103. // var DDSCAPS_COMPLEX = 0x8,
  97104. // DDSCAPS_MIPMAP = 0x400000,
  97105. // DDSCAPS_TEXTURE = 0x1000;
  97106. var DDSCAPS2_CUBEMAP = 0x200;
  97107. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  97108. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  97109. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  97110. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  97111. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  97112. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  97113. // DDSCAPS2_VOLUME = 0x200000;
  97114. var
  97115. //DDPF_ALPHAPIXELS = 0x1,
  97116. //DDPF_ALPHA = 0x2,
  97117. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  97118. //DDPF_YUV = 0x200,
  97119. DDPF_LUMINANCE = 0x20000;
  97120. function FourCCToInt32(value) {
  97121. return value.charCodeAt(0) +
  97122. (value.charCodeAt(1) << 8) +
  97123. (value.charCodeAt(2) << 16) +
  97124. (value.charCodeAt(3) << 24);
  97125. }
  97126. function Int32ToFourCC(value) {
  97127. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  97128. }
  97129. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  97130. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  97131. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  97132. var FOURCC_DX10 = FourCCToInt32("DX10");
  97133. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  97134. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  97135. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  97136. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  97137. var headerLengthInt = 31; // The header length in 32 bit ints
  97138. // Offsets into the header array
  97139. var off_magic = 0;
  97140. var off_size = 1;
  97141. var off_flags = 2;
  97142. var off_height = 3;
  97143. var off_width = 4;
  97144. var off_mipmapCount = 7;
  97145. var off_pfFlags = 20;
  97146. var off_pfFourCC = 21;
  97147. var off_RGBbpp = 22;
  97148. var off_RMask = 23;
  97149. var off_GMask = 24;
  97150. var off_BMask = 25;
  97151. var off_AMask = 26;
  97152. // var off_caps1 = 27;
  97153. var off_caps2 = 28;
  97154. // var off_caps3 = 29;
  97155. // var off_caps4 = 30;
  97156. var off_dxgiFormat = 32;
  97157. /**
  97158. * Class used to provide DDS decompression tools
  97159. */
  97160. var DDSTools = /** @class */ (function () {
  97161. function DDSTools() {
  97162. }
  97163. /**
  97164. * Gets DDS information from an array buffer
  97165. * @param arrayBuffer defines the array buffer to read data from
  97166. * @returns the DDS information
  97167. */
  97168. DDSTools.GetDDSInfo = function (arrayBuffer) {
  97169. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  97170. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  97171. var mipmapCount = 1;
  97172. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  97173. mipmapCount = Math.max(1, header[off_mipmapCount]);
  97174. }
  97175. var fourCC = header[off_pfFourCC];
  97176. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  97177. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97178. switch (fourCC) {
  97179. case FOURCC_D3DFMT_R16G16B16A16F:
  97180. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  97181. break;
  97182. case FOURCC_D3DFMT_R32G32B32A32F:
  97183. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  97184. break;
  97185. case FOURCC_DX10:
  97186. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  97187. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  97188. break;
  97189. }
  97190. }
  97191. return {
  97192. width: header[off_width],
  97193. height: header[off_height],
  97194. mipmapCount: mipmapCount,
  97195. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  97196. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  97197. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  97198. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  97199. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  97200. dxgiFormat: dxgiFormat,
  97201. textureType: textureType
  97202. };
  97203. };
  97204. DDSTools._ToHalfFloat = function (value) {
  97205. if (!DDSTools._FloatView) {
  97206. DDSTools._FloatView = new Float32Array(1);
  97207. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  97208. }
  97209. DDSTools._FloatView[0] = value;
  97210. var x = DDSTools._Int32View[0];
  97211. var bits = (x >> 16) & 0x8000; /* Get the sign */
  97212. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  97213. var e = (x >> 23) & 0xff; /* Using int is faster here */
  97214. /* If zero, or denormal, or exponent underflows too much for a denormal
  97215. * half, return signed zero. */
  97216. if (e < 103) {
  97217. return bits;
  97218. }
  97219. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  97220. if (e > 142) {
  97221. bits |= 0x7c00;
  97222. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  97223. * not Inf, so make sure we set one mantissa bit too. */
  97224. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  97225. return bits;
  97226. }
  97227. /* If exponent underflows but not too much, return a denormal */
  97228. if (e < 113) {
  97229. m |= 0x0800;
  97230. /* Extra rounding may overflow and set mantissa to 0 and exponent
  97231. * to 1, which is OK. */
  97232. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  97233. return bits;
  97234. }
  97235. bits |= ((e - 112) << 10) | (m >> 1);
  97236. bits += m & 1;
  97237. return bits;
  97238. };
  97239. DDSTools._FromHalfFloat = function (value) {
  97240. var s = (value & 0x8000) >> 15;
  97241. var e = (value & 0x7C00) >> 10;
  97242. var f = value & 0x03FF;
  97243. if (e === 0) {
  97244. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  97245. }
  97246. else if (e == 0x1F) {
  97247. return f ? NaN : ((s ? -1 : 1) * Infinity);
  97248. }
  97249. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  97250. };
  97251. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  97252. var destArray = new Float32Array(dataLength);
  97253. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  97254. var index = 0;
  97255. for (var y = 0; y < height; y++) {
  97256. for (var x = 0; x < width; x++) {
  97257. var srcPos = (x + y * width) * 4;
  97258. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  97259. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  97260. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  97261. if (DDSTools.StoreLODInAlphaChannel) {
  97262. destArray[index + 3] = lod;
  97263. }
  97264. else {
  97265. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  97266. }
  97267. index += 4;
  97268. }
  97269. }
  97270. return destArray;
  97271. };
  97272. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  97273. if (DDSTools.StoreLODInAlphaChannel) {
  97274. var destArray = new Uint16Array(dataLength);
  97275. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  97276. var index = 0;
  97277. for (var y = 0; y < height; y++) {
  97278. for (var x = 0; x < width; x++) {
  97279. var srcPos = (x + y * width) * 4;
  97280. destArray[index] = srcData[srcPos];
  97281. destArray[index + 1] = srcData[srcPos + 1];
  97282. destArray[index + 2] = srcData[srcPos + 2];
  97283. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  97284. index += 4;
  97285. }
  97286. }
  97287. return destArray;
  97288. }
  97289. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  97290. };
  97291. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  97292. if (DDSTools.StoreLODInAlphaChannel) {
  97293. var destArray = new Float32Array(dataLength);
  97294. var srcData = new Float32Array(arrayBuffer, dataOffset);
  97295. var index = 0;
  97296. for (var y = 0; y < height; y++) {
  97297. for (var x = 0; x < width; x++) {
  97298. var srcPos = (x + y * width) * 4;
  97299. destArray[index] = srcData[srcPos];
  97300. destArray[index + 1] = srcData[srcPos + 1];
  97301. destArray[index + 2] = srcData[srcPos + 2];
  97302. destArray[index + 3] = lod;
  97303. index += 4;
  97304. }
  97305. }
  97306. return destArray;
  97307. }
  97308. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  97309. };
  97310. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  97311. var destArray = new Uint8Array(dataLength);
  97312. var srcData = new Float32Array(arrayBuffer, dataOffset);
  97313. var index = 0;
  97314. for (var y = 0; y < height; y++) {
  97315. for (var x = 0; x < width; x++) {
  97316. var srcPos = (x + y * width) * 4;
  97317. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  97318. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  97319. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  97320. if (DDSTools.StoreLODInAlphaChannel) {
  97321. destArray[index + 3] = lod;
  97322. }
  97323. else {
  97324. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  97325. }
  97326. index += 4;
  97327. }
  97328. }
  97329. return destArray;
  97330. };
  97331. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  97332. var destArray = new Uint8Array(dataLength);
  97333. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  97334. var index = 0;
  97335. for (var y = 0; y < height; y++) {
  97336. for (var x = 0; x < width; x++) {
  97337. var srcPos = (x + y * width) * 4;
  97338. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  97339. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  97340. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  97341. if (DDSTools.StoreLODInAlphaChannel) {
  97342. destArray[index + 3] = lod;
  97343. }
  97344. else {
  97345. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  97346. }
  97347. index += 4;
  97348. }
  97349. }
  97350. return destArray;
  97351. };
  97352. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  97353. var byteArray = new Uint8Array(dataLength);
  97354. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  97355. var index = 0;
  97356. for (var y = 0; y < height; y++) {
  97357. for (var x = 0; x < width; x++) {
  97358. var srcPos = (x + y * width) * 4;
  97359. byteArray[index] = srcData[srcPos + rOffset];
  97360. byteArray[index + 1] = srcData[srcPos + gOffset];
  97361. byteArray[index + 2] = srcData[srcPos + bOffset];
  97362. byteArray[index + 3] = srcData[srcPos + aOffset];
  97363. index += 4;
  97364. }
  97365. }
  97366. return byteArray;
  97367. };
  97368. DDSTools._ExtractLongWordOrder = function (value) {
  97369. if (value === 0 || value === 255 || value === -16777216) {
  97370. return 0;
  97371. }
  97372. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  97373. };
  97374. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  97375. var byteArray = new Uint8Array(dataLength);
  97376. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  97377. var index = 0;
  97378. for (var y = 0; y < height; y++) {
  97379. for (var x = 0; x < width; x++) {
  97380. var srcPos = (x + y * width) * 3;
  97381. byteArray[index] = srcData[srcPos + rOffset];
  97382. byteArray[index + 1] = srcData[srcPos + gOffset];
  97383. byteArray[index + 2] = srcData[srcPos + bOffset];
  97384. index += 3;
  97385. }
  97386. }
  97387. return byteArray;
  97388. };
  97389. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  97390. var byteArray = new Uint8Array(dataLength);
  97391. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  97392. var index = 0;
  97393. for (var y = 0; y < height; y++) {
  97394. for (var x = 0; x < width; x++) {
  97395. var srcPos = (x + y * width);
  97396. byteArray[index] = srcData[srcPos];
  97397. index++;
  97398. }
  97399. }
  97400. return byteArray;
  97401. };
  97402. /**
  97403. * Uploads DDS Levels to a Babylon Texture
  97404. * @hidden
  97405. */
  97406. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  97407. if (lodIndex === void 0) { lodIndex = -1; }
  97408. var sphericalPolynomialFaces = null;
  97409. if (info.sphericalPolynomial) {
  97410. sphericalPolynomialFaces = new Array();
  97411. }
  97412. var ext = engine.getCaps().s3tc;
  97413. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  97414. var fourCC, width, height, dataLength = 0, dataOffset;
  97415. var byteArray, mipmapCount, mip;
  97416. var internalCompressedFormat = 0;
  97417. var blockBytes = 1;
  97418. if (header[off_magic] !== DDS_MAGIC) {
  97419. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  97420. return;
  97421. }
  97422. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  97423. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  97424. return;
  97425. }
  97426. if (info.isCompressed && !ext) {
  97427. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  97428. return;
  97429. }
  97430. var bpp = header[off_RGBbpp];
  97431. dataOffset = header[off_size] + 4;
  97432. var computeFormats = false;
  97433. if (info.isFourCC) {
  97434. fourCC = header[off_pfFourCC];
  97435. switch (fourCC) {
  97436. case FOURCC_DXT1:
  97437. blockBytes = 8;
  97438. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  97439. break;
  97440. case FOURCC_DXT3:
  97441. blockBytes = 16;
  97442. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  97443. break;
  97444. case FOURCC_DXT5:
  97445. blockBytes = 16;
  97446. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  97447. break;
  97448. case FOURCC_D3DFMT_R16G16B16A16F:
  97449. computeFormats = true;
  97450. break;
  97451. case FOURCC_D3DFMT_R32G32B32A32F:
  97452. computeFormats = true;
  97453. break;
  97454. case FOURCC_DX10:
  97455. // There is an additionnal header so dataOffset need to be changed
  97456. dataOffset += 5 * 4; // 5 uints
  97457. var supported = false;
  97458. switch (info.dxgiFormat) {
  97459. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  97460. computeFormats = true;
  97461. supported = true;
  97462. break;
  97463. case DXGI_FORMAT_B8G8R8X8_UNORM:
  97464. info.isRGB = true;
  97465. info.isFourCC = false;
  97466. bpp = 32;
  97467. supported = true;
  97468. break;
  97469. }
  97470. if (supported) {
  97471. break;
  97472. }
  97473. default:
  97474. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  97475. return;
  97476. }
  97477. }
  97478. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  97479. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  97480. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  97481. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  97482. if (computeFormats) {
  97483. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  97484. }
  97485. mipmapCount = 1;
  97486. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  97487. mipmapCount = Math.max(1, header[off_mipmapCount]);
  97488. }
  97489. var startFace = currentFace || 0;
  97490. for (var face = startFace; face < faces; face++) {
  97491. width = header[off_width];
  97492. height = header[off_height];
  97493. for (mip = 0; mip < mipmapCount; ++mip) {
  97494. if (lodIndex === -1 || lodIndex === mip) {
  97495. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  97496. var i = (lodIndex === -1) ? mip : 0;
  97497. if (!info.isCompressed && info.isFourCC) {
  97498. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  97499. dataLength = width * height * 4;
  97500. var floatArray = null;
  97501. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  97502. if (bpp === 128) {
  97503. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  97504. if (sphericalPolynomialFaces && i == 0) {
  97505. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  97506. }
  97507. }
  97508. else if (bpp === 64) {
  97509. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  97510. if (sphericalPolynomialFaces && i == 0) {
  97511. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  97512. }
  97513. }
  97514. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97515. }
  97516. else {
  97517. if (bpp === 128) {
  97518. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  97519. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  97520. if (sphericalPolynomialFaces && i == 0) {
  97521. sphericalPolynomialFaces.push(floatArray);
  97522. }
  97523. }
  97524. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  97525. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  97526. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  97527. if (sphericalPolynomialFaces && i == 0) {
  97528. sphericalPolynomialFaces.push(floatArray);
  97529. }
  97530. }
  97531. else { // 64
  97532. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  97533. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  97534. if (sphericalPolynomialFaces && i == 0) {
  97535. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  97536. }
  97537. }
  97538. }
  97539. if (floatArray) {
  97540. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  97541. }
  97542. }
  97543. else if (info.isRGB) {
  97544. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97545. if (bpp === 24) {
  97546. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  97547. dataLength = width * height * 3;
  97548. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  97549. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  97550. }
  97551. else { // 32
  97552. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  97553. dataLength = width * height * 4;
  97554. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  97555. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  97556. }
  97557. }
  97558. else if (info.isLuminance) {
  97559. var unpackAlignment = engine._getUnpackAlignement();
  97560. var unpaddedRowSize = width;
  97561. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  97562. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  97563. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  97564. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  97565. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97566. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  97567. }
  97568. else {
  97569. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  97570. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  97571. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97572. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  97573. }
  97574. }
  97575. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  97576. width *= 0.5;
  97577. height *= 0.5;
  97578. width = Math.max(1.0, width);
  97579. height = Math.max(1.0, height);
  97580. }
  97581. if (currentFace !== undefined) {
  97582. // Loading a single face
  97583. break;
  97584. }
  97585. }
  97586. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  97587. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  97588. size: header[off_width],
  97589. right: sphericalPolynomialFaces[0],
  97590. left: sphericalPolynomialFaces[1],
  97591. up: sphericalPolynomialFaces[2],
  97592. down: sphericalPolynomialFaces[3],
  97593. front: sphericalPolynomialFaces[4],
  97594. back: sphericalPolynomialFaces[5],
  97595. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  97596. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  97597. gammaSpace: false,
  97598. });
  97599. }
  97600. else {
  97601. info.sphericalPolynomial = undefined;
  97602. }
  97603. };
  97604. /**
  97605. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  97606. */
  97607. DDSTools.StoreLODInAlphaChannel = false;
  97608. return DDSTools;
  97609. }());
  97610. /**
  97611. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  97612. * @param rootUrl defines the url where the file to load is located
  97613. * @param scene defines the current scene
  97614. * @param lodScale defines scale to apply to the mip map selection
  97615. * @param lodOffset defines offset to apply to the mip map selection
  97616. * @param onLoad defines an optional callback raised when the texture is loaded
  97617. * @param onError defines an optional callback raised if there is an issue to load the texture
  97618. * @param format defines the format of the data
  97619. * @param forcedExtension defines the extension to use to pick the right loader
  97620. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  97621. * @returns the cube texture as an InternalTexture
  97622. */
  97623. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  97624. var _this = this;
  97625. if (onLoad === void 0) { onLoad = null; }
  97626. if (onError === void 0) { onError = null; }
  97627. if (forcedExtension === void 0) { forcedExtension = null; }
  97628. if (createPolynomials === void 0) { createPolynomials = true; }
  97629. var callback = function (loadData) {
  97630. if (!loadData) {
  97631. if (onLoad) {
  97632. onLoad(null);
  97633. }
  97634. return;
  97635. }
  97636. var texture = loadData.texture;
  97637. if (!createPolynomials) {
  97638. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  97639. }
  97640. else if (loadData.info.sphericalPolynomial) {
  97641. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  97642. }
  97643. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  97644. if (_this.getCaps().textureLOD) {
  97645. // Do not add extra process if texture lod is supported.
  97646. if (onLoad) {
  97647. onLoad(texture);
  97648. }
  97649. return;
  97650. }
  97651. var mipSlices = 3;
  97652. var gl = _this._gl;
  97653. var width = loadData.width;
  97654. if (!width) {
  97655. return;
  97656. }
  97657. var textures = [];
  97658. for (var i = 0; i < mipSlices; i++) {
  97659. //compute LOD from even spacing in smoothness (matching shader calculation)
  97660. var smoothness = i / (mipSlices - 1);
  97661. var roughness = 1 - smoothness;
  97662. var minLODIndex = lodOffset; // roughness = 0
  97663. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  97664. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  97665. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  97666. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  97667. glTextureFromLod.type = texture.type;
  97668. glTextureFromLod.format = texture.format;
  97669. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  97670. glTextureFromLod.height = glTextureFromLod.width;
  97671. glTextureFromLod.isCube = true;
  97672. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  97673. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  97674. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  97675. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  97676. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  97677. if (loadData.isDDS) {
  97678. var info = loadData.info;
  97679. var data = loadData.data;
  97680. _this._unpackFlipY(info.isCompressed);
  97681. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  97682. }
  97683. else {
  97684. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  97685. }
  97686. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  97687. // Wrap in a base texture for easy binding.
  97688. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  97689. lodTexture.isCube = true;
  97690. lodTexture._texture = glTextureFromLod;
  97691. glTextureFromLod.isReady = true;
  97692. textures.push(lodTexture);
  97693. }
  97694. texture._lodTextureHigh = textures[2];
  97695. texture._lodTextureMid = textures[1];
  97696. texture._lodTextureLow = textures[0];
  97697. if (onLoad) {
  97698. onLoad(texture);
  97699. }
  97700. };
  97701. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  97702. };
  97703. /***/ }),
  97704. /***/ "./Misc/decorators.ts":
  97705. /*!****************************!*\
  97706. !*** ./Misc/decorators.ts ***!
  97707. \****************************/
  97708. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper */
  97709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97710. "use strict";
  97711. __webpack_require__.r(__webpack_exports__);
  97712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  97713. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  97714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  97715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  97716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  97717. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  97718. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  97719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  97720. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  97721. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  97722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  97723. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  97724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return serializeAsMatrix; });
  97725. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  97726. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  97727. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  97728. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  97729. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  97730. var __decoratorInitialStore = {};
  97731. var __mergedStore = {};
  97732. var _copySource = function (creationFunction, source, instanciate) {
  97733. var destination = creationFunction();
  97734. // Tags
  97735. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  97736. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  97737. }
  97738. var classStore = getMergedStore(destination);
  97739. // Properties
  97740. for (var property in classStore) {
  97741. var propertyDescriptor = classStore[property];
  97742. var sourceProperty = source[property];
  97743. var propertyType = propertyDescriptor.type;
  97744. if (sourceProperty !== undefined && sourceProperty !== null && property !== "uniqueId") {
  97745. switch (propertyType) {
  97746. case 0: // Value
  97747. case 6: // Mesh reference
  97748. case 11: // Camera reference
  97749. destination[property] = sourceProperty;
  97750. break;
  97751. case 1: // Texture
  97752. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  97753. break;
  97754. case 2: // Color3
  97755. case 3: // FresnelParameters
  97756. case 4: // Vector2
  97757. case 5: // Vector3
  97758. case 7: // Color Curves
  97759. case 10: // Quaternion
  97760. case 12: // Matrix
  97761. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  97762. break;
  97763. }
  97764. }
  97765. }
  97766. return destination;
  97767. };
  97768. function getDirectStore(target) {
  97769. var classKey = target.getClassName();
  97770. if (!__decoratorInitialStore[classKey]) {
  97771. __decoratorInitialStore[classKey] = {};
  97772. }
  97773. return __decoratorInitialStore[classKey];
  97774. }
  97775. /**
  97776. * Return the list of properties flagged as serializable
  97777. * @param target: host object
  97778. */
  97779. function getMergedStore(target) {
  97780. var classKey = target.getClassName();
  97781. if (__mergedStore[classKey]) {
  97782. return __mergedStore[classKey];
  97783. }
  97784. __mergedStore[classKey] = {};
  97785. var store = __mergedStore[classKey];
  97786. var currentTarget = target;
  97787. var currentKey = classKey;
  97788. while (currentKey) {
  97789. var initialStore = __decoratorInitialStore[currentKey];
  97790. for (var property in initialStore) {
  97791. store[property] = initialStore[property];
  97792. }
  97793. var parent_1 = void 0;
  97794. var done = false;
  97795. do {
  97796. parent_1 = Object.getPrototypeOf(currentTarget);
  97797. if (!parent_1.getClassName) {
  97798. done = true;
  97799. break;
  97800. }
  97801. if (parent_1.getClassName() !== currentKey) {
  97802. break;
  97803. }
  97804. currentTarget = parent_1;
  97805. } while (parent_1);
  97806. if (done) {
  97807. break;
  97808. }
  97809. currentKey = parent_1.getClassName();
  97810. currentTarget = parent_1;
  97811. }
  97812. return store;
  97813. }
  97814. function generateSerializableMember(type, sourceName) {
  97815. return function (target, propertyKey) {
  97816. var classStore = getDirectStore(target);
  97817. if (!classStore[propertyKey]) {
  97818. classStore[propertyKey] = { type: type, sourceName: sourceName };
  97819. }
  97820. };
  97821. }
  97822. function generateExpandMember(setCallback, targetKey) {
  97823. if (targetKey === void 0) { targetKey = null; }
  97824. return function (target, propertyKey) {
  97825. var key = targetKey || ("_" + propertyKey);
  97826. Object.defineProperty(target, propertyKey, {
  97827. get: function () {
  97828. return this[key];
  97829. },
  97830. set: function (value) {
  97831. if (this[key] === value) {
  97832. return;
  97833. }
  97834. this[key] = value;
  97835. target[setCallback].apply(this);
  97836. },
  97837. enumerable: true,
  97838. configurable: true
  97839. });
  97840. };
  97841. }
  97842. function expandToProperty(callback, targetKey) {
  97843. if (targetKey === void 0) { targetKey = null; }
  97844. return generateExpandMember(callback, targetKey);
  97845. }
  97846. function serialize(sourceName) {
  97847. return generateSerializableMember(0, sourceName); // value member
  97848. }
  97849. function serializeAsTexture(sourceName) {
  97850. return generateSerializableMember(1, sourceName); // texture member
  97851. }
  97852. function serializeAsColor3(sourceName) {
  97853. return generateSerializableMember(2, sourceName); // color3 member
  97854. }
  97855. function serializeAsFresnelParameters(sourceName) {
  97856. return generateSerializableMember(3, sourceName); // fresnel parameters member
  97857. }
  97858. function serializeAsVector2(sourceName) {
  97859. return generateSerializableMember(4, sourceName); // vector2 member
  97860. }
  97861. function serializeAsVector3(sourceName) {
  97862. return generateSerializableMember(5, sourceName); // vector3 member
  97863. }
  97864. function serializeAsMeshReference(sourceName) {
  97865. return generateSerializableMember(6, sourceName); // mesh reference member
  97866. }
  97867. function serializeAsColorCurves(sourceName) {
  97868. return generateSerializableMember(7, sourceName); // color curves
  97869. }
  97870. function serializeAsColor4(sourceName) {
  97871. return generateSerializableMember(8, sourceName); // color 4
  97872. }
  97873. function serializeAsImageProcessingConfiguration(sourceName) {
  97874. return generateSerializableMember(9, sourceName); // image processing
  97875. }
  97876. function serializeAsQuaternion(sourceName) {
  97877. return generateSerializableMember(10, sourceName); // quaternion member
  97878. }
  97879. function serializeAsMatrix(sourceName) {
  97880. return generateSerializableMember(12, sourceName); // matrix member
  97881. }
  97882. /**
  97883. * Decorator used to define property that can be serialized as reference to a camera
  97884. * @param sourceName defines the name of the property to decorate
  97885. */
  97886. function serializeAsCameraReference(sourceName) {
  97887. return generateSerializableMember(11, sourceName); // camera reference member
  97888. }
  97889. /**
  97890. * Class used to help serialization objects
  97891. */
  97892. var SerializationHelper = /** @class */ (function () {
  97893. function SerializationHelper() {
  97894. }
  97895. /**
  97896. * Appends the serialized animations from the source animations
  97897. * @param source Source containing the animations
  97898. * @param destination Target to store the animations
  97899. */
  97900. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  97901. if (source.animations) {
  97902. destination.animations = [];
  97903. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  97904. var animation = source.animations[animationIndex];
  97905. destination.animations.push(animation.serialize());
  97906. }
  97907. }
  97908. };
  97909. /**
  97910. * Static function used to serialized a specific entity
  97911. * @param entity defines the entity to serialize
  97912. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  97913. * @returns a JSON compatible object representing the serialization of the entity
  97914. */
  97915. SerializationHelper.Serialize = function (entity, serializationObject) {
  97916. if (!serializationObject) {
  97917. serializationObject = {};
  97918. }
  97919. // Tags
  97920. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  97921. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  97922. }
  97923. var serializedProperties = getMergedStore(entity);
  97924. // Properties
  97925. for (var property in serializedProperties) {
  97926. var propertyDescriptor = serializedProperties[property];
  97927. var targetPropertyName = propertyDescriptor.sourceName || property;
  97928. var propertyType = propertyDescriptor.type;
  97929. var sourceProperty = entity[property];
  97930. if (sourceProperty !== undefined && sourceProperty !== null) {
  97931. switch (propertyType) {
  97932. case 0: // Value
  97933. serializationObject[targetPropertyName] = sourceProperty;
  97934. break;
  97935. case 1: // Texture
  97936. serializationObject[targetPropertyName] = sourceProperty.serialize();
  97937. break;
  97938. case 2: // Color3
  97939. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97940. break;
  97941. case 3: // FresnelParameters
  97942. serializationObject[targetPropertyName] = sourceProperty.serialize();
  97943. break;
  97944. case 4: // Vector2
  97945. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97946. break;
  97947. case 5: // Vector3
  97948. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97949. break;
  97950. case 6: // Mesh reference
  97951. serializationObject[targetPropertyName] = sourceProperty.id;
  97952. break;
  97953. case 7: // Color Curves
  97954. serializationObject[targetPropertyName] = sourceProperty.serialize();
  97955. break;
  97956. case 8: // Color 4
  97957. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97958. break;
  97959. case 9: // Image Processing
  97960. serializationObject[targetPropertyName] = sourceProperty.serialize();
  97961. break;
  97962. case 10: // Quaternion
  97963. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97964. break;
  97965. case 11: // Camera reference
  97966. serializationObject[targetPropertyName] = sourceProperty.id;
  97967. case 12: // Matrix
  97968. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97969. break;
  97970. }
  97971. }
  97972. }
  97973. return serializationObject;
  97974. };
  97975. /**
  97976. * Creates a new entity from a serialization data object
  97977. * @param creationFunction defines a function used to instanciated the new entity
  97978. * @param source defines the source serialization data
  97979. * @param scene defines the hosting scene
  97980. * @param rootUrl defines the root url for resources
  97981. * @returns a new entity
  97982. */
  97983. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  97984. if (rootUrl === void 0) { rootUrl = null; }
  97985. var destination = creationFunction();
  97986. if (!rootUrl) {
  97987. rootUrl = "";
  97988. }
  97989. // Tags
  97990. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  97991. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  97992. }
  97993. var classStore = getMergedStore(destination);
  97994. // Properties
  97995. for (var property in classStore) {
  97996. var propertyDescriptor = classStore[property];
  97997. var sourceProperty = source[propertyDescriptor.sourceName || property];
  97998. var propertyType = propertyDescriptor.type;
  97999. if (sourceProperty !== undefined && sourceProperty !== null) {
  98000. var dest = destination;
  98001. switch (propertyType) {
  98002. case 0: // Value
  98003. dest[property] = sourceProperty;
  98004. break;
  98005. case 1: // Texture
  98006. if (scene) {
  98007. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  98008. }
  98009. break;
  98010. case 2: // Color3
  98011. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  98012. break;
  98013. case 3: // FresnelParameters
  98014. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  98015. break;
  98016. case 4: // Vector2
  98017. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  98018. break;
  98019. case 5: // Vector3
  98020. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  98021. break;
  98022. case 6: // Mesh reference
  98023. if (scene) {
  98024. dest[property] = scene.getLastMeshByID(sourceProperty);
  98025. }
  98026. break;
  98027. case 7: // Color Curves
  98028. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  98029. break;
  98030. case 8: // Color 4
  98031. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  98032. break;
  98033. case 9: // Image Processing
  98034. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  98035. break;
  98036. case 10: // Quaternion
  98037. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  98038. break;
  98039. case 11: // Camera reference
  98040. if (scene) {
  98041. dest[property] = scene.getCameraByID(sourceProperty);
  98042. }
  98043. case 12: // Matrix
  98044. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromArray(sourceProperty);
  98045. break;
  98046. }
  98047. }
  98048. }
  98049. return destination;
  98050. };
  98051. /**
  98052. * Clones an object
  98053. * @param creationFunction defines the function used to instanciate the new object
  98054. * @param source defines the source object
  98055. * @returns the cloned object
  98056. */
  98057. SerializationHelper.Clone = function (creationFunction, source) {
  98058. return _copySource(creationFunction, source, false);
  98059. };
  98060. /**
  98061. * Instanciates a new object based on a source one (some data will be shared between both object)
  98062. * @param creationFunction defines the function used to instanciate the new object
  98063. * @param source defines the source object
  98064. * @returns the new object
  98065. */
  98066. SerializationHelper.Instanciate = function (creationFunction, source) {
  98067. return _copySource(creationFunction, source, true);
  98068. };
  98069. /** hidden */
  98070. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  98071. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ImageProcessingConfiguration");
  98072. };
  98073. /** hidden */
  98074. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  98075. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("FresnelParameters");
  98076. };
  98077. /** hidden */
  98078. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  98079. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ColorCurves");
  98080. };
  98081. /** hidden */
  98082. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  98083. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("Texture");
  98084. };
  98085. return SerializationHelper;
  98086. }());
  98087. /***/ }),
  98088. /***/ "./Misc/deepCopier.ts":
  98089. /*!****************************!*\
  98090. !*** ./Misc/deepCopier.ts ***!
  98091. \****************************/
  98092. /*! exports provided: DeepCopier */
  98093. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98094. "use strict";
  98095. __webpack_require__.r(__webpack_exports__);
  98096. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  98097. var cloneValue = function (source, destinationObject) {
  98098. if (!source) {
  98099. return null;
  98100. }
  98101. if (source.getClassName && source.getClassName() === "Mesh") {
  98102. return null;
  98103. }
  98104. if (source.getClassName && source.getClassName() === "SubMesh") {
  98105. return source.clone(destinationObject);
  98106. }
  98107. else if (source.clone) {
  98108. return source.clone();
  98109. }
  98110. return null;
  98111. };
  98112. /**
  98113. * Class containing a set of static utilities functions for deep copy.
  98114. */
  98115. var DeepCopier = /** @class */ (function () {
  98116. function DeepCopier() {
  98117. }
  98118. /**
  98119. * Tries to copy an object by duplicating every property
  98120. * @param source defines the source object
  98121. * @param destination defines the target object
  98122. * @param doNotCopyList defines a list of properties to avoid
  98123. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98124. */
  98125. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  98126. for (var prop in source) {
  98127. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  98128. continue;
  98129. }
  98130. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  98131. continue;
  98132. }
  98133. var sourceValue = source[prop];
  98134. var typeOfSourceValue = typeof sourceValue;
  98135. if (typeOfSourceValue === "function") {
  98136. continue;
  98137. }
  98138. try {
  98139. if (typeOfSourceValue === "object") {
  98140. if (sourceValue instanceof Array) {
  98141. destination[prop] = [];
  98142. if (sourceValue.length > 0) {
  98143. if (typeof sourceValue[0] == "object") {
  98144. for (var index = 0; index < sourceValue.length; index++) {
  98145. var clonedValue = cloneValue(sourceValue[index], destination);
  98146. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  98147. destination[prop].push(clonedValue);
  98148. }
  98149. }
  98150. }
  98151. else {
  98152. destination[prop] = sourceValue.slice(0);
  98153. }
  98154. }
  98155. }
  98156. else {
  98157. destination[prop] = cloneValue(sourceValue, destination);
  98158. }
  98159. }
  98160. else {
  98161. destination[prop] = sourceValue;
  98162. }
  98163. }
  98164. catch (e) {
  98165. // Just ignore error (it could be because of a read-only property)
  98166. }
  98167. }
  98168. };
  98169. return DeepCopier;
  98170. }());
  98171. /***/ }),
  98172. /***/ "./Misc/deferred.ts":
  98173. /*!**************************!*\
  98174. !*** ./Misc/deferred.ts ***!
  98175. \**************************/
  98176. /*! exports provided: Deferred */
  98177. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98178. "use strict";
  98179. __webpack_require__.r(__webpack_exports__);
  98180. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  98181. /**
  98182. * Wrapper class for promise with external resolve and reject.
  98183. */
  98184. var Deferred = /** @class */ (function () {
  98185. /**
  98186. * Constructor for this deferred object.
  98187. */
  98188. function Deferred() {
  98189. var _this = this;
  98190. this.promise = new Promise(function (resolve, reject) {
  98191. _this._resolve = resolve;
  98192. _this._reject = reject;
  98193. });
  98194. }
  98195. Object.defineProperty(Deferred.prototype, "resolve", {
  98196. /**
  98197. * The resolve method of the promise associated with this deferred object.
  98198. */
  98199. get: function () {
  98200. return this._resolve;
  98201. },
  98202. enumerable: true,
  98203. configurable: true
  98204. });
  98205. Object.defineProperty(Deferred.prototype, "reject", {
  98206. /**
  98207. * The reject method of the promise associated with this deferred object.
  98208. */
  98209. get: function () {
  98210. return this._reject;
  98211. },
  98212. enumerable: true,
  98213. configurable: true
  98214. });
  98215. return Deferred;
  98216. }());
  98217. /***/ }),
  98218. /***/ "./Misc/devTools.ts":
  98219. /*!**************************!*\
  98220. !*** ./Misc/devTools.ts ***!
  98221. \**************************/
  98222. /*! exports provided: _DevTools */
  98223. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98224. "use strict";
  98225. __webpack_require__.r(__webpack_exports__);
  98226. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DevTools", function() { return _DevTools; });
  98227. /** @hidden */
  98228. var _DevTools = /** @class */ (function () {
  98229. function _DevTools() {
  98230. }
  98231. _DevTools.WarnImport = function (name) {
  98232. return name + " needs to be imported before as it contains a side-effect required by your code.";
  98233. };
  98234. return _DevTools;
  98235. }());
  98236. /***/ }),
  98237. /***/ "./Misc/domManagement.ts":
  98238. /*!*******************************!*\
  98239. !*** ./Misc/domManagement.ts ***!
  98240. \*******************************/
  98241. /*! exports provided: DomManagement */
  98242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98243. "use strict";
  98244. __webpack_require__.r(__webpack_exports__);
  98245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  98246. /**
  98247. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  98248. * Babylon.js
  98249. */
  98250. var DomManagement = /** @class */ (function () {
  98251. function DomManagement() {
  98252. }
  98253. /**
  98254. * Checks if the window object exists
  98255. * @returns true if the window object exists
  98256. */
  98257. DomManagement.IsWindowObjectExist = function () {
  98258. return (typeof window) !== "undefined";
  98259. };
  98260. /**
  98261. * Extracts text content from a DOM element hierarchy
  98262. * @param element defines the root element
  98263. * @returns a string
  98264. */
  98265. DomManagement.GetDOMTextContent = function (element) {
  98266. var result = "";
  98267. var child = element.firstChild;
  98268. while (child) {
  98269. if (child.nodeType === 3) {
  98270. result += child.textContent;
  98271. }
  98272. child = (child.nextSibling);
  98273. }
  98274. return result;
  98275. };
  98276. return DomManagement;
  98277. }());
  98278. /***/ }),
  98279. /***/ "./Misc/environmentTextureTools.ts":
  98280. /*!*****************************************!*\
  98281. !*** ./Misc/environmentTextureTools.ts ***!
  98282. \*****************************************/
  98283. /*! exports provided: EnvironmentTextureTools */
  98284. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98285. "use strict";
  98286. __webpack_require__.r(__webpack_exports__);
  98287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  98288. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  98289. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  98290. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  98291. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  98292. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  98293. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  98294. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  98295. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  98296. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  98297. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  98298. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  98299. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  98300. /**
  98301. * Sets of helpers addressing the serialization and deserialization of environment texture
  98302. * stored in a BabylonJS env file.
  98303. * Those files are usually stored as .env files.
  98304. */
  98305. var EnvironmentTextureTools = /** @class */ (function () {
  98306. function EnvironmentTextureTools() {
  98307. }
  98308. /**
  98309. * Gets the environment info from an env file.
  98310. * @param data The array buffer containing the .env bytes.
  98311. * @returns the environment file info (the json header) if successfully parsed.
  98312. */
  98313. EnvironmentTextureTools.GetEnvInfo = function (data) {
  98314. var dataView = new DataView(data);
  98315. var pos = 0;
  98316. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  98317. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  98318. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  98319. return null;
  98320. }
  98321. }
  98322. // Read json manifest - collect characters up to null terminator
  98323. var manifestString = '';
  98324. var charCode = 0x00;
  98325. while ((charCode = dataView.getUint8(pos++))) {
  98326. manifestString += String.fromCharCode(charCode);
  98327. }
  98328. var manifest = JSON.parse(manifestString);
  98329. if (manifest.specular) {
  98330. // Extend the header with the position of the payload.
  98331. manifest.specular.specularDataPosition = pos;
  98332. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  98333. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  98334. }
  98335. return manifest;
  98336. };
  98337. /**
  98338. * Creates an environment texture from a loaded cube texture.
  98339. * @param texture defines the cube texture to convert in env file
  98340. * @return a promise containing the environment data if succesfull.
  98341. */
  98342. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  98343. var _this = this;
  98344. var internalTexture = texture.getInternalTexture();
  98345. if (!internalTexture) {
  98346. return Promise.reject("The cube texture is invalid.");
  98347. }
  98348. if (!texture._prefiltered) {
  98349. return Promise.reject("The cube texture is invalid (not prefiltered).");
  98350. }
  98351. var engine = internalTexture.getEngine();
  98352. if (engine && engine.premultipliedAlpha) {
  98353. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  98354. }
  98355. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  98356. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  98357. }
  98358. var canvas = engine.getRenderingCanvas();
  98359. if (!canvas) {
  98360. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  98361. }
  98362. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  98363. if (!engine.getCaps().textureFloatRender) {
  98364. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  98365. if (!engine.getCaps().textureHalfFloatRender) {
  98366. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  98367. }
  98368. }
  98369. var cubeWidth = internalTexture.width;
  98370. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  98371. var specularTextures = {};
  98372. var promises = [];
  98373. // Read and collect all mipmaps data from the cube.
  98374. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  98375. mipmapsCount = Math.round(mipmapsCount);
  98376. var _loop_1 = function (i) {
  98377. var faceWidth = Math.pow(2, mipmapsCount - i);
  98378. var _loop_2 = function (face) {
  98379. var data = texture.readPixels(face, i);
  98380. // Creates a temp texture with the face data.
  98381. var tempTexture = engine.createRawTexture(data, faceWidth, faceWidth, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA, false, false, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, textureType);
  98382. // And rgbdEncode them.
  98383. var promise = new Promise(function (resolve, reject) {
  98384. var rgbdPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__["PostProcess"]("rgbdEncode", "rgbdEncode", null, null, 1, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, engine, false, undefined, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT, undefined, null, false);
  98385. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  98386. rgbdPostProcess.onApply = function (effect) {
  98387. effect._bindTexture("textureSampler", tempTexture);
  98388. };
  98389. // As the process needs to happen on the main canvas, keep track of the current size
  98390. var currentW = engine.getRenderWidth();
  98391. var currentH = engine.getRenderHeight();
  98392. // Set the desired size for the texture
  98393. engine.setSize(faceWidth, faceWidth);
  98394. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  98395. // Reading datas from WebGL
  98396. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  98397. var fileReader = new FileReader();
  98398. fileReader.onload = function (event) {
  98399. var arrayBuffer = event.target.result;
  98400. specularTextures[i * 6 + face] = arrayBuffer;
  98401. resolve();
  98402. };
  98403. fileReader.readAsArrayBuffer(blob);
  98404. });
  98405. // Reapply the previous canvas size
  98406. engine.setSize(currentW, currentH);
  98407. });
  98408. });
  98409. promises.push(promise);
  98410. };
  98411. // All faces of the cube.
  98412. for (var face = 0; face < 6; face++) {
  98413. _loop_2(face);
  98414. }
  98415. };
  98416. for (var i = 0; i <= mipmapsCount; i++) {
  98417. _loop_1(i);
  98418. }
  98419. // Once all the textures haves been collected as RGBD stored in PNGs
  98420. return Promise.all(promises).then(function () {
  98421. // We can delete the hosting scene keeping track of all the creation objects
  98422. hostingScene.dispose();
  98423. // Creates the json header for the env texture
  98424. var info = {
  98425. version: 1,
  98426. width: cubeWidth,
  98427. irradiance: _this._CreateEnvTextureIrradiance(texture),
  98428. specular: {
  98429. mipmaps: [],
  98430. lodGenerationScale: texture.lodGenerationScale
  98431. }
  98432. };
  98433. // Sets the specular image data information
  98434. var position = 0;
  98435. for (var i = 0; i <= mipmapsCount; i++) {
  98436. for (var face = 0; face < 6; face++) {
  98437. var byteLength = specularTextures[i * 6 + face].byteLength;
  98438. info.specular.mipmaps.push({
  98439. length: byteLength,
  98440. position: position
  98441. });
  98442. position += byteLength;
  98443. }
  98444. }
  98445. // Encode the JSON as an array buffer
  98446. var infoString = JSON.stringify(info);
  98447. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  98448. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  98449. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  98450. infoView[i] = infoString.charCodeAt(i);
  98451. }
  98452. // Ends up with a null terminator for easier parsing
  98453. infoView[infoString.length] = 0x00;
  98454. // Computes the final required size and creates the storage
  98455. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  98456. var finalBuffer = new ArrayBuffer(totalSize);
  98457. var finalBufferView = new Uint8Array(finalBuffer);
  98458. var dataView = new DataView(finalBuffer);
  98459. // Copy the magic bytes identifying the file in
  98460. var pos = 0;
  98461. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  98462. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  98463. }
  98464. // Add the json info
  98465. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  98466. pos += infoBuffer.byteLength;
  98467. // Finally inserts the texture data
  98468. for (var i = 0; i <= mipmapsCount; i++) {
  98469. for (var face = 0; face < 6; face++) {
  98470. var dataBuffer = specularTextures[i * 6 + face];
  98471. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  98472. pos += dataBuffer.byteLength;
  98473. }
  98474. }
  98475. // Voila
  98476. return finalBuffer;
  98477. });
  98478. };
  98479. /**
  98480. * Creates a JSON representation of the spherical data.
  98481. * @param texture defines the texture containing the polynomials
  98482. * @return the JSON representation of the spherical info
  98483. */
  98484. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  98485. var polynmials = texture.sphericalPolynomial;
  98486. if (polynmials == null) {
  98487. return null;
  98488. }
  98489. return {
  98490. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  98491. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  98492. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  98493. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  98494. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  98495. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  98496. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  98497. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  98498. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  98499. };
  98500. };
  98501. /**
  98502. * Uploads the texture info contained in the env file to the GPU.
  98503. * @param texture defines the internal texture to upload to
  98504. * @param arrayBuffer defines the buffer cotaining the data to load
  98505. * @param info defines the texture info retrieved through the GetEnvInfo method
  98506. * @returns a promise
  98507. */
  98508. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  98509. if (info.version !== 1) {
  98510. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  98511. }
  98512. var specularInfo = info.specular;
  98513. if (!specularInfo) {
  98514. // Nothing else parsed so far
  98515. return Promise.resolve();
  98516. }
  98517. // Double checks the enclosed info
  98518. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  98519. mipmapsCount = Math.round(mipmapsCount) + 1;
  98520. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  98521. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  98522. }
  98523. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  98524. var imageData = new Array(mipmapsCount);
  98525. for (var i = 0; i < mipmapsCount; i++) {
  98526. imageData[i] = new Array(6);
  98527. for (var face = 0; face < 6; face++) {
  98528. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  98529. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  98530. }
  98531. }
  98532. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  98533. };
  98534. /**
  98535. * Uploads the levels of image data to the GPU.
  98536. * @param texture defines the internal texture to upload to
  98537. * @param imageData defines the array buffer views of image data [mipmap][face]
  98538. * @returns a promise
  98539. */
  98540. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  98541. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  98542. throw new Error("Texture size must be a power of two");
  98543. }
  98544. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  98545. // Gets everything ready.
  98546. var engine = texture.getEngine();
  98547. var expandTexture = false;
  98548. var generateNonLODTextures = false;
  98549. var rgbdPostProcess = null;
  98550. var cubeRtt = null;
  98551. var lodTextures = null;
  98552. var caps = engine.getCaps();
  98553. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  98554. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  98555. texture.generateMipMaps = true;
  98556. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  98557. // Add extra process if texture lod is not supported
  98558. if (!caps.textureLOD) {
  98559. expandTexture = false;
  98560. generateNonLODTextures = true;
  98561. lodTextures = {};
  98562. }
  98563. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  98564. else if (engine.webGLVersion < 2) {
  98565. expandTexture = false;
  98566. }
  98567. // If half float available we can uncompress the texture
  98568. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  98569. expandTexture = true;
  98570. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  98571. }
  98572. // If full float available we can uncompress the texture
  98573. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  98574. expandTexture = true;
  98575. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  98576. }
  98577. // Expand the texture if possible
  98578. if (expandTexture) {
  98579. // Simply run through the decode PP
  98580. rgbdPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__["PostProcess"]("rgbdDecode", "rgbdDecode", null, null, 1, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, engine, false, undefined, texture.type, undefined, null, false);
  98581. texture._isRGBD = false;
  98582. texture.invertY = false;
  98583. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  98584. generateDepthBuffer: false,
  98585. generateMipMaps: true,
  98586. generateStencilBuffer: false,
  98587. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  98588. type: texture.type,
  98589. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  98590. });
  98591. }
  98592. else {
  98593. texture._isRGBD = true;
  98594. texture.invertY = true;
  98595. // In case of missing support, applies the same patch than DDS files.
  98596. if (generateNonLODTextures) {
  98597. var mipSlices = 3;
  98598. var scale = texture._lodGenerationScale;
  98599. var offset = texture._lodGenerationOffset;
  98600. for (var i = 0; i < mipSlices; i++) {
  98601. //compute LOD from even spacing in smoothness (matching shader calculation)
  98602. var smoothness = i / (mipSlices - 1);
  98603. var roughness = 1 - smoothness;
  98604. var minLODIndex = offset; // roughness = 0
  98605. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  98606. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  98607. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  98608. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  98609. glTextureFromLod.isCube = true;
  98610. glTextureFromLod.invertY = true;
  98611. glTextureFromLod.generateMipMaps = false;
  98612. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  98613. // Wrap in a base texture for easy binding.
  98614. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  98615. lodTexture.isCube = true;
  98616. lodTexture._texture = glTextureFromLod;
  98617. lodTextures[mipmapIndex] = lodTexture;
  98618. switch (i) {
  98619. case 0:
  98620. texture._lodTextureLow = lodTexture;
  98621. break;
  98622. case 1:
  98623. texture._lodTextureMid = lodTexture;
  98624. break;
  98625. case 2:
  98626. texture._lodTextureHigh = lodTexture;
  98627. break;
  98628. }
  98629. }
  98630. }
  98631. }
  98632. var promises = [];
  98633. var _loop_3 = function (i) {
  98634. var _loop_4 = function (face) {
  98635. // Constructs an image element from image data
  98636. var bytes = imageData[i][face];
  98637. var blob = new Blob([bytes], { type: 'image/png' });
  98638. var url = URL.createObjectURL(blob);
  98639. var image = new Image();
  98640. image.src = url;
  98641. // Enqueue promise to upload to the texture.
  98642. var promise = new Promise(function (resolve, reject) {
  98643. image.onload = function () {
  98644. if (expandTexture) {
  98645. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  98646. reject(message);
  98647. }, image);
  98648. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  98649. // Uncompress the data to a RTT
  98650. rgbdPostProcess.onApply = function (effect) {
  98651. effect._bindTexture("textureSampler", tempTexture_1);
  98652. effect.setFloat2("scale", 1, 1);
  98653. };
  98654. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  98655. // Cleanup
  98656. engine.restoreDefaultFramebuffer();
  98657. tempTexture_1.dispose();
  98658. window.URL.revokeObjectURL(url);
  98659. resolve();
  98660. });
  98661. }
  98662. else {
  98663. engine._uploadImageToTexture(texture, image, face, i);
  98664. // Upload the face to the non lod texture support
  98665. if (generateNonLODTextures) {
  98666. var lodTexture = lodTextures[i];
  98667. if (lodTexture) {
  98668. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  98669. }
  98670. }
  98671. resolve();
  98672. }
  98673. };
  98674. image.onerror = function (error) {
  98675. reject(error);
  98676. };
  98677. });
  98678. promises.push(promise);
  98679. };
  98680. // All faces
  98681. for (var face = 0; face < 6; face++) {
  98682. _loop_4(face);
  98683. }
  98684. };
  98685. // All mipmaps up to provided number of images
  98686. for (var i = 0; i < imageData.length; i++) {
  98687. _loop_3(i);
  98688. }
  98689. // Fill remaining mipmaps with black textures.
  98690. if (imageData.length < mipmapsCount) {
  98691. var data = void 0;
  98692. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  98693. var dataLength = size * size * 4;
  98694. switch (texture.type) {
  98695. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  98696. data = new Uint8Array(dataLength);
  98697. break;
  98698. }
  98699. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  98700. data = new Uint16Array(dataLength);
  98701. break;
  98702. }
  98703. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  98704. data = new Float32Array(dataLength);
  98705. break;
  98706. }
  98707. }
  98708. for (var i = imageData.length; i < mipmapsCount; i++) {
  98709. for (var face = 0; face < 6; face++) {
  98710. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  98711. }
  98712. }
  98713. }
  98714. // Once all done, finishes the cleanup and return
  98715. return Promise.all(promises).then(function () {
  98716. // Release temp RTT.
  98717. if (cubeRtt) {
  98718. engine._releaseFramebufferObjects(cubeRtt);
  98719. cubeRtt._swapAndDie(texture);
  98720. }
  98721. // Release temp Post Process.
  98722. if (rgbdPostProcess) {
  98723. rgbdPostProcess.dispose();
  98724. }
  98725. // Flag internal texture as ready in case they are in use.
  98726. if (generateNonLODTextures) {
  98727. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  98728. texture._lodTextureHigh._texture.isReady = true;
  98729. }
  98730. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  98731. texture._lodTextureMid._texture.isReady = true;
  98732. }
  98733. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  98734. texture._lodTextureLow._texture.isReady = true;
  98735. }
  98736. }
  98737. });
  98738. };
  98739. /**
  98740. * Uploads spherical polynomials information to the texture.
  98741. * @param texture defines the texture we are trying to upload the information to
  98742. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  98743. */
  98744. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  98745. if (info.version !== 1) {
  98746. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  98747. }
  98748. var irradianceInfo = info.irradiance;
  98749. if (!irradianceInfo) {
  98750. return;
  98751. }
  98752. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  98753. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  98754. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  98755. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  98756. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  98757. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  98758. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  98759. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  98760. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  98761. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  98762. texture._sphericalPolynomial = sp;
  98763. };
  98764. /** @hidden */
  98765. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  98766. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  98767. internalTexture._bufferViewArrayArray = data;
  98768. internalTexture._lodGenerationScale = lodScale;
  98769. internalTexture._lodGenerationOffset = lodOffset;
  98770. internalTexture._sphericalPolynomial = sphericalPolynomial;
  98771. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  98772. internalTexture.isReady = true;
  98773. });
  98774. };
  98775. /**
  98776. * Magic number identifying the env file.
  98777. */
  98778. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  98779. return EnvironmentTextureTools;
  98780. }());
  98781. // References the dependencies.
  98782. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  98783. /***/ }),
  98784. /***/ "./Misc/filesInput.ts":
  98785. /*!****************************!*\
  98786. !*** ./Misc/filesInput.ts ***!
  98787. \****************************/
  98788. /*! exports provided: FilesInput */
  98789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98790. "use strict";
  98791. __webpack_require__.r(__webpack_exports__);
  98792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  98793. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  98794. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  98795. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  98796. /**
  98797. * Class used to help managing file picking and drag'n'drop
  98798. */
  98799. var FilesInput = /** @class */ (function () {
  98800. /**
  98801. * Creates a new FilesInput
  98802. * @param engine defines the rendering engine
  98803. * @param scene defines the hosting scene
  98804. * @param sceneLoadedCallback callback called when scene is loaded
  98805. * @param progressCallback callback called to track progress
  98806. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  98807. * @param textureLoadingCallback callback called when a texture is loading
  98808. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  98809. * @param onReloadCallback callback called when a reload is requested
  98810. * @param errorCallback callback call if an error occurs
  98811. */
  98812. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  98813. /**
  98814. * Callback called when a file is processed
  98815. */
  98816. this.onProcessFileCallback = function () { return true; };
  98817. this._engine = engine;
  98818. this._currentScene = scene;
  98819. this._sceneLoadedCallback = sceneLoadedCallback;
  98820. this._progressCallback = progressCallback;
  98821. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  98822. this._textureLoadingCallback = textureLoadingCallback;
  98823. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  98824. this._onReloadCallback = onReloadCallback;
  98825. this._errorCallback = errorCallback;
  98826. }
  98827. Object.defineProperty(FilesInput, "FilesToLoad", {
  98828. /**
  98829. * List of files ready to be loaded
  98830. */
  98831. get: function () {
  98832. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  98833. },
  98834. enumerable: true,
  98835. configurable: true
  98836. });
  98837. /**
  98838. * Calls this function to listen to drag'n'drop events on a specific DOM element
  98839. * @param elementToMonitor defines the DOM element to track
  98840. */
  98841. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  98842. var _this = this;
  98843. if (elementToMonitor) {
  98844. this._elementToMonitor = elementToMonitor;
  98845. this._dragEnterHandler = function (e) { _this.drag(e); };
  98846. this._dragOverHandler = function (e) { _this.drag(e); };
  98847. this._dropHandler = function (e) { _this.drop(e); };
  98848. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  98849. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  98850. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  98851. }
  98852. };
  98853. /**
  98854. * Release all associated resources
  98855. */
  98856. FilesInput.prototype.dispose = function () {
  98857. if (!this._elementToMonitor) {
  98858. return;
  98859. }
  98860. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  98861. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  98862. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  98863. };
  98864. FilesInput.prototype.renderFunction = function () {
  98865. if (this._additionalRenderLoopLogicCallback) {
  98866. this._additionalRenderLoopLogicCallback();
  98867. }
  98868. if (this._currentScene) {
  98869. if (this._textureLoadingCallback) {
  98870. var remaining = this._currentScene.getWaitingItemsCount();
  98871. if (remaining > 0) {
  98872. this._textureLoadingCallback(remaining);
  98873. }
  98874. }
  98875. this._currentScene.render();
  98876. }
  98877. };
  98878. FilesInput.prototype.drag = function (e) {
  98879. e.stopPropagation();
  98880. e.preventDefault();
  98881. };
  98882. FilesInput.prototype.drop = function (eventDrop) {
  98883. eventDrop.stopPropagation();
  98884. eventDrop.preventDefault();
  98885. this.loadFiles(eventDrop);
  98886. };
  98887. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  98888. var _this = this;
  98889. var reader = folder.createReader();
  98890. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  98891. reader.readEntries(function (entries) {
  98892. remaining.count += entries.length;
  98893. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  98894. var entry = entries_1[_i];
  98895. if (entry.isFile) {
  98896. entry.file(function (file) {
  98897. file.correctName = relativePath + file.name;
  98898. files.push(file);
  98899. if (--remaining.count === 0) {
  98900. callback();
  98901. }
  98902. });
  98903. }
  98904. else if (entry.isDirectory) {
  98905. _this._traverseFolder(entry, files, remaining, callback);
  98906. }
  98907. }
  98908. if (--remaining.count) {
  98909. callback();
  98910. }
  98911. });
  98912. };
  98913. FilesInput.prototype._processFiles = function (files) {
  98914. for (var i = 0; i < files.length; i++) {
  98915. var name = files[i].correctName.toLowerCase();
  98916. var extension = name.split('.').pop();
  98917. if (!this.onProcessFileCallback(files[i], name, extension)) {
  98918. continue;
  98919. }
  98920. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  98921. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  98922. this._sceneFileToLoad = files[i];
  98923. }
  98924. FilesInput.FilesToLoad[name] = files[i];
  98925. }
  98926. };
  98927. /**
  98928. * Load files from a drop event
  98929. * @param event defines the drop event to use as source
  98930. */
  98931. FilesInput.prototype.loadFiles = function (event) {
  98932. var _this = this;
  98933. // Handling data transfer via drag'n'drop
  98934. if (event && event.dataTransfer && event.dataTransfer.files) {
  98935. this._filesToLoad = event.dataTransfer.files;
  98936. }
  98937. // Handling files from input files
  98938. if (event && event.target && event.target.files) {
  98939. this._filesToLoad = event.target.files;
  98940. }
  98941. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  98942. return;
  98943. }
  98944. if (this._startingProcessingFilesCallback) {
  98945. this._startingProcessingFilesCallback(this._filesToLoad);
  98946. }
  98947. if (this._filesToLoad && this._filesToLoad.length > 0) {
  98948. var files_1 = new Array();
  98949. var folders = [];
  98950. var items = event.dataTransfer ? event.dataTransfer.items : null;
  98951. for (var i = 0; i < this._filesToLoad.length; i++) {
  98952. var fileToLoad = this._filesToLoad[i];
  98953. var name_1 = fileToLoad.name.toLowerCase();
  98954. var entry = void 0;
  98955. fileToLoad.correctName = name_1;
  98956. if (items) {
  98957. var item = items[i];
  98958. if (item.getAsEntry) {
  98959. entry = item.getAsEntry();
  98960. }
  98961. else if (item.webkitGetAsEntry) {
  98962. entry = item.webkitGetAsEntry();
  98963. }
  98964. }
  98965. if (!entry) {
  98966. files_1.push(fileToLoad);
  98967. }
  98968. else {
  98969. if (entry.isDirectory) {
  98970. folders.push(entry);
  98971. }
  98972. else {
  98973. files_1.push(fileToLoad);
  98974. }
  98975. }
  98976. }
  98977. if (folders.length === 0) {
  98978. this._processFiles(files_1);
  98979. this._processReload();
  98980. }
  98981. else {
  98982. var remaining = { count: folders.length };
  98983. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  98984. var folder = folders_1[_i];
  98985. this._traverseFolder(folder, files_1, remaining, function () {
  98986. _this._processFiles(files_1);
  98987. if (remaining.count === 0) {
  98988. _this._processReload();
  98989. }
  98990. });
  98991. }
  98992. }
  98993. }
  98994. };
  98995. FilesInput.prototype._processReload = function () {
  98996. if (this._onReloadCallback) {
  98997. this._onReloadCallback(this._sceneFileToLoad);
  98998. }
  98999. else {
  99000. this.reload();
  99001. }
  99002. };
  99003. /**
  99004. * Reload the current scene from the loaded files
  99005. */
  99006. FilesInput.prototype.reload = function () {
  99007. var _this = this;
  99008. // If a scene file has been provided
  99009. if (this._sceneFileToLoad) {
  99010. if (this._currentScene) {
  99011. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  99012. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  99013. }
  99014. this._engine.stopRenderLoop();
  99015. }
  99016. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  99017. if (_this._progressCallback) {
  99018. _this._progressCallback(progress);
  99019. }
  99020. }).then(function (scene) {
  99021. if (_this._currentScene) {
  99022. _this._currentScene.dispose();
  99023. }
  99024. _this._currentScene = scene;
  99025. if (_this._sceneLoadedCallback) {
  99026. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  99027. }
  99028. // Wait for textures and shaders to be ready
  99029. _this._currentScene.executeWhenReady(function () {
  99030. _this._engine.runRenderLoop(function () {
  99031. _this.renderFunction();
  99032. });
  99033. });
  99034. }).catch(function (error) {
  99035. if (_this._errorCallback) {
  99036. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  99037. }
  99038. });
  99039. }
  99040. else {
  99041. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  99042. }
  99043. };
  99044. return FilesInput;
  99045. }());
  99046. /***/ }),
  99047. /***/ "./Misc/filesInputStore.ts":
  99048. /*!*********************************!*\
  99049. !*** ./Misc/filesInputStore.ts ***!
  99050. \*********************************/
  99051. /*! exports provided: FilesInputStore */
  99052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99053. "use strict";
  99054. __webpack_require__.r(__webpack_exports__);
  99055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  99056. /**
  99057. * Class used to help managing file picking and drag'n'drop
  99058. * File Storage
  99059. */
  99060. var FilesInputStore = /** @class */ (function () {
  99061. function FilesInputStore() {
  99062. }
  99063. /**
  99064. * List of files ready to be loaded
  99065. */
  99066. FilesInputStore.FilesToLoad = {};
  99067. return FilesInputStore;
  99068. }());
  99069. /***/ }),
  99070. /***/ "./Misc/iInspectable.ts":
  99071. /*!******************************!*\
  99072. !*** ./Misc/iInspectable.ts ***!
  99073. \******************************/
  99074. /*! exports provided: InspectableType */
  99075. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99076. "use strict";
  99077. __webpack_require__.r(__webpack_exports__);
  99078. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return InspectableType; });
  99079. /**
  99080. * Enum that determines the text-wrapping mode to use.
  99081. */
  99082. var InspectableType;
  99083. (function (InspectableType) {
  99084. /**
  99085. * Checkbox for booleans
  99086. */
  99087. InspectableType[InspectableType["Checkbox"] = 0] = "Checkbox";
  99088. /**
  99089. * Sliders for numbers
  99090. */
  99091. InspectableType[InspectableType["Slider"] = 1] = "Slider";
  99092. /**
  99093. * Vector3
  99094. */
  99095. InspectableType[InspectableType["Vector3"] = 2] = "Vector3";
  99096. /**
  99097. * Quaternions
  99098. */
  99099. InspectableType[InspectableType["Quaternion"] = 3] = "Quaternion";
  99100. /**
  99101. * Color3
  99102. */
  99103. InspectableType[InspectableType["Color3"] = 4] = "Color3";
  99104. })(InspectableType || (InspectableType = {}));
  99105. /***/ }),
  99106. /***/ "./Misc/index.ts":
  99107. /*!***********************!*\
  99108. !*** ./Misc/index.ts ***!
  99109. \***********************/
  99110. /*! exports provided: AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, EquiRectangularCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, MeshExploder, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  99111. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99112. "use strict";
  99113. __webpack_require__.r(__webpack_exports__);
  99114. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  99115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  99116. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  99117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  99118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  99119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  99120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  99121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  99122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  99123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  99124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  99125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  99126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  99127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["EquiRectangularCubeTextureAssetTask"]; });
  99128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  99129. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  99130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  99131. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  99132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  99133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  99134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  99135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  99136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  99137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  99138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  99139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  99140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  99141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  99142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  99143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  99144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMatrix"]; });
  99145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  99146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  99147. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  99148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  99149. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  99150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  99151. /* harmony import */ var _meshExploder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshExploder */ "./Misc/meshExploder.ts");
  99152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _meshExploder__WEBPACK_IMPORTED_MODULE_6__["MeshExploder"]; });
  99153. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  99154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_7__["FilesInput"]; });
  99155. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  99156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["CubeMapToSphericalPolynomialTools"]; });
  99157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["HDRTools"]; });
  99158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["PanoramaToCubeMapTools"]; });
  99159. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  99160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_9__["KhronosTextureContainer"]; });
  99161. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  99162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["EventState"]; });
  99163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["Observer"]; });
  99164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["MultiObserver"]; });
  99165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["Observable"]; });
  99166. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  99167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__["PerformanceMonitor"]; });
  99168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__["RollingAverage"]; });
  99169. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  99170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_12__["PromisePolyfill"]; });
  99171. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  99172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimization"]; });
  99173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["TextureOptimization"]; });
  99174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["HardwareScalingOptimization"]; });
  99175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["ShadowsOptimization"]; });
  99176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["PostProcessesOptimization"]; });
  99177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["LensFlaresOptimization"]; });
  99178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["CustomOptimization"]; });
  99179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["ParticlesOptimization"]; });
  99180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["RenderTargetsOptimization"]; });
  99181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["MergeMeshesOptimization"]; });
  99182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimizerOptions"]; });
  99183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimizer"]; });
  99184. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  99185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_14__["SceneSerializer"]; });
  99186. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  99187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_15__["SmartArray"]; });
  99188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_15__["SmartArrayNoDuplicate"]; });
  99189. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  99190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_16__["StringDictionary"]; });
  99191. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  99192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_17__["Tags"]; });
  99193. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  99194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_18__["TextureTools"]; });
  99195. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  99196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_19__["TGATools"]; });
  99197. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  99198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["ColorGradient"]; });
  99199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["Color3Gradient"]; });
  99200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["FactorGradient"]; });
  99201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["LoadFileError"]; });
  99202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["RetryStrategy"]; });
  99203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["Tools"]; });
  99204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["PerfCounter"]; });
  99205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["className"]; });
  99206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["AsyncLoop"]; });
  99207. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  99208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_21__["VideoRecorder"]; });
  99209. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  99210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__["JoystickAxis"]; });
  99211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__["VirtualJoystick"]; });
  99212. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  99213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_23__["WorkerPool"]; });
  99214. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  99215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_24__["Logger"]; });
  99216. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  99217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_25__["_TypeStore"]; });
  99218. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  99219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_26__["FilesInputStore"]; });
  99220. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  99221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_27__["DeepCopier"]; });
  99222. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  99223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_28__["PivotTools"]; });
  99224. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  99225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_29__["PrecisionDate"]; });
  99226. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  99227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_30__["ScreenshotTools"]; });
  99228. /* empty/unused harmony star reexport *//* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  99229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _webRequest__WEBPACK_IMPORTED_MODULE_31__["WebRequest"]; });
  99230. /* harmony import */ var _iInspectable__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./iInspectable */ "./Misc/iInspectable.ts");
  99231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _iInspectable__WEBPACK_IMPORTED_MODULE_32__["InspectableType"]; });
  99232. /***/ }),
  99233. /***/ "./Misc/khronosTextureContainer.ts":
  99234. /*!*****************************************!*\
  99235. !*** ./Misc/khronosTextureContainer.ts ***!
  99236. \*****************************************/
  99237. /*! exports provided: KhronosTextureContainer */
  99238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99239. "use strict";
  99240. __webpack_require__.r(__webpack_exports__);
  99241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  99242. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  99243. /**
  99244. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  99245. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  99246. */
  99247. var KhronosTextureContainer = /** @class */ (function () {
  99248. /**
  99249. * Creates a new KhronosTextureContainer
  99250. * @param arrayBuffer contents of the KTX container file
  99251. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  99252. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  99253. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  99254. */
  99255. function KhronosTextureContainer(
  99256. /** contents of the KTX container file */
  99257. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  99258. this.arrayBuffer = arrayBuffer;
  99259. /**
  99260. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  99261. */
  99262. this.isInvalid = false;
  99263. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  99264. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  99265. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  99266. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  99267. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  99268. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  99269. this.isInvalid = true;
  99270. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  99271. return;
  99272. }
  99273. // load the reset of the header in native 32 bit uint
  99274. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  99275. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  99276. var endianness = headerDataView.getUint32(0, true);
  99277. var littleEndian = endianness === 0x04030201;
  99278. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  99279. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  99280. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  99281. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  99282. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  99283. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  99284. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  99285. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  99286. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  99287. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  99288. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  99289. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  99290. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  99291. if (this.glType !== 0) {
  99292. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  99293. return;
  99294. }
  99295. else {
  99296. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  99297. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  99298. }
  99299. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  99300. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  99301. return;
  99302. }
  99303. if (this.numberOfArrayElements !== 0) {
  99304. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  99305. return;
  99306. }
  99307. if (this.numberOfFaces !== facesExpected) {
  99308. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  99309. return;
  99310. }
  99311. // we now have a completely validated file, so could use existence of loadType as success
  99312. // would need to make this more elaborate & adjust checks above to support more than one load type
  99313. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  99314. }
  99315. /**
  99316. * Uploads KTX content to a Babylon Texture.
  99317. * It is assumed that the texture has already been created & is currently bound
  99318. * @hidden
  99319. */
  99320. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  99321. switch (this.loadType) {
  99322. case KhronosTextureContainer.COMPRESSED_2D:
  99323. this._upload2DCompressedLevels(texture, loadMipmaps);
  99324. break;
  99325. case KhronosTextureContainer.TEX_2D:
  99326. case KhronosTextureContainer.COMPRESSED_3D:
  99327. case KhronosTextureContainer.TEX_3D:
  99328. }
  99329. };
  99330. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  99331. // initialize width & height for level 1
  99332. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  99333. var width = this.pixelWidth;
  99334. var height = this.pixelHeight;
  99335. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  99336. for (var level = 0; level < mipmapCount; level++) {
  99337. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  99338. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  99339. for (var face = 0; face < this.numberOfFaces; face++) {
  99340. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  99341. var engine = texture.getEngine();
  99342. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  99343. dataOffset += imageSize; // add size of the image for the next face/mipmap
  99344. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  99345. }
  99346. width = Math.max(1.0, width * 0.5);
  99347. height = Math.max(1.0, height * 0.5);
  99348. }
  99349. };
  99350. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  99351. // load types
  99352. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  99353. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  99354. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  99355. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  99356. return KhronosTextureContainer;
  99357. }());
  99358. /***/ }),
  99359. /***/ "./Misc/logger.ts":
  99360. /*!************************!*\
  99361. !*** ./Misc/logger.ts ***!
  99362. \************************/
  99363. /*! exports provided: Logger */
  99364. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99365. "use strict";
  99366. __webpack_require__.r(__webpack_exports__);
  99367. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  99368. /**
  99369. * Logger used througouht the application to allow configuration of
  99370. * the log level required for the messages.
  99371. */
  99372. var Logger = /** @class */ (function () {
  99373. function Logger() {
  99374. }
  99375. Logger._AddLogEntry = function (entry) {
  99376. Logger._LogCache = entry + Logger._LogCache;
  99377. if (Logger.OnNewCacheEntry) {
  99378. Logger.OnNewCacheEntry(entry);
  99379. }
  99380. };
  99381. Logger._FormatMessage = function (message) {
  99382. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  99383. var date = new Date();
  99384. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  99385. };
  99386. Logger._LogDisabled = function (message) {
  99387. // nothing to do
  99388. };
  99389. Logger._LogEnabled = function (message) {
  99390. var formattedMessage = Logger._FormatMessage(message);
  99391. console.log("BJS - " + formattedMessage);
  99392. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  99393. Logger._AddLogEntry(entry);
  99394. };
  99395. Logger._WarnDisabled = function (message) {
  99396. // nothing to do
  99397. };
  99398. Logger._WarnEnabled = function (message) {
  99399. var formattedMessage = Logger._FormatMessage(message);
  99400. console.warn("BJS - " + formattedMessage);
  99401. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  99402. Logger._AddLogEntry(entry);
  99403. };
  99404. Logger._ErrorDisabled = function (message) {
  99405. // nothing to do
  99406. };
  99407. Logger._ErrorEnabled = function (message) {
  99408. Logger.errorsCount++;
  99409. var formattedMessage = Logger._FormatMessage(message);
  99410. console.error("BJS - " + formattedMessage);
  99411. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  99412. Logger._AddLogEntry(entry);
  99413. };
  99414. Object.defineProperty(Logger, "LogCache", {
  99415. /**
  99416. * Gets current log cache (list of logs)
  99417. */
  99418. get: function () {
  99419. return Logger._LogCache;
  99420. },
  99421. enumerable: true,
  99422. configurable: true
  99423. });
  99424. /**
  99425. * Clears the log cache
  99426. */
  99427. Logger.ClearLogCache = function () {
  99428. Logger._LogCache = "";
  99429. Logger.errorsCount = 0;
  99430. };
  99431. Object.defineProperty(Logger, "LogLevels", {
  99432. /**
  99433. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99434. */
  99435. set: function (level) {
  99436. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  99437. Logger.Log = Logger._LogEnabled;
  99438. }
  99439. else {
  99440. Logger.Log = Logger._LogDisabled;
  99441. }
  99442. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  99443. Logger.Warn = Logger._WarnEnabled;
  99444. }
  99445. else {
  99446. Logger.Warn = Logger._WarnDisabled;
  99447. }
  99448. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  99449. Logger.Error = Logger._ErrorEnabled;
  99450. }
  99451. else {
  99452. Logger.Error = Logger._ErrorDisabled;
  99453. }
  99454. },
  99455. enumerable: true,
  99456. configurable: true
  99457. });
  99458. /**
  99459. * No log
  99460. */
  99461. Logger.NoneLogLevel = 0;
  99462. /**
  99463. * Only message logs
  99464. */
  99465. Logger.MessageLogLevel = 1;
  99466. /**
  99467. * Only warning logs
  99468. */
  99469. Logger.WarningLogLevel = 2;
  99470. /**
  99471. * Only error logs
  99472. */
  99473. Logger.ErrorLogLevel = 4;
  99474. /**
  99475. * All logs
  99476. */
  99477. Logger.AllLogLevel = 7;
  99478. Logger._LogCache = "";
  99479. /**
  99480. * Gets a value indicating the number of loading errors
  99481. * @ignorenaming
  99482. */
  99483. Logger.errorsCount = 0;
  99484. /**
  99485. * Log a message to the console
  99486. */
  99487. Logger.Log = Logger._LogEnabled;
  99488. /**
  99489. * Write a warning message to the console
  99490. */
  99491. Logger.Warn = Logger._WarnEnabled;
  99492. /**
  99493. * Write an error message to the console
  99494. */
  99495. Logger.Error = Logger._ErrorEnabled;
  99496. return Logger;
  99497. }());
  99498. /***/ }),
  99499. /***/ "./Misc/meshExploder.ts":
  99500. /*!******************************!*\
  99501. !*** ./Misc/meshExploder.ts ***!
  99502. \******************************/
  99503. /*! exports provided: MeshExploder */
  99504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99505. "use strict";
  99506. __webpack_require__.r(__webpack_exports__);
  99507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return MeshExploder; });
  99508. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  99509. /**
  99510. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  99511. */
  99512. var MeshExploder = /** @class */ (function () {
  99513. /**
  99514. * Explodes meshes from a center mesh.
  99515. * @param meshes The meshes to explode.
  99516. * @param centerMesh The mesh to be center of explosion.
  99517. */
  99518. function MeshExploder(meshes, centerMesh) {
  99519. this._meshesOrigins = [];
  99520. this._toCenterVectors = [];
  99521. this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99522. this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99523. this._centerPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99524. this._meshes = meshes.slice();
  99525. if (centerMesh) {
  99526. this._centerMesh = centerMesh;
  99527. }
  99528. else {
  99529. this._setCenterMesh();
  99530. }
  99531. var centerMeshIndex = this._meshes.indexOf(this._centerMesh);
  99532. if (centerMeshIndex >= 0) {
  99533. this._meshes.splice(centerMeshIndex, 1);
  99534. }
  99535. this._centerPosition = this._centerMesh.getAbsolutePosition().clone();
  99536. for (var index = 0; index < this._meshes.length; index++) {
  99537. if (this._meshes[index]) {
  99538. var mesh = this._meshes[index];
  99539. this._meshesOrigins[index] = mesh.getAbsolutePosition().clone();
  99540. this._toCenterVectors[index] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99541. if (mesh._boundingInfo && this._centerMesh._boundingInfo) {
  99542. mesh._boundingInfo.boundingBox.centerWorld.subtractToRef(this._centerMesh._boundingInfo.boundingBox.centerWorld, this._toCenterVectors[index]);
  99543. }
  99544. }
  99545. }
  99546. }
  99547. MeshExploder.prototype._setCenterMesh = function () {
  99548. var averageCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99549. var totalCenters = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99550. var shortestToCenter = Number.MAX_VALUE;
  99551. for (var index = 0; index < this._meshes.length; index++) {
  99552. if (this._meshes[index]) {
  99553. var mesh = this._meshes[index];
  99554. var boundingInfo = mesh.getBoundingInfo();
  99555. if (boundingInfo) {
  99556. totalCenters.addInPlace(boundingInfo.boundingBox.centerWorld);
  99557. }
  99558. }
  99559. }
  99560. averageCenter = totalCenters.scale(1 / this._meshes.length);
  99561. for (var index = 0; index < this._meshes.length; index++) {
  99562. if (this._meshes[index]) {
  99563. var mesh = this._meshes[index];
  99564. var boundingInfo = mesh.getBoundingInfo();
  99565. if (boundingInfo) {
  99566. var distanceToCenter = boundingInfo.boundingBox.centerWorld.subtract(averageCenter).lengthSquared();
  99567. if (distanceToCenter < shortestToCenter) {
  99568. this._centerMesh = mesh;
  99569. shortestToCenter = distanceToCenter;
  99570. }
  99571. }
  99572. }
  99573. }
  99574. };
  99575. /**
  99576. * Get class name
  99577. * @returns "MeshExploder"
  99578. */
  99579. MeshExploder.prototype.getClassName = function () {
  99580. return "MeshExploder";
  99581. };
  99582. /**
  99583. * "Exploded meshes"
  99584. * @returns Array of meshes with the centerMesh at index 0.
  99585. */
  99586. MeshExploder.prototype.getMeshes = function () {
  99587. var meshArray = this._meshes.slice();
  99588. meshArray.unshift(this._centerMesh);
  99589. return meshArray;
  99590. };
  99591. /**
  99592. * Explodes meshes giving a specific direction
  99593. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  99594. */
  99595. MeshExploder.prototype.explode = function (direction) {
  99596. if (direction === void 0) { direction = 1.0; }
  99597. for (var index = 0; index < this._meshes.length; index++) {
  99598. if (this._meshes[index] && this._meshesOrigins[index] && this._toCenterVectors[index]) {
  99599. this._toCenterVectors[index].scaleToRef(direction, this._scaledDirection);
  99600. this._meshesOrigins[index].addToRef(this._scaledDirection, this._newPosition);
  99601. this._meshes[index].setAbsolutePosition(this._newPosition);
  99602. }
  99603. }
  99604. this._centerMesh.setAbsolutePosition(this._centerPosition);
  99605. };
  99606. return MeshExploder;
  99607. }());
  99608. /***/ }),
  99609. /***/ "./Misc/observable.ts":
  99610. /*!****************************!*\
  99611. !*** ./Misc/observable.ts ***!
  99612. \****************************/
  99613. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  99614. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99615. "use strict";
  99616. __webpack_require__.r(__webpack_exports__);
  99617. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  99618. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  99619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  99620. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  99621. /**
  99622. * A class serves as a medium between the observable and its observers
  99623. */
  99624. var EventState = /** @class */ (function () {
  99625. /**
  99626. * Create a new EventState
  99627. * @param mask defines the mask associated with this state
  99628. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  99629. * @param target defines the original target of the state
  99630. * @param currentTarget defines the current target of the state
  99631. */
  99632. function EventState(mask, skipNextObservers, target, currentTarget) {
  99633. if (skipNextObservers === void 0) { skipNextObservers = false; }
  99634. this.initalize(mask, skipNextObservers, target, currentTarget);
  99635. }
  99636. /**
  99637. * Initialize the current event state
  99638. * @param mask defines the mask associated with this state
  99639. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  99640. * @param target defines the original target of the state
  99641. * @param currentTarget defines the current target of the state
  99642. * @returns the current event state
  99643. */
  99644. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  99645. if (skipNextObservers === void 0) { skipNextObservers = false; }
  99646. this.mask = mask;
  99647. this.skipNextObservers = skipNextObservers;
  99648. this.target = target;
  99649. this.currentTarget = currentTarget;
  99650. return this;
  99651. };
  99652. return EventState;
  99653. }());
  99654. /**
  99655. * Represent an Observer registered to a given Observable object.
  99656. */
  99657. var Observer = /** @class */ (function () {
  99658. /**
  99659. * Creates a new observer
  99660. * @param callback defines the callback to call when the observer is notified
  99661. * @param mask defines the mask of the observer (used to filter notifications)
  99662. * @param scope defines the current scope used to restore the JS context
  99663. */
  99664. function Observer(
  99665. /**
  99666. * Defines the callback to call when the observer is notified
  99667. */
  99668. callback,
  99669. /**
  99670. * Defines the mask of the observer (used to filter notifications)
  99671. */
  99672. mask,
  99673. /**
  99674. * Defines the current scope used to restore the JS context
  99675. */
  99676. scope) {
  99677. if (scope === void 0) { scope = null; }
  99678. this.callback = callback;
  99679. this.mask = mask;
  99680. this.scope = scope;
  99681. /** @hidden */
  99682. this._willBeUnregistered = false;
  99683. /**
  99684. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  99685. */
  99686. this.unregisterOnNextCall = false;
  99687. }
  99688. return Observer;
  99689. }());
  99690. /**
  99691. * Represent a list of observers registered to multiple Observables object.
  99692. */
  99693. var MultiObserver = /** @class */ (function () {
  99694. function MultiObserver() {
  99695. }
  99696. /**
  99697. * Release associated resources
  99698. */
  99699. MultiObserver.prototype.dispose = function () {
  99700. if (this._observers && this._observables) {
  99701. for (var index = 0; index < this._observers.length; index++) {
  99702. this._observables[index].remove(this._observers[index]);
  99703. }
  99704. }
  99705. this._observers = null;
  99706. this._observables = null;
  99707. };
  99708. /**
  99709. * Raise a callback when one of the observable will notify
  99710. * @param observables defines a list of observables to watch
  99711. * @param callback defines the callback to call on notification
  99712. * @param mask defines the mask used to filter notifications
  99713. * @param scope defines the current scope used to restore the JS context
  99714. * @returns the new MultiObserver
  99715. */
  99716. MultiObserver.Watch = function (observables, callback, mask, scope) {
  99717. if (mask === void 0) { mask = -1; }
  99718. if (scope === void 0) { scope = null; }
  99719. var result = new MultiObserver();
  99720. result._observers = new Array();
  99721. result._observables = observables;
  99722. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  99723. var observable = observables_1[_i];
  99724. var observer = observable.add(callback, mask, false, scope);
  99725. if (observer) {
  99726. result._observers.push(observer);
  99727. }
  99728. }
  99729. return result;
  99730. };
  99731. return MultiObserver;
  99732. }());
  99733. /**
  99734. * The Observable class is a simple implementation of the Observable pattern.
  99735. *
  99736. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  99737. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  99738. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  99739. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  99740. */
  99741. var Observable = /** @class */ (function () {
  99742. /**
  99743. * Creates a new observable
  99744. * @param onObserverAdded defines a callback to call when a new observer is added
  99745. */
  99746. function Observable(onObserverAdded) {
  99747. this._observers = new Array();
  99748. this._eventState = new EventState(0);
  99749. if (onObserverAdded) {
  99750. this._onObserverAdded = onObserverAdded;
  99751. }
  99752. }
  99753. /**
  99754. * Create a new Observer with the specified callback
  99755. * @param callback the callback that will be executed for that Observer
  99756. * @param mask the mask used to filter observers
  99757. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  99758. * @param scope optional scope for the callback to be called from
  99759. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  99760. * @returns the new observer created for the callback
  99761. */
  99762. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  99763. if (mask === void 0) { mask = -1; }
  99764. if (insertFirst === void 0) { insertFirst = false; }
  99765. if (scope === void 0) { scope = null; }
  99766. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  99767. if (!callback) {
  99768. return null;
  99769. }
  99770. var observer = new Observer(callback, mask, scope);
  99771. observer.unregisterOnNextCall = unregisterOnFirstCall;
  99772. if (insertFirst) {
  99773. this._observers.unshift(observer);
  99774. }
  99775. else {
  99776. this._observers.push(observer);
  99777. }
  99778. if (this._onObserverAdded) {
  99779. this._onObserverAdded(observer);
  99780. }
  99781. return observer;
  99782. };
  99783. /**
  99784. * Create a new Observer with the specified callback and unregisters after the next notification
  99785. * @param callback the callback that will be executed for that Observer
  99786. * @returns the new observer created for the callback
  99787. */
  99788. Observable.prototype.addOnce = function (callback) {
  99789. return this.add(callback, undefined, undefined, undefined, true);
  99790. };
  99791. /**
  99792. * Remove an Observer from the Observable object
  99793. * @param observer the instance of the Observer to remove
  99794. * @returns false if it doesn't belong to this Observable
  99795. */
  99796. Observable.prototype.remove = function (observer) {
  99797. if (!observer) {
  99798. return false;
  99799. }
  99800. var index = this._observers.indexOf(observer);
  99801. if (index !== -1) {
  99802. this._deferUnregister(observer);
  99803. return true;
  99804. }
  99805. return false;
  99806. };
  99807. /**
  99808. * Remove a callback from the Observable object
  99809. * @param callback the callback to remove
  99810. * @param scope optional scope. If used only the callbacks with this scope will be removed
  99811. * @returns false if it doesn't belong to this Observable
  99812. */
  99813. Observable.prototype.removeCallback = function (callback, scope) {
  99814. for (var index = 0; index < this._observers.length; index++) {
  99815. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  99816. this._deferUnregister(this._observers[index]);
  99817. return true;
  99818. }
  99819. }
  99820. return false;
  99821. };
  99822. Observable.prototype._deferUnregister = function (observer) {
  99823. var _this = this;
  99824. observer.unregisterOnNextCall = false;
  99825. observer._willBeUnregistered = true;
  99826. setTimeout(function () {
  99827. _this._remove(observer);
  99828. }, 0);
  99829. };
  99830. // This should only be called when not iterating over _observers to avoid callback skipping.
  99831. // Removes an observer from the _observer Array.
  99832. Observable.prototype._remove = function (observer) {
  99833. if (!observer) {
  99834. return false;
  99835. }
  99836. var index = this._observers.indexOf(observer);
  99837. if (index !== -1) {
  99838. this._observers.splice(index, 1);
  99839. return true;
  99840. }
  99841. return false;
  99842. };
  99843. /**
  99844. * Moves the observable to the top of the observer list making it get called first when notified
  99845. * @param observer the observer to move
  99846. */
  99847. Observable.prototype.makeObserverTopPriority = function (observer) {
  99848. this._remove(observer);
  99849. this._observers.unshift(observer);
  99850. };
  99851. /**
  99852. * Moves the observable to the bottom of the observer list making it get called last when notified
  99853. * @param observer the observer to move
  99854. */
  99855. Observable.prototype.makeObserverBottomPriority = function (observer) {
  99856. this._remove(observer);
  99857. this._observers.push(observer);
  99858. };
  99859. /**
  99860. * Notify all Observers by calling their respective callback with the given data
  99861. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  99862. * @param eventData defines the data to send to all observers
  99863. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  99864. * @param target defines the original target of the state
  99865. * @param currentTarget defines the current target of the state
  99866. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  99867. */
  99868. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  99869. if (mask === void 0) { mask = -1; }
  99870. if (!this._observers.length) {
  99871. return true;
  99872. }
  99873. var state = this._eventState;
  99874. state.mask = mask;
  99875. state.target = target;
  99876. state.currentTarget = currentTarget;
  99877. state.skipNextObservers = false;
  99878. state.lastReturnValue = eventData;
  99879. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  99880. var obs = _a[_i];
  99881. if (obs._willBeUnregistered) {
  99882. continue;
  99883. }
  99884. if (obs.mask & mask) {
  99885. if (obs.scope) {
  99886. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  99887. }
  99888. else {
  99889. state.lastReturnValue = obs.callback(eventData, state);
  99890. }
  99891. if (obs.unregisterOnNextCall) {
  99892. this._deferUnregister(obs);
  99893. }
  99894. }
  99895. if (state.skipNextObservers) {
  99896. return false;
  99897. }
  99898. }
  99899. return true;
  99900. };
  99901. /**
  99902. * Calling this will execute each callback, expecting it to be a promise or return a value.
  99903. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  99904. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  99905. * and it is crucial that all callbacks will be executed.
  99906. * The order of the callbacks is kept, callbacks are not executed parallel.
  99907. *
  99908. * @param eventData The data to be sent to each callback
  99909. * @param mask is used to filter observers defaults to -1
  99910. * @param target defines the callback target (see EventState)
  99911. * @param currentTarget defines he current object in the bubbling phase
  99912. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  99913. */
  99914. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  99915. var _this = this;
  99916. if (mask === void 0) { mask = -1; }
  99917. // create an empty promise
  99918. var p = Promise.resolve(eventData);
  99919. // no observers? return this promise.
  99920. if (!this._observers.length) {
  99921. return p;
  99922. }
  99923. var state = this._eventState;
  99924. state.mask = mask;
  99925. state.target = target;
  99926. state.currentTarget = currentTarget;
  99927. state.skipNextObservers = false;
  99928. // execute one callback after another (not using Promise.all, the order is important)
  99929. this._observers.forEach(function (obs) {
  99930. if (state.skipNextObservers) {
  99931. return;
  99932. }
  99933. if (obs._willBeUnregistered) {
  99934. return;
  99935. }
  99936. if (obs.mask & mask) {
  99937. if (obs.scope) {
  99938. p = p.then(function (lastReturnedValue) {
  99939. state.lastReturnValue = lastReturnedValue;
  99940. return obs.callback.apply(obs.scope, [eventData, state]);
  99941. });
  99942. }
  99943. else {
  99944. p = p.then(function (lastReturnedValue) {
  99945. state.lastReturnValue = lastReturnedValue;
  99946. return obs.callback(eventData, state);
  99947. });
  99948. }
  99949. if (obs.unregisterOnNextCall) {
  99950. _this._deferUnregister(obs);
  99951. }
  99952. }
  99953. });
  99954. // return the eventData
  99955. return p.then(function () { return eventData; });
  99956. };
  99957. /**
  99958. * Notify a specific observer
  99959. * @param observer defines the observer to notify
  99960. * @param eventData defines the data to be sent to each callback
  99961. * @param mask is used to filter observers defaults to -1
  99962. */
  99963. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  99964. if (mask === void 0) { mask = -1; }
  99965. var state = this._eventState;
  99966. state.mask = mask;
  99967. state.skipNextObservers = false;
  99968. observer.callback(eventData, state);
  99969. };
  99970. /**
  99971. * Gets a boolean indicating if the observable has at least one observer
  99972. * @returns true is the Observable has at least one Observer registered
  99973. */
  99974. Observable.prototype.hasObservers = function () {
  99975. return this._observers.length > 0;
  99976. };
  99977. /**
  99978. * Clear the list of observers
  99979. */
  99980. Observable.prototype.clear = function () {
  99981. this._observers = new Array();
  99982. this._onObserverAdded = null;
  99983. };
  99984. /**
  99985. * Clone the current observable
  99986. * @returns a new observable
  99987. */
  99988. Observable.prototype.clone = function () {
  99989. var result = new Observable();
  99990. result._observers = this._observers.slice(0);
  99991. return result;
  99992. };
  99993. /**
  99994. * Does this observable handles observer registered with a given mask
  99995. * @param mask defines the mask to be tested
  99996. * @return whether or not one observer registered with the given mask is handeled
  99997. **/
  99998. Observable.prototype.hasSpecificMask = function (mask) {
  99999. if (mask === void 0) { mask = -1; }
  100000. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  100001. var obs = _a[_i];
  100002. if (obs.mask & mask || obs.mask === mask) {
  100003. return true;
  100004. }
  100005. }
  100006. return false;
  100007. };
  100008. return Observable;
  100009. }());
  100010. /***/ }),
  100011. /***/ "./Misc/performanceMonitor.ts":
  100012. /*!************************************!*\
  100013. !*** ./Misc/performanceMonitor.ts ***!
  100014. \************************************/
  100015. /*! exports provided: PerformanceMonitor, RollingAverage */
  100016. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100017. "use strict";
  100018. __webpack_require__.r(__webpack_exports__);
  100019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  100020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  100021. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  100022. /**
  100023. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  100024. */
  100025. var PerformanceMonitor = /** @class */ (function () {
  100026. /**
  100027. * constructor
  100028. * @param frameSampleSize The number of samples required to saturate the sliding window
  100029. */
  100030. function PerformanceMonitor(frameSampleSize) {
  100031. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  100032. this._enabled = true;
  100033. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  100034. }
  100035. /**
  100036. * Samples current frame
  100037. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  100038. */
  100039. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  100040. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  100041. if (!this._enabled) {
  100042. return;
  100043. }
  100044. if (this._lastFrameTimeMs != null) {
  100045. var dt = timeMs - this._lastFrameTimeMs;
  100046. this._rollingFrameTime.add(dt);
  100047. }
  100048. this._lastFrameTimeMs = timeMs;
  100049. };
  100050. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  100051. /**
  100052. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  100053. */
  100054. get: function () {
  100055. return this._rollingFrameTime.average;
  100056. },
  100057. enumerable: true,
  100058. configurable: true
  100059. });
  100060. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  100061. /**
  100062. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  100063. */
  100064. get: function () {
  100065. return this._rollingFrameTime.variance;
  100066. },
  100067. enumerable: true,
  100068. configurable: true
  100069. });
  100070. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  100071. /**
  100072. * Returns the frame time of the most recent frame
  100073. */
  100074. get: function () {
  100075. return this._rollingFrameTime.history(0);
  100076. },
  100077. enumerable: true,
  100078. configurable: true
  100079. });
  100080. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  100081. /**
  100082. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  100083. */
  100084. get: function () {
  100085. return 1000.0 / this._rollingFrameTime.average;
  100086. },
  100087. enumerable: true,
  100088. configurable: true
  100089. });
  100090. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  100091. /**
  100092. * Returns the average framerate in frames per second using the most recent frame time
  100093. */
  100094. get: function () {
  100095. var history = this._rollingFrameTime.history(0);
  100096. if (history === 0) {
  100097. return 0;
  100098. }
  100099. return 1000.0 / history;
  100100. },
  100101. enumerable: true,
  100102. configurable: true
  100103. });
  100104. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  100105. /**
  100106. * Returns true if enough samples have been taken to completely fill the sliding window
  100107. */
  100108. get: function () {
  100109. return this._rollingFrameTime.isSaturated();
  100110. },
  100111. enumerable: true,
  100112. configurable: true
  100113. });
  100114. /**
  100115. * Enables contributions to the sliding window sample set
  100116. */
  100117. PerformanceMonitor.prototype.enable = function () {
  100118. this._enabled = true;
  100119. };
  100120. /**
  100121. * Disables contributions to the sliding window sample set
  100122. * Samples will not be interpolated over the disabled period
  100123. */
  100124. PerformanceMonitor.prototype.disable = function () {
  100125. this._enabled = false;
  100126. //clear last sample to avoid interpolating over the disabled period when next enabled
  100127. this._lastFrameTimeMs = null;
  100128. };
  100129. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  100130. /**
  100131. * Returns true if sampling is enabled
  100132. */
  100133. get: function () {
  100134. return this._enabled;
  100135. },
  100136. enumerable: true,
  100137. configurable: true
  100138. });
  100139. /**
  100140. * Resets performance monitor
  100141. */
  100142. PerformanceMonitor.prototype.reset = function () {
  100143. //clear last sample to avoid interpolating over the disabled period when next enabled
  100144. this._lastFrameTimeMs = null;
  100145. //wipe record
  100146. this._rollingFrameTime.reset();
  100147. };
  100148. return PerformanceMonitor;
  100149. }());
  100150. /**
  100151. * RollingAverage
  100152. *
  100153. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  100154. */
  100155. var RollingAverage = /** @class */ (function () {
  100156. /**
  100157. * constructor
  100158. * @param length The number of samples required to saturate the sliding window
  100159. */
  100160. function RollingAverage(length) {
  100161. this._samples = new Array(length);
  100162. this.reset();
  100163. }
  100164. /**
  100165. * Adds a sample to the sample set
  100166. * @param v The sample value
  100167. */
  100168. RollingAverage.prototype.add = function (v) {
  100169. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  100170. var delta;
  100171. //we need to check if we've already wrapped round
  100172. if (this.isSaturated()) {
  100173. //remove bottom of stack from mean
  100174. var bottomValue = this._samples[this._pos];
  100175. delta = bottomValue - this.average;
  100176. this.average -= delta / (this._sampleCount - 1);
  100177. this._m2 -= delta * (bottomValue - this.average);
  100178. }
  100179. else {
  100180. this._sampleCount++;
  100181. }
  100182. //add new value to mean
  100183. delta = v - this.average;
  100184. this.average += delta / (this._sampleCount);
  100185. this._m2 += delta * (v - this.average);
  100186. //set the new variance
  100187. this.variance = this._m2 / (this._sampleCount - 1);
  100188. this._samples[this._pos] = v;
  100189. this._pos++;
  100190. this._pos %= this._samples.length; //positive wrap around
  100191. };
  100192. /**
  100193. * Returns previously added values or null if outside of history or outside the sliding window domain
  100194. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  100195. * @return Value previously recorded with add() or null if outside of range
  100196. */
  100197. RollingAverage.prototype.history = function (i) {
  100198. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  100199. return 0;
  100200. }
  100201. var i0 = this._wrapPosition(this._pos - 1.0);
  100202. return this._samples[this._wrapPosition(i0 - i)];
  100203. };
  100204. /**
  100205. * Returns true if enough samples have been taken to completely fill the sliding window
  100206. * @return true if sample-set saturated
  100207. */
  100208. RollingAverage.prototype.isSaturated = function () {
  100209. return this._sampleCount >= this._samples.length;
  100210. };
  100211. /**
  100212. * Resets the rolling average (equivalent to 0 samples taken so far)
  100213. */
  100214. RollingAverage.prototype.reset = function () {
  100215. this.average = 0;
  100216. this.variance = 0;
  100217. this._sampleCount = 0;
  100218. this._pos = 0;
  100219. this._m2 = 0;
  100220. };
  100221. /**
  100222. * Wraps a value around the sample range boundaries
  100223. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  100224. * @return Wrapped position in sample range
  100225. */
  100226. RollingAverage.prototype._wrapPosition = function (i) {
  100227. var max = this._samples.length;
  100228. return ((i % max) + max) % max;
  100229. };
  100230. return RollingAverage;
  100231. }());
  100232. /***/ }),
  100233. /***/ "./Misc/pivotTools.ts":
  100234. /*!****************************!*\
  100235. !*** ./Misc/pivotTools.ts ***!
  100236. \****************************/
  100237. /*! exports provided: PivotTools */
  100238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100239. "use strict";
  100240. __webpack_require__.r(__webpack_exports__);
  100241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  100242. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  100243. /**
  100244. * Class containing a set of static utilities functions for managing Pivots
  100245. * @hidden
  100246. */
  100247. var PivotTools = /** @class */ (function () {
  100248. function PivotTools() {
  100249. }
  100250. /** @hidden */
  100251. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  100252. if (mesh && PivotTools._PivotCached === 0) {
  100253. // Save old pivot and set pivot to 0,0,0
  100254. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  100255. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  100256. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  100257. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  100258. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  100259. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  100260. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  100261. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  100262. }
  100263. }
  100264. PivotTools._PivotCached++;
  100265. };
  100266. /** @hidden */
  100267. PivotTools._RestorePivotPoint = function (mesh) {
  100268. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  100269. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  100270. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  100271. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  100272. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  100273. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  100274. }
  100275. this._PivotCached--;
  100276. };
  100277. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  100278. // store/remove pivot point should only be applied during their outermost calls
  100279. PivotTools._PivotCached = 0;
  100280. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  100281. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  100282. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  100283. return PivotTools;
  100284. }());
  100285. /***/ }),
  100286. /***/ "./Misc/precisionDate.ts":
  100287. /*!*******************************!*\
  100288. !*** ./Misc/precisionDate.ts ***!
  100289. \*******************************/
  100290. /*! exports provided: PrecisionDate */
  100291. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100292. "use strict";
  100293. __webpack_require__.r(__webpack_exports__);
  100294. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  100295. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  100296. /**
  100297. * Class containing a set of static utilities functions for precision date
  100298. */
  100299. var PrecisionDate = /** @class */ (function () {
  100300. function PrecisionDate() {
  100301. }
  100302. Object.defineProperty(PrecisionDate, "Now", {
  100303. /**
  100304. * Gets either window.performance.now() if supported or Date.now() else
  100305. */
  100306. get: function () {
  100307. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  100308. return window.performance.now();
  100309. }
  100310. return Date.now();
  100311. },
  100312. enumerable: true,
  100313. configurable: true
  100314. });
  100315. return PrecisionDate;
  100316. }());
  100317. /***/ }),
  100318. /***/ "./Misc/promise.ts":
  100319. /*!*************************!*\
  100320. !*** ./Misc/promise.ts ***!
  100321. \*************************/
  100322. /*! exports provided: PromisePolyfill */
  100323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100324. "use strict";
  100325. __webpack_require__.r(__webpack_exports__);
  100326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  100327. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  100328. var PromiseStates;
  100329. (function (PromiseStates) {
  100330. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  100331. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  100332. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  100333. })(PromiseStates || (PromiseStates = {}));
  100334. var FulFillmentAgregator = /** @class */ (function () {
  100335. function FulFillmentAgregator() {
  100336. this.count = 0;
  100337. this.target = 0;
  100338. this.results = [];
  100339. }
  100340. return FulFillmentAgregator;
  100341. }());
  100342. var InternalPromise = /** @class */ (function () {
  100343. function InternalPromise(resolver) {
  100344. var _this = this;
  100345. this._state = PromiseStates.Pending;
  100346. this._children = new Array();
  100347. this._rejectWasConsumed = false;
  100348. if (!resolver) {
  100349. return;
  100350. }
  100351. try {
  100352. resolver(function (value) {
  100353. _this._resolve(value);
  100354. }, function (reason) {
  100355. _this._reject(reason);
  100356. });
  100357. }
  100358. catch (e) {
  100359. this._reject(e);
  100360. }
  100361. }
  100362. Object.defineProperty(InternalPromise.prototype, "_result", {
  100363. get: function () {
  100364. return this._resultValue;
  100365. },
  100366. set: function (value) {
  100367. this._resultValue = value;
  100368. if (this._parent && this._parent._result === undefined) {
  100369. this._parent._result = value;
  100370. }
  100371. },
  100372. enumerable: true,
  100373. configurable: true
  100374. });
  100375. InternalPromise.prototype.catch = function (onRejected) {
  100376. return this.then(undefined, onRejected);
  100377. };
  100378. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  100379. var _this = this;
  100380. var newPromise = new InternalPromise();
  100381. newPromise._onFulfilled = onFulfilled;
  100382. newPromise._onRejected = onRejected;
  100383. // Composition
  100384. this._children.push(newPromise);
  100385. newPromise._parent = this;
  100386. if (this._state !== PromiseStates.Pending) {
  100387. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  100388. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  100389. var returnedValue = newPromise._resolve(_this._result);
  100390. if (returnedValue !== undefined && returnedValue !== null) {
  100391. if (returnedValue._state !== undefined) {
  100392. var returnedPromise = returnedValue;
  100393. newPromise._children.push(returnedPromise);
  100394. returnedPromise._parent = newPromise;
  100395. newPromise = returnedPromise;
  100396. }
  100397. else {
  100398. newPromise._result = returnedValue;
  100399. }
  100400. }
  100401. }
  100402. else {
  100403. newPromise._reject(_this._reason);
  100404. }
  100405. });
  100406. }
  100407. return newPromise;
  100408. };
  100409. InternalPromise.prototype._moveChildren = function (children) {
  100410. var _this = this;
  100411. var _a;
  100412. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  100413. this._children.forEach(function (child) {
  100414. child._parent = _this;
  100415. });
  100416. if (this._state === PromiseStates.Fulfilled) {
  100417. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  100418. var child = _b[_i];
  100419. child._resolve(this._result);
  100420. }
  100421. }
  100422. else if (this._state === PromiseStates.Rejected) {
  100423. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  100424. var child = _d[_c];
  100425. child._reject(this._reason);
  100426. }
  100427. }
  100428. };
  100429. InternalPromise.prototype._resolve = function (value) {
  100430. try {
  100431. this._state = PromiseStates.Fulfilled;
  100432. var returnedValue = null;
  100433. if (this._onFulfilled) {
  100434. returnedValue = this._onFulfilled(value);
  100435. }
  100436. if (returnedValue !== undefined && returnedValue !== null) {
  100437. if (returnedValue._state !== undefined) {
  100438. // Transmit children
  100439. var returnedPromise = returnedValue;
  100440. returnedPromise._parent = this;
  100441. returnedPromise._moveChildren(this._children);
  100442. value = returnedPromise._result;
  100443. }
  100444. else {
  100445. value = returnedValue;
  100446. }
  100447. }
  100448. this._result = value;
  100449. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  100450. var child = _a[_i];
  100451. child._resolve(value);
  100452. }
  100453. this._children.length = 0;
  100454. delete this._onFulfilled;
  100455. delete this._onRejected;
  100456. }
  100457. catch (e) {
  100458. this._reject(e, true);
  100459. }
  100460. };
  100461. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  100462. if (onLocalThrow === void 0) { onLocalThrow = false; }
  100463. this._state = PromiseStates.Rejected;
  100464. this._reason = reason;
  100465. if (this._onRejected && !onLocalThrow) {
  100466. try {
  100467. this._onRejected(reason);
  100468. this._rejectWasConsumed = true;
  100469. }
  100470. catch (e) {
  100471. reason = e;
  100472. }
  100473. }
  100474. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  100475. var child = _a[_i];
  100476. if (this._rejectWasConsumed) {
  100477. child._resolve(null);
  100478. }
  100479. else {
  100480. child._reject(reason);
  100481. }
  100482. }
  100483. this._children.length = 0;
  100484. delete this._onFulfilled;
  100485. delete this._onRejected;
  100486. };
  100487. InternalPromise.resolve = function (value) {
  100488. var newPromise = new InternalPromise();
  100489. newPromise._resolve(value);
  100490. return newPromise;
  100491. };
  100492. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  100493. promise.then(function (value) {
  100494. agregator.results[index] = value;
  100495. agregator.count++;
  100496. if (agregator.count === agregator.target) {
  100497. agregator.rootPromise._resolve(agregator.results);
  100498. }
  100499. return null;
  100500. }, function (reason) {
  100501. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  100502. agregator.rootPromise._reject(reason);
  100503. }
  100504. });
  100505. };
  100506. InternalPromise.all = function (promises) {
  100507. var newPromise = new InternalPromise();
  100508. var agregator = new FulFillmentAgregator();
  100509. agregator.target = promises.length;
  100510. agregator.rootPromise = newPromise;
  100511. if (promises.length) {
  100512. for (var index = 0; index < promises.length; index++) {
  100513. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  100514. }
  100515. }
  100516. else {
  100517. newPromise._resolve([]);
  100518. }
  100519. return newPromise;
  100520. };
  100521. InternalPromise.race = function (promises) {
  100522. var newPromise = new InternalPromise();
  100523. if (promises.length) {
  100524. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  100525. var promise = promises_1[_i];
  100526. promise.then(function (value) {
  100527. if (newPromise) {
  100528. newPromise._resolve(value);
  100529. newPromise = null;
  100530. }
  100531. return null;
  100532. }, function (reason) {
  100533. if (newPromise) {
  100534. newPromise._reject(reason);
  100535. newPromise = null;
  100536. }
  100537. });
  100538. }
  100539. }
  100540. return newPromise;
  100541. };
  100542. return InternalPromise;
  100543. }());
  100544. /**
  100545. * Helper class that provides a small promise polyfill
  100546. */
  100547. var PromisePolyfill = /** @class */ (function () {
  100548. function PromisePolyfill() {
  100549. }
  100550. /**
  100551. * Static function used to check if the polyfill is required
  100552. * If this is the case then the function will inject the polyfill to window.Promise
  100553. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  100554. */
  100555. PromisePolyfill.Apply = function (force) {
  100556. if (force === void 0) { force = false; }
  100557. if (force || typeof Promise === 'undefined') {
  100558. var root = window;
  100559. root.Promise = InternalPromise;
  100560. }
  100561. };
  100562. return PromisePolyfill;
  100563. }());
  100564. /***/ }),
  100565. /***/ "./Misc/sceneOptimizer.ts":
  100566. /*!********************************!*\
  100567. !*** ./Misc/sceneOptimizer.ts ***!
  100568. \********************************/
  100569. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  100570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100571. "use strict";
  100572. __webpack_require__.r(__webpack_exports__);
  100573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  100574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  100575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  100576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  100577. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  100578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  100579. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  100580. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  100581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  100582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  100583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  100584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  100585. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100586. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  100587. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  100588. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  100589. /**
  100590. * Defines the root class used to create scene optimization to use with SceneOptimizer
  100591. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100592. */
  100593. var SceneOptimization = /** @class */ (function () {
  100594. /**
  100595. * Creates the SceneOptimization object
  100596. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  100597. * @param desc defines the description associated with the optimization
  100598. */
  100599. function SceneOptimization(
  100600. /**
  100601. * Defines the priority of this optimization (0 by default which means first in the list)
  100602. */
  100603. priority) {
  100604. if (priority === void 0) { priority = 0; }
  100605. this.priority = priority;
  100606. }
  100607. /**
  100608. * Gets a string describing the action executed by the current optimization
  100609. * @returns description string
  100610. */
  100611. SceneOptimization.prototype.getDescription = function () {
  100612. return "";
  100613. };
  100614. /**
  100615. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100616. * @param scene defines the current scene where to apply this optimization
  100617. * @param optimizer defines the current optimizer
  100618. * @returns true if everything that can be done was applied
  100619. */
  100620. SceneOptimization.prototype.apply = function (scene, optimizer) {
  100621. return true;
  100622. };
  100623. return SceneOptimization;
  100624. }());
  100625. /**
  100626. * Defines an optimization used to reduce the size of render target textures
  100627. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100628. */
  100629. var TextureOptimization = /** @class */ (function (_super) {
  100630. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  100631. /**
  100632. * Creates the TextureOptimization object
  100633. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  100634. * @param maximumSize defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  100635. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  100636. */
  100637. function TextureOptimization(
  100638. /**
  100639. * Defines the priority of this optimization (0 by default which means first in the list)
  100640. */
  100641. priority,
  100642. /**
  100643. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  100644. */
  100645. maximumSize,
  100646. /**
  100647. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  100648. */
  100649. step) {
  100650. if (priority === void 0) { priority = 0; }
  100651. if (maximumSize === void 0) { maximumSize = 1024; }
  100652. if (step === void 0) { step = 0.5; }
  100653. var _this = _super.call(this, priority) || this;
  100654. _this.priority = priority;
  100655. _this.maximumSize = maximumSize;
  100656. _this.step = step;
  100657. return _this;
  100658. }
  100659. /**
  100660. * Gets a string describing the action executed by the current optimization
  100661. * @returns description string
  100662. */
  100663. TextureOptimization.prototype.getDescription = function () {
  100664. return "Reducing render target texture size to " + this.maximumSize;
  100665. };
  100666. /**
  100667. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100668. * @param scene defines the current scene where to apply this optimization
  100669. * @param optimizer defines the current optimizer
  100670. * @returns true if everything that can be done was applied
  100671. */
  100672. TextureOptimization.prototype.apply = function (scene, optimizer) {
  100673. var allDone = true;
  100674. for (var index = 0; index < scene.textures.length; index++) {
  100675. var texture = scene.textures[index];
  100676. if (!texture.canRescale || texture.getContext) {
  100677. continue;
  100678. }
  100679. var currentSize = texture.getSize();
  100680. var maxDimension = Math.max(currentSize.width, currentSize.height);
  100681. if (maxDimension > this.maximumSize) {
  100682. texture.scale(this.step);
  100683. allDone = false;
  100684. }
  100685. }
  100686. return allDone;
  100687. };
  100688. return TextureOptimization;
  100689. }(SceneOptimization));
  100690. /**
  100691. * Defines an optimization used to increase or decrease the rendering resolution
  100692. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100693. */
  100694. var HardwareScalingOptimization = /** @class */ (function (_super) {
  100695. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  100696. /**
  100697. * Creates the HardwareScalingOptimization object
  100698. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  100699. * @param maximumScale defines the maximum scale to use (2 by default)
  100700. * @param step defines the step to use between two passes (0.5 by default)
  100701. */
  100702. function HardwareScalingOptimization(
  100703. /**
  100704. * Defines the priority of this optimization (0 by default which means first in the list)
  100705. */
  100706. priority,
  100707. /**
  100708. * Defines the maximum scale to use (2 by default)
  100709. */
  100710. maximumScale,
  100711. /**
  100712. * Defines the step to use between two passes (0.5 by default)
  100713. */
  100714. step) {
  100715. if (priority === void 0) { priority = 0; }
  100716. if (maximumScale === void 0) { maximumScale = 2; }
  100717. if (step === void 0) { step = 0.25; }
  100718. var _this = _super.call(this, priority) || this;
  100719. _this.priority = priority;
  100720. _this.maximumScale = maximumScale;
  100721. _this.step = step;
  100722. _this._currentScale = -1;
  100723. _this._directionOffset = 1;
  100724. return _this;
  100725. }
  100726. /**
  100727. * Gets a string describing the action executed by the current optimization
  100728. * @return description string
  100729. */
  100730. HardwareScalingOptimization.prototype.getDescription = function () {
  100731. return "Setting hardware scaling level to " + this._currentScale;
  100732. };
  100733. /**
  100734. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100735. * @param scene defines the current scene where to apply this optimization
  100736. * @param optimizer defines the current optimizer
  100737. * @returns true if everything that can be done was applied
  100738. */
  100739. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  100740. if (this._currentScale === -1) {
  100741. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  100742. if (this._currentScale > this.maximumScale) {
  100743. this._directionOffset = -1;
  100744. }
  100745. }
  100746. this._currentScale += this._directionOffset * this.step;
  100747. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  100748. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  100749. };
  100750. return HardwareScalingOptimization;
  100751. }(SceneOptimization));
  100752. /**
  100753. * Defines an optimization used to remove shadows
  100754. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100755. */
  100756. var ShadowsOptimization = /** @class */ (function (_super) {
  100757. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  100758. function ShadowsOptimization() {
  100759. return _super !== null && _super.apply(this, arguments) || this;
  100760. }
  100761. /**
  100762. * Gets a string describing the action executed by the current optimization
  100763. * @return description string
  100764. */
  100765. ShadowsOptimization.prototype.getDescription = function () {
  100766. return "Turning shadows on/off";
  100767. };
  100768. /**
  100769. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100770. * @param scene defines the current scene where to apply this optimization
  100771. * @param optimizer defines the current optimizer
  100772. * @returns true if everything that can be done was applied
  100773. */
  100774. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  100775. scene.shadowsEnabled = optimizer.isInImprovementMode;
  100776. return true;
  100777. };
  100778. return ShadowsOptimization;
  100779. }(SceneOptimization));
  100780. /**
  100781. * Defines an optimization used to turn post-processes off
  100782. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100783. */
  100784. var PostProcessesOptimization = /** @class */ (function (_super) {
  100785. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  100786. function PostProcessesOptimization() {
  100787. return _super !== null && _super.apply(this, arguments) || this;
  100788. }
  100789. /**
  100790. * Gets a string describing the action executed by the current optimization
  100791. * @return description string
  100792. */
  100793. PostProcessesOptimization.prototype.getDescription = function () {
  100794. return "Turning post-processes on/off";
  100795. };
  100796. /**
  100797. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100798. * @param scene defines the current scene where to apply this optimization
  100799. * @param optimizer defines the current optimizer
  100800. * @returns true if everything that can be done was applied
  100801. */
  100802. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  100803. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  100804. return true;
  100805. };
  100806. return PostProcessesOptimization;
  100807. }(SceneOptimization));
  100808. /**
  100809. * Defines an optimization used to turn lens flares off
  100810. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100811. */
  100812. var LensFlaresOptimization = /** @class */ (function (_super) {
  100813. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  100814. function LensFlaresOptimization() {
  100815. return _super !== null && _super.apply(this, arguments) || this;
  100816. }
  100817. /**
  100818. * Gets a string describing the action executed by the current optimization
  100819. * @return description string
  100820. */
  100821. LensFlaresOptimization.prototype.getDescription = function () {
  100822. return "Turning lens flares on/off";
  100823. };
  100824. /**
  100825. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100826. * @param scene defines the current scene where to apply this optimization
  100827. * @param optimizer defines the current optimizer
  100828. * @returns true if everything that can be done was applied
  100829. */
  100830. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  100831. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  100832. return true;
  100833. };
  100834. return LensFlaresOptimization;
  100835. }(SceneOptimization));
  100836. /**
  100837. * Defines an optimization based on user defined callback.
  100838. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100839. */
  100840. var CustomOptimization = /** @class */ (function (_super) {
  100841. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  100842. function CustomOptimization() {
  100843. return _super !== null && _super.apply(this, arguments) || this;
  100844. }
  100845. /**
  100846. * Gets a string describing the action executed by the current optimization
  100847. * @returns description string
  100848. */
  100849. CustomOptimization.prototype.getDescription = function () {
  100850. if (this.onGetDescription) {
  100851. return this.onGetDescription();
  100852. }
  100853. return "Running user defined callback";
  100854. };
  100855. /**
  100856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100857. * @param scene defines the current scene where to apply this optimization
  100858. * @param optimizer defines the current optimizer
  100859. * @returns true if everything that can be done was applied
  100860. */
  100861. CustomOptimization.prototype.apply = function (scene, optimizer) {
  100862. if (this.onApply) {
  100863. return this.onApply(scene, optimizer);
  100864. }
  100865. return true;
  100866. };
  100867. return CustomOptimization;
  100868. }(SceneOptimization));
  100869. /**
  100870. * Defines an optimization used to turn particles off
  100871. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100872. */
  100873. var ParticlesOptimization = /** @class */ (function (_super) {
  100874. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  100875. function ParticlesOptimization() {
  100876. return _super !== null && _super.apply(this, arguments) || this;
  100877. }
  100878. /**
  100879. * Gets a string describing the action executed by the current optimization
  100880. * @return description string
  100881. */
  100882. ParticlesOptimization.prototype.getDescription = function () {
  100883. return "Turning particles on/off";
  100884. };
  100885. /**
  100886. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100887. * @param scene defines the current scene where to apply this optimization
  100888. * @param optimizer defines the current optimizer
  100889. * @returns true if everything that can be done was applied
  100890. */
  100891. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  100892. scene.particlesEnabled = optimizer.isInImprovementMode;
  100893. return true;
  100894. };
  100895. return ParticlesOptimization;
  100896. }(SceneOptimization));
  100897. /**
  100898. * Defines an optimization used to turn render targets off
  100899. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100900. */
  100901. var RenderTargetsOptimization = /** @class */ (function (_super) {
  100902. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  100903. function RenderTargetsOptimization() {
  100904. return _super !== null && _super.apply(this, arguments) || this;
  100905. }
  100906. /**
  100907. * Gets a string describing the action executed by the current optimization
  100908. * @return description string
  100909. */
  100910. RenderTargetsOptimization.prototype.getDescription = function () {
  100911. return "Turning render targets off";
  100912. };
  100913. /**
  100914. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100915. * @param scene defines the current scene where to apply this optimization
  100916. * @param optimizer defines the current optimizer
  100917. * @returns true if everything that can be done was applied
  100918. */
  100919. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  100920. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  100921. return true;
  100922. };
  100923. return RenderTargetsOptimization;
  100924. }(SceneOptimization));
  100925. /**
  100926. * Defines an optimization used to merge meshes with compatible materials
  100927. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100928. */
  100929. var MergeMeshesOptimization = /** @class */ (function (_super) {
  100930. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  100931. function MergeMeshesOptimization() {
  100932. var _this = _super !== null && _super.apply(this, arguments) || this;
  100933. _this._canBeMerged = function (abstractMesh) {
  100934. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  100935. return false;
  100936. }
  100937. var mesh = abstractMesh;
  100938. if (mesh.isDisposed()) {
  100939. return false;
  100940. }
  100941. if (!mesh.isVisible || !mesh.isEnabled()) {
  100942. return false;
  100943. }
  100944. if (mesh.instances.length > 0) {
  100945. return false;
  100946. }
  100947. if (mesh.skeleton || mesh.hasLODLevels) {
  100948. return false;
  100949. }
  100950. return true;
  100951. };
  100952. return _this;
  100953. }
  100954. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  100955. /**
  100956. * Gets or sets a boolean which defines if optimization octree has to be updated
  100957. */
  100958. get: function () {
  100959. return MergeMeshesOptimization._UpdateSelectionTree;
  100960. },
  100961. /**
  100962. * Gets or sets a boolean which defines if optimization octree has to be updated
  100963. */
  100964. set: function (value) {
  100965. MergeMeshesOptimization._UpdateSelectionTree = value;
  100966. },
  100967. enumerable: true,
  100968. configurable: true
  100969. });
  100970. /**
  100971. * Gets a string describing the action executed by the current optimization
  100972. * @return description string
  100973. */
  100974. MergeMeshesOptimization.prototype.getDescription = function () {
  100975. return "Merging similar meshes together";
  100976. };
  100977. /**
  100978. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100979. * @param scene defines the current scene where to apply this optimization
  100980. * @param optimizer defines the current optimizer
  100981. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  100982. * @returns true if everything that can be done was applied
  100983. */
  100984. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  100985. var globalPool = scene.meshes.slice(0);
  100986. var globalLength = globalPool.length;
  100987. for (var index = 0; index < globalLength; index++) {
  100988. var currentPool = new Array();
  100989. var current = globalPool[index];
  100990. // Checks
  100991. if (!this._canBeMerged(current)) {
  100992. continue;
  100993. }
  100994. currentPool.push(current);
  100995. // Find compatible meshes
  100996. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  100997. var otherMesh = globalPool[subIndex];
  100998. if (!this._canBeMerged(otherMesh)) {
  100999. continue;
  101000. }
  101001. if (otherMesh.material !== current.material) {
  101002. continue;
  101003. }
  101004. if (otherMesh.checkCollisions !== current.checkCollisions) {
  101005. continue;
  101006. }
  101007. currentPool.push(otherMesh);
  101008. globalLength--;
  101009. globalPool.splice(subIndex, 1);
  101010. subIndex--;
  101011. }
  101012. if (currentPool.length < 2) {
  101013. continue;
  101014. }
  101015. // Merge meshes
  101016. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  101017. }
  101018. // Call the octree system optimization if it is defined.
  101019. var sceneAsAny = scene;
  101020. if (sceneAsAny.createOrUpdateSelectionOctree) {
  101021. if (updateSelectionTree != undefined) {
  101022. if (updateSelectionTree) {
  101023. sceneAsAny.createOrUpdateSelectionOctree();
  101024. }
  101025. }
  101026. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  101027. sceneAsAny.createOrUpdateSelectionOctree();
  101028. }
  101029. }
  101030. return true;
  101031. };
  101032. MergeMeshesOptimization._UpdateSelectionTree = false;
  101033. return MergeMeshesOptimization;
  101034. }(SceneOptimization));
  101035. /**
  101036. * Defines a list of options used by SceneOptimizer
  101037. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101038. */
  101039. var SceneOptimizerOptions = /** @class */ (function () {
  101040. /**
  101041. * Creates a new list of options used by SceneOptimizer
  101042. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  101043. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  101044. */
  101045. function SceneOptimizerOptions(
  101046. /**
  101047. * Defines the target frame rate to reach (60 by default)
  101048. */
  101049. targetFrameRate,
  101050. /**
  101051. * Defines the interval between two checkes (2000ms by default)
  101052. */
  101053. trackerDuration) {
  101054. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  101055. if (trackerDuration === void 0) { trackerDuration = 2000; }
  101056. this.targetFrameRate = targetFrameRate;
  101057. this.trackerDuration = trackerDuration;
  101058. /**
  101059. * Gets the list of optimizations to apply
  101060. */
  101061. this.optimizations = new Array();
  101062. }
  101063. /**
  101064. * Add a new optimization
  101065. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  101066. * @returns the current SceneOptimizerOptions
  101067. */
  101068. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  101069. this.optimizations.push(optimization);
  101070. return this;
  101071. };
  101072. /**
  101073. * Add a new custom optimization
  101074. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  101075. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  101076. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  101077. * @returns the current SceneOptimizerOptions
  101078. */
  101079. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  101080. if (priority === void 0) { priority = 0; }
  101081. var optimization = new CustomOptimization(priority);
  101082. optimization.onApply = onApply;
  101083. optimization.onGetDescription = onGetDescription;
  101084. this.optimizations.push(optimization);
  101085. return this;
  101086. };
  101087. /**
  101088. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  101089. * @param targetFrameRate defines the target frame rate (60 by default)
  101090. * @returns a SceneOptimizerOptions object
  101091. */
  101092. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  101093. var result = new SceneOptimizerOptions(targetFrameRate);
  101094. var priority = 0;
  101095. result.addOptimization(new MergeMeshesOptimization(priority));
  101096. result.addOptimization(new ShadowsOptimization(priority));
  101097. result.addOptimization(new LensFlaresOptimization(priority));
  101098. // Next priority
  101099. priority++;
  101100. result.addOptimization(new PostProcessesOptimization(priority));
  101101. result.addOptimization(new ParticlesOptimization(priority));
  101102. // Next priority
  101103. priority++;
  101104. result.addOptimization(new TextureOptimization(priority, 1024));
  101105. return result;
  101106. };
  101107. /**
  101108. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  101109. * @param targetFrameRate defines the target frame rate (60 by default)
  101110. * @returns a SceneOptimizerOptions object
  101111. */
  101112. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  101113. var result = new SceneOptimizerOptions(targetFrameRate);
  101114. var priority = 0;
  101115. result.addOptimization(new MergeMeshesOptimization(priority));
  101116. result.addOptimization(new ShadowsOptimization(priority));
  101117. result.addOptimization(new LensFlaresOptimization(priority));
  101118. // Next priority
  101119. priority++;
  101120. result.addOptimization(new PostProcessesOptimization(priority));
  101121. result.addOptimization(new ParticlesOptimization(priority));
  101122. // Next priority
  101123. priority++;
  101124. result.addOptimization(new TextureOptimization(priority, 512));
  101125. // Next priority
  101126. priority++;
  101127. result.addOptimization(new RenderTargetsOptimization(priority));
  101128. // Next priority
  101129. priority++;
  101130. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  101131. return result;
  101132. };
  101133. /**
  101134. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  101135. * @param targetFrameRate defines the target frame rate (60 by default)
  101136. * @returns a SceneOptimizerOptions object
  101137. */
  101138. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  101139. var result = new SceneOptimizerOptions(targetFrameRate);
  101140. var priority = 0;
  101141. result.addOptimization(new MergeMeshesOptimization(priority));
  101142. result.addOptimization(new ShadowsOptimization(priority));
  101143. result.addOptimization(new LensFlaresOptimization(priority));
  101144. // Next priority
  101145. priority++;
  101146. result.addOptimization(new PostProcessesOptimization(priority));
  101147. result.addOptimization(new ParticlesOptimization(priority));
  101148. // Next priority
  101149. priority++;
  101150. result.addOptimization(new TextureOptimization(priority, 256));
  101151. // Next priority
  101152. priority++;
  101153. result.addOptimization(new RenderTargetsOptimization(priority));
  101154. // Next priority
  101155. priority++;
  101156. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  101157. return result;
  101158. };
  101159. return SceneOptimizerOptions;
  101160. }());
  101161. /**
  101162. * Class used to run optimizations in order to reach a target frame rate
  101163. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101164. */
  101165. var SceneOptimizer = /** @class */ (function () {
  101166. /**
  101167. * Creates a new SceneOptimizer
  101168. * @param scene defines the scene to work on
  101169. * @param options defines the options to use with the SceneOptimizer
  101170. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  101171. * @param improvementMode defines if the scene optimizer must run the maximum optimization while staying over a target frame instead of trying to reach the target framerate (false by default)
  101172. */
  101173. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  101174. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  101175. if (improvementMode === void 0) { improvementMode = false; }
  101176. var _this = this;
  101177. this._isRunning = false;
  101178. this._currentPriorityLevel = 0;
  101179. this._targetFrameRate = 60;
  101180. this._trackerDuration = 2000;
  101181. this._currentFrameRate = 0;
  101182. this._improvementMode = false;
  101183. /**
  101184. * Defines an observable called when the optimizer reaches the target frame rate
  101185. */
  101186. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  101187. /**
  101188. * Defines an observable called when the optimizer enables an optimization
  101189. */
  101190. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  101191. /**
  101192. * Defines an observable called when the optimizer is not able to reach the target frame rate
  101193. */
  101194. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  101195. if (!options) {
  101196. this._options = new SceneOptimizerOptions();
  101197. }
  101198. else {
  101199. this._options = options;
  101200. }
  101201. if (this._options.targetFrameRate) {
  101202. this._targetFrameRate = this._options.targetFrameRate;
  101203. }
  101204. if (this._options.trackerDuration) {
  101205. this._trackerDuration = this._options.trackerDuration;
  101206. }
  101207. if (autoGeneratePriorities) {
  101208. var priority = 0;
  101209. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  101210. var optim = _a[_i];
  101211. optim.priority = priority++;
  101212. }
  101213. }
  101214. this._improvementMode = improvementMode;
  101215. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  101216. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  101217. _this._sceneDisposeObserver = null;
  101218. _this.dispose();
  101219. });
  101220. }
  101221. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  101222. /**
  101223. * Gets a boolean indicating if the optimizer is in improvement mode
  101224. */
  101225. get: function () {
  101226. return this._improvementMode;
  101227. },
  101228. enumerable: true,
  101229. configurable: true
  101230. });
  101231. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  101232. /**
  101233. * Gets the current priority level (0 at start)
  101234. */
  101235. get: function () {
  101236. return this._currentPriorityLevel;
  101237. },
  101238. enumerable: true,
  101239. configurable: true
  101240. });
  101241. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  101242. /**
  101243. * Gets the current frame rate checked by the SceneOptimizer
  101244. */
  101245. get: function () {
  101246. return this._currentFrameRate;
  101247. },
  101248. enumerable: true,
  101249. configurable: true
  101250. });
  101251. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  101252. /**
  101253. * Gets or sets the current target frame rate (60 by default)
  101254. */
  101255. get: function () {
  101256. return this._targetFrameRate;
  101257. },
  101258. /**
  101259. * Gets or sets the current target frame rate (60 by default)
  101260. */
  101261. set: function (value) {
  101262. this._targetFrameRate = value;
  101263. },
  101264. enumerable: true,
  101265. configurable: true
  101266. });
  101267. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  101268. /**
  101269. * Gets or sets the current interval between two checks (every 2000ms by default)
  101270. */
  101271. get: function () {
  101272. return this._trackerDuration;
  101273. },
  101274. /**
  101275. * Gets or sets the current interval between two checks (every 2000ms by default)
  101276. */
  101277. set: function (value) {
  101278. this._trackerDuration = value;
  101279. },
  101280. enumerable: true,
  101281. configurable: true
  101282. });
  101283. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  101284. /**
  101285. * Gets the list of active optimizations
  101286. */
  101287. get: function () {
  101288. return this._options.optimizations;
  101289. },
  101290. enumerable: true,
  101291. configurable: true
  101292. });
  101293. /**
  101294. * Stops the current optimizer
  101295. */
  101296. SceneOptimizer.prototype.stop = function () {
  101297. this._isRunning = false;
  101298. };
  101299. /**
  101300. * Reset the optimizer to initial step (current priority level = 0)
  101301. */
  101302. SceneOptimizer.prototype.reset = function () {
  101303. this._currentPriorityLevel = 0;
  101304. };
  101305. /**
  101306. * Start the optimizer. By default it will try to reach a specific framerate
  101307. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  101308. */
  101309. SceneOptimizer.prototype.start = function () {
  101310. var _this = this;
  101311. if (this._isRunning) {
  101312. return;
  101313. }
  101314. this._isRunning = true;
  101315. // Let's wait for the scene to be ready before running our check
  101316. this._scene.executeWhenReady(function () {
  101317. setTimeout(function () {
  101318. _this._checkCurrentState();
  101319. }, _this._trackerDuration);
  101320. });
  101321. };
  101322. SceneOptimizer.prototype._checkCurrentState = function () {
  101323. var _this = this;
  101324. if (!this._isRunning) {
  101325. return;
  101326. }
  101327. var scene = this._scene;
  101328. var options = this._options;
  101329. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  101330. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  101331. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  101332. this._isRunning = false;
  101333. this.onSuccessObservable.notifyObservers(this);
  101334. return;
  101335. }
  101336. // Apply current level of optimizations
  101337. var allDone = true;
  101338. var noOptimizationApplied = true;
  101339. for (var index = 0; index < options.optimizations.length; index++) {
  101340. var optimization = options.optimizations[index];
  101341. if (optimization.priority === this._currentPriorityLevel) {
  101342. noOptimizationApplied = false;
  101343. allDone = allDone && optimization.apply(scene, this);
  101344. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  101345. }
  101346. }
  101347. // If no optimization was applied, this is a failure :(
  101348. if (noOptimizationApplied) {
  101349. this._isRunning = false;
  101350. this.onFailureObservable.notifyObservers(this);
  101351. return;
  101352. }
  101353. // If all optimizations were done, move to next level
  101354. if (allDone) {
  101355. this._currentPriorityLevel++;
  101356. }
  101357. // Let's the system running for a specific amount of time before checking FPS
  101358. scene.executeWhenReady(function () {
  101359. setTimeout(function () {
  101360. _this._checkCurrentState();
  101361. }, _this._trackerDuration);
  101362. });
  101363. };
  101364. /**
  101365. * Release all resources
  101366. */
  101367. SceneOptimizer.prototype.dispose = function () {
  101368. this.stop();
  101369. this.onSuccessObservable.clear();
  101370. this.onFailureObservable.clear();
  101371. this.onNewOptimizationAppliedObservable.clear();
  101372. if (this._sceneDisposeObserver) {
  101373. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  101374. }
  101375. };
  101376. /**
  101377. * Helper function to create a SceneOptimizer with one single line of code
  101378. * @param scene defines the scene to work on
  101379. * @param options defines the options to use with the SceneOptimizer
  101380. * @param onSuccess defines a callback to call on success
  101381. * @param onFailure defines a callback to call on failure
  101382. * @returns the new SceneOptimizer object
  101383. */
  101384. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  101385. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  101386. if (onSuccess) {
  101387. optimizer.onSuccessObservable.add(function () {
  101388. onSuccess();
  101389. });
  101390. }
  101391. if (onFailure) {
  101392. optimizer.onFailureObservable.add(function () {
  101393. onFailure();
  101394. });
  101395. }
  101396. optimizer.start();
  101397. return optimizer;
  101398. };
  101399. return SceneOptimizer;
  101400. }());
  101401. /***/ }),
  101402. /***/ "./Misc/sceneSerializer.ts":
  101403. /*!*********************************!*\
  101404. !*** ./Misc/sceneSerializer.ts ***!
  101405. \*********************************/
  101406. /*! exports provided: SceneSerializer */
  101407. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101408. "use strict";
  101409. __webpack_require__.r(__webpack_exports__);
  101410. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  101411. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  101412. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  101413. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  101414. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  101415. var serializedGeometries = [];
  101416. var serializeGeometry = function (geometry, serializationGeometries) {
  101417. if (serializedGeometries[geometry.id]) {
  101418. return;
  101419. }
  101420. if (geometry.doNotSerialize) {
  101421. return;
  101422. }
  101423. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  101424. serializedGeometries[geometry.id] = true;
  101425. };
  101426. var serializeMesh = function (mesh, serializationScene) {
  101427. var serializationObject = {};
  101428. // Geometry
  101429. var geometry = mesh._geometry;
  101430. if (geometry) {
  101431. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  101432. // Geometry was in the memory but not added to the scene, nevertheless it's better to serialize to be able to reload the mesh with its geometry
  101433. serializeGeometry(geometry, serializationScene.geometries);
  101434. }
  101435. }
  101436. // Custom
  101437. if (mesh.serialize) {
  101438. mesh.serialize(serializationObject);
  101439. }
  101440. return serializationObject;
  101441. };
  101442. var finalizeSingleMesh = function (mesh, serializationObject) {
  101443. //only works if the mesh is already loaded
  101444. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  101445. //serialize material
  101446. if (mesh.material) {
  101447. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__["MultiMaterial"]) {
  101448. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  101449. serializationObject.materials = serializationObject.materials || [];
  101450. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  101451. serializationObject.multiMaterials.push(mesh.material.serialize());
  101452. var _loop_1 = function (submaterial) {
  101453. if (submaterial) {
  101454. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  101455. serializationObject.materials.push(submaterial.serialize());
  101456. }
  101457. }
  101458. };
  101459. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  101460. var submaterial = _a[_i];
  101461. _loop_1(submaterial);
  101462. }
  101463. }
  101464. }
  101465. else {
  101466. serializationObject.materials = serializationObject.materials || [];
  101467. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  101468. serializationObject.materials.push(mesh.material.serialize());
  101469. }
  101470. }
  101471. }
  101472. //serialize geometry
  101473. var geometry = mesh._geometry;
  101474. if (geometry) {
  101475. if (!serializationObject.geometries) {
  101476. serializationObject.geometries = {};
  101477. serializationObject.geometries.boxes = [];
  101478. serializationObject.geometries.spheres = [];
  101479. serializationObject.geometries.cylinders = [];
  101480. serializationObject.geometries.toruses = [];
  101481. serializationObject.geometries.grounds = [];
  101482. serializationObject.geometries.planes = [];
  101483. serializationObject.geometries.torusKnots = [];
  101484. serializationObject.geometries.vertexData = [];
  101485. }
  101486. serializeGeometry(geometry, serializationObject.geometries);
  101487. }
  101488. // Skeletons
  101489. if (mesh.skeleton) {
  101490. serializationObject.skeletons = serializationObject.skeletons || [];
  101491. serializationObject.skeletons.push(mesh.skeleton.serialize());
  101492. }
  101493. //serialize the actual mesh
  101494. serializationObject.meshes = serializationObject.meshes || [];
  101495. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  101496. }
  101497. };
  101498. /**
  101499. * Class used to serialize a scene into a string
  101500. */
  101501. var SceneSerializer = /** @class */ (function () {
  101502. function SceneSerializer() {
  101503. }
  101504. /**
  101505. * Clear cache used by a previous serialization
  101506. */
  101507. SceneSerializer.ClearCache = function () {
  101508. serializedGeometries = [];
  101509. };
  101510. /**
  101511. * Serialize a scene into a JSON compatible object
  101512. * @param scene defines the scene to serialize
  101513. * @returns a JSON compatible object
  101514. */
  101515. SceneSerializer.Serialize = function (scene) {
  101516. var serializationObject = {};
  101517. SceneSerializer.ClearCache();
  101518. // Scene
  101519. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  101520. serializationObject.autoClear = scene.autoClear;
  101521. serializationObject.clearColor = scene.clearColor.asArray();
  101522. serializationObject.ambientColor = scene.ambientColor.asArray();
  101523. serializationObject.gravity = scene.gravity.asArray();
  101524. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  101525. // Fog
  101526. if (scene.fogMode && scene.fogMode !== 0) {
  101527. serializationObject.fogMode = scene.fogMode;
  101528. serializationObject.fogColor = scene.fogColor.asArray();
  101529. serializationObject.fogStart = scene.fogStart;
  101530. serializationObject.fogEnd = scene.fogEnd;
  101531. serializationObject.fogDensity = scene.fogDensity;
  101532. }
  101533. //Physics
  101534. if (scene.isPhysicsEnabled()) {
  101535. var physicEngine = scene.getPhysicsEngine();
  101536. if (physicEngine) {
  101537. serializationObject.physicsEnabled = true;
  101538. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  101539. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  101540. }
  101541. }
  101542. // Metadata
  101543. if (scene.metadata) {
  101544. serializationObject.metadata = scene.metadata;
  101545. }
  101546. // Morph targets
  101547. serializationObject.morphTargetManagers = [];
  101548. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  101549. var abstractMesh = _a[_i];
  101550. var manager = abstractMesh.morphTargetManager;
  101551. if (manager) {
  101552. serializationObject.morphTargetManagers.push(manager.serialize());
  101553. }
  101554. }
  101555. // Lights
  101556. serializationObject.lights = [];
  101557. var index;
  101558. var light;
  101559. for (index = 0; index < scene.lights.length; index++) {
  101560. light = scene.lights[index];
  101561. if (!light.doNotSerialize) {
  101562. serializationObject.lights.push(light.serialize());
  101563. }
  101564. }
  101565. // Cameras
  101566. serializationObject.cameras = [];
  101567. for (index = 0; index < scene.cameras.length; index++) {
  101568. var camera = scene.cameras[index];
  101569. if (!camera.doNotSerialize) {
  101570. serializationObject.cameras.push(camera.serialize());
  101571. }
  101572. }
  101573. if (scene.activeCamera) {
  101574. serializationObject.activeCameraID = scene.activeCamera.id;
  101575. }
  101576. // Animations
  101577. _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  101578. // Reflection probes
  101579. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  101580. serializationObject.reflectionProbes = [];
  101581. for (index = 0; index < scene.reflectionProbes.length; index++) {
  101582. var reflectionProbe = scene.reflectionProbes[index];
  101583. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  101584. }
  101585. }
  101586. // Materials
  101587. serializationObject.materials = [];
  101588. serializationObject.multiMaterials = [];
  101589. var material;
  101590. for (index = 0; index < scene.materials.length; index++) {
  101591. material = scene.materials[index];
  101592. if (!material.doNotSerialize) {
  101593. serializationObject.materials.push(material.serialize());
  101594. }
  101595. }
  101596. // MultiMaterials
  101597. serializationObject.multiMaterials = [];
  101598. for (index = 0; index < scene.multiMaterials.length; index++) {
  101599. var multiMaterial = scene.multiMaterials[index];
  101600. serializationObject.multiMaterials.push(multiMaterial.serialize());
  101601. }
  101602. // Environment texture
  101603. if (scene.environmentTexture) {
  101604. serializationObject.environmentTexture = scene.environmentTexture.name;
  101605. }
  101606. // Skeletons
  101607. serializationObject.skeletons = [];
  101608. for (index = 0; index < scene.skeletons.length; index++) {
  101609. var skeleton = scene.skeletons[index];
  101610. if (!skeleton.doNotSerialize) {
  101611. serializationObject.skeletons.push(skeleton.serialize());
  101612. }
  101613. }
  101614. // Transform nodes
  101615. serializationObject.transformNodes = [];
  101616. for (index = 0; index < scene.transformNodes.length; index++) {
  101617. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  101618. }
  101619. // Geometries
  101620. serializationObject.geometries = {};
  101621. serializationObject.geometries.boxes = [];
  101622. serializationObject.geometries.spheres = [];
  101623. serializationObject.geometries.cylinders = [];
  101624. serializationObject.geometries.toruses = [];
  101625. serializationObject.geometries.grounds = [];
  101626. serializationObject.geometries.planes = [];
  101627. serializationObject.geometries.torusKnots = [];
  101628. serializationObject.geometries.vertexData = [];
  101629. serializedGeometries = [];
  101630. var geometries = scene.getGeometries();
  101631. for (index = 0; index < geometries.length; index++) {
  101632. var geometry = geometries[index];
  101633. if (geometry.isReady()) {
  101634. serializeGeometry(geometry, serializationObject.geometries);
  101635. }
  101636. }
  101637. // Meshes
  101638. serializationObject.meshes = [];
  101639. for (index = 0; index < scene.meshes.length; index++) {
  101640. var abstractMesh = scene.meshes[index];
  101641. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]) {
  101642. var mesh = abstractMesh;
  101643. if (!mesh.doNotSerialize) {
  101644. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  101645. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  101646. }
  101647. }
  101648. }
  101649. }
  101650. // Particles Systems
  101651. serializationObject.particleSystems = [];
  101652. for (index = 0; index < scene.particleSystems.length; index++) {
  101653. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  101654. }
  101655. // Action Manager
  101656. if (scene.actionManager) {
  101657. serializationObject.actions = scene.actionManager.serialize("scene");
  101658. }
  101659. // Components
  101660. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  101661. var component = _c[_b];
  101662. component.serialize(serializationObject);
  101663. }
  101664. return serializationObject;
  101665. };
  101666. /**
  101667. * Serialize a mesh into a JSON compatible object
  101668. * @param toSerialize defines the mesh to serialize
  101669. * @param withParents defines if parents must be serialized as well
  101670. * @param withChildren defines if children must be serialized as well
  101671. * @returns a JSON compatible object
  101672. */
  101673. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  101674. if (withParents === void 0) { withParents = false; }
  101675. if (withChildren === void 0) { withChildren = false; }
  101676. var serializationObject = {};
  101677. SceneSerializer.ClearCache();
  101678. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  101679. if (withParents || withChildren) {
  101680. //deliberate for loop! not for each, appended should be processed as well.
  101681. for (var i = 0; i < toSerialize.length; ++i) {
  101682. if (withChildren) {
  101683. toSerialize[i].getDescendants().forEach(function (node) {
  101684. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  101685. toSerialize.push(node);
  101686. }
  101687. });
  101688. }
  101689. //make sure the array doesn't contain the object already
  101690. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  101691. toSerialize.push(toSerialize[i].parent);
  101692. }
  101693. }
  101694. }
  101695. toSerialize.forEach(function (mesh) {
  101696. finalizeSingleMesh(mesh, serializationObject);
  101697. });
  101698. return serializationObject;
  101699. };
  101700. return SceneSerializer;
  101701. }());
  101702. /***/ }),
  101703. /***/ "./Misc/screenshotTools.ts":
  101704. /*!*********************************!*\
  101705. !*** ./Misc/screenshotTools.ts ***!
  101706. \*********************************/
  101707. /*! exports provided: ScreenshotTools */
  101708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101709. "use strict";
  101710. __webpack_require__.r(__webpack_exports__);
  101711. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  101712. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  101713. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  101714. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  101715. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  101716. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  101717. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  101718. /**
  101719. * Class containing a set of static utilities functions for screenshots
  101720. */
  101721. var ScreenshotTools = /** @class */ (function () {
  101722. function ScreenshotTools() {
  101723. }
  101724. /**
  101725. * Captures a screenshot of the current rendering
  101726. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101727. * @param engine defines the rendering engine
  101728. * @param camera defines the source camera
  101729. * @param size This parameter can be set to a single number or to an object with the
  101730. * following (optional) properties: precision, width, height. If a single number is passed,
  101731. * it will be used for both width and height. If an object is passed, the screenshot size
  101732. * will be derived from the parameters. The precision property is a multiplier allowing
  101733. * rendering at a higher or lower resolution
  101734. * @param successCallback defines the callback receives a single parameter which contains the
  101735. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  101736. * src parameter of an <img> to display it
  101737. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  101738. * Check your browser for supported MIME types
  101739. */
  101740. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  101741. if (mimeType === void 0) { mimeType = "image/png"; }
  101742. var width;
  101743. var height;
  101744. // If a precision value is specified
  101745. if (size.precision) {
  101746. width = Math.round(engine.getRenderWidth() * size.precision);
  101747. height = Math.round(width / engine.getAspectRatio(camera));
  101748. }
  101749. else if (size.width && size.height) {
  101750. width = size.width;
  101751. height = size.height;
  101752. }
  101753. //If passing only width, computing height to keep display canvas ratio.
  101754. else if (size.width && !size.height) {
  101755. width = size.width;
  101756. height = Math.round(width / engine.getAspectRatio(camera));
  101757. }
  101758. //If passing only height, computing width to keep display canvas ratio.
  101759. else if (size.height && !size.width) {
  101760. height = size.height;
  101761. width = Math.round(height * engine.getAspectRatio(camera));
  101762. }
  101763. //Assuming here that "size" parameter is a number
  101764. else if (!isNaN(size)) {
  101765. height = size;
  101766. width = size;
  101767. }
  101768. else {
  101769. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  101770. return;
  101771. }
  101772. if (!_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas) {
  101773. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas = document.createElement('canvas');
  101774. }
  101775. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.width = width;
  101776. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.height = height;
  101777. var renderContext = _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.getContext("2d");
  101778. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  101779. var newWidth = width;
  101780. var newHeight = newWidth / ratio;
  101781. if (newHeight > height) {
  101782. newHeight = height;
  101783. newWidth = newHeight * ratio;
  101784. }
  101785. var offsetX = Math.max(0, width - newWidth) / 2;
  101786. var offsetY = Math.max(0, height - newHeight) / 2;
  101787. var renderingCanvas = engine.getRenderingCanvas();
  101788. if (renderContext && renderingCanvas) {
  101789. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  101790. }
  101791. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  101792. };
  101793. /**
  101794. * Generates an image screenshot from the specified camera.
  101795. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101796. * @param engine The engine to use for rendering
  101797. * @param camera The camera to use for rendering
  101798. * @param size This parameter can be set to a single number or to an object with the
  101799. * following (optional) properties: precision, width, height. If a single number is passed,
  101800. * it will be used for both width and height. If an object is passed, the screenshot size
  101801. * will be derived from the parameters. The precision property is a multiplier allowing
  101802. * rendering at a higher or lower resolution
  101803. * @param successCallback The callback receives a single parameter which contains the
  101804. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  101805. * src parameter of an <img> to display it
  101806. * @param mimeType The MIME type of the screenshot image (default: image/png).
  101807. * Check your browser for supported MIME types
  101808. * @param samples Texture samples (default: 1)
  101809. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  101810. * @param fileName A name for for the downloaded file.
  101811. */
  101812. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  101813. if (mimeType === void 0) { mimeType = "image/png"; }
  101814. if (samples === void 0) { samples = 1; }
  101815. if (antialiasing === void 0) { antialiasing = false; }
  101816. var width;
  101817. var height;
  101818. //If a precision value is specified
  101819. if (size.precision) {
  101820. width = Math.round(engine.getRenderWidth() * size.precision);
  101821. height = Math.round(width / engine.getAspectRatio(camera));
  101822. size = { width: width, height: height };
  101823. }
  101824. else if (size.width && size.height) {
  101825. width = size.width;
  101826. height = size.height;
  101827. }
  101828. //If passing only width, computing height to keep display canvas ratio.
  101829. else if (size.width && !size.height) {
  101830. width = size.width;
  101831. height = Math.round(width / engine.getAspectRatio(camera));
  101832. size = { width: width, height: height };
  101833. }
  101834. //If passing only height, computing width to keep display canvas ratio.
  101835. else if (size.height && !size.width) {
  101836. height = size.height;
  101837. width = Math.round(height * engine.getAspectRatio(camera));
  101838. size = { width: width, height: height };
  101839. }
  101840. //Assuming here that "size" parameter is a number
  101841. else if (!isNaN(size)) {
  101842. height = size;
  101843. width = size;
  101844. }
  101845. else {
  101846. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  101847. return;
  101848. }
  101849. var scene = camera.getScene();
  101850. var previousCamera = null;
  101851. if (scene.activeCamera !== camera) {
  101852. previousCamera = scene.activeCamera;
  101853. scene.activeCamera = camera;
  101854. }
  101855. var renderCanvas = engine.getRenderingCanvas();
  101856. if (!renderCanvas) {
  101857. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  101858. return;
  101859. }
  101860. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  101861. engine.setSize(width, height);
  101862. scene.render();
  101863. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  101864. var texture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__["RenderTargetTexture"]("screenShot", size, scene, false, false, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].NEAREST_SAMPLINGMODE);
  101865. texture.renderList = null;
  101866. texture.samples = samples;
  101867. if (antialiasing) {
  101868. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  101869. }
  101870. texture.onAfterRenderObservable.add(function () {
  101871. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  101872. });
  101873. scene.incrementRenderId();
  101874. scene.resetCachedMaterial();
  101875. texture.render(true);
  101876. texture.dispose();
  101877. if (previousCamera) {
  101878. scene.activeCamera = previousCamera;
  101879. }
  101880. engine.setSize(originalSize.width, originalSize.height);
  101881. camera.getProjectionMatrix(true); // Force cache refresh;
  101882. };
  101883. return ScreenshotTools;
  101884. }());
  101885. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  101886. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  101887. /***/ }),
  101888. /***/ "./Misc/smartArray.ts":
  101889. /*!****************************!*\
  101890. !*** ./Misc/smartArray.ts ***!
  101891. \****************************/
  101892. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  101893. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101894. "use strict";
  101895. __webpack_require__.r(__webpack_exports__);
  101896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  101897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  101898. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  101899. /**
  101900. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  101901. */
  101902. var SmartArray = /** @class */ (function () {
  101903. /**
  101904. * Instantiates a Smart Array.
  101905. * @param capacity defines the default capacity of the array.
  101906. */
  101907. function SmartArray(capacity) {
  101908. /**
  101909. * The active length of the array.
  101910. */
  101911. this.length = 0;
  101912. this.data = new Array(capacity);
  101913. this._id = SmartArray._GlobalId++;
  101914. }
  101915. /**
  101916. * Pushes a value at the end of the active data.
  101917. * @param value defines the object to push in the array.
  101918. */
  101919. SmartArray.prototype.push = function (value) {
  101920. this.data[this.length++] = value;
  101921. if (this.length > this.data.length) {
  101922. this.data.length *= 2;
  101923. }
  101924. };
  101925. /**
  101926. * Iterates over the active data and apply the lambda to them.
  101927. * @param func defines the action to apply on each value.
  101928. */
  101929. SmartArray.prototype.forEach = function (func) {
  101930. for (var index = 0; index < this.length; index++) {
  101931. func(this.data[index]);
  101932. }
  101933. };
  101934. /**
  101935. * Sorts the full sets of data.
  101936. * @param compareFn defines the comparison function to apply.
  101937. */
  101938. SmartArray.prototype.sort = function (compareFn) {
  101939. this.data.sort(compareFn);
  101940. };
  101941. /**
  101942. * Resets the active data to an empty array.
  101943. */
  101944. SmartArray.prototype.reset = function () {
  101945. this.length = 0;
  101946. };
  101947. /**
  101948. * Releases all the data from the array as well as the array.
  101949. */
  101950. SmartArray.prototype.dispose = function () {
  101951. this.reset();
  101952. if (this.data) {
  101953. this.data.length = 0;
  101954. this.data = [];
  101955. }
  101956. };
  101957. /**
  101958. * Concats the active data with a given array.
  101959. * @param array defines the data to concatenate with.
  101960. */
  101961. SmartArray.prototype.concat = function (array) {
  101962. if (array.length === 0) {
  101963. return;
  101964. }
  101965. if (this.length + array.length > this.data.length) {
  101966. this.data.length = (this.length + array.length) * 2;
  101967. }
  101968. for (var index = 0; index < array.length; index++) {
  101969. this.data[this.length++] = (array.data || array)[index];
  101970. }
  101971. };
  101972. /**
  101973. * Returns the position of a value in the active data.
  101974. * @param value defines the value to find the index for
  101975. * @returns the index if found in the active data otherwise -1
  101976. */
  101977. SmartArray.prototype.indexOf = function (value) {
  101978. var position = this.data.indexOf(value);
  101979. if (position >= this.length) {
  101980. return -1;
  101981. }
  101982. return position;
  101983. };
  101984. /**
  101985. * Returns whether an element is part of the active data.
  101986. * @param value defines the value to look for
  101987. * @returns true if found in the active data otherwise false
  101988. */
  101989. SmartArray.prototype.contains = function (value) {
  101990. return this.indexOf(value) !== -1;
  101991. };
  101992. // Statics
  101993. SmartArray._GlobalId = 0;
  101994. return SmartArray;
  101995. }());
  101996. /**
  101997. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  101998. * The data in this array can only be present once
  101999. */
  102000. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  102001. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  102002. function SmartArrayNoDuplicate() {
  102003. var _this = _super !== null && _super.apply(this, arguments) || this;
  102004. _this._duplicateId = 0;
  102005. return _this;
  102006. }
  102007. /**
  102008. * Pushes a value at the end of the active data.
  102009. * THIS DOES NOT PREVENT DUPPLICATE DATA
  102010. * @param value defines the object to push in the array.
  102011. */
  102012. SmartArrayNoDuplicate.prototype.push = function (value) {
  102013. _super.prototype.push.call(this, value);
  102014. if (!value.__smartArrayFlags) {
  102015. value.__smartArrayFlags = {};
  102016. }
  102017. value.__smartArrayFlags[this._id] = this._duplicateId;
  102018. };
  102019. /**
  102020. * Pushes a value at the end of the active data.
  102021. * If the data is already present, it won t be added again
  102022. * @param value defines the object to push in the array.
  102023. * @returns true if added false if it was already present
  102024. */
  102025. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  102026. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  102027. return false;
  102028. }
  102029. this.push(value);
  102030. return true;
  102031. };
  102032. /**
  102033. * Resets the active data to an empty array.
  102034. */
  102035. SmartArrayNoDuplicate.prototype.reset = function () {
  102036. _super.prototype.reset.call(this);
  102037. this._duplicateId++;
  102038. };
  102039. /**
  102040. * Concats the active data with a given array.
  102041. * This ensures no dupplicate will be present in the result.
  102042. * @param array defines the data to concatenate with.
  102043. */
  102044. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  102045. if (array.length === 0) {
  102046. return;
  102047. }
  102048. if (this.length + array.length > this.data.length) {
  102049. this.data.length = (this.length + array.length) * 2;
  102050. }
  102051. for (var index = 0; index < array.length; index++) {
  102052. var item = (array.data || array)[index];
  102053. this.pushNoDuplicate(item);
  102054. }
  102055. };
  102056. return SmartArrayNoDuplicate;
  102057. }(SmartArray));
  102058. /***/ }),
  102059. /***/ "./Misc/stringDictionary.ts":
  102060. /*!**********************************!*\
  102061. !*** ./Misc/stringDictionary.ts ***!
  102062. \**********************************/
  102063. /*! exports provided: StringDictionary */
  102064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102065. "use strict";
  102066. __webpack_require__.r(__webpack_exports__);
  102067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  102068. /**
  102069. * This class implement a typical dictionary using a string as key and the generic type T as value.
  102070. * The underlying implementation relies on an associative array to ensure the best performances.
  102071. * The value can be anything including 'null' but except 'undefined'
  102072. */
  102073. var StringDictionary = /** @class */ (function () {
  102074. function StringDictionary() {
  102075. this._count = 0;
  102076. this._data = {};
  102077. }
  102078. /**
  102079. * This will clear this dictionary and copy the content from the 'source' one.
  102080. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  102081. * @param source the dictionary to take the content from and copy to this dictionary
  102082. */
  102083. StringDictionary.prototype.copyFrom = function (source) {
  102084. var _this = this;
  102085. this.clear();
  102086. source.forEach(function (t, v) { return _this.add(t, v); });
  102087. };
  102088. /**
  102089. * Get a value based from its key
  102090. * @param key the given key to get the matching value from
  102091. * @return the value if found, otherwise undefined is returned
  102092. */
  102093. StringDictionary.prototype.get = function (key) {
  102094. var val = this._data[key];
  102095. if (val !== undefined) {
  102096. return val;
  102097. }
  102098. return undefined;
  102099. };
  102100. /**
  102101. * Get a value from its key or add it if it doesn't exist.
  102102. * This method will ensure you that a given key/data will be present in the dictionary.
  102103. * @param key the given key to get the matching value from
  102104. * @param factory the factory that will create the value if the key is not present in the dictionary.
  102105. * The factory will only be invoked if there's no data for the given key.
  102106. * @return the value corresponding to the key.
  102107. */
  102108. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  102109. var val = this.get(key);
  102110. if (val !== undefined) {
  102111. return val;
  102112. }
  102113. val = factory(key);
  102114. if (val) {
  102115. this.add(key, val);
  102116. }
  102117. return val;
  102118. };
  102119. /**
  102120. * Get a value from its key if present in the dictionary otherwise add it
  102121. * @param key the key to get the value from
  102122. * @param val if there's no such key/value pair in the dictionary add it with this value
  102123. * @return the value corresponding to the key
  102124. */
  102125. StringDictionary.prototype.getOrAdd = function (key, val) {
  102126. var curVal = this.get(key);
  102127. if (curVal !== undefined) {
  102128. return curVal;
  102129. }
  102130. this.add(key, val);
  102131. return val;
  102132. };
  102133. /**
  102134. * Check if there's a given key in the dictionary
  102135. * @param key the key to check for
  102136. * @return true if the key is present, false otherwise
  102137. */
  102138. StringDictionary.prototype.contains = function (key) {
  102139. return this._data[key] !== undefined;
  102140. };
  102141. /**
  102142. * Add a new key and its corresponding value
  102143. * @param key the key to add
  102144. * @param value the value corresponding to the key
  102145. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  102146. */
  102147. StringDictionary.prototype.add = function (key, value) {
  102148. if (this._data[key] !== undefined) {
  102149. return false;
  102150. }
  102151. this._data[key] = value;
  102152. ++this._count;
  102153. return true;
  102154. };
  102155. /**
  102156. * Update a specific value associated to a key
  102157. * @param key defines the key to use
  102158. * @param value defines the value to store
  102159. * @returns true if the value was updated (or false if the key was not found)
  102160. */
  102161. StringDictionary.prototype.set = function (key, value) {
  102162. if (this._data[key] === undefined) {
  102163. return false;
  102164. }
  102165. this._data[key] = value;
  102166. return true;
  102167. };
  102168. /**
  102169. * Get the element of the given key and remove it from the dictionary
  102170. * @param key defines the key to search
  102171. * @returns the value associated with the key or null if not found
  102172. */
  102173. StringDictionary.prototype.getAndRemove = function (key) {
  102174. var val = this.get(key);
  102175. if (val !== undefined) {
  102176. delete this._data[key];
  102177. --this._count;
  102178. return val;
  102179. }
  102180. return null;
  102181. };
  102182. /**
  102183. * Remove a key/value from the dictionary.
  102184. * @param key the key to remove
  102185. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  102186. */
  102187. StringDictionary.prototype.remove = function (key) {
  102188. if (this.contains(key)) {
  102189. delete this._data[key];
  102190. --this._count;
  102191. return true;
  102192. }
  102193. return false;
  102194. };
  102195. /**
  102196. * Clear the whole content of the dictionary
  102197. */
  102198. StringDictionary.prototype.clear = function () {
  102199. this._data = {};
  102200. this._count = 0;
  102201. };
  102202. Object.defineProperty(StringDictionary.prototype, "count", {
  102203. /**
  102204. * Gets the current count
  102205. */
  102206. get: function () {
  102207. return this._count;
  102208. },
  102209. enumerable: true,
  102210. configurable: true
  102211. });
  102212. /**
  102213. * Execute a callback on each key/val of the dictionary.
  102214. * Note that you can remove any element in this dictionary in the callback implementation
  102215. * @param callback the callback to execute on a given key/value pair
  102216. */
  102217. StringDictionary.prototype.forEach = function (callback) {
  102218. for (var cur in this._data) {
  102219. var val = this._data[cur];
  102220. callback(cur, val);
  102221. }
  102222. };
  102223. /**
  102224. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  102225. * If the callback returns null or undefined the method will iterate to the next key/value pair
  102226. * Note that you can remove any element in this dictionary in the callback implementation
  102227. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  102228. * @returns the first item
  102229. */
  102230. StringDictionary.prototype.first = function (callback) {
  102231. for (var cur in this._data) {
  102232. var val = this._data[cur];
  102233. var res = callback(cur, val);
  102234. if (res) {
  102235. return res;
  102236. }
  102237. }
  102238. return null;
  102239. };
  102240. return StringDictionary;
  102241. }());
  102242. /***/ }),
  102243. /***/ "./Misc/tags.ts":
  102244. /*!**********************!*\
  102245. !*** ./Misc/tags.ts ***!
  102246. \**********************/
  102247. /*! exports provided: Tags */
  102248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102249. "use strict";
  102250. __webpack_require__.r(__webpack_exports__);
  102251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  102252. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  102253. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  102254. /**
  102255. * Class used to store custom tags
  102256. */
  102257. var Tags = /** @class */ (function () {
  102258. function Tags() {
  102259. }
  102260. /**
  102261. * Adds support for tags on the given object
  102262. * @param obj defines the object to use
  102263. */
  102264. Tags.EnableFor = function (obj) {
  102265. obj._tags = obj._tags || {};
  102266. obj.hasTags = function () {
  102267. return Tags.HasTags(obj);
  102268. };
  102269. obj.addTags = function (tagsString) {
  102270. return Tags.AddTagsTo(obj, tagsString);
  102271. };
  102272. obj.removeTags = function (tagsString) {
  102273. return Tags.RemoveTagsFrom(obj, tagsString);
  102274. };
  102275. obj.matchesTagsQuery = function (tagsQuery) {
  102276. return Tags.MatchesQuery(obj, tagsQuery);
  102277. };
  102278. };
  102279. /**
  102280. * Removes tags support
  102281. * @param obj defines the object to use
  102282. */
  102283. Tags.DisableFor = function (obj) {
  102284. delete obj._tags;
  102285. delete obj.hasTags;
  102286. delete obj.addTags;
  102287. delete obj.removeTags;
  102288. delete obj.matchesTagsQuery;
  102289. };
  102290. /**
  102291. * Gets a boolean indicating if the given object has tags
  102292. * @param obj defines the object to use
  102293. * @returns a boolean
  102294. */
  102295. Tags.HasTags = function (obj) {
  102296. if (!obj._tags) {
  102297. return false;
  102298. }
  102299. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  102300. };
  102301. /**
  102302. * Gets the tags available on a given object
  102303. * @param obj defines the object to use
  102304. * @param asString defines if the tags must be returned as a string instead of an array of strings
  102305. * @returns the tags
  102306. */
  102307. Tags.GetTags = function (obj, asString) {
  102308. if (asString === void 0) { asString = true; }
  102309. if (!obj._tags) {
  102310. return null;
  102311. }
  102312. if (asString) {
  102313. var tagsArray = [];
  102314. for (var tag in obj._tags) {
  102315. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  102316. tagsArray.push(tag);
  102317. }
  102318. }
  102319. return tagsArray.join(" ");
  102320. }
  102321. else {
  102322. return obj._tags;
  102323. }
  102324. };
  102325. /**
  102326. * Adds tags to an object
  102327. * @param obj defines the object to use
  102328. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  102329. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  102330. */
  102331. Tags.AddTagsTo = function (obj, tagsString) {
  102332. if (!tagsString) {
  102333. return;
  102334. }
  102335. if (typeof tagsString !== "string") {
  102336. return;
  102337. }
  102338. var tags = tagsString.split(" ");
  102339. tags.forEach(function (tag, index, array) {
  102340. Tags._AddTagTo(obj, tag);
  102341. });
  102342. };
  102343. /**
  102344. * @hidden
  102345. */
  102346. Tags._AddTagTo = function (obj, tag) {
  102347. tag = tag.trim();
  102348. if (tag === "" || tag === "true" || tag === "false") {
  102349. return;
  102350. }
  102351. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  102352. return;
  102353. }
  102354. Tags.EnableFor(obj);
  102355. obj._tags[tag] = true;
  102356. };
  102357. /**
  102358. * Removes specific tags from a specific object
  102359. * @param obj defines the object to use
  102360. * @param tagsString defines the tags to remove
  102361. */
  102362. Tags.RemoveTagsFrom = function (obj, tagsString) {
  102363. if (!Tags.HasTags(obj)) {
  102364. return;
  102365. }
  102366. var tags = tagsString.split(" ");
  102367. for (var t in tags) {
  102368. Tags._RemoveTagFrom(obj, tags[t]);
  102369. }
  102370. };
  102371. /**
  102372. * @hidden
  102373. */
  102374. Tags._RemoveTagFrom = function (obj, tag) {
  102375. delete obj._tags[tag];
  102376. };
  102377. /**
  102378. * Defines if tags hosted on an object match a given query
  102379. * @param obj defines the object to use
  102380. * @param tagsQuery defines the tag query
  102381. * @returns a boolean
  102382. */
  102383. Tags.MatchesQuery = function (obj, tagsQuery) {
  102384. if (tagsQuery === undefined) {
  102385. return true;
  102386. }
  102387. if (tagsQuery === "") {
  102388. return Tags.HasTags(obj);
  102389. }
  102390. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  102391. };
  102392. return Tags;
  102393. }());
  102394. /***/ }),
  102395. /***/ "./Misc/textureTools.ts":
  102396. /*!******************************!*\
  102397. !*** ./Misc/textureTools.ts ***!
  102398. \******************************/
  102399. /*! exports provided: TextureTools */
  102400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102401. "use strict";
  102402. __webpack_require__.r(__webpack_exports__);
  102403. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  102404. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  102405. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  102406. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  102407. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  102408. /**
  102409. * Class used to host texture specific utilities
  102410. */
  102411. var TextureTools = /** @class */ (function () {
  102412. function TextureTools() {
  102413. }
  102414. /**
  102415. * Uses the GPU to create a copy texture rescaled at a given size
  102416. * @param texture Texture to copy from
  102417. * @param width defines the desired width
  102418. * @param height defines the desired height
  102419. * @param useBilinearMode defines if bilinear mode has to be used
  102420. * @return the generated texture
  102421. */
  102422. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  102423. if (useBilinearMode === void 0) { useBilinearMode = true; }
  102424. var scene = texture.getScene();
  102425. var engine = scene.getEngine();
  102426. var rtt = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__["RenderTargetTexture"]('resized' + texture.name, { width: width, height: height }, scene, !texture.noMipmap, true, texture._texture.type, false, texture.samplingMode, false);
  102427. rtt.wrapU = texture.wrapU;
  102428. rtt.wrapV = texture.wrapV;
  102429. rtt.uOffset = texture.uOffset;
  102430. rtt.vOffset = texture.vOffset;
  102431. rtt.uScale = texture.uScale;
  102432. rtt.vScale = texture.vScale;
  102433. rtt.uAng = texture.uAng;
  102434. rtt.vAng = texture.vAng;
  102435. rtt.wAng = texture.wAng;
  102436. rtt.coordinatesIndex = texture.coordinatesIndex;
  102437. rtt.level = texture.level;
  102438. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  102439. rtt._texture.isReady = false;
  102440. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  102441. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  102442. var passPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__["PassPostProcess"]("pass", 1, null, useBilinearMode ? _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].BILINEAR_SAMPLINGMODE : _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].NEAREST_SAMPLINGMODE, engine, false, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  102443. passPostProcess.getEffect().executeWhenCompiled(function () {
  102444. passPostProcess.onApply = function (effect) {
  102445. effect.setTexture("textureSampler", texture);
  102446. };
  102447. var internalTexture = rtt.getInternalTexture();
  102448. if (internalTexture) {
  102449. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  102450. engine.unBindFramebuffer(internalTexture);
  102451. rtt.disposeFramebufferObjects();
  102452. passPostProcess.dispose();
  102453. internalTexture.isReady = true;
  102454. }
  102455. });
  102456. return rtt;
  102457. };
  102458. return TextureTools;
  102459. }());
  102460. /***/ }),
  102461. /***/ "./Misc/tga.ts":
  102462. /*!*********************!*\
  102463. !*** ./Misc/tga.ts ***!
  102464. \*********************/
  102465. /*! exports provided: TGATools */
  102466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102467. "use strict";
  102468. __webpack_require__.r(__webpack_exports__);
  102469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  102470. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  102471. /**
  102472. * Based on jsTGALoader - Javascript loader for TGA file
  102473. * By Vincent Thibault
  102474. * @see http://blog.robrowser.com/javascript-tga-loader.html
  102475. */
  102476. var TGATools = /** @class */ (function () {
  102477. function TGATools() {
  102478. }
  102479. /**
  102480. * Gets the header of a TGA file
  102481. * @param data defines the TGA data
  102482. * @returns the header
  102483. */
  102484. TGATools.GetTGAHeader = function (data) {
  102485. var offset = 0;
  102486. var header = {
  102487. id_length: data[offset++],
  102488. colormap_type: data[offset++],
  102489. image_type: data[offset++],
  102490. colormap_index: data[offset++] | data[offset++] << 8,
  102491. colormap_length: data[offset++] | data[offset++] << 8,
  102492. colormap_size: data[offset++],
  102493. origin: [
  102494. data[offset++] | data[offset++] << 8,
  102495. data[offset++] | data[offset++] << 8
  102496. ],
  102497. width: data[offset++] | data[offset++] << 8,
  102498. height: data[offset++] | data[offset++] << 8,
  102499. pixel_size: data[offset++],
  102500. flags: data[offset++]
  102501. };
  102502. return header;
  102503. };
  102504. /**
  102505. * Uploads TGA content to a Babylon Texture
  102506. * @hidden
  102507. */
  102508. TGATools.UploadContent = function (texture, data) {
  102509. // Not enough data to contain header ?
  102510. if (data.length < 19) {
  102511. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  102512. return;
  102513. }
  102514. // Read Header
  102515. var offset = 18;
  102516. var header = TGATools.GetTGAHeader(data);
  102517. // Assume it's a valid Targa file.
  102518. if (header.id_length + offset > data.length) {
  102519. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  102520. return;
  102521. }
  102522. // Skip not needed data
  102523. offset += header.id_length;
  102524. var use_rle = false;
  102525. var use_pal = false;
  102526. var use_grey = false;
  102527. // Get some informations.
  102528. switch (header.image_type) {
  102529. case TGATools._TYPE_RLE_INDEXED:
  102530. use_rle = true;
  102531. case TGATools._TYPE_INDEXED:
  102532. use_pal = true;
  102533. break;
  102534. case TGATools._TYPE_RLE_RGB:
  102535. use_rle = true;
  102536. case TGATools._TYPE_RGB:
  102537. // use_rgb = true;
  102538. break;
  102539. case TGATools._TYPE_RLE_GREY:
  102540. use_rle = true;
  102541. case TGATools._TYPE_GREY:
  102542. use_grey = true;
  102543. break;
  102544. }
  102545. var pixel_data;
  102546. // var numAlphaBits = header.flags & 0xf;
  102547. var pixel_size = header.pixel_size >> 3;
  102548. var pixel_total = header.width * header.height * pixel_size;
  102549. // Read palettes
  102550. var palettes;
  102551. if (use_pal) {
  102552. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  102553. }
  102554. // Read LRE
  102555. if (use_rle) {
  102556. pixel_data = new Uint8Array(pixel_total);
  102557. var c, count, i;
  102558. var localOffset = 0;
  102559. var pixels = new Uint8Array(pixel_size);
  102560. while (offset < pixel_total && localOffset < pixel_total) {
  102561. c = data[offset++];
  102562. count = (c & 0x7f) + 1;
  102563. // RLE pixels
  102564. if (c & 0x80) {
  102565. // Bind pixel tmp array
  102566. for (i = 0; i < pixel_size; ++i) {
  102567. pixels[i] = data[offset++];
  102568. }
  102569. // Copy pixel array
  102570. for (i = 0; i < count; ++i) {
  102571. pixel_data.set(pixels, localOffset + i * pixel_size);
  102572. }
  102573. localOffset += pixel_size * count;
  102574. }
  102575. // Raw pixels
  102576. else {
  102577. count *= pixel_size;
  102578. for (i = 0; i < count; ++i) {
  102579. pixel_data[localOffset + i] = data[offset++];
  102580. }
  102581. localOffset += count;
  102582. }
  102583. }
  102584. }
  102585. // RAW Pixels
  102586. else {
  102587. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  102588. }
  102589. // Load to texture
  102590. var x_start, y_start, x_step, y_step, y_end, x_end;
  102591. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  102592. default:
  102593. case TGATools._ORIGIN_UL:
  102594. x_start = 0;
  102595. x_step = 1;
  102596. x_end = header.width;
  102597. y_start = 0;
  102598. y_step = 1;
  102599. y_end = header.height;
  102600. break;
  102601. case TGATools._ORIGIN_BL:
  102602. x_start = 0;
  102603. x_step = 1;
  102604. x_end = header.width;
  102605. y_start = header.height - 1;
  102606. y_step = -1;
  102607. y_end = -1;
  102608. break;
  102609. case TGATools._ORIGIN_UR:
  102610. x_start = header.width - 1;
  102611. x_step = -1;
  102612. x_end = -1;
  102613. y_start = 0;
  102614. y_step = 1;
  102615. y_end = header.height;
  102616. break;
  102617. case TGATools._ORIGIN_BR:
  102618. x_start = header.width - 1;
  102619. x_step = -1;
  102620. x_end = -1;
  102621. y_start = header.height - 1;
  102622. y_step = -1;
  102623. y_end = -1;
  102624. break;
  102625. }
  102626. // Load the specify method
  102627. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  102628. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  102629. var engine = texture.getEngine();
  102630. engine._uploadDataToTextureDirectly(texture, imageData);
  102631. };
  102632. /** @hidden */
  102633. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  102634. var image = pixel_data, colormap = palettes;
  102635. var width = header.width, height = header.height;
  102636. var color, i = 0, x, y;
  102637. var imageData = new Uint8Array(width * height * 4);
  102638. for (y = y_start; y !== y_end; y += y_step) {
  102639. for (x = x_start; x !== x_end; x += x_step, i++) {
  102640. color = image[i];
  102641. imageData[(x + width * y) * 4 + 3] = 255;
  102642. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  102643. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  102644. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  102645. }
  102646. }
  102647. return imageData;
  102648. };
  102649. /** @hidden */
  102650. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  102651. var image = pixel_data;
  102652. var width = header.width, height = header.height;
  102653. var color, i = 0, x, y;
  102654. var imageData = new Uint8Array(width * height * 4);
  102655. for (y = y_start; y !== y_end; y += y_step) {
  102656. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  102657. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  102658. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  102659. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  102660. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  102661. imageData[(x + width * y) * 4 + 0] = r;
  102662. imageData[(x + width * y) * 4 + 1] = g;
  102663. imageData[(x + width * y) * 4 + 2] = b;
  102664. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  102665. }
  102666. }
  102667. return imageData;
  102668. };
  102669. /** @hidden */
  102670. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  102671. var image = pixel_data;
  102672. var width = header.width, height = header.height;
  102673. var i = 0, x, y;
  102674. var imageData = new Uint8Array(width * height * 4);
  102675. for (y = y_start; y !== y_end; y += y_step) {
  102676. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  102677. imageData[(x + width * y) * 4 + 3] = 255;
  102678. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  102679. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  102680. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  102681. }
  102682. }
  102683. return imageData;
  102684. };
  102685. /** @hidden */
  102686. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  102687. var image = pixel_data;
  102688. var width = header.width, height = header.height;
  102689. var i = 0, x, y;
  102690. var imageData = new Uint8Array(width * height * 4);
  102691. for (y = y_start; y !== y_end; y += y_step) {
  102692. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  102693. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  102694. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  102695. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  102696. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  102697. }
  102698. }
  102699. return imageData;
  102700. };
  102701. /** @hidden */
  102702. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  102703. var image = pixel_data;
  102704. var width = header.width, height = header.height;
  102705. var color, i = 0, x, y;
  102706. var imageData = new Uint8Array(width * height * 4);
  102707. for (y = y_start; y !== y_end; y += y_step) {
  102708. for (x = x_start; x !== x_end; x += x_step, i++) {
  102709. color = image[i];
  102710. imageData[(x + width * y) * 4 + 0] = color;
  102711. imageData[(x + width * y) * 4 + 1] = color;
  102712. imageData[(x + width * y) * 4 + 2] = color;
  102713. imageData[(x + width * y) * 4 + 3] = 255;
  102714. }
  102715. }
  102716. return imageData;
  102717. };
  102718. /** @hidden */
  102719. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  102720. var image = pixel_data;
  102721. var width = header.width, height = header.height;
  102722. var i = 0, x, y;
  102723. var imageData = new Uint8Array(width * height * 4);
  102724. for (y = y_start; y !== y_end; y += y_step) {
  102725. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  102726. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  102727. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  102728. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  102729. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  102730. }
  102731. }
  102732. return imageData;
  102733. };
  102734. //private static _TYPE_NO_DATA = 0;
  102735. TGATools._TYPE_INDEXED = 1;
  102736. TGATools._TYPE_RGB = 2;
  102737. TGATools._TYPE_GREY = 3;
  102738. TGATools._TYPE_RLE_INDEXED = 9;
  102739. TGATools._TYPE_RLE_RGB = 10;
  102740. TGATools._TYPE_RLE_GREY = 11;
  102741. TGATools._ORIGIN_MASK = 0x30;
  102742. TGATools._ORIGIN_SHIFT = 0x04;
  102743. TGATools._ORIGIN_BL = 0x00;
  102744. TGATools._ORIGIN_BR = 0x01;
  102745. TGATools._ORIGIN_UL = 0x02;
  102746. TGATools._ORIGIN_UR = 0x03;
  102747. return TGATools;
  102748. }());
  102749. /***/ }),
  102750. /***/ "./Misc/tools.ts":
  102751. /*!***********************!*\
  102752. !*** ./Misc/tools.ts ***!
  102753. \***********************/
  102754. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  102755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102756. "use strict";
  102757. __webpack_require__.r(__webpack_exports__);
  102758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  102759. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  102760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  102761. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  102762. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  102763. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  102764. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  102765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  102766. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  102767. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102768. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  102769. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102770. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  102771. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  102772. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  102773. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  102774. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  102775. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  102776. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  102777. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  102778. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  102779. /* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  102780. /** Class used to store color4 gradient */
  102781. var ColorGradient = /** @class */ (function () {
  102782. function ColorGradient() {
  102783. }
  102784. /**
  102785. * Will get a color picked randomly between color1 and color2.
  102786. * If color2 is undefined then color1 will be used
  102787. * @param result defines the target Color4 to store the result in
  102788. */
  102789. ColorGradient.prototype.getColorToRef = function (result) {
  102790. if (!this.color2) {
  102791. result.copyFrom(this.color1);
  102792. return;
  102793. }
  102794. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  102795. };
  102796. return ColorGradient;
  102797. }());
  102798. /** Class used to store color 3 gradient */
  102799. var Color3Gradient = /** @class */ (function () {
  102800. function Color3Gradient() {
  102801. }
  102802. return Color3Gradient;
  102803. }());
  102804. /** Class used to store factor gradient */
  102805. var FactorGradient = /** @class */ (function () {
  102806. function FactorGradient() {
  102807. }
  102808. /**
  102809. * Will get a number picked randomly between factor1 and factor2.
  102810. * If factor2 is undefined then factor1 will be used
  102811. * @returns the picked number
  102812. */
  102813. FactorGradient.prototype.getFactor = function () {
  102814. if (this.factor2 === undefined) {
  102815. return this.factor1;
  102816. }
  102817. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  102818. };
  102819. return FactorGradient;
  102820. }());
  102821. /**
  102822. * @ignore
  102823. * Application error to support additional information when loading a file
  102824. */
  102825. var LoadFileError = /** @class */ (function (_super) {
  102826. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  102827. /**
  102828. * Creates a new LoadFileError
  102829. * @param message defines the message of the error
  102830. * @param request defines the optional web request
  102831. */
  102832. function LoadFileError(message,
  102833. /** defines the optional web request */
  102834. request) {
  102835. var _this = _super.call(this, message) || this;
  102836. _this.request = request;
  102837. _this.name = "LoadFileError";
  102838. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  102839. return _this;
  102840. }
  102841. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  102842. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  102843. // Polyfill for Object.setPrototypeOf if necessary.
  102844. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  102845. return LoadFileError;
  102846. }(Error));
  102847. /**
  102848. * Class used to define a retry strategy when error happens while loading assets
  102849. */
  102850. var RetryStrategy = /** @class */ (function () {
  102851. function RetryStrategy() {
  102852. }
  102853. /**
  102854. * Function used to defines an exponential back off strategy
  102855. * @param maxRetries defines the maximum number of retries (3 by default)
  102856. * @param baseInterval defines the interval between retries
  102857. * @returns the strategy function to use
  102858. */
  102859. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  102860. if (maxRetries === void 0) { maxRetries = 3; }
  102861. if (baseInterval === void 0) { baseInterval = 500; }
  102862. return function (url, request, retryIndex) {
  102863. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  102864. return -1;
  102865. }
  102866. return Math.pow(2, retryIndex) * baseInterval;
  102867. };
  102868. };
  102869. return RetryStrategy;
  102870. }());
  102871. /**
  102872. * Class containing a set of static utilities functions
  102873. */
  102874. var Tools = /** @class */ (function () {
  102875. function Tools() {
  102876. }
  102877. /**
  102878. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  102879. * @param u defines the coordinate on X axis
  102880. * @param v defines the coordinate on Y axis
  102881. * @param width defines the width of the source data
  102882. * @param height defines the height of the source data
  102883. * @param pixels defines the source byte array
  102884. * @param color defines the output color
  102885. */
  102886. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  102887. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  102888. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  102889. var position = (wrappedU + wrappedV * width) * 4;
  102890. color.r = pixels[position] / 255;
  102891. color.g = pixels[position + 1] / 255;
  102892. color.b = pixels[position + 2] / 255;
  102893. color.a = pixels[position + 3] / 255;
  102894. };
  102895. /**
  102896. * Interpolates between a and b via alpha
  102897. * @param a The lower value (returned when alpha = 0)
  102898. * @param b The upper value (returned when alpha = 1)
  102899. * @param alpha The interpolation-factor
  102900. * @return The mixed value
  102901. */
  102902. Tools.Mix = function (a, b, alpha) {
  102903. return a * (1 - alpha) + b * alpha;
  102904. };
  102905. /**
  102906. * Tries to instantiate a new object from a given class name
  102907. * @param className defines the class name to instantiate
  102908. * @returns the new object or null if the system was not able to do the instantiation
  102909. */
  102910. Tools.Instantiate = function (className) {
  102911. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  102912. return Tools.RegisteredExternalClasses[className];
  102913. }
  102914. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  102915. if (internalClass) {
  102916. return internalClass;
  102917. }
  102918. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  102919. var arr = className.split(".");
  102920. var fn = (window || this);
  102921. for (var i = 0, len = arr.length; i < len; i++) {
  102922. fn = fn[arr[i]];
  102923. }
  102924. if (typeof fn !== "function") {
  102925. return null;
  102926. }
  102927. return fn;
  102928. };
  102929. /**
  102930. * Provides a slice function that will work even on IE
  102931. * @param data defines the array to slice
  102932. * @param start defines the start of the data (optional)
  102933. * @param end defines the end of the data (optional)
  102934. * @returns the new sliced array
  102935. */
  102936. Tools.Slice = function (data, start, end) {
  102937. if (data.slice) {
  102938. return data.slice(start, end);
  102939. }
  102940. return Array.prototype.slice.call(data, start, end);
  102941. };
  102942. /**
  102943. * Polyfill for setImmediate
  102944. * @param action defines the action to execute after the current execution block
  102945. */
  102946. Tools.SetImmediate = function (action) {
  102947. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  102948. window.setImmediate(action);
  102949. }
  102950. else {
  102951. setTimeout(action, 1);
  102952. }
  102953. };
  102954. /**
  102955. * Function indicating if a number is an exponent of 2
  102956. * @param value defines the value to test
  102957. * @returns true if the value is an exponent of 2
  102958. */
  102959. Tools.IsExponentOfTwo = function (value) {
  102960. var count = 1;
  102961. do {
  102962. count *= 2;
  102963. } while (count < value);
  102964. return count === value;
  102965. };
  102966. /**
  102967. * Returns the nearest 32-bit single precision float representation of a Number
  102968. * @param value A Number. If the parameter is of a different type, it will get converted
  102969. * to a number or to NaN if it cannot be converted
  102970. * @returns number
  102971. */
  102972. Tools.FloatRound = function (value) {
  102973. if (Math.fround) {
  102974. return Math.fround(value);
  102975. }
  102976. return (Tools._tmpFloatArray[0] = value);
  102977. };
  102978. /**
  102979. * Find the next highest power of two.
  102980. * @param x Number to start search from.
  102981. * @return Next highest power of two.
  102982. */
  102983. Tools.CeilingPOT = function (x) {
  102984. x--;
  102985. x |= x >> 1;
  102986. x |= x >> 2;
  102987. x |= x >> 4;
  102988. x |= x >> 8;
  102989. x |= x >> 16;
  102990. x++;
  102991. return x;
  102992. };
  102993. /**
  102994. * Find the next lowest power of two.
  102995. * @param x Number to start search from.
  102996. * @return Next lowest power of two.
  102997. */
  102998. Tools.FloorPOT = function (x) {
  102999. x = x | (x >> 1);
  103000. x = x | (x >> 2);
  103001. x = x | (x >> 4);
  103002. x = x | (x >> 8);
  103003. x = x | (x >> 16);
  103004. return x - (x >> 1);
  103005. };
  103006. /**
  103007. * Find the nearest power of two.
  103008. * @param x Number to start search from.
  103009. * @return Next nearest power of two.
  103010. */
  103011. Tools.NearestPOT = function (x) {
  103012. var c = Tools.CeilingPOT(x);
  103013. var f = Tools.FloorPOT(x);
  103014. return (c - x) > (x - f) ? f : c;
  103015. };
  103016. /**
  103017. * Get the closest exponent of two
  103018. * @param value defines the value to approximate
  103019. * @param max defines the maximum value to return
  103020. * @param mode defines how to define the closest value
  103021. * @returns closest exponent of two of the given value
  103022. */
  103023. Tools.GetExponentOfTwo = function (value, max, mode) {
  103024. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  103025. var pot;
  103026. switch (mode) {
  103027. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  103028. pot = Tools.FloorPOT(value);
  103029. break;
  103030. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  103031. pot = Tools.NearestPOT(value);
  103032. break;
  103033. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  103034. default:
  103035. pot = Tools.CeilingPOT(value);
  103036. break;
  103037. }
  103038. return Math.min(pot, max);
  103039. };
  103040. /**
  103041. * Extracts the filename from a path
  103042. * @param path defines the path to use
  103043. * @returns the filename
  103044. */
  103045. Tools.GetFilename = function (path) {
  103046. var index = path.lastIndexOf("/");
  103047. if (index < 0) {
  103048. return path;
  103049. }
  103050. return path.substring(index + 1);
  103051. };
  103052. /**
  103053. * Extracts the "folder" part of a path (everything before the filename).
  103054. * @param uri The URI to extract the info from
  103055. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  103056. * @returns The "folder" part of the path
  103057. */
  103058. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  103059. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  103060. var index = uri.lastIndexOf("/");
  103061. if (index < 0) {
  103062. if (returnUnchangedIfNoSlash) {
  103063. return uri;
  103064. }
  103065. return "";
  103066. }
  103067. return uri.substring(0, index + 1);
  103068. };
  103069. /**
  103070. * Convert an angle in radians to degrees
  103071. * @param angle defines the angle to convert
  103072. * @returns the angle in degrees
  103073. */
  103074. Tools.ToDegrees = function (angle) {
  103075. return angle * 180 / Math.PI;
  103076. };
  103077. /**
  103078. * Convert an angle in degrees to radians
  103079. * @param angle defines the angle to convert
  103080. * @returns the angle in radians
  103081. */
  103082. Tools.ToRadians = function (angle) {
  103083. return angle * Math.PI / 180;
  103084. };
  103085. /**
  103086. * Encode a buffer to a base64 string
  103087. * @param buffer defines the buffer to encode
  103088. * @returns the encoded string
  103089. */
  103090. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  103091. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  103092. var output = "";
  103093. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  103094. var i = 0;
  103095. var bytes = new Uint8Array(buffer);
  103096. while (i < bytes.length) {
  103097. chr1 = bytes[i++];
  103098. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  103099. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  103100. enc1 = chr1 >> 2;
  103101. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  103102. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  103103. enc4 = chr3 & 63;
  103104. if (isNaN(chr2)) {
  103105. enc3 = enc4 = 64;
  103106. }
  103107. else if (isNaN(chr3)) {
  103108. enc4 = 64;
  103109. }
  103110. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  103111. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  103112. }
  103113. return "data:image/png;base64," + output;
  103114. };
  103115. /**
  103116. * Extracts minimum and maximum values from a list of indexed positions
  103117. * @param positions defines the positions to use
  103118. * @param indices defines the indices to the positions
  103119. * @param indexStart defines the start index
  103120. * @param indexCount defines the end index
  103121. * @param bias defines bias value to add to the result
  103122. * @return minimum and maximum values
  103123. */
  103124. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  103125. if (bias === void 0) { bias = null; }
  103126. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  103127. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  103128. for (var index = indexStart; index < indexStart + indexCount; index++) {
  103129. var offset = indices[index] * 3;
  103130. var x = positions[offset];
  103131. var y = positions[offset + 1];
  103132. var z = positions[offset + 2];
  103133. minimum.minimizeInPlaceFromFloats(x, y, z);
  103134. maximum.maximizeInPlaceFromFloats(x, y, z);
  103135. }
  103136. if (bias) {
  103137. minimum.x -= minimum.x * bias.x + bias.y;
  103138. minimum.y -= minimum.y * bias.x + bias.y;
  103139. minimum.z -= minimum.z * bias.x + bias.y;
  103140. maximum.x += maximum.x * bias.x + bias.y;
  103141. maximum.y += maximum.y * bias.x + bias.y;
  103142. maximum.z += maximum.z * bias.x + bias.y;
  103143. }
  103144. return {
  103145. minimum: minimum,
  103146. maximum: maximum
  103147. };
  103148. };
  103149. /**
  103150. * Extracts minimum and maximum values from a list of positions
  103151. * @param positions defines the positions to use
  103152. * @param start defines the start index in the positions array
  103153. * @param count defines the number of positions to handle
  103154. * @param bias defines bias value to add to the result
  103155. * @param stride defines the stride size to use (distance between two positions in the positions array)
  103156. * @return minimum and maximum values
  103157. */
  103158. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  103159. if (bias === void 0) { bias = null; }
  103160. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  103161. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  103162. if (!stride) {
  103163. stride = 3;
  103164. }
  103165. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  103166. var x = positions[offset];
  103167. var y = positions[offset + 1];
  103168. var z = positions[offset + 2];
  103169. minimum.minimizeInPlaceFromFloats(x, y, z);
  103170. maximum.maximizeInPlaceFromFloats(x, y, z);
  103171. }
  103172. if (bias) {
  103173. minimum.x -= minimum.x * bias.x + bias.y;
  103174. minimum.y -= minimum.y * bias.x + bias.y;
  103175. minimum.z -= minimum.z * bias.x + bias.y;
  103176. maximum.x += maximum.x * bias.x + bias.y;
  103177. maximum.y += maximum.y * bias.x + bias.y;
  103178. maximum.z += maximum.z * bias.x + bias.y;
  103179. }
  103180. return {
  103181. minimum: minimum,
  103182. maximum: maximum
  103183. };
  103184. };
  103185. /**
  103186. * Returns an array if obj is not an array
  103187. * @param obj defines the object to evaluate as an array
  103188. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  103189. * @returns either obj directly if obj is an array or a new array containing obj
  103190. */
  103191. Tools.MakeArray = function (obj, allowsNullUndefined) {
  103192. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  103193. return null;
  103194. }
  103195. return Array.isArray(obj) ? obj : [obj];
  103196. };
  103197. /**
  103198. * Gets the pointer prefix to use
  103199. * @returns "pointer" if touch is enabled. Else returns "mouse"
  103200. */
  103201. Tools.GetPointerPrefix = function () {
  103202. var eventPrefix = "pointer";
  103203. // Check if pointer events are supported
  103204. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  103205. eventPrefix = "mouse";
  103206. }
  103207. return eventPrefix;
  103208. };
  103209. /**
  103210. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  103211. * @param func - the function to be called
  103212. * @param requester - the object that will request the next frame. Falls back to window.
  103213. * @returns frame number
  103214. */
  103215. Tools.QueueNewFrame = function (func, requester) {
  103216. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  103217. return setTimeout(func, 16);
  103218. }
  103219. if (!requester) {
  103220. requester = window;
  103221. }
  103222. if (requester.requestAnimationFrame) {
  103223. return requester.requestAnimationFrame(func);
  103224. }
  103225. else if (requester.msRequestAnimationFrame) {
  103226. return requester.msRequestAnimationFrame(func);
  103227. }
  103228. else if (requester.webkitRequestAnimationFrame) {
  103229. return requester.webkitRequestAnimationFrame(func);
  103230. }
  103231. else if (requester.mozRequestAnimationFrame) {
  103232. return requester.mozRequestAnimationFrame(func);
  103233. }
  103234. else if (requester.oRequestAnimationFrame) {
  103235. return requester.oRequestAnimationFrame(func);
  103236. }
  103237. else {
  103238. return window.setTimeout(func, 16);
  103239. }
  103240. };
  103241. /**
  103242. * Ask the browser to promote the current element to fullscreen rendering mode
  103243. * @param element defines the DOM element to promote
  103244. */
  103245. Tools.RequestFullscreen = function (element) {
  103246. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  103247. if (!requestFunction) {
  103248. return;
  103249. }
  103250. requestFunction.call(element);
  103251. };
  103252. /**
  103253. * Asks the browser to exit fullscreen mode
  103254. */
  103255. Tools.ExitFullscreen = function () {
  103256. var anyDoc = document;
  103257. if (document.exitFullscreen) {
  103258. document.exitFullscreen();
  103259. }
  103260. else if (anyDoc.mozCancelFullScreen) {
  103261. anyDoc.mozCancelFullScreen();
  103262. }
  103263. else if (anyDoc.webkitCancelFullScreen) {
  103264. anyDoc.webkitCancelFullScreen();
  103265. }
  103266. else if (anyDoc.msCancelFullScreen) {
  103267. anyDoc.msCancelFullScreen();
  103268. }
  103269. };
  103270. /**
  103271. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  103272. * @param url define the url we are trying
  103273. * @param element define the dom element where to configure the cors policy
  103274. */
  103275. Tools.SetCorsBehavior = function (url, element) {
  103276. if (url && url.indexOf("data:") === 0) {
  103277. return;
  103278. }
  103279. if (Tools.CorsBehavior) {
  103280. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  103281. element.crossOrigin = Tools.CorsBehavior;
  103282. }
  103283. else {
  103284. var result = Tools.CorsBehavior(url);
  103285. if (result) {
  103286. element.crossOrigin = result;
  103287. }
  103288. }
  103289. }
  103290. };
  103291. // External files
  103292. /**
  103293. * Removes unwanted characters from an url
  103294. * @param url defines the url to clean
  103295. * @returns the cleaned url
  103296. */
  103297. Tools.CleanUrl = function (url) {
  103298. url = url.replace(/#/mg, "%23");
  103299. return url;
  103300. };
  103301. /**
  103302. * Loads an image as an HTMLImageElement.
  103303. * @param input url string, ArrayBuffer, or Blob to load
  103304. * @param onLoad callback called when the image successfully loads
  103305. * @param onError callback called when the image fails to load
  103306. * @param offlineProvider offline provider for caching
  103307. * @returns the HTMLImageElement of the loaded image
  103308. */
  103309. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  103310. var url;
  103311. var usingObjectURL = false;
  103312. if (input instanceof ArrayBuffer) {
  103313. url = URL.createObjectURL(new Blob([input]));
  103314. usingObjectURL = true;
  103315. }
  103316. else if (input instanceof Blob) {
  103317. url = URL.createObjectURL(input);
  103318. usingObjectURL = true;
  103319. }
  103320. else {
  103321. url = Tools.CleanUrl(input);
  103322. url = Tools.PreprocessUrl(input);
  103323. }
  103324. var img = new Image();
  103325. Tools.SetCorsBehavior(url, img);
  103326. var loadHandler = function () {
  103327. img.removeEventListener("load", loadHandler);
  103328. img.removeEventListener("error", errorHandler);
  103329. onLoad(img);
  103330. // Must revoke the URL after calling onLoad to avoid security exceptions in
  103331. // certain scenarios (e.g. when hosted in vscode).
  103332. if (usingObjectURL && img.src) {
  103333. URL.revokeObjectURL(img.src);
  103334. }
  103335. };
  103336. var errorHandler = function (err) {
  103337. img.removeEventListener("load", loadHandler);
  103338. img.removeEventListener("error", errorHandler);
  103339. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  103340. if (onError) {
  103341. onError("Error while trying to load image: " + input, err);
  103342. }
  103343. if (usingObjectURL && img.src) {
  103344. URL.revokeObjectURL(img.src);
  103345. }
  103346. };
  103347. img.addEventListener("load", loadHandler);
  103348. img.addEventListener("error", errorHandler);
  103349. var noOfflineSupport = function () {
  103350. img.src = url;
  103351. };
  103352. var loadFromOfflineSupport = function () {
  103353. if (offlineProvider) {
  103354. offlineProvider.loadImage(url, img);
  103355. }
  103356. };
  103357. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  103358. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  103359. }
  103360. else {
  103361. if (url.indexOf("file:") !== -1) {
  103362. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  103363. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  103364. try {
  103365. var blobURL;
  103366. try {
  103367. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  103368. }
  103369. catch (ex) {
  103370. // Chrome doesn't support oneTimeOnly parameter
  103371. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  103372. }
  103373. img.src = blobURL;
  103374. usingObjectURL = true;
  103375. }
  103376. catch (e) {
  103377. img.src = "";
  103378. }
  103379. return img;
  103380. }
  103381. }
  103382. noOfflineSupport();
  103383. }
  103384. return img;
  103385. };
  103386. /**
  103387. * Loads a file
  103388. * @param url url string, ArrayBuffer, or Blob to load
  103389. * @param onSuccess callback called when the file successfully loads
  103390. * @param onProgress callback called while file is loading (if the server supports this mode)
  103391. * @param offlineProvider defines the offline provider for caching
  103392. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  103393. * @param onError callback called when the file fails to load
  103394. * @returns a file request object
  103395. */
  103396. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  103397. url = Tools.CleanUrl(url);
  103398. url = Tools.PreprocessUrl(url);
  103399. // If file and file input are set
  103400. if (url.indexOf("file:") !== -1) {
  103401. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  103402. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  103403. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  103404. }
  103405. }
  103406. var loadUrl = Tools.BaseUrl + url;
  103407. var aborted = false;
  103408. var fileRequest = {
  103409. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  103410. abort: function () { return aborted = true; },
  103411. };
  103412. var requestFile = function () {
  103413. var request = new _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"]();
  103414. var retryHandle = null;
  103415. fileRequest.abort = function () {
  103416. aborted = true;
  103417. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  103418. request.abort();
  103419. }
  103420. if (retryHandle !== null) {
  103421. clearTimeout(retryHandle);
  103422. retryHandle = null;
  103423. }
  103424. };
  103425. var retryLoop = function (retryIndex) {
  103426. request.open('GET', loadUrl);
  103427. if (useArrayBuffer) {
  103428. request.responseType = "arraybuffer";
  103429. }
  103430. if (onProgress) {
  103431. request.addEventListener("progress", onProgress);
  103432. }
  103433. var onLoadEnd = function () {
  103434. request.removeEventListener("loadend", onLoadEnd);
  103435. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  103436. fileRequest.onCompleteObservable.clear();
  103437. };
  103438. request.addEventListener("loadend", onLoadEnd);
  103439. var onReadyStateChange = function () {
  103440. if (aborted) {
  103441. return;
  103442. }
  103443. // In case of undefined state in some browsers.
  103444. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  103445. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  103446. request.removeEventListener("readystatechange", onReadyStateChange);
  103447. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  103448. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  103449. return;
  103450. }
  103451. var retryStrategy = Tools.DefaultRetryStrategy;
  103452. if (retryStrategy) {
  103453. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  103454. if (waitTime !== -1) {
  103455. // Prevent the request from completing for retry.
  103456. request.removeEventListener("loadend", onLoadEnd);
  103457. request = new _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"]();
  103458. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  103459. return;
  103460. }
  103461. }
  103462. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  103463. if (onError) {
  103464. onError(request, e);
  103465. }
  103466. else {
  103467. throw e;
  103468. }
  103469. }
  103470. };
  103471. request.addEventListener("readystatechange", onReadyStateChange);
  103472. request.send();
  103473. };
  103474. retryLoop(0);
  103475. };
  103476. // Caching all files
  103477. if (offlineProvider && offlineProvider.enableSceneOffline) {
  103478. var noOfflineSupport_1 = function (request) {
  103479. if (request && request.status > 400) {
  103480. if (onError) {
  103481. onError(request);
  103482. }
  103483. }
  103484. else {
  103485. if (!aborted) {
  103486. requestFile();
  103487. }
  103488. }
  103489. };
  103490. var loadFromOfflineSupport = function () {
  103491. // TODO: database needs to support aborting and should return a IFileRequest
  103492. if (aborted) {
  103493. return;
  103494. }
  103495. if (offlineProvider) {
  103496. offlineProvider.loadFile(url, function (data) {
  103497. if (!aborted) {
  103498. onSuccess(data);
  103499. }
  103500. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  103501. }, onProgress ? function (event) {
  103502. if (!aborted) {
  103503. onProgress(event);
  103504. }
  103505. } : undefined, noOfflineSupport_1, useArrayBuffer);
  103506. }
  103507. };
  103508. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  103509. }
  103510. else {
  103511. requestFile();
  103512. }
  103513. return fileRequest;
  103514. };
  103515. /**
  103516. * Load a script (identified by an url). When the url returns, the
  103517. * content of this file is added into a new script element, attached to the DOM (body element)
  103518. * @param scriptUrl defines the url of the script to laod
  103519. * @param onSuccess defines the callback called when the script is loaded
  103520. * @param onError defines the callback to call if an error occurs
  103521. * @param scriptId defines the id of the script element
  103522. */
  103523. Tools.LoadScript = function (scriptUrl, onSuccess, onError, scriptId) {
  103524. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  103525. return;
  103526. }
  103527. var head = document.getElementsByTagName('head')[0];
  103528. var script = document.createElement('script');
  103529. script.setAttribute('type', 'text/javascript');
  103530. script.setAttribute('src', scriptUrl);
  103531. if (scriptId) {
  103532. script.id = scriptId;
  103533. }
  103534. script.onload = function () {
  103535. if (onSuccess) {
  103536. onSuccess();
  103537. }
  103538. };
  103539. script.onerror = function (e) {
  103540. if (onError) {
  103541. onError("Unable to load script '" + scriptUrl + "'", e);
  103542. }
  103543. };
  103544. head.appendChild(script);
  103545. };
  103546. /**
  103547. * Load an asynchronous script (identified by an url). When the url returns, the
  103548. * content of this file is added into a new script element, attached to the DOM (body element)
  103549. * @param scriptUrl defines the url of the script to laod
  103550. * @param scriptId defines the id of the script element
  103551. * @returns a promise request object
  103552. */
  103553. Tools.LoadScriptAsync = function (scriptUrl, scriptId) {
  103554. return new Promise(function (resolve, reject) {
  103555. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  103556. resolve(false);
  103557. return;
  103558. }
  103559. var head = document.getElementsByTagName('head')[0];
  103560. var script = document.createElement('script');
  103561. script.setAttribute('type', 'text/javascript');
  103562. script.setAttribute('src', scriptUrl);
  103563. if (scriptId) {
  103564. script.id = scriptId;
  103565. }
  103566. script.onload = function () {
  103567. resolve(true);
  103568. };
  103569. script.onerror = function (e) {
  103570. resolve(false);
  103571. };
  103572. head.appendChild(script);
  103573. });
  103574. };
  103575. /**
  103576. * Loads a file from a blob
  103577. * @param fileToLoad defines the blob to use
  103578. * @param callback defines the callback to call when data is loaded
  103579. * @param progressCallback defines the callback to call during loading process
  103580. * @returns a file request object
  103581. */
  103582. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  103583. var reader = new FileReader();
  103584. var request = {
  103585. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  103586. abort: function () { return reader.abort(); },
  103587. };
  103588. reader.onloadend = function (e) {
  103589. request.onCompleteObservable.notifyObservers(request);
  103590. };
  103591. reader.onload = function (e) {
  103592. //target doesn't have result from ts 1.3
  103593. callback(e.target['result']);
  103594. };
  103595. reader.onprogress = progressCallback;
  103596. reader.readAsDataURL(fileToLoad);
  103597. return request;
  103598. };
  103599. /**
  103600. * Loads a file
  103601. * @param fileToLoad defines the file to load
  103602. * @param callback defines the callback to call when data is loaded
  103603. * @param progressCallBack defines the callback to call during loading process
  103604. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  103605. * @returns a file request object
  103606. */
  103607. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  103608. var reader = new FileReader();
  103609. var request = {
  103610. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  103611. abort: function () { return reader.abort(); },
  103612. };
  103613. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  103614. reader.onerror = function (e) {
  103615. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  103616. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  103617. };
  103618. reader.onload = function (e) {
  103619. //target doesn't have result from ts 1.3
  103620. callback(e.target['result']);
  103621. };
  103622. if (progressCallBack) {
  103623. reader.onprogress = progressCallBack;
  103624. }
  103625. if (!useArrayBuffer) {
  103626. // Asynchronous read
  103627. reader.readAsText(fileToLoad);
  103628. }
  103629. else {
  103630. reader.readAsArrayBuffer(fileToLoad);
  103631. }
  103632. return request;
  103633. };
  103634. /**
  103635. * Creates a data url from a given string content
  103636. * @param content defines the content to convert
  103637. * @returns the new data url link
  103638. */
  103639. Tools.FileAsURL = function (content) {
  103640. var fileBlob = new Blob([content]);
  103641. var url = window.URL || window.webkitURL;
  103642. var link = url.createObjectURL(fileBlob);
  103643. return link;
  103644. };
  103645. /**
  103646. * Format the given number to a specific decimal format
  103647. * @param value defines the number to format
  103648. * @param decimals defines the number of decimals to use
  103649. * @returns the formatted string
  103650. */
  103651. Tools.Format = function (value, decimals) {
  103652. if (decimals === void 0) { decimals = 2; }
  103653. return value.toFixed(decimals);
  103654. };
  103655. /**
  103656. * Checks if a given vector is inside a specific range
  103657. * @param v defines the vector to test
  103658. * @param min defines the minimum range
  103659. * @param max defines the maximum range
  103660. */
  103661. Tools.CheckExtends = function (v, min, max) {
  103662. min.minimizeInPlace(v);
  103663. max.maximizeInPlace(v);
  103664. };
  103665. /**
  103666. * Tries to copy an object by duplicating every property
  103667. * @param source defines the source object
  103668. * @param destination defines the target object
  103669. * @param doNotCopyList defines a list of properties to avoid
  103670. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  103671. */
  103672. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  103673. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  103674. };
  103675. /**
  103676. * Gets a boolean indicating if the given object has no own property
  103677. * @param obj defines the object to test
  103678. * @returns true if object has no own property
  103679. */
  103680. Tools.IsEmpty = function (obj) {
  103681. for (var i in obj) {
  103682. if (obj.hasOwnProperty(i)) {
  103683. return false;
  103684. }
  103685. }
  103686. return true;
  103687. };
  103688. /**
  103689. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  103690. * @param str Source string
  103691. * @param suffix Suffix to search for in the source string
  103692. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  103693. */
  103694. Tools.EndsWith = function (str, suffix) {
  103695. return str.indexOf(suffix, str.length - suffix.length) !== -1;
  103696. };
  103697. /**
  103698. * Function used to register events at window level
  103699. * @param events defines the events to register
  103700. */
  103701. Tools.RegisterTopRootEvents = function (events) {
  103702. for (var index = 0; index < events.length; index++) {
  103703. var event = events[index];
  103704. window.addEventListener(event.name, event.handler, false);
  103705. try {
  103706. if (window.parent) {
  103707. window.parent.addEventListener(event.name, event.handler, false);
  103708. }
  103709. }
  103710. catch (e) {
  103711. // Silently fails...
  103712. }
  103713. }
  103714. };
  103715. /**
  103716. * Function used to unregister events from window level
  103717. * @param events defines the events to unregister
  103718. */
  103719. Tools.UnregisterTopRootEvents = function (events) {
  103720. for (var index = 0; index < events.length; index++) {
  103721. var event = events[index];
  103722. window.removeEventListener(event.name, event.handler);
  103723. try {
  103724. if (window.parent) {
  103725. window.parent.removeEventListener(event.name, event.handler);
  103726. }
  103727. }
  103728. catch (e) {
  103729. // Silently fails...
  103730. }
  103731. }
  103732. };
  103733. /**
  103734. * Dumps the current bound framebuffer
  103735. * @param width defines the rendering width
  103736. * @param height defines the rendering height
  103737. * @param engine defines the hosting engine
  103738. * @param successCallback defines the callback triggered once the data are available
  103739. * @param mimeType defines the mime type of the result
  103740. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  103741. */
  103742. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  103743. if (mimeType === void 0) { mimeType = "image/png"; }
  103744. // Read the contents of the framebuffer
  103745. var numberOfChannelsByLine = width * 4;
  103746. var halfHeight = height / 2;
  103747. //Reading datas from WebGL
  103748. var data = engine.readPixels(0, 0, width, height);
  103749. //To flip image on Y axis.
  103750. for (var i = 0; i < halfHeight; i++) {
  103751. for (var j = 0; j < numberOfChannelsByLine; j++) {
  103752. var currentCell = j + i * numberOfChannelsByLine;
  103753. var targetLine = height - i - 1;
  103754. var targetCell = j + targetLine * numberOfChannelsByLine;
  103755. var temp = data[currentCell];
  103756. data[currentCell] = data[targetCell];
  103757. data[targetCell] = temp;
  103758. }
  103759. }
  103760. // Create a 2D canvas to store the result
  103761. if (!Tools._ScreenshotCanvas) {
  103762. Tools._ScreenshotCanvas = document.createElement('canvas');
  103763. }
  103764. Tools._ScreenshotCanvas.width = width;
  103765. Tools._ScreenshotCanvas.height = height;
  103766. var context = Tools._ScreenshotCanvas.getContext('2d');
  103767. if (context) {
  103768. // Copy the pixels to a 2D canvas
  103769. var imageData = context.createImageData(width, height);
  103770. var castData = (imageData.data);
  103771. castData.set(data);
  103772. context.putImageData(imageData, 0, 0);
  103773. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  103774. }
  103775. };
  103776. /**
  103777. * Converts the canvas data to blob.
  103778. * This acts as a polyfill for browsers not supporting the to blob function.
  103779. * @param canvas Defines the canvas to extract the data from
  103780. * @param successCallback Defines the callback triggered once the data are available
  103781. * @param mimeType Defines the mime type of the result
  103782. */
  103783. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  103784. if (mimeType === void 0) { mimeType = "image/png"; }
  103785. // We need HTMLCanvasElement.toBlob for HD screenshots
  103786. if (!canvas.toBlob) {
  103787. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  103788. canvas.toBlob = function (callback, type, quality) {
  103789. var _this = this;
  103790. setTimeout(function () {
  103791. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  103792. for (var i = 0; i < len; i++) {
  103793. arr[i] = binStr.charCodeAt(i);
  103794. }
  103795. callback(new Blob([arr]));
  103796. });
  103797. };
  103798. }
  103799. canvas.toBlob(function (blob) {
  103800. successCallback(blob);
  103801. }, mimeType);
  103802. };
  103803. /**
  103804. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  103805. * @param successCallback defines the callback triggered once the data are available
  103806. * @param mimeType defines the mime type of the result
  103807. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  103808. */
  103809. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  103810. if (mimeType === void 0) { mimeType = "image/png"; }
  103811. if (successCallback) {
  103812. var base64Image = Tools._ScreenshotCanvas.toDataURL(mimeType);
  103813. successCallback(base64Image);
  103814. }
  103815. else {
  103816. this.ToBlob(Tools._ScreenshotCanvas, function (blob) {
  103817. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  103818. if (("download" in document.createElement("a"))) {
  103819. if (!fileName) {
  103820. var date = new Date();
  103821. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  103822. fileName = "screenshot_" + stringDate + ".png";
  103823. }
  103824. Tools.Download(blob, fileName);
  103825. }
  103826. else {
  103827. var url = URL.createObjectURL(blob);
  103828. var newWindow = window.open("");
  103829. if (!newWindow) {
  103830. return;
  103831. }
  103832. var img = newWindow.document.createElement("img");
  103833. img.onload = function () {
  103834. // no longer need to read the blob so it's revoked
  103835. URL.revokeObjectURL(url);
  103836. };
  103837. img.src = url;
  103838. newWindow.document.body.appendChild(img);
  103839. }
  103840. }, mimeType);
  103841. }
  103842. };
  103843. /**
  103844. * Downloads a blob in the browser
  103845. * @param blob defines the blob to download
  103846. * @param fileName defines the name of the downloaded file
  103847. */
  103848. Tools.Download = function (blob, fileName) {
  103849. if (navigator && navigator.msSaveBlob) {
  103850. navigator.msSaveBlob(blob, fileName);
  103851. return;
  103852. }
  103853. var url = window.URL.createObjectURL(blob);
  103854. var a = document.createElement("a");
  103855. document.body.appendChild(a);
  103856. a.style.display = "none";
  103857. a.href = url;
  103858. a.download = fileName;
  103859. a.addEventListener("click", function () {
  103860. if (a.parentElement) {
  103861. a.parentElement.removeChild(a);
  103862. }
  103863. });
  103864. a.click();
  103865. window.URL.revokeObjectURL(url);
  103866. };
  103867. /**
  103868. * Captures a screenshot of the current rendering
  103869. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103870. * @param engine defines the rendering engine
  103871. * @param camera defines the source camera
  103872. * @param size This parameter can be set to a single number or to an object with the
  103873. * following (optional) properties: precision, width, height. If a single number is passed,
  103874. * it will be used for both width and height. If an object is passed, the screenshot size
  103875. * will be derived from the parameters. The precision property is a multiplier allowing
  103876. * rendering at a higher or lower resolution
  103877. * @param successCallback defines the callback receives a single parameter which contains the
  103878. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  103879. * src parameter of an <img> to display it
  103880. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  103881. * Check your browser for supported MIME types
  103882. */
  103883. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  103884. if (mimeType === void 0) { mimeType = "image/png"; }
  103885. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  103886. };
  103887. /**
  103888. * Generates an image screenshot from the specified camera.
  103889. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103890. * @param engine The engine to use for rendering
  103891. * @param camera The camera to use for rendering
  103892. * @param size This parameter can be set to a single number or to an object with the
  103893. * following (optional) properties: precision, width, height. If a single number is passed,
  103894. * it will be used for both width and height. If an object is passed, the screenshot size
  103895. * will be derived from the parameters. The precision property is a multiplier allowing
  103896. * rendering at a higher or lower resolution
  103897. * @param successCallback The callback receives a single parameter which contains the
  103898. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  103899. * src parameter of an <img> to display it
  103900. * @param mimeType The MIME type of the screenshot image (default: image/png).
  103901. * Check your browser for supported MIME types
  103902. * @param samples Texture samples (default: 1)
  103903. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  103904. * @param fileName A name for for the downloaded file.
  103905. */
  103906. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  103907. if (mimeType === void 0) { mimeType = "image/png"; }
  103908. if (samples === void 0) { samples = 1; }
  103909. if (antialiasing === void 0) { antialiasing = false; }
  103910. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  103911. };
  103912. /**
  103913. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103914. * Be aware Math.random() could cause collisions, but:
  103915. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  103916. * @returns a pseudo random id
  103917. */
  103918. Tools.RandomId = function () {
  103919. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  103920. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  103921. return v.toString(16);
  103922. });
  103923. };
  103924. /**
  103925. * Test if the given uri is a base64 string
  103926. * @param uri The uri to test
  103927. * @return True if the uri is a base64 string or false otherwise
  103928. */
  103929. Tools.IsBase64 = function (uri) {
  103930. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  103931. };
  103932. /**
  103933. * Decode the given base64 uri.
  103934. * @param uri The uri to decode
  103935. * @return The decoded base64 data.
  103936. */
  103937. Tools.DecodeBase64 = function (uri) {
  103938. var decodedString = atob(uri.split(",")[1]);
  103939. var bufferLength = decodedString.length;
  103940. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  103941. for (var i = 0; i < bufferLength; i++) {
  103942. bufferView[i] = decodedString.charCodeAt(i);
  103943. }
  103944. return bufferView.buffer;
  103945. };
  103946. /**
  103947. * Gets the absolute url.
  103948. * @param url the input url
  103949. * @return the absolute url
  103950. */
  103951. Tools.GetAbsoluteUrl = function (url) {
  103952. var a = document.createElement("a");
  103953. a.href = url;
  103954. return a.href;
  103955. };
  103956. Object.defineProperty(Tools, "errorsCount", {
  103957. /**
  103958. * Gets a value indicating the number of loading errors
  103959. * @ignorenaming
  103960. */
  103961. get: function () {
  103962. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  103963. },
  103964. enumerable: true,
  103965. configurable: true
  103966. });
  103967. /**
  103968. * Log a message to the console
  103969. * @param message defines the message to log
  103970. */
  103971. Tools.Log = function (message) {
  103972. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  103973. };
  103974. /**
  103975. * Write a warning message to the console
  103976. * @param message defines the message to log
  103977. */
  103978. Tools.Warn = function (message) {
  103979. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  103980. };
  103981. /**
  103982. * Write an error message to the console
  103983. * @param message defines the message to log
  103984. */
  103985. Tools.Error = function (message) {
  103986. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  103987. };
  103988. Object.defineProperty(Tools, "LogCache", {
  103989. /**
  103990. * Gets current log cache (list of logs)
  103991. */
  103992. get: function () {
  103993. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  103994. },
  103995. enumerable: true,
  103996. configurable: true
  103997. });
  103998. /**
  103999. * Clears the log cache
  104000. */
  104001. Tools.ClearLogCache = function () {
  104002. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  104003. };
  104004. Object.defineProperty(Tools, "LogLevels", {
  104005. /**
  104006. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  104007. */
  104008. set: function (level) {
  104009. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  104010. },
  104011. enumerable: true,
  104012. configurable: true
  104013. });
  104014. /**
  104015. * Checks if the loaded document was accessed via `file:`-Protocol.
  104016. * @returns boolean
  104017. */
  104018. Tools.IsFileURL = function () {
  104019. return location.protocol === "file:";
  104020. };
  104021. Object.defineProperty(Tools, "PerformanceLogLevel", {
  104022. /**
  104023. * Sets the current performance log level
  104024. */
  104025. set: function (level) {
  104026. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  104027. Tools.StartPerformanceCounter = Tools._StartUserMark;
  104028. Tools.EndPerformanceCounter = Tools._EndUserMark;
  104029. return;
  104030. }
  104031. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  104032. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  104033. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  104034. return;
  104035. }
  104036. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  104037. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  104038. },
  104039. enumerable: true,
  104040. configurable: true
  104041. });
  104042. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  104043. };
  104044. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  104045. };
  104046. Tools._StartUserMark = function (counterName, condition) {
  104047. if (condition === void 0) { condition = true; }
  104048. if (!Tools._performance) {
  104049. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  104050. return;
  104051. }
  104052. Tools._performance = window.performance;
  104053. }
  104054. if (!condition || !Tools._performance.mark) {
  104055. return;
  104056. }
  104057. Tools._performance.mark(counterName + "-Begin");
  104058. };
  104059. Tools._EndUserMark = function (counterName, condition) {
  104060. if (condition === void 0) { condition = true; }
  104061. if (!condition || !Tools._performance.mark) {
  104062. return;
  104063. }
  104064. Tools._performance.mark(counterName + "-End");
  104065. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  104066. };
  104067. Tools._StartPerformanceConsole = function (counterName, condition) {
  104068. if (condition === void 0) { condition = true; }
  104069. if (!condition) {
  104070. return;
  104071. }
  104072. Tools._StartUserMark(counterName, condition);
  104073. if (console.time) {
  104074. console.time(counterName);
  104075. }
  104076. };
  104077. Tools._EndPerformanceConsole = function (counterName, condition) {
  104078. if (condition === void 0) { condition = true; }
  104079. if (!condition) {
  104080. return;
  104081. }
  104082. Tools._EndUserMark(counterName, condition);
  104083. if (console.time) {
  104084. console.timeEnd(counterName);
  104085. }
  104086. };
  104087. Object.defineProperty(Tools, "Now", {
  104088. /**
  104089. * Gets either window.performance.now() if supported or Date.now() else
  104090. */
  104091. get: function () {
  104092. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  104093. },
  104094. enumerable: true,
  104095. configurable: true
  104096. });
  104097. /**
  104098. * This method will return the name of the class used to create the instance of the given object.
  104099. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  104100. * @param object the object to get the class name from
  104101. * @param isType defines if the object is actually a type
  104102. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  104103. */
  104104. Tools.GetClassName = function (object, isType) {
  104105. if (isType === void 0) { isType = false; }
  104106. var name = null;
  104107. if (!isType && object.getClassName) {
  104108. name = object.getClassName();
  104109. }
  104110. else {
  104111. if (object instanceof Object) {
  104112. var classObj = isType ? object : Object.getPrototypeOf(object);
  104113. name = classObj.constructor["__bjsclassName__"];
  104114. }
  104115. if (!name) {
  104116. name = typeof object;
  104117. }
  104118. }
  104119. return name;
  104120. };
  104121. /**
  104122. * Gets the first element of an array satisfying a given predicate
  104123. * @param array defines the array to browse
  104124. * @param predicate defines the predicate to use
  104125. * @returns null if not found or the element
  104126. */
  104127. Tools.First = function (array, predicate) {
  104128. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  104129. var el = array_1[_i];
  104130. if (predicate(el)) {
  104131. return el;
  104132. }
  104133. }
  104134. return null;
  104135. };
  104136. /**
  104137. * This method will return the name of the full name of the class, including its owning module (if any).
  104138. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified).
  104139. * @param object the object to get the class name from
  104140. * @param isType defines if the object is actually a type
  104141. * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified.
  104142. * @ignorenaming
  104143. */
  104144. Tools.getFullClassName = function (object, isType) {
  104145. if (isType === void 0) { isType = false; }
  104146. var className = null;
  104147. var moduleName = null;
  104148. if (!isType && object.getClassName) {
  104149. className = object.getClassName();
  104150. }
  104151. else {
  104152. if (object instanceof Object) {
  104153. var classObj = isType ? object : Object.getPrototypeOf(object);
  104154. className = classObj.constructor["__bjsclassName__"];
  104155. moduleName = classObj.constructor["__bjsmoduleName__"];
  104156. }
  104157. if (!className) {
  104158. className = typeof object;
  104159. }
  104160. }
  104161. if (!className) {
  104162. return null;
  104163. }
  104164. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  104165. };
  104166. /**
  104167. * Returns a promise that resolves after the given amount of time.
  104168. * @param delay Number of milliseconds to delay
  104169. * @returns Promise that resolves after the given amount of time
  104170. */
  104171. Tools.DelayAsync = function (delay) {
  104172. return new Promise(function (resolve) {
  104173. setTimeout(function () {
  104174. resolve();
  104175. }, delay);
  104176. });
  104177. };
  104178. /**
  104179. * Gets the current gradient from an array of IValueGradient
  104180. * @param ratio defines the current ratio to get
  104181. * @param gradients defines the array of IValueGradient
  104182. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  104183. */
  104184. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  104185. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  104186. var currentGradient = gradients[gradientIndex];
  104187. var nextGradient = gradients[gradientIndex + 1];
  104188. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  104189. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  104190. updateFunc(currentGradient, nextGradient, scale);
  104191. return;
  104192. }
  104193. }
  104194. // Use last index if over
  104195. var lastIndex = gradients.length - 1;
  104196. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  104197. };
  104198. /**
  104199. * Gets or sets the base URL to use to load assets
  104200. */
  104201. Tools.BaseUrl = "";
  104202. /**
  104203. * Enable/Disable Custom HTTP Request Headers globally.
  104204. * default = false
  104205. * @see CustomRequestHeaders
  104206. */
  104207. Tools.UseCustomRequestHeaders = false;
  104208. /**
  104209. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  104210. * i.e. when loading files, where the server/service expects an Authorization header
  104211. */
  104212. Tools.CustomRequestHeaders = _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"].CustomRequestHeaders;
  104213. /**
  104214. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  104215. */
  104216. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  104217. /**
  104218. * Default behaviour for cors in the application.
  104219. * It can be a string if the expected behavior is identical in the entire app.
  104220. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  104221. */
  104222. Tools.CorsBehavior = "anonymous";
  104223. /**
  104224. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104225. * @ignorenaming
  104226. */
  104227. Tools.UseFallbackTexture = true;
  104228. /**
  104229. * Use this object to register external classes like custom textures or material
  104230. * to allow the laoders to instantiate them
  104231. */
  104232. Tools.RegisteredExternalClasses = {};
  104233. /**
  104234. * Texture content used if a texture cannot loaded
  104235. * @ignorenaming
  104236. */
  104237. Tools.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";
  104238. Tools._tmpFloatArray = new Float32Array(1);
  104239. /**
  104240. * Extracts text content from a DOM element hierarchy
  104241. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  104242. */
  104243. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  104244. /**
  104245. * Gets or sets a function used to pre-process url before using them to load assets
  104246. */
  104247. Tools.PreprocessUrl = function (url) {
  104248. return url;
  104249. };
  104250. // Logs
  104251. /**
  104252. * No log
  104253. */
  104254. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  104255. /**
  104256. * Only message logs
  104257. */
  104258. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  104259. /**
  104260. * Only warning logs
  104261. */
  104262. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  104263. /**
  104264. * Only error logs
  104265. */
  104266. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  104267. /**
  104268. * All logs
  104269. */
  104270. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  104271. /**
  104272. * Checks if the window object exists
  104273. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  104274. */
  104275. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  104276. // Performances
  104277. /**
  104278. * No performance log
  104279. */
  104280. Tools.PerformanceNoneLogLevel = 0;
  104281. /**
  104282. * Use user marks to log performance
  104283. */
  104284. Tools.PerformanceUserMarkLogLevel = 1;
  104285. /**
  104286. * Log performance to the console
  104287. */
  104288. Tools.PerformanceConsoleLogLevel = 2;
  104289. /**
  104290. * Starts a performance counter
  104291. */
  104292. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  104293. /**
  104294. * Ends a specific performance coutner
  104295. */
  104296. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  104297. return Tools;
  104298. }());
  104299. /**
  104300. * This class is used to track a performance counter which is number based.
  104301. * The user has access to many properties which give statistics of different nature.
  104302. *
  104303. * The implementer can track two kinds of Performance Counter: time and count.
  104304. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  104305. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  104306. */
  104307. var PerfCounter = /** @class */ (function () {
  104308. /**
  104309. * Creates a new counter
  104310. */
  104311. function PerfCounter() {
  104312. this._startMonitoringTime = 0;
  104313. this._min = 0;
  104314. this._max = 0;
  104315. this._average = 0;
  104316. this._lastSecAverage = 0;
  104317. this._current = 0;
  104318. this._totalValueCount = 0;
  104319. this._totalAccumulated = 0;
  104320. this._lastSecAccumulated = 0;
  104321. this._lastSecTime = 0;
  104322. this._lastSecValueCount = 0;
  104323. }
  104324. Object.defineProperty(PerfCounter.prototype, "min", {
  104325. /**
  104326. * Returns the smallest value ever
  104327. */
  104328. get: function () {
  104329. return this._min;
  104330. },
  104331. enumerable: true,
  104332. configurable: true
  104333. });
  104334. Object.defineProperty(PerfCounter.prototype, "max", {
  104335. /**
  104336. * Returns the biggest value ever
  104337. */
  104338. get: function () {
  104339. return this._max;
  104340. },
  104341. enumerable: true,
  104342. configurable: true
  104343. });
  104344. Object.defineProperty(PerfCounter.prototype, "average", {
  104345. /**
  104346. * Returns the average value since the performance counter is running
  104347. */
  104348. get: function () {
  104349. return this._average;
  104350. },
  104351. enumerable: true,
  104352. configurable: true
  104353. });
  104354. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  104355. /**
  104356. * Returns the average value of the last second the counter was monitored
  104357. */
  104358. get: function () {
  104359. return this._lastSecAverage;
  104360. },
  104361. enumerable: true,
  104362. configurable: true
  104363. });
  104364. Object.defineProperty(PerfCounter.prototype, "current", {
  104365. /**
  104366. * Returns the current value
  104367. */
  104368. get: function () {
  104369. return this._current;
  104370. },
  104371. enumerable: true,
  104372. configurable: true
  104373. });
  104374. Object.defineProperty(PerfCounter.prototype, "total", {
  104375. /**
  104376. * Gets the accumulated total
  104377. */
  104378. get: function () {
  104379. return this._totalAccumulated;
  104380. },
  104381. enumerable: true,
  104382. configurable: true
  104383. });
  104384. Object.defineProperty(PerfCounter.prototype, "count", {
  104385. /**
  104386. * Gets the total value count
  104387. */
  104388. get: function () {
  104389. return this._totalValueCount;
  104390. },
  104391. enumerable: true,
  104392. configurable: true
  104393. });
  104394. /**
  104395. * Call this method to start monitoring a new frame.
  104396. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  104397. */
  104398. PerfCounter.prototype.fetchNewFrame = function () {
  104399. this._totalValueCount++;
  104400. this._current = 0;
  104401. this._lastSecValueCount++;
  104402. };
  104403. /**
  104404. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  104405. * @param newCount the count value to add to the monitored count
  104406. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  104407. */
  104408. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  104409. if (!PerfCounter.Enabled) {
  104410. return;
  104411. }
  104412. this._current += newCount;
  104413. if (fetchResult) {
  104414. this._fetchResult();
  104415. }
  104416. };
  104417. /**
  104418. * Start monitoring this performance counter
  104419. */
  104420. PerfCounter.prototype.beginMonitoring = function () {
  104421. if (!PerfCounter.Enabled) {
  104422. return;
  104423. }
  104424. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  104425. };
  104426. /**
  104427. * Compute the time lapsed since the previous beginMonitoring() call.
  104428. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  104429. */
  104430. PerfCounter.prototype.endMonitoring = function (newFrame) {
  104431. if (newFrame === void 0) { newFrame = true; }
  104432. if (!PerfCounter.Enabled) {
  104433. return;
  104434. }
  104435. if (newFrame) {
  104436. this.fetchNewFrame();
  104437. }
  104438. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  104439. this._current = currentTime - this._startMonitoringTime;
  104440. if (newFrame) {
  104441. this._fetchResult();
  104442. }
  104443. };
  104444. PerfCounter.prototype._fetchResult = function () {
  104445. this._totalAccumulated += this._current;
  104446. this._lastSecAccumulated += this._current;
  104447. // Min/Max update
  104448. this._min = Math.min(this._min, this._current);
  104449. this._max = Math.max(this._max, this._current);
  104450. this._average = this._totalAccumulated / this._totalValueCount;
  104451. // Reset last sec?
  104452. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  104453. if ((now - this._lastSecTime) > 1000) {
  104454. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  104455. this._lastSecTime = now;
  104456. this._lastSecAccumulated = 0;
  104457. this._lastSecValueCount = 0;
  104458. }
  104459. };
  104460. /**
  104461. * Gets or sets a global boolean to turn on and off all the counters
  104462. */
  104463. PerfCounter.Enabled = true;
  104464. return PerfCounter;
  104465. }());
  104466. /**
  104467. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  104468. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  104469. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  104470. * @param name The name of the class, case should be preserved
  104471. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  104472. */
  104473. function className(name, module) {
  104474. return function (target) {
  104475. target["__bjsclassName__"] = name;
  104476. target["__bjsmoduleName__"] = (module != null) ? module : null;
  104477. };
  104478. }
  104479. /**
  104480. * An implementation of a loop for asynchronous functions.
  104481. */
  104482. var AsyncLoop = /** @class */ (function () {
  104483. /**
  104484. * Constructor.
  104485. * @param iterations the number of iterations.
  104486. * @param func the function to run each iteration
  104487. * @param successCallback the callback that will be called upon succesful execution
  104488. * @param offset starting offset.
  104489. */
  104490. function AsyncLoop(
  104491. /**
  104492. * Defines the number of iterations for the loop
  104493. */
  104494. iterations, func, successCallback, offset) {
  104495. if (offset === void 0) { offset = 0; }
  104496. this.iterations = iterations;
  104497. this.index = offset - 1;
  104498. this._done = false;
  104499. this._fn = func;
  104500. this._successCallback = successCallback;
  104501. }
  104502. /**
  104503. * Execute the next iteration. Must be called after the last iteration was finished.
  104504. */
  104505. AsyncLoop.prototype.executeNext = function () {
  104506. if (!this._done) {
  104507. if (this.index + 1 < this.iterations) {
  104508. ++this.index;
  104509. this._fn(this);
  104510. }
  104511. else {
  104512. this.breakLoop();
  104513. }
  104514. }
  104515. };
  104516. /**
  104517. * Break the loop and run the success callback.
  104518. */
  104519. AsyncLoop.prototype.breakLoop = function () {
  104520. this._done = true;
  104521. this._successCallback();
  104522. };
  104523. /**
  104524. * Create and run an async loop.
  104525. * @param iterations the number of iterations.
  104526. * @param fn the function to run each iteration
  104527. * @param successCallback the callback that will be called upon succesful execution
  104528. * @param offset starting offset.
  104529. * @returns the created async loop object
  104530. */
  104531. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  104532. if (offset === void 0) { offset = 0; }
  104533. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  104534. loop.executeNext();
  104535. return loop;
  104536. };
  104537. /**
  104538. * A for-loop that will run a given number of iterations synchronous and the rest async.
  104539. * @param iterations total number of iterations
  104540. * @param syncedIterations number of synchronous iterations in each async iteration.
  104541. * @param fn the function to call each iteration.
  104542. * @param callback a success call back that will be called when iterating stops.
  104543. * @param breakFunction a break condition (optional)
  104544. * @param timeout timeout settings for the setTimeout function. default - 0.
  104545. * @returns the created async loop object
  104546. */
  104547. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  104548. if (timeout === void 0) { timeout = 0; }
  104549. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  104550. if (breakFunction && breakFunction()) {
  104551. loop.breakLoop();
  104552. }
  104553. else {
  104554. setTimeout(function () {
  104555. for (var i = 0; i < syncedIterations; ++i) {
  104556. var iteration = (loop.index * syncedIterations) + i;
  104557. if (iteration >= iterations) {
  104558. break;
  104559. }
  104560. fn(iteration);
  104561. if (breakFunction && breakFunction()) {
  104562. loop.breakLoop();
  104563. break;
  104564. }
  104565. }
  104566. loop.executeNext();
  104567. }, timeout);
  104568. }
  104569. }, callback);
  104570. };
  104571. return AsyncLoop;
  104572. }());
  104573. /***/ }),
  104574. /***/ "./Misc/typeStore.ts":
  104575. /*!***************************!*\
  104576. !*** ./Misc/typeStore.ts ***!
  104577. \***************************/
  104578. /*! exports provided: _TypeStore */
  104579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104580. "use strict";
  104581. __webpack_require__.r(__webpack_exports__);
  104582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  104583. /** @hidden */
  104584. var _TypeStore = /** @class */ (function () {
  104585. function _TypeStore() {
  104586. }
  104587. /** @hidden */
  104588. _TypeStore.GetClass = function (fqdn) {
  104589. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  104590. return this.RegisteredTypes[fqdn];
  104591. }
  104592. return null;
  104593. };
  104594. /** @hidden */
  104595. _TypeStore.RegisteredTypes = {};
  104596. return _TypeStore;
  104597. }());
  104598. /***/ }),
  104599. /***/ "./Misc/videoRecorder.ts":
  104600. /*!*******************************!*\
  104601. !*** ./Misc/videoRecorder.ts ***!
  104602. \*******************************/
  104603. /*! exports provided: VideoRecorder */
  104604. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104605. "use strict";
  104606. __webpack_require__.r(__webpack_exports__);
  104607. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  104608. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  104609. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  104610. /**
  104611. * This can helps recording videos from BabylonJS.
  104612. * This is based on the available WebRTC functionalities of the browser.
  104613. *
  104614. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  104615. */
  104616. var VideoRecorder = /** @class */ (function () {
  104617. /**
  104618. * Create a new VideoCapture object which can help converting what you see in Babylon to
  104619. * a video file.
  104620. * @param engine Defines the BabylonJS Engine you wish to record
  104621. * @param options Defines options that can be used to customized the capture
  104622. */
  104623. function VideoRecorder(engine, options) {
  104624. if (options === void 0) { options = null; }
  104625. if (!VideoRecorder.IsSupported(engine)) {
  104626. throw "Your browser does not support recording so far.";
  104627. }
  104628. var canvas = engine.getRenderingCanvas();
  104629. if (!canvas) {
  104630. throw "The babylon engine must have a canvas to be recorded";
  104631. }
  104632. this._canvas = canvas;
  104633. this._canvas.isRecording = false;
  104634. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  104635. var stream = this._canvas.captureStream(this._options.fps);
  104636. if (this._options.audioTracks) {
  104637. for (var _i = 0, _a = this._options.audioTracks; _i < _a.length; _i++) {
  104638. var track = _a[_i];
  104639. stream.addTrack(track);
  104640. }
  104641. }
  104642. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  104643. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  104644. this._mediaRecorder.onerror = this._handleError.bind(this);
  104645. this._mediaRecorder.onstop = this._handleStop.bind(this);
  104646. }
  104647. /**
  104648. * Returns wehther or not the VideoRecorder is available in your browser.
  104649. * @param engine Defines the Babylon Engine to check the support for
  104650. * @returns true if supported otherwise false
  104651. */
  104652. VideoRecorder.IsSupported = function (engine) {
  104653. var canvas = engine.getRenderingCanvas();
  104654. return (!!canvas && typeof canvas.captureStream === "function");
  104655. };
  104656. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  104657. /**
  104658. * True wether a recording is already in progress.
  104659. */
  104660. get: function () {
  104661. return !!this._canvas && this._canvas.isRecording;
  104662. },
  104663. enumerable: true,
  104664. configurable: true
  104665. });
  104666. /**
  104667. * Stops the current recording before the default capture timeout passed in the startRecording
  104668. * functions.
  104669. */
  104670. VideoRecorder.prototype.stopRecording = function () {
  104671. if (!this._canvas || !this._mediaRecorder) {
  104672. return;
  104673. }
  104674. if (!this.isRecording) {
  104675. return;
  104676. }
  104677. this._canvas.isRecording = false;
  104678. this._mediaRecorder.stop();
  104679. };
  104680. /**
  104681. * Starts recording the canvas for a max duration specified in parameters.
  104682. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  104683. * @param maxDuration Defines the maximum recording time in seconds.
  104684. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  104685. * @return a promise callback at the end of the recording with the video data in Blob.
  104686. */
  104687. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  104688. var _this = this;
  104689. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  104690. if (maxDuration === void 0) { maxDuration = 7; }
  104691. if (!this._canvas || !this._mediaRecorder) {
  104692. throw "Recorder has already been disposed";
  104693. }
  104694. if (this.isRecording) {
  104695. throw "Recording already in progress";
  104696. }
  104697. if (maxDuration > 0) {
  104698. setTimeout(function () {
  104699. _this.stopRecording();
  104700. }, maxDuration * 1000);
  104701. }
  104702. this._fileName = fileName;
  104703. this._recordedChunks = [];
  104704. this._resolve = null;
  104705. this._reject = null;
  104706. this._canvas.isRecording = true;
  104707. this._mediaRecorder.start(this._options.recordChunckSize);
  104708. return new Promise(function (resolve, reject) {
  104709. _this._resolve = resolve;
  104710. _this._reject = reject;
  104711. });
  104712. };
  104713. /**
  104714. * Releases internal resources used during the recording.
  104715. */
  104716. VideoRecorder.prototype.dispose = function () {
  104717. this._canvas = null;
  104718. this._mediaRecorder = null;
  104719. this._recordedChunks = [];
  104720. this._fileName = null;
  104721. this._resolve = null;
  104722. this._reject = null;
  104723. };
  104724. VideoRecorder.prototype._handleDataAvailable = function (event) {
  104725. if (event.data.size > 0) {
  104726. this._recordedChunks.push(event.data);
  104727. }
  104728. };
  104729. VideoRecorder.prototype._handleError = function (event) {
  104730. this.stopRecording();
  104731. if (this._reject) {
  104732. this._reject(event.error);
  104733. }
  104734. else {
  104735. throw new event.error();
  104736. }
  104737. };
  104738. VideoRecorder.prototype._handleStop = function () {
  104739. this.stopRecording();
  104740. var superBuffer = new Blob(this._recordedChunks);
  104741. if (this._resolve) {
  104742. this._resolve(superBuffer);
  104743. }
  104744. window.URL.createObjectURL(superBuffer);
  104745. if (this._fileName) {
  104746. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  104747. }
  104748. };
  104749. VideoRecorder._defaultOptions = {
  104750. mimeType: "video/webm",
  104751. fps: 25,
  104752. recordChunckSize: 3000
  104753. };
  104754. return VideoRecorder;
  104755. }());
  104756. /***/ }),
  104757. /***/ "./Misc/virtualJoystick.ts":
  104758. /*!*********************************!*\
  104759. !*** ./Misc/virtualJoystick.ts ***!
  104760. \*********************************/
  104761. /*! exports provided: JoystickAxis, VirtualJoystick */
  104762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104763. "use strict";
  104764. __webpack_require__.r(__webpack_exports__);
  104765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  104766. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  104767. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104768. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  104769. // Mainly based on these 2 articles :
  104770. // Creating an universal virtual touch joystick working for all Touch models thanks to Hand.JS : http://blogs.msdn.com/b/davrous/archive/2013/02/22/creating-an-universal-virtual-touch-joystick-working-for-all-touch-models-thanks-to-hand-js.aspx
  104771. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  104772. /**
  104773. * Defines the potential axis of a Joystick
  104774. */
  104775. var JoystickAxis;
  104776. (function (JoystickAxis) {
  104777. /** X axis */
  104778. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  104779. /** Y axis */
  104780. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  104781. /** Z axis */
  104782. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  104783. })(JoystickAxis || (JoystickAxis = {}));
  104784. /**
  104785. * Class used to define virtual joystick (used in touch mode)
  104786. */
  104787. var VirtualJoystick = /** @class */ (function () {
  104788. /**
  104789. * Creates a new virtual joystick
  104790. * @param leftJoystick defines that the joystick is for left hand (false by default)
  104791. */
  104792. function VirtualJoystick(leftJoystick) {
  104793. var _this = this;
  104794. if (leftJoystick) {
  104795. this._leftJoystick = true;
  104796. }
  104797. else {
  104798. this._leftJoystick = false;
  104799. }
  104800. VirtualJoystick._globalJoystickIndex++;
  104801. // By default left & right arrow keys are moving the X
  104802. // and up & down keys are moving the Y
  104803. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  104804. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  104805. this.reverseLeftRight = false;
  104806. this.reverseUpDown = false;
  104807. // collections of pointers
  104808. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  104809. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104810. this._joystickSensibility = 25;
  104811. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  104812. this._onResize = function (evt) {
  104813. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  104814. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  104815. if (VirtualJoystick.Canvas) {
  104816. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  104817. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  104818. }
  104819. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  104820. };
  104821. // injecting a canvas element on top of the canvas 3D game
  104822. if (!VirtualJoystick.Canvas) {
  104823. window.addEventListener("resize", this._onResize, false);
  104824. VirtualJoystick.Canvas = document.createElement("canvas");
  104825. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  104826. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  104827. VirtualJoystick.Canvas.width = window.innerWidth;
  104828. VirtualJoystick.Canvas.height = window.innerHeight;
  104829. VirtualJoystick.Canvas.style.width = "100%";
  104830. VirtualJoystick.Canvas.style.height = "100%";
  104831. VirtualJoystick.Canvas.style.position = "absolute";
  104832. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  104833. VirtualJoystick.Canvas.style.top = "0px";
  104834. VirtualJoystick.Canvas.style.left = "0px";
  104835. VirtualJoystick.Canvas.style.zIndex = "5";
  104836. VirtualJoystick.Canvas.style.msTouchAction = "none";
  104837. // Support for jQuery PEP polyfill
  104838. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  104839. var context = VirtualJoystick.Canvas.getContext('2d');
  104840. if (!context) {
  104841. throw new Error("Unable to create canvas for virtual joystick");
  104842. }
  104843. VirtualJoystick.vjCanvasContext = context;
  104844. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  104845. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  104846. document.body.appendChild(VirtualJoystick.Canvas);
  104847. }
  104848. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  104849. this.pressed = false;
  104850. // default joystick color
  104851. this._joystickColor = "cyan";
  104852. this._joystickPointerID = -1;
  104853. // current joystick position
  104854. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  104855. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  104856. // origin joystick position
  104857. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  104858. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  104859. this._onPointerDownHandlerRef = function (evt) {
  104860. _this._onPointerDown(evt);
  104861. };
  104862. this._onPointerMoveHandlerRef = function (evt) {
  104863. _this._onPointerMove(evt);
  104864. };
  104865. this._onPointerUpHandlerRef = function (evt) {
  104866. _this._onPointerUp(evt);
  104867. };
  104868. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  104869. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  104870. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  104871. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  104872. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  104873. evt.preventDefault(); // Disables system menu
  104874. }, false);
  104875. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  104876. }
  104877. /**
  104878. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  104879. * @param newJoystickSensibility defines the new sensibility
  104880. */
  104881. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  104882. this._joystickSensibility = newJoystickSensibility;
  104883. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  104884. };
  104885. VirtualJoystick.prototype._onPointerDown = function (e) {
  104886. var positionOnScreenCondition;
  104887. e.preventDefault();
  104888. if (this._leftJoystick === true) {
  104889. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  104890. }
  104891. else {
  104892. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  104893. }
  104894. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  104895. // First contact will be dedicated to the virtual joystick
  104896. this._joystickPointerID = e.pointerId;
  104897. this._joystickPointerStartPos.x = e.clientX;
  104898. this._joystickPointerStartPos.y = e.clientY;
  104899. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  104900. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  104901. this._deltaJoystickVector.x = 0;
  104902. this._deltaJoystickVector.y = 0;
  104903. this.pressed = true;
  104904. this._touches.add(e.pointerId.toString(), e);
  104905. }
  104906. else {
  104907. // You can only trigger the action buttons with a joystick declared
  104908. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  104909. this._action();
  104910. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  104911. }
  104912. }
  104913. };
  104914. VirtualJoystick.prototype._onPointerMove = function (e) {
  104915. // If the current pointer is the one associated to the joystick (first touch contact)
  104916. if (this._joystickPointerID == e.pointerId) {
  104917. this._joystickPointerPos.x = e.clientX;
  104918. this._joystickPointerPos.y = e.clientY;
  104919. this._deltaJoystickVector = this._joystickPointerPos.clone();
  104920. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  104921. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  104922. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  104923. switch (this._axisTargetedByLeftAndRight) {
  104924. case JoystickAxis.X:
  104925. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  104926. break;
  104927. case JoystickAxis.Y:
  104928. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  104929. break;
  104930. case JoystickAxis.Z:
  104931. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  104932. break;
  104933. }
  104934. var directionUpDown = this.reverseUpDown ? 1 : -1;
  104935. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  104936. switch (this._axisTargetedByUpAndDown) {
  104937. case JoystickAxis.X:
  104938. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  104939. break;
  104940. case JoystickAxis.Y:
  104941. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  104942. break;
  104943. case JoystickAxis.Z:
  104944. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  104945. break;
  104946. }
  104947. }
  104948. else {
  104949. var data = this._touches.get(e.pointerId.toString());
  104950. if (data) {
  104951. data.x = e.clientX;
  104952. data.y = e.clientY;
  104953. }
  104954. }
  104955. };
  104956. VirtualJoystick.prototype._onPointerUp = function (e) {
  104957. if (this._joystickPointerID == e.pointerId) {
  104958. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  104959. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  104960. this._joystickPointerID = -1;
  104961. this.pressed = false;
  104962. }
  104963. else {
  104964. var touch = this._touches.get(e.pointerId.toString());
  104965. if (touch) {
  104966. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  104967. }
  104968. }
  104969. this._deltaJoystickVector.x = 0;
  104970. this._deltaJoystickVector.y = 0;
  104971. this._touches.remove(e.pointerId.toString());
  104972. };
  104973. /**
  104974. * Change the color of the virtual joystick
  104975. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  104976. */
  104977. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  104978. this._joystickColor = newColor;
  104979. };
  104980. /**
  104981. * Defines a callback to call when the joystick is touched
  104982. * @param action defines the callback
  104983. */
  104984. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  104985. this._action = action;
  104986. };
  104987. /**
  104988. * Defines which axis you'd like to control for left & right
  104989. * @param axis defines the axis to use
  104990. */
  104991. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  104992. switch (axis) {
  104993. case JoystickAxis.X:
  104994. case JoystickAxis.Y:
  104995. case JoystickAxis.Z:
  104996. this._axisTargetedByLeftAndRight = axis;
  104997. break;
  104998. default:
  104999. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  105000. break;
  105001. }
  105002. };
  105003. /**
  105004. * Defines which axis you'd like to control for up & down
  105005. * @param axis defines the axis to use
  105006. */
  105007. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  105008. switch (axis) {
  105009. case JoystickAxis.X:
  105010. case JoystickAxis.Y:
  105011. case JoystickAxis.Z:
  105012. this._axisTargetedByUpAndDown = axis;
  105013. break;
  105014. default:
  105015. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  105016. break;
  105017. }
  105018. };
  105019. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  105020. var _this = this;
  105021. if (this.pressed) {
  105022. this._touches.forEach(function (key, touch) {
  105023. if (touch.pointerId === _this._joystickPointerID) {
  105024. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  105025. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  105026. VirtualJoystick.vjCanvasContext.beginPath();
  105027. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  105028. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  105029. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  105030. VirtualJoystick.vjCanvasContext.stroke();
  105031. VirtualJoystick.vjCanvasContext.closePath();
  105032. VirtualJoystick.vjCanvasContext.beginPath();
  105033. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  105034. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  105035. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  105036. VirtualJoystick.vjCanvasContext.stroke();
  105037. VirtualJoystick.vjCanvasContext.closePath();
  105038. VirtualJoystick.vjCanvasContext.beginPath();
  105039. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  105040. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  105041. VirtualJoystick.vjCanvasContext.stroke();
  105042. VirtualJoystick.vjCanvasContext.closePath();
  105043. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  105044. }
  105045. else {
  105046. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  105047. VirtualJoystick.vjCanvasContext.beginPath();
  105048. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  105049. VirtualJoystick.vjCanvasContext.beginPath();
  105050. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  105051. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  105052. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  105053. VirtualJoystick.vjCanvasContext.stroke();
  105054. VirtualJoystick.vjCanvasContext.closePath();
  105055. touch.prevX = touch.x;
  105056. touch.prevY = touch.y;
  105057. }
  105058. });
  105059. }
  105060. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  105061. };
  105062. /**
  105063. * Release internal HTML canvas
  105064. */
  105065. VirtualJoystick.prototype.releaseCanvas = function () {
  105066. if (VirtualJoystick.Canvas) {
  105067. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  105068. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  105069. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  105070. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  105071. window.removeEventListener("resize", this._onResize);
  105072. document.body.removeChild(VirtualJoystick.Canvas);
  105073. VirtualJoystick.Canvas = null;
  105074. }
  105075. };
  105076. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  105077. VirtualJoystick._globalJoystickIndex = 0;
  105078. return VirtualJoystick;
  105079. }());
  105080. /***/ }),
  105081. /***/ "./Misc/webRequest.ts":
  105082. /*!****************************!*\
  105083. !*** ./Misc/webRequest.ts ***!
  105084. \****************************/
  105085. /*! exports provided: WebRequest */
  105086. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105087. "use strict";
  105088. __webpack_require__.r(__webpack_exports__);
  105089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return WebRequest; });
  105090. /**
  105091. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  105092. */
  105093. var WebRequest = /** @class */ (function () {
  105094. function WebRequest() {
  105095. this._xhr = new XMLHttpRequest();
  105096. }
  105097. WebRequest.prototype._injectCustomRequestHeaders = function () {
  105098. for (var key in WebRequest.CustomRequestHeaders) {
  105099. var val = WebRequest.CustomRequestHeaders[key];
  105100. if (val) {
  105101. this._xhr.setRequestHeader(key, val);
  105102. }
  105103. }
  105104. };
  105105. Object.defineProperty(WebRequest.prototype, "onprogress", {
  105106. /**
  105107. * Gets or sets a function to be called when loading progress changes
  105108. */
  105109. get: function () {
  105110. return this._xhr.onprogress;
  105111. },
  105112. set: function (value) {
  105113. this._xhr.onprogress = value;
  105114. },
  105115. enumerable: true,
  105116. configurable: true
  105117. });
  105118. Object.defineProperty(WebRequest.prototype, "readyState", {
  105119. /**
  105120. * Returns client's state
  105121. */
  105122. get: function () {
  105123. return this._xhr.readyState;
  105124. },
  105125. enumerable: true,
  105126. configurable: true
  105127. });
  105128. Object.defineProperty(WebRequest.prototype, "status", {
  105129. /**
  105130. * Returns client's status
  105131. */
  105132. get: function () {
  105133. return this._xhr.status;
  105134. },
  105135. enumerable: true,
  105136. configurable: true
  105137. });
  105138. Object.defineProperty(WebRequest.prototype, "statusText", {
  105139. /**
  105140. * Returns client's status as a text
  105141. */
  105142. get: function () {
  105143. return this._xhr.statusText;
  105144. },
  105145. enumerable: true,
  105146. configurable: true
  105147. });
  105148. Object.defineProperty(WebRequest.prototype, "response", {
  105149. /**
  105150. * Returns client's response
  105151. */
  105152. get: function () {
  105153. return this._xhr.response;
  105154. },
  105155. enumerable: true,
  105156. configurable: true
  105157. });
  105158. Object.defineProperty(WebRequest.prototype, "responseURL", {
  105159. /**
  105160. * Returns client's response url
  105161. */
  105162. get: function () {
  105163. return this._xhr.responseURL;
  105164. },
  105165. enumerable: true,
  105166. configurable: true
  105167. });
  105168. Object.defineProperty(WebRequest.prototype, "responseText", {
  105169. /**
  105170. * Returns client's response as text
  105171. */
  105172. get: function () {
  105173. return this._xhr.responseText;
  105174. },
  105175. enumerable: true,
  105176. configurable: true
  105177. });
  105178. Object.defineProperty(WebRequest.prototype, "responseType", {
  105179. /**
  105180. * Gets or sets the expected response type
  105181. */
  105182. get: function () {
  105183. return this._xhr.responseType;
  105184. },
  105185. set: function (value) {
  105186. this._xhr.responseType = value;
  105187. },
  105188. enumerable: true,
  105189. configurable: true
  105190. });
  105191. WebRequest.prototype.addEventListener = function (type, listener, options) {
  105192. this._xhr.addEventListener(type, listener, options);
  105193. };
  105194. WebRequest.prototype.removeEventListener = function (type, listener, options) {
  105195. this._xhr.removeEventListener(type, listener, options);
  105196. };
  105197. /**
  105198. * Cancels any network activity
  105199. */
  105200. WebRequest.prototype.abort = function () {
  105201. this._xhr.abort();
  105202. };
  105203. /**
  105204. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  105205. * @param body defines an optional request body
  105206. */
  105207. WebRequest.prototype.send = function (body) {
  105208. if (WebRequest.CustomRequestHeaders) {
  105209. this._injectCustomRequestHeaders();
  105210. }
  105211. this._xhr.send(body);
  105212. };
  105213. /**
  105214. * Sets the request method, request URL
  105215. * @param method defines the method to use (GET, POST, etc..)
  105216. * @param url defines the url to connect with
  105217. */
  105218. WebRequest.prototype.open = function (method, url) {
  105219. for (var _i = 0, _a = WebRequest.CustomRequestModifiers; _i < _a.length; _i++) {
  105220. var update = _a[_i];
  105221. update(this._xhr);
  105222. }
  105223. return this._xhr.open(method, url, true);
  105224. };
  105225. /**
  105226. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  105227. * i.e. when loading files, where the server/service expects an Authorization header
  105228. */
  105229. WebRequest.CustomRequestHeaders = {};
  105230. /**
  105231. * Add callback functions in this array to update all the requests before they get sent to the network
  105232. */
  105233. WebRequest.CustomRequestModifiers = new Array();
  105234. return WebRequest;
  105235. }());
  105236. /***/ }),
  105237. /***/ "./Misc/workerPool.ts":
  105238. /*!****************************!*\
  105239. !*** ./Misc/workerPool.ts ***!
  105240. \****************************/
  105241. /*! exports provided: WorkerPool */
  105242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105243. "use strict";
  105244. __webpack_require__.r(__webpack_exports__);
  105245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  105246. /**
  105247. * Helper class to push actions to a pool of workers.
  105248. */
  105249. var WorkerPool = /** @class */ (function () {
  105250. /**
  105251. * Constructor
  105252. * @param workers Array of workers to use for actions
  105253. */
  105254. function WorkerPool(workers) {
  105255. this._pendingActions = new Array();
  105256. this._workerInfos = workers.map(function (worker) { return ({
  105257. worker: worker,
  105258. active: false
  105259. }); });
  105260. }
  105261. /**
  105262. * Terminates all workers and clears any pending actions.
  105263. */
  105264. WorkerPool.prototype.dispose = function () {
  105265. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  105266. var workerInfo = _a[_i];
  105267. workerInfo.worker.terminate();
  105268. }
  105269. delete this._workerInfos;
  105270. delete this._pendingActions;
  105271. };
  105272. /**
  105273. * Pushes an action to the worker pool. If all the workers are active, the action will be
  105274. * pended until a worker has completed its action.
  105275. * @param action The action to perform. Call onComplete when the action is complete.
  105276. */
  105277. WorkerPool.prototype.push = function (action) {
  105278. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  105279. var workerInfo = _a[_i];
  105280. if (!workerInfo.active) {
  105281. this._execute(workerInfo, action);
  105282. return;
  105283. }
  105284. }
  105285. this._pendingActions.push(action);
  105286. };
  105287. WorkerPool.prototype._execute = function (workerInfo, action) {
  105288. var _this = this;
  105289. workerInfo.active = true;
  105290. action(workerInfo.worker, function () {
  105291. workerInfo.active = false;
  105292. var nextAction = _this._pendingActions.shift();
  105293. if (nextAction) {
  105294. _this._execute(workerInfo, nextAction);
  105295. }
  105296. });
  105297. };
  105298. return WorkerPool;
  105299. }());
  105300. /***/ }),
  105301. /***/ "./Morph/index.ts":
  105302. /*!************************!*\
  105303. !*** ./Morph/index.ts ***!
  105304. \************************/
  105305. /*! exports provided: MorphTarget, MorphTargetManager */
  105306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105307. "use strict";
  105308. __webpack_require__.r(__webpack_exports__);
  105309. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  105310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  105311. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  105312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  105313. /***/ }),
  105314. /***/ "./Morph/morphTarget.ts":
  105315. /*!******************************!*\
  105316. !*** ./Morph/morphTarget.ts ***!
  105317. \******************************/
  105318. /*! exports provided: MorphTarget */
  105319. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105320. "use strict";
  105321. __webpack_require__.r(__webpack_exports__);
  105322. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  105323. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105324. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  105325. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105326. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  105327. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  105328. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  105329. /**
  105330. * Defines a target to use with MorphTargetManager
  105331. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105332. */
  105333. var MorphTarget = /** @class */ (function () {
  105334. /**
  105335. * Creates a new MorphTarget
  105336. * @param name defines the name of the target
  105337. * @param influence defines the influence to use
  105338. * @param scene defines the scene the morphtarget belongs to
  105339. */
  105340. function MorphTarget(
  105341. /** defines the name of the target */
  105342. name, influence, scene) {
  105343. if (influence === void 0) { influence = 0; }
  105344. if (scene === void 0) { scene = null; }
  105345. this.name = name;
  105346. /**
  105347. * Gets or sets the list of animations
  105348. */
  105349. this.animations = new Array();
  105350. this._positions = null;
  105351. this._normals = null;
  105352. this._tangents = null;
  105353. /**
  105354. * Observable raised when the influence changes
  105355. */
  105356. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  105357. /** @hidden */
  105358. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  105359. this._animationPropertiesOverride = null;
  105360. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  105361. this.influence = influence;
  105362. }
  105363. Object.defineProperty(MorphTarget.prototype, "influence", {
  105364. /**
  105365. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  105366. */
  105367. get: function () {
  105368. return this._influence;
  105369. },
  105370. set: function (influence) {
  105371. if (this._influence === influence) {
  105372. return;
  105373. }
  105374. var previous = this._influence;
  105375. this._influence = influence;
  105376. if (this.onInfluenceChanged.hasObservers) {
  105377. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  105378. }
  105379. },
  105380. enumerable: true,
  105381. configurable: true
  105382. });
  105383. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  105384. /**
  105385. * Gets or sets the animation properties override
  105386. */
  105387. get: function () {
  105388. if (!this._animationPropertiesOverride && this._scene) {
  105389. return this._scene.animationPropertiesOverride;
  105390. }
  105391. return this._animationPropertiesOverride;
  105392. },
  105393. set: function (value) {
  105394. this._animationPropertiesOverride = value;
  105395. },
  105396. enumerable: true,
  105397. configurable: true
  105398. });
  105399. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  105400. /**
  105401. * Gets a boolean defining if the target contains position data
  105402. */
  105403. get: function () {
  105404. return !!this._positions;
  105405. },
  105406. enumerable: true,
  105407. configurable: true
  105408. });
  105409. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  105410. /**
  105411. * Gets a boolean defining if the target contains normal data
  105412. */
  105413. get: function () {
  105414. return !!this._normals;
  105415. },
  105416. enumerable: true,
  105417. configurable: true
  105418. });
  105419. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  105420. /**
  105421. * Gets a boolean defining if the target contains tangent data
  105422. */
  105423. get: function () {
  105424. return !!this._tangents;
  105425. },
  105426. enumerable: true,
  105427. configurable: true
  105428. });
  105429. /**
  105430. * Affects position data to this target
  105431. * @param data defines the position data to use
  105432. */
  105433. MorphTarget.prototype.setPositions = function (data) {
  105434. var hadPositions = this.hasPositions;
  105435. this._positions = data;
  105436. if (hadPositions !== this.hasPositions) {
  105437. this._onDataLayoutChanged.notifyObservers(undefined);
  105438. }
  105439. };
  105440. /**
  105441. * Gets the position data stored in this target
  105442. * @returns a FloatArray containing the position data (or null if not present)
  105443. */
  105444. MorphTarget.prototype.getPositions = function () {
  105445. return this._positions;
  105446. };
  105447. /**
  105448. * Affects normal data to this target
  105449. * @param data defines the normal data to use
  105450. */
  105451. MorphTarget.prototype.setNormals = function (data) {
  105452. var hadNormals = this.hasNormals;
  105453. this._normals = data;
  105454. if (hadNormals !== this.hasNormals) {
  105455. this._onDataLayoutChanged.notifyObservers(undefined);
  105456. }
  105457. };
  105458. /**
  105459. * Gets the normal data stored in this target
  105460. * @returns a FloatArray containing the normal data (or null if not present)
  105461. */
  105462. MorphTarget.prototype.getNormals = function () {
  105463. return this._normals;
  105464. };
  105465. /**
  105466. * Affects tangent data to this target
  105467. * @param data defines the tangent data to use
  105468. */
  105469. MorphTarget.prototype.setTangents = function (data) {
  105470. var hadTangents = this.hasTangents;
  105471. this._tangents = data;
  105472. if (hadTangents !== this.hasTangents) {
  105473. this._onDataLayoutChanged.notifyObservers(undefined);
  105474. }
  105475. };
  105476. /**
  105477. * Gets the tangent data stored in this target
  105478. * @returns a FloatArray containing the tangent data (or null if not present)
  105479. */
  105480. MorphTarget.prototype.getTangents = function () {
  105481. return this._tangents;
  105482. };
  105483. /**
  105484. * Serializes the current target into a Serialization object
  105485. * @returns the serialized object
  105486. */
  105487. MorphTarget.prototype.serialize = function () {
  105488. var serializationObject = {};
  105489. serializationObject.name = this.name;
  105490. serializationObject.influence = this.influence;
  105491. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  105492. if (this.id != null) {
  105493. serializationObject.id = this.id;
  105494. }
  105495. if (this.hasNormals) {
  105496. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  105497. }
  105498. if (this.hasTangents) {
  105499. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  105500. }
  105501. // Animations
  105502. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  105503. return serializationObject;
  105504. };
  105505. /**
  105506. * Returns the string "MorphTarget"
  105507. * @returns "MorphTarget"
  105508. */
  105509. MorphTarget.prototype.getClassName = function () {
  105510. return "MorphTarget";
  105511. };
  105512. // Statics
  105513. /**
  105514. * Creates a new target from serialized data
  105515. * @param serializationObject defines the serialized data to use
  105516. * @returns a new MorphTarget
  105517. */
  105518. MorphTarget.Parse = function (serializationObject) {
  105519. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  105520. result.setPositions(serializationObject.positions);
  105521. if (serializationObject.id != null) {
  105522. result.id = serializationObject.id;
  105523. }
  105524. if (serializationObject.normals) {
  105525. result.setNormals(serializationObject.normals);
  105526. }
  105527. if (serializationObject.tangents) {
  105528. result.setTangents(serializationObject.tangents);
  105529. }
  105530. // Animations
  105531. if (serializationObject.animations) {
  105532. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  105533. var parsedAnimation = serializationObject.animations[animationIndex];
  105534. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  105535. if (internalClass) {
  105536. result.animations.push(internalClass.Parse(parsedAnimation));
  105537. }
  105538. }
  105539. }
  105540. return result;
  105541. };
  105542. /**
  105543. * Creates a MorphTarget from mesh data
  105544. * @param mesh defines the source mesh
  105545. * @param name defines the name to use for the new target
  105546. * @param influence defines the influence to attach to the target
  105547. * @returns a new MorphTarget
  105548. */
  105549. MorphTarget.FromMesh = function (mesh, name, influence) {
  105550. if (!name) {
  105551. name = mesh.name;
  105552. }
  105553. var result = new MorphTarget(name, influence, mesh.getScene());
  105554. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  105555. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  105556. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  105557. }
  105558. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  105559. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  105560. }
  105561. return result;
  105562. };
  105563. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  105564. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["serialize"])()
  105565. ], MorphTarget.prototype, "id", void 0);
  105566. return MorphTarget;
  105567. }());
  105568. /***/ }),
  105569. /***/ "./Morph/morphTargetManager.ts":
  105570. /*!*************************************!*\
  105571. !*** ./Morph/morphTargetManager.ts ***!
  105572. \*************************************/
  105573. /*! exports provided: MorphTargetManager */
  105574. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105575. "use strict";
  105576. __webpack_require__.r(__webpack_exports__);
  105577. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  105578. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  105579. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  105580. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105581. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  105582. /**
  105583. * This class is used to deform meshes using morphing between different targets
  105584. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105585. */
  105586. var MorphTargetManager = /** @class */ (function () {
  105587. /**
  105588. * Creates a new MorphTargetManager
  105589. * @param scene defines the current scene
  105590. */
  105591. function MorphTargetManager(scene) {
  105592. if (scene === void 0) { scene = null; }
  105593. this._targets = new Array();
  105594. this._targetInfluenceChangedObservers = new Array();
  105595. this._targetDataLayoutChangedObservers = new Array();
  105596. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  105597. this._supportsNormals = false;
  105598. this._supportsTangents = false;
  105599. this._vertexCount = 0;
  105600. this._uniqueId = 0;
  105601. this._tempInfluences = new Array();
  105602. if (!scene) {
  105603. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  105604. }
  105605. this._scene = scene;
  105606. if (this._scene) {
  105607. this._scene.morphTargetManagers.push(this);
  105608. this._uniqueId = this._scene.getUniqueId();
  105609. }
  105610. }
  105611. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  105612. /**
  105613. * Gets the unique ID of this manager
  105614. */
  105615. get: function () {
  105616. return this._uniqueId;
  105617. },
  105618. enumerable: true,
  105619. configurable: true
  105620. });
  105621. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  105622. /**
  105623. * Gets the number of vertices handled by this manager
  105624. */
  105625. get: function () {
  105626. return this._vertexCount;
  105627. },
  105628. enumerable: true,
  105629. configurable: true
  105630. });
  105631. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  105632. /**
  105633. * Gets a boolean indicating if this manager supports morphing of normals
  105634. */
  105635. get: function () {
  105636. return this._supportsNormals;
  105637. },
  105638. enumerable: true,
  105639. configurable: true
  105640. });
  105641. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  105642. /**
  105643. * Gets a boolean indicating if this manager supports morphing of tangents
  105644. */
  105645. get: function () {
  105646. return this._supportsTangents;
  105647. },
  105648. enumerable: true,
  105649. configurable: true
  105650. });
  105651. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  105652. /**
  105653. * Gets the number of targets stored in this manager
  105654. */
  105655. get: function () {
  105656. return this._targets.length;
  105657. },
  105658. enumerable: true,
  105659. configurable: true
  105660. });
  105661. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  105662. /**
  105663. * Gets the number of influencers (ie. the number of targets with influences > 0)
  105664. */
  105665. get: function () {
  105666. return this._activeTargets.length;
  105667. },
  105668. enumerable: true,
  105669. configurable: true
  105670. });
  105671. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  105672. /**
  105673. * Gets the list of influences (one per target)
  105674. */
  105675. get: function () {
  105676. return this._influences;
  105677. },
  105678. enumerable: true,
  105679. configurable: true
  105680. });
  105681. /**
  105682. * Gets the active target at specified index. An active target is a target with an influence > 0
  105683. * @param index defines the index to check
  105684. * @returns the requested target
  105685. */
  105686. MorphTargetManager.prototype.getActiveTarget = function (index) {
  105687. return this._activeTargets.data[index];
  105688. };
  105689. /**
  105690. * Gets the target at specified index
  105691. * @param index defines the index to check
  105692. * @returns the requested target
  105693. */
  105694. MorphTargetManager.prototype.getTarget = function (index) {
  105695. return this._targets[index];
  105696. };
  105697. /**
  105698. * Add a new target to this manager
  105699. * @param target defines the target to add
  105700. */
  105701. MorphTargetManager.prototype.addTarget = function (target) {
  105702. var _this = this;
  105703. this._targets.push(target);
  105704. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  105705. _this._syncActiveTargets(needUpdate);
  105706. }));
  105707. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  105708. _this._syncActiveTargets(true);
  105709. }));
  105710. this._syncActiveTargets(true);
  105711. };
  105712. /**
  105713. * Removes a target from the manager
  105714. * @param target defines the target to remove
  105715. */
  105716. MorphTargetManager.prototype.removeTarget = function (target) {
  105717. var index = this._targets.indexOf(target);
  105718. if (index >= 0) {
  105719. this._targets.splice(index, 1);
  105720. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  105721. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  105722. this._syncActiveTargets(true);
  105723. }
  105724. };
  105725. /**
  105726. * Serializes the current manager into a Serialization object
  105727. * @returns the serialized object
  105728. */
  105729. MorphTargetManager.prototype.serialize = function () {
  105730. var serializationObject = {};
  105731. serializationObject.id = this.uniqueId;
  105732. serializationObject.targets = [];
  105733. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  105734. var target = _a[_i];
  105735. serializationObject.targets.push(target.serialize());
  105736. }
  105737. return serializationObject;
  105738. };
  105739. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  105740. var influenceCount = 0;
  105741. this._activeTargets.reset();
  105742. this._supportsNormals = true;
  105743. this._supportsTangents = true;
  105744. this._vertexCount = 0;
  105745. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  105746. var target = _a[_i];
  105747. if (target.influence === 0) {
  105748. continue;
  105749. }
  105750. this._activeTargets.push(target);
  105751. this._tempInfluences[influenceCount++] = target.influence;
  105752. this._supportsNormals = this._supportsNormals && target.hasNormals;
  105753. this._supportsTangents = this._supportsTangents && target.hasTangents;
  105754. var positions = target.getPositions();
  105755. if (positions) {
  105756. var vertexCount = positions.length / 3;
  105757. if (this._vertexCount === 0) {
  105758. this._vertexCount = vertexCount;
  105759. }
  105760. else if (this._vertexCount !== vertexCount) {
  105761. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  105762. return;
  105763. }
  105764. }
  105765. }
  105766. if (!this._influences || this._influences.length !== influenceCount) {
  105767. this._influences = new Float32Array(influenceCount);
  105768. }
  105769. for (var index = 0; index < influenceCount; index++) {
  105770. this._influences[index] = this._tempInfluences[index];
  105771. }
  105772. if (needUpdate) {
  105773. this.synchronize();
  105774. }
  105775. };
  105776. /**
  105777. * Syncrhonize the targets with all the meshes using this morph target manager
  105778. */
  105779. MorphTargetManager.prototype.synchronize = function () {
  105780. if (!this._scene) {
  105781. return;
  105782. }
  105783. // Flag meshes as dirty to resync with the active targets
  105784. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  105785. var mesh = _a[_i];
  105786. if (mesh.morphTargetManager === this) {
  105787. mesh._syncGeometryWithMorphTargetManager();
  105788. }
  105789. }
  105790. };
  105791. // Statics
  105792. /**
  105793. * Creates a new MorphTargetManager from serialized data
  105794. * @param serializationObject defines the serialized data
  105795. * @param scene defines the hosting scene
  105796. * @returns the new MorphTargetManager
  105797. */
  105798. MorphTargetManager.Parse = function (serializationObject, scene) {
  105799. var result = new MorphTargetManager(scene);
  105800. result._uniqueId = serializationObject.id;
  105801. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  105802. var targetData = _a[_i];
  105803. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  105804. }
  105805. return result;
  105806. };
  105807. return MorphTargetManager;
  105808. }());
  105809. /***/ }),
  105810. /***/ "./Offline/database.ts":
  105811. /*!*****************************!*\
  105812. !*** ./Offline/database.ts ***!
  105813. \*****************************/
  105814. /*! exports provided: Database */
  105815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105816. "use strict";
  105817. __webpack_require__.r(__webpack_exports__);
  105818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  105819. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  105820. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  105821. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  105822. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  105823. /* harmony import */ var _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/webRequest */ "./Misc/webRequest.ts");
  105824. // Sets the default offline provider to Babylon.js
  105825. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  105826. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  105827. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  105828. };
  105829. /**
  105830. * Class used to enable access to IndexedDB
  105831. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  105832. */
  105833. var Database = /** @class */ (function () {
  105834. /**
  105835. * Creates a new Database
  105836. * @param urlToScene defines the url to load the scene
  105837. * @param callbackManifestChecked defines the callback to use when manifest is checked
  105838. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  105839. */
  105840. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  105841. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  105842. var _this = this;
  105843. // Handling various flavors of prefixed version of IndexedDB
  105844. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  105845. this._callbackManifestChecked = callbackManifestChecked;
  105846. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  105847. this._db = null;
  105848. this._enableSceneOffline = false;
  105849. this._enableTexturesOffline = false;
  105850. this._manifestVersionFound = 0;
  105851. this._mustUpdateRessources = false;
  105852. this._hasReachedQuota = false;
  105853. if (!Database.IDBStorageEnabled) {
  105854. this._callbackManifestChecked(true);
  105855. }
  105856. else {
  105857. if (disableManifestCheck) {
  105858. this._enableSceneOffline = true;
  105859. this._enableTexturesOffline = true;
  105860. this._manifestVersionFound = 1;
  105861. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  105862. _this._callbackManifestChecked(true);
  105863. });
  105864. }
  105865. else {
  105866. this._checkManifestFile();
  105867. }
  105868. }
  105869. }
  105870. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  105871. /**
  105872. * Gets a boolean indicating if scene must be saved in the database
  105873. */
  105874. get: function () {
  105875. return this._enableSceneOffline;
  105876. },
  105877. enumerable: true,
  105878. configurable: true
  105879. });
  105880. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  105881. /**
  105882. * Gets a boolean indicating if textures must be saved in the database
  105883. */
  105884. get: function () {
  105885. return this._enableTexturesOffline;
  105886. },
  105887. enumerable: true,
  105888. configurable: true
  105889. });
  105890. Database.prototype._checkManifestFile = function () {
  105891. var _this = this;
  105892. var noManifestFile = function () {
  105893. _this._enableSceneOffline = false;
  105894. _this._enableTexturesOffline = false;
  105895. _this._callbackManifestChecked(false);
  105896. };
  105897. var timeStampUsed = false;
  105898. var manifestURL = this._currentSceneUrl + ".manifest";
  105899. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"]();
  105900. if (navigator.onLine) {
  105901. // Adding a timestamp to by-pass browsers' cache
  105902. timeStampUsed = true;
  105903. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  105904. }
  105905. xhr.open("GET", manifestURL);
  105906. xhr.addEventListener("load", function () {
  105907. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  105908. try {
  105909. var manifestFile = JSON.parse(xhr.response);
  105910. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  105911. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  105912. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  105913. _this._manifestVersionFound = manifestFile.version;
  105914. }
  105915. if (_this._callbackManifestChecked) {
  105916. _this._callbackManifestChecked(true);
  105917. }
  105918. }
  105919. catch (ex) {
  105920. noManifestFile();
  105921. }
  105922. }
  105923. else {
  105924. noManifestFile();
  105925. }
  105926. }, false);
  105927. xhr.addEventListener("error", function () {
  105928. if (timeStampUsed) {
  105929. timeStampUsed = false;
  105930. // Let's retry without the timeStamp
  105931. // It could fail when coupled with HTML5 Offline API
  105932. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  105933. xhr.open("GET", retryManifestURL);
  105934. xhr.send();
  105935. }
  105936. else {
  105937. noManifestFile();
  105938. }
  105939. }, false);
  105940. try {
  105941. xhr.send();
  105942. }
  105943. catch (ex) {
  105944. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  105945. this._callbackManifestChecked(false);
  105946. }
  105947. };
  105948. /**
  105949. * Open the database and make it available
  105950. * @param successCallback defines the callback to call on success
  105951. * @param errorCallback defines the callback to call on error
  105952. */
  105953. Database.prototype.open = function (successCallback, errorCallback) {
  105954. var _this = this;
  105955. var handleError = function () {
  105956. _this._isSupported = false;
  105957. if (errorCallback) {
  105958. errorCallback();
  105959. }
  105960. };
  105961. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  105962. // Your browser doesn't support IndexedDB
  105963. this._isSupported = false;
  105964. if (errorCallback) {
  105965. errorCallback();
  105966. }
  105967. }
  105968. else {
  105969. // If the DB hasn't been opened or created yet
  105970. if (!this._db) {
  105971. this._hasReachedQuota = false;
  105972. this._isSupported = true;
  105973. var request = this._idbFactory.open("babylonjs", 1);
  105974. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  105975. request.onerror = function () {
  105976. handleError();
  105977. };
  105978. // executes when a version change transaction cannot complete due to other active transactions
  105979. request.onblocked = function () {
  105980. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  105981. handleError();
  105982. };
  105983. // DB has been opened successfully
  105984. request.onsuccess = function () {
  105985. _this._db = request.result;
  105986. successCallback();
  105987. };
  105988. // Initialization of the DB. Creating Scenes & Textures stores
  105989. request.onupgradeneeded = function (event) {
  105990. _this._db = (event.target).result;
  105991. if (_this._db) {
  105992. try {
  105993. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  105994. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  105995. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  105996. }
  105997. catch (ex) {
  105998. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  105999. handleError();
  106000. }
  106001. }
  106002. };
  106003. }
  106004. // DB has already been created and opened
  106005. else {
  106006. if (successCallback) {
  106007. successCallback();
  106008. }
  106009. }
  106010. }
  106011. };
  106012. /**
  106013. * Loads an image from the database
  106014. * @param url defines the url to load from
  106015. * @param image defines the target DOM image
  106016. */
  106017. Database.prototype.loadImage = function (url, image) {
  106018. var _this = this;
  106019. var completeURL = Database._ReturnFullUrlLocation(url);
  106020. var saveAndLoadImage = function () {
  106021. if (!_this._hasReachedQuota && _this._db !== null) {
  106022. // the texture is not yet in the DB, let's try to save it
  106023. _this._saveImageIntoDBAsync(completeURL, image);
  106024. }
  106025. // If the texture is not in the DB and we've reached the DB quota limit
  106026. // let's load it directly from the web
  106027. else {
  106028. image.src = url;
  106029. }
  106030. };
  106031. if (!this._mustUpdateRessources) {
  106032. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  106033. }
  106034. // First time we're download the images or update requested in the manifest file by a version change
  106035. else {
  106036. saveAndLoadImage();
  106037. }
  106038. };
  106039. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  106040. if (this._isSupported && this._db !== null) {
  106041. var texture;
  106042. var transaction = this._db.transaction(["textures"]);
  106043. transaction.onabort = function () {
  106044. image.src = url;
  106045. };
  106046. transaction.oncomplete = function () {
  106047. var blobTextureURL;
  106048. if (texture) {
  106049. var URL = window.URL || window.webkitURL;
  106050. blobTextureURL = URL.createObjectURL(texture.data);
  106051. image.onerror = function () {
  106052. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  106053. image.src = url;
  106054. };
  106055. image.src = blobTextureURL;
  106056. }
  106057. else {
  106058. notInDBCallback();
  106059. }
  106060. };
  106061. var getRequest = transaction.objectStore("textures").get(url);
  106062. getRequest.onsuccess = function (event) {
  106063. texture = (event.target).result;
  106064. };
  106065. getRequest.onerror = function () {
  106066. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  106067. image.src = url;
  106068. };
  106069. }
  106070. else {
  106071. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  106072. image.src = url;
  106073. }
  106074. };
  106075. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  106076. var _this = this;
  106077. if (this._isSupported) {
  106078. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  106079. var generateBlobUrl = function () {
  106080. var blobTextureURL;
  106081. if (blob) {
  106082. var URL = window.URL || window.webkitURL;
  106083. try {
  106084. blobTextureURL = URL.createObjectURL(blob);
  106085. }
  106086. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  106087. catch (ex) {
  106088. blobTextureURL = URL.createObjectURL(blob);
  106089. }
  106090. }
  106091. if (blobTextureURL) {
  106092. image.src = blobTextureURL;
  106093. }
  106094. };
  106095. if (Database.IsUASupportingBlobStorage) { // Create XHR
  106096. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"](), blob;
  106097. xhr.open("GET", url);
  106098. xhr.responseType = "blob";
  106099. xhr.addEventListener("load", function () {
  106100. if (xhr.status === 200 && _this._db) {
  106101. // Blob as response (XHR2)
  106102. blob = xhr.response;
  106103. var transaction = _this._db.transaction(["textures"], "readwrite");
  106104. // the transaction could abort because of a QuotaExceededError error
  106105. transaction.onabort = function (event) {
  106106. try {
  106107. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  106108. var srcElement = (event.srcElement || event.target);
  106109. var error = srcElement.error;
  106110. if (error && error.name === "QuotaExceededError") {
  106111. _this._hasReachedQuota = true;
  106112. }
  106113. }
  106114. catch (ex) { }
  106115. generateBlobUrl();
  106116. };
  106117. transaction.oncomplete = function () {
  106118. generateBlobUrl();
  106119. };
  106120. var newTexture = { textureUrl: url, data: blob };
  106121. try {
  106122. // Put the blob into the dabase
  106123. var addRequest = transaction.objectStore("textures").put(newTexture);
  106124. addRequest.onsuccess = function () {
  106125. };
  106126. addRequest.onerror = function () {
  106127. generateBlobUrl();
  106128. };
  106129. }
  106130. catch (ex) {
  106131. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  106132. if (ex.code === 25) {
  106133. Database.IsUASupportingBlobStorage = false;
  106134. _this._enableTexturesOffline = false;
  106135. }
  106136. image.src = url;
  106137. }
  106138. }
  106139. else {
  106140. image.src = url;
  106141. }
  106142. }, false);
  106143. xhr.addEventListener("error", function () {
  106144. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  106145. image.src = url;
  106146. }, false);
  106147. xhr.send();
  106148. }
  106149. else {
  106150. image.src = url;
  106151. }
  106152. }
  106153. else {
  106154. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  106155. image.src = url;
  106156. }
  106157. };
  106158. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  106159. var _this = this;
  106160. var updateVersion = function () {
  106161. // the version is not yet in the DB or we need to update it
  106162. _this._saveVersionIntoDBAsync(url, versionLoaded);
  106163. };
  106164. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  106165. };
  106166. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  106167. var _this = this;
  106168. if (this._isSupported && this._db) {
  106169. var version;
  106170. try {
  106171. var transaction = this._db.transaction(["versions"]);
  106172. transaction.oncomplete = function () {
  106173. if (version) {
  106174. // If the version in the JSON file is different from the version in DB
  106175. if (_this._manifestVersionFound !== version.data) {
  106176. _this._mustUpdateRessources = true;
  106177. updateInDBCallback();
  106178. }
  106179. else {
  106180. callback(version.data);
  106181. }
  106182. }
  106183. // version was not found in DB
  106184. else {
  106185. _this._mustUpdateRessources = true;
  106186. updateInDBCallback();
  106187. }
  106188. };
  106189. transaction.onabort = function () {
  106190. callback(-1);
  106191. };
  106192. var getRequest = transaction.objectStore("versions").get(url);
  106193. getRequest.onsuccess = function (event) {
  106194. version = (event.target).result;
  106195. };
  106196. getRequest.onerror = function () {
  106197. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  106198. callback(-1);
  106199. };
  106200. }
  106201. catch (ex) {
  106202. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  106203. callback(-1);
  106204. }
  106205. }
  106206. else {
  106207. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  106208. callback(-1);
  106209. }
  106210. };
  106211. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  106212. var _this = this;
  106213. if (this._isSupported && !this._hasReachedQuota && this._db) {
  106214. try {
  106215. // Open a transaction to the database
  106216. var transaction = this._db.transaction(["versions"], "readwrite");
  106217. // the transaction could abort because of a QuotaExceededError error
  106218. transaction.onabort = function (event) {
  106219. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  106220. var error = event.srcElement['error'];
  106221. if (error && error.name === "QuotaExceededError") {
  106222. _this._hasReachedQuota = true;
  106223. }
  106224. }
  106225. catch (ex) { }
  106226. callback(-1);
  106227. };
  106228. transaction.oncomplete = function () {
  106229. callback(_this._manifestVersionFound);
  106230. };
  106231. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  106232. // Put the scene into the database
  106233. var addRequest = transaction.objectStore("versions").put(newVersion);
  106234. addRequest.onsuccess = function () {
  106235. };
  106236. addRequest.onerror = function () {
  106237. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  106238. };
  106239. }
  106240. catch (ex) {
  106241. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  106242. callback(-1);
  106243. }
  106244. }
  106245. else {
  106246. callback(-1);
  106247. }
  106248. };
  106249. /**
  106250. * Loads a file from database
  106251. * @param url defines the URL to load from
  106252. * @param sceneLoaded defines a callback to call on success
  106253. * @param progressCallBack defines a callback to call when progress changed
  106254. * @param errorCallback defines a callback to call on error
  106255. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  106256. */
  106257. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  106258. var _this = this;
  106259. var completeUrl = Database._ReturnFullUrlLocation(url);
  106260. var saveAndLoadFile = function () {
  106261. // the scene is not yet in the DB, let's try to save it
  106262. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  106263. };
  106264. this._checkVersionFromDB(completeUrl, function (version) {
  106265. if (version !== -1) {
  106266. if (!_this._mustUpdateRessources) {
  106267. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  106268. }
  106269. else {
  106270. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  106271. }
  106272. }
  106273. else {
  106274. if (errorCallback) {
  106275. errorCallback();
  106276. }
  106277. }
  106278. });
  106279. };
  106280. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  106281. if (this._isSupported && this._db) {
  106282. var targetStore;
  106283. if (url.indexOf(".babylon") !== -1) {
  106284. targetStore = "scenes";
  106285. }
  106286. else {
  106287. targetStore = "textures";
  106288. }
  106289. var file;
  106290. var transaction = this._db.transaction([targetStore]);
  106291. transaction.oncomplete = function () {
  106292. if (file) {
  106293. callback(file.data);
  106294. }
  106295. // file was not found in DB
  106296. else {
  106297. notInDBCallback();
  106298. }
  106299. };
  106300. transaction.onabort = function () {
  106301. notInDBCallback();
  106302. };
  106303. var getRequest = transaction.objectStore(targetStore).get(url);
  106304. getRequest.onsuccess = function (event) {
  106305. file = (event.target).result;
  106306. };
  106307. getRequest.onerror = function () {
  106308. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  106309. notInDBCallback();
  106310. };
  106311. }
  106312. else {
  106313. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  106314. callback();
  106315. }
  106316. };
  106317. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  106318. var _this = this;
  106319. if (this._isSupported) {
  106320. var targetStore;
  106321. if (url.indexOf(".babylon") !== -1) {
  106322. targetStore = "scenes";
  106323. }
  106324. else {
  106325. targetStore = "textures";
  106326. }
  106327. // Create XHR
  106328. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"]();
  106329. var fileData;
  106330. xhr.open("GET", url + "?" + Date.now());
  106331. if (useArrayBuffer) {
  106332. xhr.responseType = "arraybuffer";
  106333. }
  106334. if (progressCallback) {
  106335. xhr.onprogress = progressCallback;
  106336. }
  106337. xhr.addEventListener("load", function () {
  106338. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  106339. // Blob as response (XHR2)
  106340. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  106341. if (!_this._hasReachedQuota && _this._db) {
  106342. // Open a transaction to the database
  106343. var transaction = _this._db.transaction([targetStore], "readwrite");
  106344. // the transaction could abort because of a QuotaExceededError error
  106345. transaction.onabort = function (event) {
  106346. try {
  106347. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  106348. var error = event.srcElement['error'];
  106349. if (error && error.name === "QuotaExceededError") {
  106350. _this._hasReachedQuota = true;
  106351. }
  106352. }
  106353. catch (ex) { }
  106354. callback(fileData);
  106355. };
  106356. transaction.oncomplete = function () {
  106357. callback(fileData);
  106358. };
  106359. var newFile;
  106360. if (targetStore === "scenes") {
  106361. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  106362. }
  106363. else {
  106364. newFile = { textureUrl: url, data: fileData };
  106365. }
  106366. try {
  106367. // Put the scene into the database
  106368. var addRequest = transaction.objectStore(targetStore).put(newFile);
  106369. addRequest.onsuccess = function () {
  106370. };
  106371. addRequest.onerror = function () {
  106372. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  106373. };
  106374. }
  106375. catch (ex) {
  106376. callback(fileData);
  106377. }
  106378. }
  106379. else {
  106380. callback(fileData);
  106381. }
  106382. }
  106383. else {
  106384. if (xhr.status >= 400 && errorCallback) {
  106385. errorCallback(xhr);
  106386. }
  106387. else {
  106388. callback();
  106389. }
  106390. }
  106391. }, false);
  106392. xhr.addEventListener("error", function () {
  106393. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  106394. callback();
  106395. }, false);
  106396. xhr.send();
  106397. }
  106398. else {
  106399. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  106400. callback();
  106401. }
  106402. };
  106403. /**
  106404. * Validates if xhr data is correct
  106405. * @param xhr defines the request to validate
  106406. * @param dataType defines the expected data type
  106407. * @returns true if data is correct
  106408. */
  106409. Database._ValidateXHRData = function (xhr, dataType) {
  106410. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  106411. if (dataType === void 0) { dataType = 7; }
  106412. try {
  106413. if (dataType & 1) {
  106414. if (xhr.responseText && xhr.responseText.length > 0) {
  106415. return true;
  106416. }
  106417. else if (dataType === 1) {
  106418. return false;
  106419. }
  106420. }
  106421. if (dataType & 2) {
  106422. // Check header width and height since there is no "TGA" magic number
  106423. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  106424. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  106425. return true;
  106426. }
  106427. else if (dataType === 2) {
  106428. return false;
  106429. }
  106430. }
  106431. if (dataType & 4) {
  106432. // Check for the "DDS" magic number
  106433. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  106434. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  106435. return true;
  106436. }
  106437. else {
  106438. return false;
  106439. }
  106440. }
  106441. }
  106442. catch (e) {
  106443. // Global protection
  106444. }
  106445. return false;
  106446. };
  106447. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  106448. Database.IsUASupportingBlobStorage = true;
  106449. /**
  106450. * Gets a boolean indicating if Database storate is enabled (off by default)
  106451. */
  106452. Database.IDBStorageEnabled = false;
  106453. Database._ParseURL = function (url) {
  106454. var a = document.createElement('a');
  106455. a.href = url;
  106456. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  106457. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  106458. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  106459. return absLocation;
  106460. };
  106461. Database._ReturnFullUrlLocation = function (url) {
  106462. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  106463. return (Database._ParseURL(window.location.href) + url);
  106464. }
  106465. else {
  106466. return url;
  106467. }
  106468. };
  106469. return Database;
  106470. }());
  106471. /***/ }),
  106472. /***/ "./Offline/index.ts":
  106473. /*!**************************!*\
  106474. !*** ./Offline/index.ts ***!
  106475. \**************************/
  106476. /*! exports provided: Database */
  106477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106478. "use strict";
  106479. __webpack_require__.r(__webpack_exports__);
  106480. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  106481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  106482. /***/ }),
  106483. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  106484. /*!******************************************************!*\
  106485. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  106486. \******************************************************/
  106487. /*! exports provided: BoxParticleEmitter */
  106488. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106489. "use strict";
  106490. __webpack_require__.r(__webpack_exports__);
  106491. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  106492. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  106493. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  106494. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106495. /**
  106496. * Particle emitter emitting particles from the inside of a box.
  106497. * It emits the particles randomly between 2 given directions.
  106498. */
  106499. var BoxParticleEmitter = /** @class */ (function () {
  106500. /**
  106501. * Creates a new instance BoxParticleEmitter
  106502. */
  106503. function BoxParticleEmitter() {
  106504. /**
  106505. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  106506. */
  106507. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  106508. /**
  106509. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  106510. */
  106511. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  106512. /**
  106513. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  106514. */
  106515. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  106516. /**
  106517. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  106518. */
  106519. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  106520. }
  106521. /**
  106522. * Called by the particle System when the direction is computed for the created particle.
  106523. * @param worldMatrix is the world matrix of the particle system
  106524. * @param directionToUpdate is the direction vector to update with the result
  106525. * @param particle is the particle we are computed the direction for
  106526. */
  106527. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  106528. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  106529. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  106530. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  106531. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  106532. };
  106533. /**
  106534. * Called by the particle System when the position is computed for the created particle.
  106535. * @param worldMatrix is the world matrix of the particle system
  106536. * @param positionToUpdate is the position vector to update with the result
  106537. * @param particle is the particle we are computed the position for
  106538. */
  106539. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  106540. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  106541. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  106542. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  106543. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  106544. };
  106545. /**
  106546. * Clones the current emitter and returns a copy of it
  106547. * @returns the new emitter
  106548. */
  106549. BoxParticleEmitter.prototype.clone = function () {
  106550. var newOne = new BoxParticleEmitter();
  106551. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  106552. return newOne;
  106553. };
  106554. /**
  106555. * Called by the GPUParticleSystem to setup the update shader
  106556. * @param effect defines the update shader
  106557. */
  106558. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  106559. effect.setVector3("direction1", this.direction1);
  106560. effect.setVector3("direction2", this.direction2);
  106561. effect.setVector3("minEmitBox", this.minEmitBox);
  106562. effect.setVector3("maxEmitBox", this.maxEmitBox);
  106563. };
  106564. /**
  106565. * Returns a string to use to update the GPU particles update shader
  106566. * @returns a string containng the defines string
  106567. */
  106568. BoxParticleEmitter.prototype.getEffectDefines = function () {
  106569. return "#define BOXEMITTER";
  106570. };
  106571. /**
  106572. * Returns the string "BoxParticleEmitter"
  106573. * @returns a string containing the class name
  106574. */
  106575. BoxParticleEmitter.prototype.getClassName = function () {
  106576. return "BoxParticleEmitter";
  106577. };
  106578. /**
  106579. * Serializes the particle system to a JSON object.
  106580. * @returns the JSON object
  106581. */
  106582. BoxParticleEmitter.prototype.serialize = function () {
  106583. var serializationObject = {};
  106584. serializationObject.type = this.getClassName();
  106585. serializationObject.direction1 = this.direction1.asArray();
  106586. serializationObject.direction2 = this.direction2.asArray();
  106587. serializationObject.minEmitBox = this.minEmitBox.asArray();
  106588. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  106589. return serializationObject;
  106590. };
  106591. /**
  106592. * Parse properties from a JSON object
  106593. * @param serializationObject defines the JSON object
  106594. */
  106595. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  106596. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  106597. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  106598. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  106599. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  106600. };
  106601. return BoxParticleEmitter;
  106602. }());
  106603. /***/ }),
  106604. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  106605. /*!*******************************************************!*\
  106606. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  106607. \*******************************************************/
  106608. /*! exports provided: ConeParticleEmitter */
  106609. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106610. "use strict";
  106611. __webpack_require__.r(__webpack_exports__);
  106612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  106613. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  106614. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  106615. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106616. /**
  106617. * Particle emitter emitting particles from the inside of a cone.
  106618. * It emits the particles alongside the cone volume from the base to the particle.
  106619. * The emission direction might be randomized.
  106620. */
  106621. var ConeParticleEmitter = /** @class */ (function () {
  106622. /**
  106623. * Creates a new instance ConeParticleEmitter
  106624. * @param radius the radius of the emission cone (1 by default)
  106625. * @param angle the cone base angle (PI by default)
  106626. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  106627. */
  106628. function ConeParticleEmitter(radius, angle,
  106629. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  106630. directionRandomizer) {
  106631. if (radius === void 0) { radius = 1; }
  106632. if (angle === void 0) { angle = Math.PI; }
  106633. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  106634. this.directionRandomizer = directionRandomizer;
  106635. /**
  106636. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  106637. */
  106638. this.radiusRange = 1;
  106639. /**
  106640. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  106641. */
  106642. this.heightRange = 1;
  106643. /**
  106644. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  106645. */
  106646. this.emitFromSpawnPointOnly = false;
  106647. this.angle = angle;
  106648. this.radius = radius;
  106649. }
  106650. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  106651. /**
  106652. * Gets or sets the radius of the emission cone
  106653. */
  106654. get: function () {
  106655. return this._radius;
  106656. },
  106657. set: function (value) {
  106658. this._radius = value;
  106659. this._buildHeight();
  106660. },
  106661. enumerable: true,
  106662. configurable: true
  106663. });
  106664. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  106665. /**
  106666. * Gets or sets the angle of the emission cone
  106667. */
  106668. get: function () {
  106669. return this._angle;
  106670. },
  106671. set: function (value) {
  106672. this._angle = value;
  106673. this._buildHeight();
  106674. },
  106675. enumerable: true,
  106676. configurable: true
  106677. });
  106678. ConeParticleEmitter.prototype._buildHeight = function () {
  106679. if (this._angle !== 0) {
  106680. this._height = this._radius / Math.tan(this._angle / 2);
  106681. }
  106682. else {
  106683. this._height = 1;
  106684. }
  106685. };
  106686. /**
  106687. * Called by the particle System when the direction is computed for the created particle.
  106688. * @param worldMatrix is the world matrix of the particle system
  106689. * @param directionToUpdate is the direction vector to update with the result
  106690. * @param particle is the particle we are computed the direction for
  106691. */
  106692. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  106693. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  106694. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  106695. }
  106696. else {
  106697. // measure the direction Vector from the emitter to the particle.
  106698. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  106699. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  106700. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  106701. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  106702. direction.x += randX;
  106703. direction.y += randY;
  106704. direction.z += randZ;
  106705. direction.normalize();
  106706. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  106707. }
  106708. };
  106709. /**
  106710. * Called by the particle System when the position is computed for the created particle.
  106711. * @param worldMatrix is the world matrix of the particle system
  106712. * @param positionToUpdate is the position vector to update with the result
  106713. * @param particle is the particle we are computed the position for
  106714. */
  106715. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  106716. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  106717. var h;
  106718. if (!this.emitFromSpawnPointOnly) {
  106719. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  106720. // Better distribution in a cone at normal angles.
  106721. h = 1 - h * h;
  106722. }
  106723. else {
  106724. h = 0.0001;
  106725. }
  106726. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  106727. radius = radius * h;
  106728. var randX = radius * Math.sin(s);
  106729. var randZ = radius * Math.cos(s);
  106730. var randY = h * this._height;
  106731. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  106732. };
  106733. /**
  106734. * Clones the current emitter and returns a copy of it
  106735. * @returns the new emitter
  106736. */
  106737. ConeParticleEmitter.prototype.clone = function () {
  106738. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  106739. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  106740. return newOne;
  106741. };
  106742. /**
  106743. * Called by the GPUParticleSystem to setup the update shader
  106744. * @param effect defines the update shader
  106745. */
  106746. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  106747. effect.setFloat2("radius", this._radius, this.radiusRange);
  106748. effect.setFloat("coneAngle", this._angle);
  106749. effect.setFloat2("height", this._height, this.heightRange);
  106750. effect.setFloat("directionRandomizer", this.directionRandomizer);
  106751. };
  106752. /**
  106753. * Returns a string to use to update the GPU particles update shader
  106754. * @returns a string containng the defines string
  106755. */
  106756. ConeParticleEmitter.prototype.getEffectDefines = function () {
  106757. var defines = "#define CONEEMITTER";
  106758. if (this.emitFromSpawnPointOnly) {
  106759. defines += "\n#define CONEEMITTERSPAWNPOINT";
  106760. }
  106761. return defines;
  106762. };
  106763. /**
  106764. * Returns the string "ConeParticleEmitter"
  106765. * @returns a string containing the class name
  106766. */
  106767. ConeParticleEmitter.prototype.getClassName = function () {
  106768. return "ConeParticleEmitter";
  106769. };
  106770. /**
  106771. * Serializes the particle system to a JSON object.
  106772. * @returns the JSON object
  106773. */
  106774. ConeParticleEmitter.prototype.serialize = function () {
  106775. var serializationObject = {};
  106776. serializationObject.type = this.getClassName();
  106777. serializationObject.radius = this._radius;
  106778. serializationObject.angle = this._angle;
  106779. serializationObject.directionRandomizer = this.directionRandomizer;
  106780. return serializationObject;
  106781. };
  106782. /**
  106783. * Parse properties from a JSON object
  106784. * @param serializationObject defines the JSON object
  106785. */
  106786. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  106787. this.radius = serializationObject.radius;
  106788. this.angle = serializationObject.angle;
  106789. this.directionRandomizer = serializationObject.directionRandomizer;
  106790. };
  106791. return ConeParticleEmitter;
  106792. }());
  106793. /***/ }),
  106794. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  106795. /*!***********************************************************!*\
  106796. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  106797. \***********************************************************/
  106798. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  106799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106800. "use strict";
  106801. __webpack_require__.r(__webpack_exports__);
  106802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  106803. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  106804. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  106805. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  106806. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106807. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  106808. /**
  106809. * Particle emitter emitting particles from the inside of a cylinder.
  106810. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  106811. */
  106812. var CylinderParticleEmitter = /** @class */ (function () {
  106813. /**
  106814. * Creates a new instance CylinderParticleEmitter
  106815. * @param radius the radius of the emission cylinder (1 by default)
  106816. * @param height the height of the emission cylinder (1 by default)
  106817. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  106818. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  106819. */
  106820. function CylinderParticleEmitter(
  106821. /**
  106822. * The radius of the emission cylinder.
  106823. */
  106824. radius,
  106825. /**
  106826. * The height of the emission cylinder.
  106827. */
  106828. height,
  106829. /**
  106830. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  106831. */
  106832. radiusRange,
  106833. /**
  106834. * How much to randomize the particle direction [0-1].
  106835. */
  106836. directionRandomizer) {
  106837. if (radius === void 0) { radius = 1; }
  106838. if (height === void 0) { height = 1; }
  106839. if (radiusRange === void 0) { radiusRange = 1; }
  106840. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  106841. this.radius = radius;
  106842. this.height = height;
  106843. this.radiusRange = radiusRange;
  106844. this.directionRandomizer = directionRandomizer;
  106845. }
  106846. /**
  106847. * Called by the particle System when the direction is computed for the created particle.
  106848. * @param worldMatrix is the world matrix of the particle system
  106849. * @param directionToUpdate is the direction vector to update with the result
  106850. * @param particle is the particle we are computed the direction for
  106851. */
  106852. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  106853. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  106854. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  106855. var angle = Math.atan2(direction.x, direction.z);
  106856. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  106857. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  106858. direction.x = Math.sin(angle);
  106859. direction.z = Math.cos(angle);
  106860. direction.normalize();
  106861. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  106862. };
  106863. /**
  106864. * Called by the particle System when the position is computed for the created particle.
  106865. * @param worldMatrix is the world matrix of the particle system
  106866. * @param positionToUpdate is the position vector to update with the result
  106867. * @param particle is the particle we are computed the position for
  106868. */
  106869. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  106870. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  106871. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  106872. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  106873. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  106874. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  106875. var xPos = positionRadius * Math.cos(angle);
  106876. var zPos = positionRadius * Math.sin(angle);
  106877. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  106878. };
  106879. /**
  106880. * Clones the current emitter and returns a copy of it
  106881. * @returns the new emitter
  106882. */
  106883. CylinderParticleEmitter.prototype.clone = function () {
  106884. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  106885. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  106886. return newOne;
  106887. };
  106888. /**
  106889. * Called by the GPUParticleSystem to setup the update shader
  106890. * @param effect defines the update shader
  106891. */
  106892. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  106893. effect.setFloat("radius", this.radius);
  106894. effect.setFloat("height", this.height);
  106895. effect.setFloat("radiusRange", this.radiusRange);
  106896. effect.setFloat("directionRandomizer", this.directionRandomizer);
  106897. };
  106898. /**
  106899. * Returns a string to use to update the GPU particles update shader
  106900. * @returns a string containng the defines string
  106901. */
  106902. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  106903. return "#define CYLINDEREMITTER";
  106904. };
  106905. /**
  106906. * Returns the string "CylinderParticleEmitter"
  106907. * @returns a string containing the class name
  106908. */
  106909. CylinderParticleEmitter.prototype.getClassName = function () {
  106910. return "CylinderParticleEmitter";
  106911. };
  106912. /**
  106913. * Serializes the particle system to a JSON object.
  106914. * @returns the JSON object
  106915. */
  106916. CylinderParticleEmitter.prototype.serialize = function () {
  106917. var serializationObject = {};
  106918. serializationObject.type = this.getClassName();
  106919. serializationObject.radius = this.radius;
  106920. serializationObject.height = this.height;
  106921. serializationObject.radiusRange = this.radiusRange;
  106922. serializationObject.directionRandomizer = this.directionRandomizer;
  106923. return serializationObject;
  106924. };
  106925. /**
  106926. * Parse properties from a JSON object
  106927. * @param serializationObject defines the JSON object
  106928. */
  106929. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  106930. this.radius = serializationObject.radius;
  106931. this.height = serializationObject.height;
  106932. this.radiusRange = serializationObject.radiusRange;
  106933. this.directionRandomizer = serializationObject.directionRandomizer;
  106934. };
  106935. return CylinderParticleEmitter;
  106936. }());
  106937. /**
  106938. * Particle emitter emitting particles from the inside of a cylinder.
  106939. * It emits the particles randomly between two vectors.
  106940. */
  106941. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  106942. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  106943. /**
  106944. * Creates a new instance CylinderDirectedParticleEmitter
  106945. * @param radius the radius of the emission cylinder (1 by default)
  106946. * @param height the height of the emission cylinder (1 by default)
  106947. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  106948. * @param direction1 the min limit of the emission direction (up vector by default)
  106949. * @param direction2 the max limit of the emission direction (up vector by default)
  106950. */
  106951. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  106952. /**
  106953. * The min limit of the emission direction.
  106954. */
  106955. direction1,
  106956. /**
  106957. * The max limit of the emission direction.
  106958. */
  106959. direction2) {
  106960. if (radius === void 0) { radius = 1; }
  106961. if (height === void 0) { height = 1; }
  106962. if (radiusRange === void 0) { radiusRange = 1; }
  106963. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  106964. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  106965. var _this = _super.call(this, radius, height, radiusRange) || this;
  106966. _this.direction1 = direction1;
  106967. _this.direction2 = direction2;
  106968. return _this;
  106969. }
  106970. /**
  106971. * Called by the particle System when the direction is computed for the created particle.
  106972. * @param worldMatrix is the world matrix of the particle system
  106973. * @param directionToUpdate is the direction vector to update with the result
  106974. * @param particle is the particle we are computed the direction for
  106975. */
  106976. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  106977. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  106978. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  106979. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  106980. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  106981. };
  106982. /**
  106983. * Clones the current emitter and returns a copy of it
  106984. * @returns the new emitter
  106985. */
  106986. CylinderDirectedParticleEmitter.prototype.clone = function () {
  106987. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  106988. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  106989. return newOne;
  106990. };
  106991. /**
  106992. * Called by the GPUParticleSystem to setup the update shader
  106993. * @param effect defines the update shader
  106994. */
  106995. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  106996. effect.setFloat("radius", this.radius);
  106997. effect.setFloat("height", this.height);
  106998. effect.setFloat("radiusRange", this.radiusRange);
  106999. effect.setVector3("direction1", this.direction1);
  107000. effect.setVector3("direction2", this.direction2);
  107001. };
  107002. /**
  107003. * Returns a string to use to update the GPU particles update shader
  107004. * @returns a string containng the defines string
  107005. */
  107006. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  107007. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  107008. };
  107009. /**
  107010. * Returns the string "CylinderDirectedParticleEmitter"
  107011. * @returns a string containing the class name
  107012. */
  107013. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  107014. return "CylinderDirectedParticleEmitter";
  107015. };
  107016. /**
  107017. * Serializes the particle system to a JSON object.
  107018. * @returns the JSON object
  107019. */
  107020. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  107021. var serializationObject = _super.prototype.serialize.call(this);
  107022. serializationObject.direction1 = this.direction1.asArray();
  107023. serializationObject.direction2 = this.direction2.asArray();
  107024. return serializationObject;
  107025. };
  107026. /**
  107027. * Parse properties from a JSON object
  107028. * @param serializationObject defines the JSON object
  107029. */
  107030. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  107031. _super.prototype.parse.call(this, serializationObject);
  107032. this.direction1.copyFrom(serializationObject.direction1);
  107033. this.direction2.copyFrom(serializationObject.direction2);
  107034. };
  107035. return CylinderDirectedParticleEmitter;
  107036. }(CylinderParticleEmitter));
  107037. /***/ }),
  107038. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  107039. /*!**************************************************************!*\
  107040. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  107041. \**************************************************************/
  107042. /*! exports provided: HemisphericParticleEmitter */
  107043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107044. "use strict";
  107045. __webpack_require__.r(__webpack_exports__);
  107046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  107047. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  107048. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  107049. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  107050. /**
  107051. * Particle emitter emitting particles from the inside of a hemisphere.
  107052. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  107053. */
  107054. var HemisphericParticleEmitter = /** @class */ (function () {
  107055. /**
  107056. * Creates a new instance HemisphericParticleEmitter
  107057. * @param radius the radius of the emission hemisphere (1 by default)
  107058. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  107059. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  107060. */
  107061. function HemisphericParticleEmitter(
  107062. /**
  107063. * The radius of the emission hemisphere.
  107064. */
  107065. radius,
  107066. /**
  107067. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  107068. */
  107069. radiusRange,
  107070. /**
  107071. * How much to randomize the particle direction [0-1].
  107072. */
  107073. directionRandomizer) {
  107074. if (radius === void 0) { radius = 1; }
  107075. if (radiusRange === void 0) { radiusRange = 1; }
  107076. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  107077. this.radius = radius;
  107078. this.radiusRange = radiusRange;
  107079. this.directionRandomizer = directionRandomizer;
  107080. }
  107081. /**
  107082. * Called by the particle System when the direction is computed for the created particle.
  107083. * @param worldMatrix is the world matrix of the particle system
  107084. * @param directionToUpdate is the direction vector to update with the result
  107085. * @param particle is the particle we are computed the direction for
  107086. */
  107087. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  107088. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  107089. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107090. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107091. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107092. direction.x += randX;
  107093. direction.y += randY;
  107094. direction.z += randZ;
  107095. direction.normalize();
  107096. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  107097. };
  107098. /**
  107099. * Called by the particle System when the position is computed for the created particle.
  107100. * @param worldMatrix is the world matrix of the particle system
  107101. * @param positionToUpdate is the position vector to update with the result
  107102. * @param particle is the particle we are computed the position for
  107103. */
  107104. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  107105. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  107106. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  107107. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  107108. var theta = Math.acos(2 * v - 1);
  107109. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  107110. var randY = randRadius * Math.cos(theta);
  107111. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  107112. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  107113. };
  107114. /**
  107115. * Clones the current emitter and returns a copy of it
  107116. * @returns the new emitter
  107117. */
  107118. HemisphericParticleEmitter.prototype.clone = function () {
  107119. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  107120. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  107121. return newOne;
  107122. };
  107123. /**
  107124. * Called by the GPUParticleSystem to setup the update shader
  107125. * @param effect defines the update shader
  107126. */
  107127. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  107128. effect.setFloat("radius", this.radius);
  107129. effect.setFloat("radiusRange", this.radiusRange);
  107130. effect.setFloat("directionRandomizer", this.directionRandomizer);
  107131. };
  107132. /**
  107133. * Returns a string to use to update the GPU particles update shader
  107134. * @returns a string containng the defines string
  107135. */
  107136. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  107137. return "#define HEMISPHERICEMITTER";
  107138. };
  107139. /**
  107140. * Returns the string "HemisphericParticleEmitter"
  107141. * @returns a string containing the class name
  107142. */
  107143. HemisphericParticleEmitter.prototype.getClassName = function () {
  107144. return "HemisphericParticleEmitter";
  107145. };
  107146. /**
  107147. * Serializes the particle system to a JSON object.
  107148. * @returns the JSON object
  107149. */
  107150. HemisphericParticleEmitter.prototype.serialize = function () {
  107151. var serializationObject = {};
  107152. serializationObject.type = this.getClassName();
  107153. serializationObject.radius = this.radius;
  107154. serializationObject.radiusRange = this.radiusRange;
  107155. serializationObject.directionRandomizer = this.directionRandomizer;
  107156. return serializationObject;
  107157. };
  107158. /**
  107159. * Parse properties from a JSON object
  107160. * @param serializationObject defines the JSON object
  107161. */
  107162. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  107163. this.radius = serializationObject.radius;
  107164. this.radiusRange = serializationObject.radiusRange;
  107165. this.directionRandomizer = serializationObject.directionRandomizer;
  107166. };
  107167. return HemisphericParticleEmitter;
  107168. }());
  107169. /***/ }),
  107170. /***/ "./Particles/EmitterTypes/index.ts":
  107171. /*!*****************************************!*\
  107172. !*** ./Particles/EmitterTypes/index.ts ***!
  107173. \*****************************************/
  107174. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  107175. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107176. "use strict";
  107177. __webpack_require__.r(__webpack_exports__);
  107178. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  107179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  107180. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  107181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  107182. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  107183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  107184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  107185. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  107186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  107187. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  107188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  107189. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  107190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  107191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  107192. /***/ }),
  107193. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  107194. /*!********************************************************!*\
  107195. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  107196. \********************************************************/
  107197. /*! exports provided: PointParticleEmitter */
  107198. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107199. "use strict";
  107200. __webpack_require__.r(__webpack_exports__);
  107201. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  107202. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  107203. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  107204. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  107205. /**
  107206. * Particle emitter emitting particles from a point.
  107207. * It emits the particles randomly between 2 given directions.
  107208. */
  107209. var PointParticleEmitter = /** @class */ (function () {
  107210. /**
  107211. * Creates a new instance PointParticleEmitter
  107212. */
  107213. function PointParticleEmitter() {
  107214. /**
  107215. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  107216. */
  107217. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  107218. /**
  107219. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  107220. */
  107221. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  107222. }
  107223. /**
  107224. * Called by the particle System when the direction is computed for the created particle.
  107225. * @param worldMatrix is the world matrix of the particle system
  107226. * @param directionToUpdate is the direction vector to update with the result
  107227. * @param particle is the particle we are computed the direction for
  107228. */
  107229. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  107230. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  107231. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  107232. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  107233. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  107234. };
  107235. /**
  107236. * Called by the particle System when the position is computed for the created particle.
  107237. * @param worldMatrix is the world matrix of the particle system
  107238. * @param positionToUpdate is the position vector to update with the result
  107239. * @param particle is the particle we are computed the position for
  107240. */
  107241. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  107242. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  107243. };
  107244. /**
  107245. * Clones the current emitter and returns a copy of it
  107246. * @returns the new emitter
  107247. */
  107248. PointParticleEmitter.prototype.clone = function () {
  107249. var newOne = new PointParticleEmitter();
  107250. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  107251. return newOne;
  107252. };
  107253. /**
  107254. * Called by the GPUParticleSystem to setup the update shader
  107255. * @param effect defines the update shader
  107256. */
  107257. PointParticleEmitter.prototype.applyToShader = function (effect) {
  107258. effect.setVector3("direction1", this.direction1);
  107259. effect.setVector3("direction2", this.direction2);
  107260. };
  107261. /**
  107262. * Returns a string to use to update the GPU particles update shader
  107263. * @returns a string containng the defines string
  107264. */
  107265. PointParticleEmitter.prototype.getEffectDefines = function () {
  107266. return "#define POINTEMITTER";
  107267. };
  107268. /**
  107269. * Returns the string "PointParticleEmitter"
  107270. * @returns a string containing the class name
  107271. */
  107272. PointParticleEmitter.prototype.getClassName = function () {
  107273. return "PointParticleEmitter";
  107274. };
  107275. /**
  107276. * Serializes the particle system to a JSON object.
  107277. * @returns the JSON object
  107278. */
  107279. PointParticleEmitter.prototype.serialize = function () {
  107280. var serializationObject = {};
  107281. serializationObject.type = this.getClassName();
  107282. serializationObject.direction1 = this.direction1.asArray();
  107283. serializationObject.direction2 = this.direction2.asArray();
  107284. return serializationObject;
  107285. };
  107286. /**
  107287. * Parse properties from a JSON object
  107288. * @param serializationObject defines the JSON object
  107289. */
  107290. PointParticleEmitter.prototype.parse = function (serializationObject) {
  107291. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  107292. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  107293. };
  107294. return PointParticleEmitter;
  107295. }());
  107296. /***/ }),
  107297. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  107298. /*!*********************************************************!*\
  107299. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  107300. \*********************************************************/
  107301. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  107302. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107303. "use strict";
  107304. __webpack_require__.r(__webpack_exports__);
  107305. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  107306. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  107307. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  107308. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  107309. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  107310. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  107311. /**
  107312. * Particle emitter emitting particles from the inside of a sphere.
  107313. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  107314. */
  107315. var SphereParticleEmitter = /** @class */ (function () {
  107316. /**
  107317. * Creates a new instance SphereParticleEmitter
  107318. * @param radius the radius of the emission sphere (1 by default)
  107319. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  107320. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  107321. */
  107322. function SphereParticleEmitter(
  107323. /**
  107324. * The radius of the emission sphere.
  107325. */
  107326. radius,
  107327. /**
  107328. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  107329. */
  107330. radiusRange,
  107331. /**
  107332. * How much to randomize the particle direction [0-1].
  107333. */
  107334. directionRandomizer) {
  107335. if (radius === void 0) { radius = 1; }
  107336. if (radiusRange === void 0) { radiusRange = 1; }
  107337. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  107338. this.radius = radius;
  107339. this.radiusRange = radiusRange;
  107340. this.directionRandomizer = directionRandomizer;
  107341. }
  107342. /**
  107343. * Called by the particle System when the direction is computed for the created particle.
  107344. * @param worldMatrix is the world matrix of the particle system
  107345. * @param directionToUpdate is the direction vector to update with the result
  107346. * @param particle is the particle we are computed the direction for
  107347. */
  107348. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  107349. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  107350. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107351. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107352. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107353. direction.x += randX;
  107354. direction.y += randY;
  107355. direction.z += randZ;
  107356. direction.normalize();
  107357. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  107358. };
  107359. /**
  107360. * Called by the particle System when the position is computed for the created particle.
  107361. * @param worldMatrix is the world matrix of the particle system
  107362. * @param positionToUpdate is the position vector to update with the result
  107363. * @param particle is the particle we are computed the position for
  107364. */
  107365. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  107366. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  107367. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  107368. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  107369. var theta = Math.acos(2 * v - 1);
  107370. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  107371. var randY = randRadius * Math.cos(theta);
  107372. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  107373. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  107374. };
  107375. /**
  107376. * Clones the current emitter and returns a copy of it
  107377. * @returns the new emitter
  107378. */
  107379. SphereParticleEmitter.prototype.clone = function () {
  107380. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  107381. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  107382. return newOne;
  107383. };
  107384. /**
  107385. * Called by the GPUParticleSystem to setup the update shader
  107386. * @param effect defines the update shader
  107387. */
  107388. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  107389. effect.setFloat("radius", this.radius);
  107390. effect.setFloat("radiusRange", this.radiusRange);
  107391. effect.setFloat("directionRandomizer", this.directionRandomizer);
  107392. };
  107393. /**
  107394. * Returns a string to use to update the GPU particles update shader
  107395. * @returns a string containng the defines string
  107396. */
  107397. SphereParticleEmitter.prototype.getEffectDefines = function () {
  107398. return "#define SPHEREEMITTER";
  107399. };
  107400. /**
  107401. * Returns the string "SphereParticleEmitter"
  107402. * @returns a string containing the class name
  107403. */
  107404. SphereParticleEmitter.prototype.getClassName = function () {
  107405. return "SphereParticleEmitter";
  107406. };
  107407. /**
  107408. * Serializes the particle system to a JSON object.
  107409. * @returns the JSON object
  107410. */
  107411. SphereParticleEmitter.prototype.serialize = function () {
  107412. var serializationObject = {};
  107413. serializationObject.type = this.getClassName();
  107414. serializationObject.radius = this.radius;
  107415. serializationObject.radiusRange = this.radiusRange;
  107416. serializationObject.directionRandomizer = this.directionRandomizer;
  107417. return serializationObject;
  107418. };
  107419. /**
  107420. * Parse properties from a JSON object
  107421. * @param serializationObject defines the JSON object
  107422. */
  107423. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  107424. this.radius = serializationObject.radius;
  107425. this.radiusRange = serializationObject.radiusRange;
  107426. this.directionRandomizer = serializationObject.directionRandomizer;
  107427. };
  107428. return SphereParticleEmitter;
  107429. }());
  107430. /**
  107431. * Particle emitter emitting particles from the inside of a sphere.
  107432. * It emits the particles randomly between two vectors.
  107433. */
  107434. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  107435. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  107436. /**
  107437. * Creates a new instance SphereDirectedParticleEmitter
  107438. * @param radius the radius of the emission sphere (1 by default)
  107439. * @param direction1 the min limit of the emission direction (up vector by default)
  107440. * @param direction2 the max limit of the emission direction (up vector by default)
  107441. */
  107442. function SphereDirectedParticleEmitter(radius,
  107443. /**
  107444. * The min limit of the emission direction.
  107445. */
  107446. direction1,
  107447. /**
  107448. * The max limit of the emission direction.
  107449. */
  107450. direction2) {
  107451. if (radius === void 0) { radius = 1; }
  107452. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  107453. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  107454. var _this = _super.call(this, radius) || this;
  107455. _this.direction1 = direction1;
  107456. _this.direction2 = direction2;
  107457. return _this;
  107458. }
  107459. /**
  107460. * Called by the particle System when the direction is computed for the created particle.
  107461. * @param worldMatrix is the world matrix of the particle system
  107462. * @param directionToUpdate is the direction vector to update with the result
  107463. * @param particle is the particle we are computed the direction for
  107464. */
  107465. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  107466. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  107467. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  107468. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  107469. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  107470. };
  107471. /**
  107472. * Clones the current emitter and returns a copy of it
  107473. * @returns the new emitter
  107474. */
  107475. SphereDirectedParticleEmitter.prototype.clone = function () {
  107476. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  107477. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  107478. return newOne;
  107479. };
  107480. /**
  107481. * Called by the GPUParticleSystem to setup the update shader
  107482. * @param effect defines the update shader
  107483. */
  107484. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  107485. effect.setFloat("radius", this.radius);
  107486. effect.setFloat("radiusRange", this.radiusRange);
  107487. effect.setVector3("direction1", this.direction1);
  107488. effect.setVector3("direction2", this.direction2);
  107489. };
  107490. /**
  107491. * Returns a string to use to update the GPU particles update shader
  107492. * @returns a string containng the defines string
  107493. */
  107494. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  107495. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  107496. };
  107497. /**
  107498. * Returns the string "SphereDirectedParticleEmitter"
  107499. * @returns a string containing the class name
  107500. */
  107501. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  107502. return "SphereDirectedParticleEmitter";
  107503. };
  107504. /**
  107505. * Serializes the particle system to a JSON object.
  107506. * @returns the JSON object
  107507. */
  107508. SphereDirectedParticleEmitter.prototype.serialize = function () {
  107509. var serializationObject = _super.prototype.serialize.call(this);
  107510. serializationObject.direction1 = this.direction1.asArray();
  107511. serializationObject.direction2 = this.direction2.asArray();
  107512. return serializationObject;
  107513. };
  107514. /**
  107515. * Parse properties from a JSON object
  107516. * @param serializationObject defines the JSON object
  107517. */
  107518. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  107519. _super.prototype.parse.call(this, serializationObject);
  107520. this.direction1.copyFrom(serializationObject.direction1);
  107521. this.direction2.copyFrom(serializationObject.direction2);
  107522. };
  107523. return SphereDirectedParticleEmitter;
  107524. }(SphereParticleEmitter));
  107525. /***/ }),
  107526. /***/ "./Particles/baseParticleSystem.ts":
  107527. /*!*****************************************!*\
  107528. !*** ./Particles/baseParticleSystem.ts ***!
  107529. \*****************************************/
  107530. /*! exports provided: BaseParticleSystem */
  107531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107532. "use strict";
  107533. __webpack_require__.r(__webpack_exports__);
  107534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  107535. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107536. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  107537. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  107538. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  107539. /**
  107540. * This represents the base class for particle system in Babylon.
  107541. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  107542. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  107543. * @example https://doc.babylonjs.com/babylon101/particles
  107544. */
  107545. var BaseParticleSystem = /** @class */ (function () {
  107546. /**
  107547. * Instantiates a particle system.
  107548. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  107549. * @param name The name of the particle system
  107550. */
  107551. function BaseParticleSystem(name) {
  107552. /**
  107553. * List of animations used by the particle system.
  107554. */
  107555. this.animations = [];
  107556. /**
  107557. * The rendering group used by the Particle system to chose when to render.
  107558. */
  107559. this.renderingGroupId = 0;
  107560. /**
  107561. * The emitter represents the Mesh or position we are attaching the particle system to.
  107562. */
  107563. this.emitter = null;
  107564. /**
  107565. * The maximum number of particles to emit per frame
  107566. */
  107567. this.emitRate = 10;
  107568. /**
  107569. * If you want to launch only a few particles at once, that can be done, as well.
  107570. */
  107571. this.manualEmitCount = -1;
  107572. /**
  107573. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  107574. */
  107575. this.updateSpeed = 0.01;
  107576. /**
  107577. * The amount of time the particle system is running (depends of the overall update speed).
  107578. */
  107579. this.targetStopDuration = 0;
  107580. /**
  107581. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  107582. */
  107583. this.disposeOnStop = false;
  107584. /**
  107585. * Minimum power of emitting particles.
  107586. */
  107587. this.minEmitPower = 1;
  107588. /**
  107589. * Maximum power of emitting particles.
  107590. */
  107591. this.maxEmitPower = 1;
  107592. /**
  107593. * Minimum life time of emitting particles.
  107594. */
  107595. this.minLifeTime = 1;
  107596. /**
  107597. * Maximum life time of emitting particles.
  107598. */
  107599. this.maxLifeTime = 1;
  107600. /**
  107601. * Minimum Size of emitting particles.
  107602. */
  107603. this.minSize = 1;
  107604. /**
  107605. * Maximum Size of emitting particles.
  107606. */
  107607. this.maxSize = 1;
  107608. /**
  107609. * Minimum scale of emitting particles on X axis.
  107610. */
  107611. this.minScaleX = 1;
  107612. /**
  107613. * Maximum scale of emitting particles on X axis.
  107614. */
  107615. this.maxScaleX = 1;
  107616. /**
  107617. * Minimum scale of emitting particles on Y axis.
  107618. */
  107619. this.minScaleY = 1;
  107620. /**
  107621. * Maximum scale of emitting particles on Y axis.
  107622. */
  107623. this.maxScaleY = 1;
  107624. /**
  107625. * Gets or sets the minimal initial rotation in radians.
  107626. */
  107627. this.minInitialRotation = 0;
  107628. /**
  107629. * Gets or sets the maximal initial rotation in radians.
  107630. */
  107631. this.maxInitialRotation = 0;
  107632. /**
  107633. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  107634. */
  107635. this.minAngularSpeed = 0;
  107636. /**
  107637. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  107638. */
  107639. this.maxAngularSpeed = 0;
  107640. /**
  107641. * The layer mask we are rendering the particles through.
  107642. */
  107643. this.layerMask = 0x0FFFFFFF;
  107644. /**
  107645. * This can help using your own shader to render the particle system.
  107646. * The according effect will be created
  107647. */
  107648. this.customShader = null;
  107649. /**
  107650. * By default particle system starts as soon as they are created. This prevents the
  107651. * automatic start to happen and let you decide when to start emitting particles.
  107652. */
  107653. this.preventAutoStart = false;
  107654. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  107655. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  107656. /**
  107657. * Callback triggered when the particle animation is ending.
  107658. */
  107659. this.onAnimationEnd = null;
  107660. /**
  107661. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  107662. */
  107663. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  107664. /**
  107665. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  107666. * to override the particles.
  107667. */
  107668. this.forceDepthWrite = false;
  107669. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  107670. this.preWarmCycles = 0;
  107671. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  107672. this.preWarmStepOffset = 1;
  107673. /**
  107674. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  107675. */
  107676. this.spriteCellChangeSpeed = 1;
  107677. /**
  107678. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  107679. */
  107680. this.startSpriteCellID = 0;
  107681. /**
  107682. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  107683. */
  107684. this.endSpriteCellID = 0;
  107685. /**
  107686. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  107687. */
  107688. this.spriteCellWidth = 0;
  107689. /**
  107690. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  107691. */
  107692. this.spriteCellHeight = 0;
  107693. /**
  107694. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  107695. */
  107696. this.spriteRandomStartCell = false;
  107697. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  107698. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  107699. /**
  107700. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  107701. */
  107702. this.beginAnimationOnStart = false;
  107703. /**
  107704. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  107705. */
  107706. this.beginAnimationFrom = 0;
  107707. /**
  107708. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  107709. */
  107710. this.beginAnimationTo = 60;
  107711. /**
  107712. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  107713. */
  107714. this.beginAnimationLoop = false;
  107715. /**
  107716. * Gets or sets a world offset applied to all particles
  107717. */
  107718. this.worldOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  107719. /**
  107720. * You can use gravity if you want to give an orientation to your particles.
  107721. */
  107722. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107723. this._colorGradients = null;
  107724. this._sizeGradients = null;
  107725. this._lifeTimeGradients = null;
  107726. this._angularSpeedGradients = null;
  107727. this._velocityGradients = null;
  107728. this._limitVelocityGradients = null;
  107729. this._dragGradients = null;
  107730. this._emitRateGradients = null;
  107731. this._startSizeGradients = null;
  107732. this._rampGradients = null;
  107733. this._colorRemapGradients = null;
  107734. this._alphaRemapGradients = null;
  107735. /**
  107736. * Defines the delay in milliseconds before starting the system (0 by default)
  107737. */
  107738. this.startDelay = 0;
  107739. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  107740. this.limitVelocityDamping = 0.4;
  107741. /**
  107742. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  107743. */
  107744. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  107745. /**
  107746. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  107747. */
  107748. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  107749. /**
  107750. * Color the particle will have at the end of its lifetime
  107751. */
  107752. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  107753. /**
  107754. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  107755. */
  107756. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  107757. /** @hidden */
  107758. this._isSubEmitter = false;
  107759. /**
  107760. * Gets or sets the billboard mode to use when isBillboardBased = true.
  107761. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  107762. */
  107763. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  107764. this._isBillboardBased = true;
  107765. /**
  107766. * Local cache of defines for image processing.
  107767. */
  107768. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  107769. this.id = name;
  107770. this.name = name;
  107771. }
  107772. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  107773. /**
  107774. * Gets or sets a texture used to add random noise to particle positions
  107775. */
  107776. get: function () {
  107777. return this._noiseTexture;
  107778. },
  107779. set: function (value) {
  107780. if (this._noiseTexture === value) {
  107781. return;
  107782. }
  107783. this._noiseTexture = value;
  107784. this._reset();
  107785. },
  107786. enumerable: true,
  107787. configurable: true
  107788. });
  107789. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  107790. /**
  107791. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  107792. */
  107793. get: function () {
  107794. return this._isAnimationSheetEnabled;
  107795. },
  107796. set: function (value) {
  107797. if (this._isAnimationSheetEnabled == value) {
  107798. return;
  107799. }
  107800. this._isAnimationSheetEnabled = value;
  107801. this._reset();
  107802. },
  107803. enumerable: true,
  107804. configurable: true
  107805. });
  107806. /**
  107807. * Get hosting scene
  107808. * @returns the scene
  107809. */
  107810. BaseParticleSystem.prototype.getScene = function () {
  107811. return this._scene;
  107812. };
  107813. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  107814. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  107815. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  107816. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  107817. };
  107818. /**
  107819. * Gets the current list of drag gradients.
  107820. * You must use addDragGradient and removeDragGradient to udpate this list
  107821. * @returns the list of drag gradients
  107822. */
  107823. BaseParticleSystem.prototype.getDragGradients = function () {
  107824. return this._dragGradients;
  107825. };
  107826. /**
  107827. * Gets the current list of limit velocity gradients.
  107828. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  107829. * @returns the list of limit velocity gradients
  107830. */
  107831. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  107832. return this._limitVelocityGradients;
  107833. };
  107834. /**
  107835. * Gets the current list of color gradients.
  107836. * You must use addColorGradient and removeColorGradient to udpate this list
  107837. * @returns the list of color gradients
  107838. */
  107839. BaseParticleSystem.prototype.getColorGradients = function () {
  107840. return this._colorGradients;
  107841. };
  107842. /**
  107843. * Gets the current list of size gradients.
  107844. * You must use addSizeGradient and removeSizeGradient to udpate this list
  107845. * @returns the list of size gradients
  107846. */
  107847. BaseParticleSystem.prototype.getSizeGradients = function () {
  107848. return this._sizeGradients;
  107849. };
  107850. /**
  107851. * Gets the current list of color remap gradients.
  107852. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  107853. * @returns the list of color remap gradients
  107854. */
  107855. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  107856. return this._colorRemapGradients;
  107857. };
  107858. /**
  107859. * Gets the current list of alpha remap gradients.
  107860. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  107861. * @returns the list of alpha remap gradients
  107862. */
  107863. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  107864. return this._alphaRemapGradients;
  107865. };
  107866. /**
  107867. * Gets the current list of life time gradients.
  107868. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  107869. * @returns the list of life time gradients
  107870. */
  107871. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  107872. return this._lifeTimeGradients;
  107873. };
  107874. /**
  107875. * Gets the current list of angular speed gradients.
  107876. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  107877. * @returns the list of angular speed gradients
  107878. */
  107879. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  107880. return this._angularSpeedGradients;
  107881. };
  107882. /**
  107883. * Gets the current list of velocity gradients.
  107884. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  107885. * @returns the list of velocity gradients
  107886. */
  107887. BaseParticleSystem.prototype.getVelocityGradients = function () {
  107888. return this._velocityGradients;
  107889. };
  107890. /**
  107891. * Gets the current list of start size gradients.
  107892. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  107893. * @returns the list of start size gradients
  107894. */
  107895. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  107896. return this._startSizeGradients;
  107897. };
  107898. /**
  107899. * Gets the current list of emit rate gradients.
  107900. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  107901. * @returns the list of emit rate gradients
  107902. */
  107903. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  107904. return this._emitRateGradients;
  107905. };
  107906. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  107907. /**
  107908. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  107909. * This only works when particleEmitterTyps is a BoxParticleEmitter
  107910. */
  107911. get: function () {
  107912. if (this.particleEmitterType.direction1) {
  107913. return this.particleEmitterType.direction1;
  107914. }
  107915. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107916. },
  107917. set: function (value) {
  107918. if (this.particleEmitterType.direction1) {
  107919. this.particleEmitterType.direction1 = value;
  107920. }
  107921. },
  107922. enumerable: true,
  107923. configurable: true
  107924. });
  107925. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  107926. /**
  107927. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  107928. * This only works when particleEmitterTyps is a BoxParticleEmitter
  107929. */
  107930. get: function () {
  107931. if (this.particleEmitterType.direction2) {
  107932. return this.particleEmitterType.direction2;
  107933. }
  107934. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107935. },
  107936. set: function (value) {
  107937. if (this.particleEmitterType.direction2) {
  107938. this.particleEmitterType.direction2 = value;
  107939. }
  107940. },
  107941. enumerable: true,
  107942. configurable: true
  107943. });
  107944. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  107945. /**
  107946. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  107947. * This only works when particleEmitterTyps is a BoxParticleEmitter
  107948. */
  107949. get: function () {
  107950. if (this.particleEmitterType.minEmitBox) {
  107951. return this.particleEmitterType.minEmitBox;
  107952. }
  107953. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107954. },
  107955. set: function (value) {
  107956. if (this.particleEmitterType.minEmitBox) {
  107957. this.particleEmitterType.minEmitBox = value;
  107958. }
  107959. },
  107960. enumerable: true,
  107961. configurable: true
  107962. });
  107963. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  107964. /**
  107965. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  107966. * This only works when particleEmitterTyps is a BoxParticleEmitter
  107967. */
  107968. get: function () {
  107969. if (this.particleEmitterType.maxEmitBox) {
  107970. return this.particleEmitterType.maxEmitBox;
  107971. }
  107972. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107973. },
  107974. set: function (value) {
  107975. if (this.particleEmitterType.maxEmitBox) {
  107976. this.particleEmitterType.maxEmitBox = value;
  107977. }
  107978. },
  107979. enumerable: true,
  107980. configurable: true
  107981. });
  107982. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  107983. /**
  107984. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  107985. */
  107986. get: function () {
  107987. return this._isBillboardBased;
  107988. },
  107989. set: function (value) {
  107990. if (this._isBillboardBased === value) {
  107991. return;
  107992. }
  107993. this._isBillboardBased = value;
  107994. this._reset();
  107995. },
  107996. enumerable: true,
  107997. configurable: true
  107998. });
  107999. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  108000. /**
  108001. * Gets the image processing configuration used either in this material.
  108002. */
  108003. get: function () {
  108004. return this._imageProcessingConfiguration;
  108005. },
  108006. /**
  108007. * Sets the Default image processing configuration used either in the this material.
  108008. *
  108009. * If sets to null, the scene one is in use.
  108010. */
  108011. set: function (value) {
  108012. this._attachImageProcessingConfiguration(value);
  108013. },
  108014. enumerable: true,
  108015. configurable: true
  108016. });
  108017. /**
  108018. * Attaches a new image processing configuration to the Standard Material.
  108019. * @param configuration
  108020. */
  108021. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  108022. if (configuration === this._imageProcessingConfiguration) {
  108023. return;
  108024. }
  108025. // Pick the scene configuration if needed.
  108026. if (!configuration) {
  108027. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  108028. }
  108029. else {
  108030. this._imageProcessingConfiguration = configuration;
  108031. }
  108032. };
  108033. /** @hidden */
  108034. BaseParticleSystem.prototype._reset = function () {
  108035. };
  108036. /** @hidden */
  108037. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  108038. if (!gradients) {
  108039. return this;
  108040. }
  108041. var index = 0;
  108042. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  108043. var valueGradient = gradients_1[_i];
  108044. if (valueGradient.gradient === gradient) {
  108045. gradients.splice(index, 1);
  108046. break;
  108047. }
  108048. index++;
  108049. }
  108050. if (texture) {
  108051. texture.dispose();
  108052. }
  108053. return this;
  108054. };
  108055. /**
  108056. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  108057. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  108058. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  108059. * @returns the emitter
  108060. */
  108061. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  108062. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  108063. particleEmitter.direction1 = direction1;
  108064. particleEmitter.direction2 = direction2;
  108065. this.particleEmitterType = particleEmitter;
  108066. return particleEmitter;
  108067. };
  108068. /**
  108069. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  108070. * @param radius The radius of the hemisphere to emit from
  108071. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  108072. * @returns the emitter
  108073. */
  108074. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  108075. if (radius === void 0) { radius = 1; }
  108076. if (radiusRange === void 0) { radiusRange = 1; }
  108077. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  108078. this.particleEmitterType = particleEmitter;
  108079. return particleEmitter;
  108080. };
  108081. /**
  108082. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  108083. * @param radius The radius of the sphere to emit from
  108084. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  108085. * @returns the emitter
  108086. */
  108087. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  108088. if (radius === void 0) { radius = 1; }
  108089. if (radiusRange === void 0) { radiusRange = 1; }
  108090. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  108091. this.particleEmitterType = particleEmitter;
  108092. return particleEmitter;
  108093. };
  108094. /**
  108095. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  108096. * @param radius The radius of the sphere to emit from
  108097. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  108098. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  108099. * @returns the emitter
  108100. */
  108101. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  108102. if (radius === void 0) { radius = 1; }
  108103. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  108104. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  108105. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  108106. this.particleEmitterType = particleEmitter;
  108107. return particleEmitter;
  108108. };
  108109. /**
  108110. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  108111. * @param radius The radius of the emission cylinder
  108112. * @param height The height of the emission cylinder
  108113. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  108114. * @param directionRandomizer How much to randomize the particle direction [0-1]
  108115. * @returns the emitter
  108116. */
  108117. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  108118. if (radius === void 0) { radius = 1; }
  108119. if (height === void 0) { height = 1; }
  108120. if (radiusRange === void 0) { radiusRange = 1; }
  108121. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  108122. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  108123. this.particleEmitterType = particleEmitter;
  108124. return particleEmitter;
  108125. };
  108126. /**
  108127. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  108128. * @param radius The radius of the cylinder to emit from
  108129. * @param height The height of the emission cylinder
  108130. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  108131. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  108132. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  108133. * @returns the emitter
  108134. */
  108135. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  108136. if (radius === void 0) { radius = 1; }
  108137. if (height === void 0) { height = 1; }
  108138. if (radiusRange === void 0) { radiusRange = 1; }
  108139. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  108140. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  108141. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  108142. this.particleEmitterType = particleEmitter;
  108143. return particleEmitter;
  108144. };
  108145. /**
  108146. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  108147. * @param radius The radius of the cone to emit from
  108148. * @param angle The base angle of the cone
  108149. * @returns the emitter
  108150. */
  108151. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  108152. if (radius === void 0) { radius = 1; }
  108153. if (angle === void 0) { angle = Math.PI / 4; }
  108154. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  108155. this.particleEmitterType = particleEmitter;
  108156. return particleEmitter;
  108157. };
  108158. /**
  108159. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  108160. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  108161. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  108162. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  108163. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  108164. * @returns the emitter
  108165. */
  108166. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  108167. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  108168. this.particleEmitterType = particleEmitter;
  108169. this.direction1 = direction1;
  108170. this.direction2 = direction2;
  108171. this.minEmitBox = minEmitBox;
  108172. this.maxEmitBox = maxEmitBox;
  108173. return particleEmitter;
  108174. };
  108175. /**
  108176. * Source color is added to the destination color without alpha affecting the result
  108177. */
  108178. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  108179. /**
  108180. * Blend current color and particle color using particle’s alpha
  108181. */
  108182. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  108183. /**
  108184. * Add current color and particle color multiplied by particle’s alpha
  108185. */
  108186. BaseParticleSystem.BLENDMODE_ADD = 2;
  108187. /**
  108188. * Multiply current color with particle color
  108189. */
  108190. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  108191. /**
  108192. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  108193. */
  108194. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  108195. return BaseParticleSystem;
  108196. }());
  108197. /***/ }),
  108198. /***/ "./Particles/gpuParticleSystem.ts":
  108199. /*!****************************************!*\
  108200. !*** ./Particles/gpuParticleSystem.ts ***!
  108201. \****************************************/
  108202. /*! exports provided: GPUParticleSystem */
  108203. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108204. "use strict";
  108205. __webpack_require__.r(__webpack_exports__);
  108206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  108207. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  108208. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  108209. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  108210. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108211. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  108212. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  108213. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  108214. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  108215. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  108216. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  108217. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  108218. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  108219. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  108220. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  108221. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  108222. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  108223. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  108224. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  108225. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  108226. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  108227. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  108228. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  108229. /**
  108230. * This represents a GPU particle system in Babylon
  108231. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  108232. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  108233. */
  108234. var GPUParticleSystem = /** @class */ (function (_super) {
  108235. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  108236. /**
  108237. * Instantiates a GPU particle system.
  108238. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  108239. * @param name The name of the particle system
  108240. * @param options The options used to create the system
  108241. * @param scene The scene the particle system belongs to
  108242. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  108243. */
  108244. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  108245. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  108246. var _this = _super.call(this, name) || this;
  108247. /**
  108248. * The layer mask we are rendering the particles through.
  108249. */
  108250. _this.layerMask = 0x0FFFFFFF;
  108251. _this._accumulatedCount = 0;
  108252. _this._targetIndex = 0;
  108253. _this._currentRenderId = -1;
  108254. _this._started = false;
  108255. _this._stopped = false;
  108256. _this._timeDelta = 0;
  108257. _this._actualFrame = 0;
  108258. _this._rawTextureWidth = 256;
  108259. /**
  108260. * An event triggered when the system is disposed.
  108261. */
  108262. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  108263. /**
  108264. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  108265. * to override the particles.
  108266. */
  108267. _this.forceDepthWrite = false;
  108268. _this._preWarmDone = false;
  108269. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  108270. // Setup the default processing configuration to the scene.
  108271. _this._attachImageProcessingConfiguration(null);
  108272. _this._engine = _this._scene.getEngine();
  108273. if (!options.randomTextureSize) {
  108274. delete options.randomTextureSize;
  108275. }
  108276. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  108277. var optionsAsNumber = options;
  108278. if (isFinite(optionsAsNumber)) {
  108279. fullOptions.capacity = optionsAsNumber;
  108280. }
  108281. _this._capacity = fullOptions.capacity;
  108282. _this._activeCount = fullOptions.capacity;
  108283. _this._currentActiveCount = 0;
  108284. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  108285. _this._scene.particleSystems.push(_this);
  108286. _this._updateEffectOptions = {
  108287. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  108288. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  108289. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  108290. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  108291. uniformBuffersNames: [],
  108292. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  108293. defines: "",
  108294. fallbacks: null,
  108295. onCompiled: null,
  108296. onError: null,
  108297. indexParameters: null,
  108298. maxSimultaneousLights: 0,
  108299. transformFeedbackVaryings: []
  108300. };
  108301. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  108302. // Random data
  108303. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  108304. var d = [];
  108305. for (var i = 0; i < maxTextureSize; ++i) {
  108306. d.push(Math.random());
  108307. d.push(Math.random());
  108308. d.push(Math.random());
  108309. d.push(Math.random());
  108310. }
  108311. _this._randomTexture = new _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__["RawTexture"](new Float32Array(d), maxTextureSize, 1, _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].TEXTUREFORMAT_RGBA, _this._scene, false, false, _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].TEXTURETYPE_FLOAT);
  108312. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  108313. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  108314. d = [];
  108315. for (var i = 0; i < maxTextureSize; ++i) {
  108316. d.push(Math.random());
  108317. d.push(Math.random());
  108318. d.push(Math.random());
  108319. d.push(Math.random());
  108320. }
  108321. _this._randomTexture2 = new _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__["RawTexture"](new Float32Array(d), maxTextureSize, 1, _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].TEXTUREFORMAT_RGBA, _this._scene, false, false, _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].TEXTURETYPE_FLOAT);
  108322. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  108323. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  108324. _this._randomTextureSize = maxTextureSize;
  108325. return _this;
  108326. }
  108327. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  108328. /**
  108329. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  108330. */
  108331. get: function () {
  108332. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  108333. return false;
  108334. }
  108335. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  108336. },
  108337. enumerable: true,
  108338. configurable: true
  108339. });
  108340. /**
  108341. * Gets the maximum number of particles active at the same time.
  108342. * @returns The max number of active particles.
  108343. */
  108344. GPUParticleSystem.prototype.getCapacity = function () {
  108345. return this._capacity;
  108346. };
  108347. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  108348. /**
  108349. * Gets or set the number of active particles
  108350. */
  108351. get: function () {
  108352. return this._activeCount;
  108353. },
  108354. set: function (value) {
  108355. this._activeCount = Math.min(value, this._capacity);
  108356. },
  108357. enumerable: true,
  108358. configurable: true
  108359. });
  108360. /**
  108361. * Is this system ready to be used/rendered
  108362. * @return true if the system is ready
  108363. */
  108364. GPUParticleSystem.prototype.isReady = function () {
  108365. if (!this._updateEffect) {
  108366. this._recreateUpdateEffect();
  108367. this._recreateRenderEffect();
  108368. return false;
  108369. }
  108370. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  108371. return false;
  108372. }
  108373. return true;
  108374. };
  108375. /**
  108376. * Gets if the system has been started. (Note: this will still be true after stop is called)
  108377. * @returns True if it has been started, otherwise false.
  108378. */
  108379. GPUParticleSystem.prototype.isStarted = function () {
  108380. return this._started;
  108381. };
  108382. /**
  108383. * Starts the particle system and begins to emit
  108384. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  108385. */
  108386. GPUParticleSystem.prototype.start = function (delay) {
  108387. var _this = this;
  108388. if (delay === void 0) { delay = this.startDelay; }
  108389. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  108390. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  108391. }
  108392. if (delay) {
  108393. setTimeout(function () {
  108394. _this.start(0);
  108395. }, delay);
  108396. return;
  108397. }
  108398. this._started = true;
  108399. this._stopped = false;
  108400. this._preWarmDone = false;
  108401. // Animations
  108402. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  108403. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  108404. }
  108405. };
  108406. /**
  108407. * Stops the particle system.
  108408. */
  108409. GPUParticleSystem.prototype.stop = function () {
  108410. this._stopped = true;
  108411. };
  108412. /**
  108413. * Remove all active particles
  108414. */
  108415. GPUParticleSystem.prototype.reset = function () {
  108416. this._releaseBuffers();
  108417. this._releaseVAOs();
  108418. this._currentActiveCount = 0;
  108419. this._targetIndex = 0;
  108420. };
  108421. /**
  108422. * Returns the string "GPUParticleSystem"
  108423. * @returns a string containing the class name
  108424. */
  108425. GPUParticleSystem.prototype.getClassName = function () {
  108426. return "GPUParticleSystem";
  108427. };
  108428. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  108429. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  108430. this._releaseBuffers();
  108431. return this;
  108432. };
  108433. /**
  108434. * Adds a new color gradient
  108435. * @param gradient defines the gradient to use (between 0 and 1)
  108436. * @param color1 defines the color to affect to the specified gradient
  108437. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  108438. * @returns the current particle system
  108439. */
  108440. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  108441. if (!this._colorGradients) {
  108442. this._colorGradients = [];
  108443. }
  108444. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  108445. colorGradient.gradient = gradient;
  108446. colorGradient.color1 = color1;
  108447. this._colorGradients.push(colorGradient);
  108448. this._colorGradients.sort(function (a, b) {
  108449. if (a.gradient < b.gradient) {
  108450. return -1;
  108451. }
  108452. else if (a.gradient > b.gradient) {
  108453. return 1;
  108454. }
  108455. return 0;
  108456. });
  108457. if (this._colorGradientsTexture) {
  108458. this._colorGradientsTexture.dispose();
  108459. this._colorGradientsTexture = null;
  108460. }
  108461. this._releaseBuffers();
  108462. return this;
  108463. };
  108464. /**
  108465. * Remove a specific color gradient
  108466. * @param gradient defines the gradient to remove
  108467. * @returns the current particle system
  108468. */
  108469. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  108470. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  108471. this._colorGradientsTexture = null;
  108472. return this;
  108473. };
  108474. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  108475. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  108476. valueGradient.gradient = gradient;
  108477. valueGradient.factor1 = factor;
  108478. factorGradients.push(valueGradient);
  108479. factorGradients.sort(function (a, b) {
  108480. if (a.gradient < b.gradient) {
  108481. return -1;
  108482. }
  108483. else if (a.gradient > b.gradient) {
  108484. return 1;
  108485. }
  108486. return 0;
  108487. });
  108488. this._releaseBuffers();
  108489. };
  108490. /**
  108491. * Adds a new size gradient
  108492. * @param gradient defines the gradient to use (between 0 and 1)
  108493. * @param factor defines the size factor to affect to the specified gradient
  108494. * @returns the current particle system
  108495. */
  108496. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  108497. if (!this._sizeGradients) {
  108498. this._sizeGradients = [];
  108499. }
  108500. this._addFactorGradient(this._sizeGradients, gradient, factor);
  108501. if (this._sizeGradientsTexture) {
  108502. this._sizeGradientsTexture.dispose();
  108503. this._sizeGradientsTexture = null;
  108504. }
  108505. this._releaseBuffers();
  108506. return this;
  108507. };
  108508. /**
  108509. * Remove a specific size gradient
  108510. * @param gradient defines the gradient to remove
  108511. * @returns the current particle system
  108512. */
  108513. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  108514. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  108515. this._sizeGradientsTexture = null;
  108516. return this;
  108517. };
  108518. /**
  108519. * Adds a new angular speed gradient
  108520. * @param gradient defines the gradient to use (between 0 and 1)
  108521. * @param factor defines the angular speed to affect to the specified gradient
  108522. * @returns the current particle system
  108523. */
  108524. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  108525. if (!this._angularSpeedGradients) {
  108526. this._angularSpeedGradients = [];
  108527. }
  108528. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  108529. if (this._angularSpeedGradientsTexture) {
  108530. this._angularSpeedGradientsTexture.dispose();
  108531. this._angularSpeedGradientsTexture = null;
  108532. }
  108533. this._releaseBuffers();
  108534. return this;
  108535. };
  108536. /**
  108537. * Remove a specific angular speed gradient
  108538. * @param gradient defines the gradient to remove
  108539. * @returns the current particle system
  108540. */
  108541. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  108542. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  108543. this._angularSpeedGradientsTexture = null;
  108544. return this;
  108545. };
  108546. /**
  108547. * Adds a new velocity gradient
  108548. * @param gradient defines the gradient to use (between 0 and 1)
  108549. * @param factor defines the velocity to affect to the specified gradient
  108550. * @returns the current particle system
  108551. */
  108552. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  108553. if (!this._velocityGradients) {
  108554. this._velocityGradients = [];
  108555. }
  108556. this._addFactorGradient(this._velocityGradients, gradient, factor);
  108557. if (this._velocityGradientsTexture) {
  108558. this._velocityGradientsTexture.dispose();
  108559. this._velocityGradientsTexture = null;
  108560. }
  108561. this._releaseBuffers();
  108562. return this;
  108563. };
  108564. /**
  108565. * Remove a specific velocity gradient
  108566. * @param gradient defines the gradient to remove
  108567. * @returns the current particle system
  108568. */
  108569. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  108570. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  108571. this._velocityGradientsTexture = null;
  108572. return this;
  108573. };
  108574. /**
  108575. * Adds a new limit velocity gradient
  108576. * @param gradient defines the gradient to use (between 0 and 1)
  108577. * @param factor defines the limit velocity value to affect to the specified gradient
  108578. * @returns the current particle system
  108579. */
  108580. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  108581. if (!this._limitVelocityGradients) {
  108582. this._limitVelocityGradients = [];
  108583. }
  108584. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  108585. if (this._limitVelocityGradientsTexture) {
  108586. this._limitVelocityGradientsTexture.dispose();
  108587. this._limitVelocityGradientsTexture = null;
  108588. }
  108589. this._releaseBuffers();
  108590. return this;
  108591. };
  108592. /**
  108593. * Remove a specific limit velocity gradient
  108594. * @param gradient defines the gradient to remove
  108595. * @returns the current particle system
  108596. */
  108597. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  108598. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  108599. this._limitVelocityGradientsTexture = null;
  108600. return this;
  108601. };
  108602. /**
  108603. * Adds a new drag gradient
  108604. * @param gradient defines the gradient to use (between 0 and 1)
  108605. * @param factor defines the drag value to affect to the specified gradient
  108606. * @returns the current particle system
  108607. */
  108608. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  108609. if (!this._dragGradients) {
  108610. this._dragGradients = [];
  108611. }
  108612. this._addFactorGradient(this._dragGradients, gradient, factor);
  108613. if (this._dragGradientsTexture) {
  108614. this._dragGradientsTexture.dispose();
  108615. this._dragGradientsTexture = null;
  108616. }
  108617. this._releaseBuffers();
  108618. return this;
  108619. };
  108620. /**
  108621. * Remove a specific drag gradient
  108622. * @param gradient defines the gradient to remove
  108623. * @returns the current particle system
  108624. */
  108625. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  108626. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  108627. this._dragGradientsTexture = null;
  108628. return this;
  108629. };
  108630. /**
  108631. * Not supported by GPUParticleSystem
  108632. * @param gradient defines the gradient to use (between 0 and 1)
  108633. * @param factor defines the emit rate value to affect to the specified gradient
  108634. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108635. * @returns the current particle system
  108636. */
  108637. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  108638. // Do nothing as emit rate is not supported by GPUParticleSystem
  108639. return this;
  108640. };
  108641. /**
  108642. * Not supported by GPUParticleSystem
  108643. * @param gradient defines the gradient to remove
  108644. * @returns the current particle system
  108645. */
  108646. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  108647. // Do nothing as emit rate is not supported by GPUParticleSystem
  108648. return this;
  108649. };
  108650. /**
  108651. * Not supported by GPUParticleSystem
  108652. * @param gradient defines the gradient to use (between 0 and 1)
  108653. * @param factor defines the start size value to affect to the specified gradient
  108654. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108655. * @returns the current particle system
  108656. */
  108657. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  108658. // Do nothing as start size is not supported by GPUParticleSystem
  108659. return this;
  108660. };
  108661. /**
  108662. * Not supported by GPUParticleSystem
  108663. * @param gradient defines the gradient to remove
  108664. * @returns the current particle system
  108665. */
  108666. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  108667. // Do nothing as start size is not supported by GPUParticleSystem
  108668. return this;
  108669. };
  108670. /**
  108671. * Not supported by GPUParticleSystem
  108672. * @param gradient defines the gradient to use (between 0 and 1)
  108673. * @param min defines the color remap minimal range
  108674. * @param max defines the color remap maximal range
  108675. * @returns the current particle system
  108676. */
  108677. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  108678. // Do nothing as start size is not supported by GPUParticleSystem
  108679. return this;
  108680. };
  108681. /**
  108682. * Not supported by GPUParticleSystem
  108683. * @param gradient defines the gradient to remove
  108684. * @returns the current particle system
  108685. */
  108686. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  108687. // Do nothing as start size is not supported by GPUParticleSystem
  108688. return this;
  108689. };
  108690. /**
  108691. * Not supported by GPUParticleSystem
  108692. * @param gradient defines the gradient to use (between 0 and 1)
  108693. * @param min defines the alpha remap minimal range
  108694. * @param max defines the alpha remap maximal range
  108695. * @returns the current particle system
  108696. */
  108697. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  108698. // Do nothing as start size is not supported by GPUParticleSystem
  108699. return this;
  108700. };
  108701. /**
  108702. * Not supported by GPUParticleSystem
  108703. * @param gradient defines the gradient to remove
  108704. * @returns the current particle system
  108705. */
  108706. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  108707. // Do nothing as start size is not supported by GPUParticleSystem
  108708. return this;
  108709. };
  108710. /**
  108711. * Not supported by GPUParticleSystem
  108712. * @param gradient defines the gradient to use (between 0 and 1)
  108713. * @param color defines the color to affect to the specified gradient
  108714. * @returns the current particle system
  108715. */
  108716. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  108717. //Not supported by GPUParticleSystem
  108718. return this;
  108719. };
  108720. /**
  108721. * Not supported by GPUParticleSystem
  108722. * @param gradient defines the gradient to remove
  108723. * @returns the current particle system
  108724. */
  108725. GPUParticleSystem.prototype.removeRampGradient = function () {
  108726. //Not supported by GPUParticleSystem
  108727. return this;
  108728. };
  108729. /**
  108730. * Not supported by GPUParticleSystem
  108731. * @returns the list of ramp gradients
  108732. */
  108733. GPUParticleSystem.prototype.getRampGradients = function () {
  108734. return null;
  108735. };
  108736. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  108737. /**
  108738. * Not supported by GPUParticleSystem
  108739. * Gets or sets a boolean indicating that ramp gradients must be used
  108740. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  108741. */
  108742. get: function () {
  108743. //Not supported by GPUParticleSystem
  108744. return false;
  108745. },
  108746. set: function (value) {
  108747. //Not supported by GPUParticleSystem
  108748. },
  108749. enumerable: true,
  108750. configurable: true
  108751. });
  108752. /**
  108753. * Not supported by GPUParticleSystem
  108754. * @param gradient defines the gradient to use (between 0 and 1)
  108755. * @param factor defines the life time factor to affect to the specified gradient
  108756. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108757. * @returns the current particle system
  108758. */
  108759. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  108760. //Not supported by GPUParticleSystem
  108761. return this;
  108762. };
  108763. /**
  108764. * Not supported by GPUParticleSystem
  108765. * @param gradient defines the gradient to remove
  108766. * @returns the current particle system
  108767. */
  108768. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  108769. //Not supported by GPUParticleSystem
  108770. return this;
  108771. };
  108772. GPUParticleSystem.prototype._reset = function () {
  108773. this._releaseBuffers();
  108774. };
  108775. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  108776. var updateVertexBuffers = {};
  108777. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  108778. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  108779. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  108780. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  108781. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  108782. var offset = 12;
  108783. if (!this._colorGradientsTexture) {
  108784. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  108785. offset += 4;
  108786. }
  108787. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  108788. offset += 3;
  108789. if (!this._isBillboardBased) {
  108790. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  108791. offset += 3;
  108792. }
  108793. if (this._angularSpeedGradientsTexture) {
  108794. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  108795. offset += 1;
  108796. }
  108797. else {
  108798. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  108799. offset += 2;
  108800. }
  108801. if (this._isAnimationSheetEnabled) {
  108802. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  108803. offset += 1;
  108804. if (this.spriteRandomStartCell) {
  108805. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  108806. offset += 1;
  108807. }
  108808. }
  108809. if (this.noiseTexture) {
  108810. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  108811. offset += 3;
  108812. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  108813. offset += 3;
  108814. }
  108815. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  108816. this._engine.bindArrayBuffer(null);
  108817. return vao;
  108818. };
  108819. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  108820. var renderVertexBuffers = {};
  108821. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  108822. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  108823. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  108824. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  108825. var offset = 12;
  108826. if (!this._colorGradientsTexture) {
  108827. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  108828. offset += 4;
  108829. }
  108830. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  108831. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  108832. }
  108833. offset += 3; // Direction
  108834. if (!this._isBillboardBased) {
  108835. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  108836. offset += 3;
  108837. }
  108838. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  108839. if (this._angularSpeedGradientsTexture) {
  108840. offset++;
  108841. }
  108842. else {
  108843. offset += 2;
  108844. }
  108845. if (this._isAnimationSheetEnabled) {
  108846. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  108847. offset += 1;
  108848. if (this.spriteRandomStartCell) {
  108849. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  108850. offset += 1;
  108851. }
  108852. }
  108853. if (this.noiseTexture) {
  108854. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  108855. offset += 3;
  108856. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  108857. offset += 3;
  108858. }
  108859. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  108860. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  108861. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  108862. this._engine.bindArrayBuffer(null);
  108863. return vao;
  108864. };
  108865. GPUParticleSystem.prototype._initialize = function (force) {
  108866. if (force === void 0) { force = false; }
  108867. if (this._buffer0 && !force) {
  108868. return;
  108869. }
  108870. var engine = this._scene.getEngine();
  108871. var data = new Array();
  108872. this._attributesStrideSize = 21;
  108873. this._targetIndex = 0;
  108874. if (!this.isBillboardBased) {
  108875. this._attributesStrideSize += 3;
  108876. }
  108877. if (this._colorGradientsTexture) {
  108878. this._attributesStrideSize -= 4;
  108879. }
  108880. if (this._angularSpeedGradientsTexture) {
  108881. this._attributesStrideSize -= 1;
  108882. }
  108883. if (this._isAnimationSheetEnabled) {
  108884. this._attributesStrideSize += 1;
  108885. if (this.spriteRandomStartCell) {
  108886. this._attributesStrideSize += 1;
  108887. }
  108888. }
  108889. if (this.noiseTexture) {
  108890. this._attributesStrideSize += 6;
  108891. }
  108892. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  108893. // position
  108894. data.push(0.0);
  108895. data.push(0.0);
  108896. data.push(0.0);
  108897. // Age and life
  108898. data.push(0.0); // create the particle as a dead one to create a new one at start
  108899. data.push(0.0);
  108900. // Seed
  108901. data.push(Math.random());
  108902. data.push(Math.random());
  108903. data.push(Math.random());
  108904. data.push(Math.random());
  108905. // Size
  108906. data.push(0.0);
  108907. data.push(0.0);
  108908. data.push(0.0);
  108909. if (!this._colorGradientsTexture) {
  108910. // color
  108911. data.push(0.0);
  108912. data.push(0.0);
  108913. data.push(0.0);
  108914. data.push(0.0);
  108915. }
  108916. // direction
  108917. data.push(0.0);
  108918. data.push(0.0);
  108919. data.push(0.0);
  108920. if (!this.isBillboardBased) {
  108921. // initialDirection
  108922. data.push(0.0);
  108923. data.push(0.0);
  108924. data.push(0.0);
  108925. }
  108926. // angle
  108927. data.push(0.0);
  108928. if (!this._angularSpeedGradientsTexture) {
  108929. data.push(0.0);
  108930. }
  108931. if (this._isAnimationSheetEnabled) {
  108932. data.push(0.0);
  108933. if (this.spriteRandomStartCell) {
  108934. data.push(0.0);
  108935. }
  108936. }
  108937. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  108938. data.push(Math.random());
  108939. data.push(Math.random());
  108940. data.push(Math.random());
  108941. data.push(Math.random());
  108942. data.push(Math.random());
  108943. data.push(Math.random());
  108944. }
  108945. }
  108946. // Sprite data
  108947. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  108948. -0.5, 0.5, 0, 1,
  108949. -0.5, -0.5, 0, 0,
  108950. 0.5, -0.5, 1, 0]);
  108951. // Buffers
  108952. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  108953. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  108954. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  108955. // Update VAO
  108956. this._updateVAO = [];
  108957. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  108958. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  108959. // Render VAO
  108960. this._renderVAO = [];
  108961. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  108962. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  108963. // Links
  108964. this._sourceBuffer = this._buffer0;
  108965. this._targetBuffer = this._buffer1;
  108966. };
  108967. /** @hidden */
  108968. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  108969. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  108970. if (this._isBillboardBased) {
  108971. defines += "\n#define BILLBOARD";
  108972. }
  108973. if (this._colorGradientsTexture) {
  108974. defines += "\n#define COLORGRADIENTS";
  108975. }
  108976. if (this._sizeGradientsTexture) {
  108977. defines += "\n#define SIZEGRADIENTS";
  108978. }
  108979. if (this._angularSpeedGradientsTexture) {
  108980. defines += "\n#define ANGULARSPEEDGRADIENTS";
  108981. }
  108982. if (this._velocityGradientsTexture) {
  108983. defines += "\n#define VELOCITYGRADIENTS";
  108984. }
  108985. if (this._limitVelocityGradientsTexture) {
  108986. defines += "\n#define LIMITVELOCITYGRADIENTS";
  108987. }
  108988. if (this._dragGradientsTexture) {
  108989. defines += "\n#define DRAGGRADIENTS";
  108990. }
  108991. if (this.isAnimationSheetEnabled) {
  108992. defines += "\n#define ANIMATESHEET";
  108993. if (this.spriteRandomStartCell) {
  108994. defines += "\n#define ANIMATESHEETRANDOMSTART";
  108995. }
  108996. }
  108997. if (this.noiseTexture) {
  108998. defines += "\n#define NOISE";
  108999. }
  109000. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  109001. return;
  109002. }
  109003. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  109004. if (!this._colorGradientsTexture) {
  109005. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  109006. }
  109007. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  109008. if (!this._isBillboardBased) {
  109009. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  109010. }
  109011. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  109012. if (this.isAnimationSheetEnabled) {
  109013. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  109014. if (this.spriteRandomStartCell) {
  109015. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  109016. }
  109017. }
  109018. if (this.noiseTexture) {
  109019. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  109020. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  109021. }
  109022. this._updateEffectOptions.defines = defines;
  109023. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  109024. };
  109025. /** @hidden */
  109026. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  109027. var defines = "";
  109028. if (this._scene.clipPlane) {
  109029. defines = "\n#define CLIPPLANE";
  109030. }
  109031. if (this._scene.clipPlane2) {
  109032. defines = "\n#define CLIPPLANE2";
  109033. }
  109034. if (this._scene.clipPlane3) {
  109035. defines = "\n#define CLIPPLANE3";
  109036. }
  109037. if (this._scene.clipPlane4) {
  109038. defines = "\n#define CLIPPLANE4";
  109039. }
  109040. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  109041. defines = "\n#define BLENDMULTIPLYMODE";
  109042. }
  109043. if (this._isBillboardBased) {
  109044. defines += "\n#define BILLBOARD";
  109045. switch (this.billboardMode) {
  109046. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  109047. defines += "\n#define BILLBOARDY";
  109048. break;
  109049. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  109050. defines += "\n#define BILLBOARDSTRETCHED";
  109051. break;
  109052. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  109053. default:
  109054. break;
  109055. }
  109056. }
  109057. if (this._colorGradientsTexture) {
  109058. defines += "\n#define COLORGRADIENTS";
  109059. }
  109060. if (this.isAnimationSheetEnabled) {
  109061. defines += "\n#define ANIMATESHEET";
  109062. }
  109063. if (this._imageProcessingConfiguration) {
  109064. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  109065. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  109066. }
  109067. if (this._renderEffect && this._renderEffect.defines === defines) {
  109068. return;
  109069. }
  109070. var uniforms = ["worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  109071. var samplers = ["textureSampler", "colorGradientSampler"];
  109072. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  109073. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  109074. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  109075. }
  109076. this._renderEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuRenderParticles", ["position", "age", "life", "size", "color", "offset", "uv", "direction", "initialDirection", "angle", "cellIndex"], uniforms, samplers, this._scene.getEngine(), defines);
  109077. };
  109078. /**
  109079. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  109080. * @param preWarm defines if we are in the pre-warmimg phase
  109081. */
  109082. GPUParticleSystem.prototype.animate = function (preWarm) {
  109083. if (preWarm === void 0) { preWarm = false; }
  109084. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  109085. this._actualFrame += this._timeDelta;
  109086. if (!this._stopped) {
  109087. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  109088. this.stop();
  109089. }
  109090. }
  109091. };
  109092. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  109093. var texture = this[textureName];
  109094. if (!factorGradients || !factorGradients.length || texture) {
  109095. return;
  109096. }
  109097. var data = new Float32Array(this._rawTextureWidth);
  109098. for (var x = 0; x < this._rawTextureWidth; x++) {
  109099. var ratio = x / this._rawTextureWidth;
  109100. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  109101. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  109102. });
  109103. }
  109104. this[textureName] = _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__["RawTexture"].CreateRTexture(data, this._rawTextureWidth, 1, this._scene, false, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].NEAREST_SAMPLINGMODE);
  109105. };
  109106. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  109107. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  109108. };
  109109. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  109110. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  109111. };
  109112. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  109113. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  109114. };
  109115. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  109116. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  109117. };
  109118. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  109119. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  109120. };
  109121. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  109122. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  109123. return;
  109124. }
  109125. var data = new Uint8Array(this._rawTextureWidth * 4);
  109126. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  109127. for (var x = 0; x < this._rawTextureWidth; x++) {
  109128. var ratio = x / this._rawTextureWidth;
  109129. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  109130. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  109131. data[x * 4] = tmpColor.r * 255;
  109132. data[x * 4 + 1] = tmpColor.g * 255;
  109133. data[x * 4 + 2] = tmpColor.b * 255;
  109134. data[x * 4 + 3] = tmpColor.a * 255;
  109135. });
  109136. }
  109137. this._colorGradientsTexture = _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__["RawTexture"].CreateRGBATexture(data, this._rawTextureWidth, 1, this._scene, false, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].NEAREST_SAMPLINGMODE);
  109138. };
  109139. /**
  109140. * Renders the particle system in its current state
  109141. * @param preWarm defines if the system should only update the particles but not render them
  109142. * @returns the current number of particles
  109143. */
  109144. GPUParticleSystem.prototype.render = function (preWarm) {
  109145. if (preWarm === void 0) { preWarm = false; }
  109146. if (!this._started) {
  109147. return 0;
  109148. }
  109149. this._createColorGradientTexture();
  109150. this._createSizeGradientTexture();
  109151. this._createAngularSpeedGradientTexture();
  109152. this._createVelocityGradientTexture();
  109153. this._createLimitVelocityGradientTexture();
  109154. this._createDragGradientTexture();
  109155. this._recreateUpdateEffect();
  109156. this._recreateRenderEffect();
  109157. if (!this.isReady()) {
  109158. return 0;
  109159. }
  109160. if (!preWarm) {
  109161. if (!this._preWarmDone && this.preWarmCycles) {
  109162. for (var index = 0; index < this.preWarmCycles; index++) {
  109163. this.animate(true);
  109164. this.render(true);
  109165. }
  109166. this._preWarmDone = true;
  109167. }
  109168. if (this._currentRenderId === this._scene.getFrameId()) {
  109169. return 0;
  109170. }
  109171. this._currentRenderId = this._scene.getFrameId();
  109172. }
  109173. // Get everything ready to render
  109174. this._initialize();
  109175. this._accumulatedCount += this.emitRate * this._timeDelta;
  109176. if (this._accumulatedCount > 1) {
  109177. var intPart = this._accumulatedCount | 0;
  109178. this._accumulatedCount -= intPart;
  109179. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  109180. }
  109181. if (!this._currentActiveCount) {
  109182. return 0;
  109183. }
  109184. // Enable update effect
  109185. this._engine.enableEffect(this._updateEffect);
  109186. this._engine.setState(false);
  109187. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  109188. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  109189. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  109190. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  109191. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  109192. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  109193. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  109194. if (!this._colorGradientsTexture) {
  109195. this._updateEffect.setDirectColor4("color1", this.color1);
  109196. this._updateEffect.setDirectColor4("color2", this.color2);
  109197. }
  109198. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  109199. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  109200. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  109201. this._updateEffect.setVector3("gravity", this.gravity);
  109202. if (this._sizeGradientsTexture) {
  109203. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  109204. }
  109205. if (this._angularSpeedGradientsTexture) {
  109206. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  109207. }
  109208. if (this._velocityGradientsTexture) {
  109209. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  109210. }
  109211. if (this._limitVelocityGradientsTexture) {
  109212. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  109213. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  109214. }
  109215. if (this._dragGradientsTexture) {
  109216. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  109217. }
  109218. if (this.particleEmitterType) {
  109219. this.particleEmitterType.applyToShader(this._updateEffect);
  109220. }
  109221. if (this._isAnimationSheetEnabled) {
  109222. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  109223. }
  109224. if (this.noiseTexture) {
  109225. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  109226. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  109227. }
  109228. var emitterWM;
  109229. if (this.emitter.position) {
  109230. var emitterMesh = this.emitter;
  109231. emitterWM = emitterMesh.getWorldMatrix();
  109232. }
  109233. else {
  109234. var emitterPosition = this.emitter;
  109235. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  109236. }
  109237. this._updateEffect.setMatrix("emitterWM", emitterWM);
  109238. // Bind source VAO
  109239. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  109240. // Update
  109241. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  109242. this._engine.setRasterizerState(false);
  109243. this._engine.beginTransformFeedback(true);
  109244. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  109245. this._engine.endTransformFeedback();
  109246. this._engine.setRasterizerState(true);
  109247. this._engine.bindTransformFeedbackBuffer(null);
  109248. if (!preWarm) {
  109249. // Enable render effect
  109250. this._engine.enableEffect(this._renderEffect);
  109251. var viewMatrix = this._scene.getViewMatrix();
  109252. this._renderEffect.setMatrix("view", viewMatrix);
  109253. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  109254. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  109255. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  109256. this._renderEffect.setVector3("worldOffset", this.worldOffset);
  109257. if (this._colorGradientsTexture) {
  109258. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  109259. }
  109260. else {
  109261. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  109262. }
  109263. if (this._isAnimationSheetEnabled && this.particleTexture) {
  109264. var baseSize = this.particleTexture.getBaseSize();
  109265. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  109266. }
  109267. if (this._isBillboardBased) {
  109268. var camera = this._scene.activeCamera;
  109269. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  109270. }
  109271. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  109272. var invView = viewMatrix.clone();
  109273. invView.invert();
  109274. this._renderEffect.setMatrix("invView", invView);
  109275. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  109276. }
  109277. // image processing
  109278. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  109279. this._imageProcessingConfiguration.bind(this._renderEffect);
  109280. }
  109281. // Draw order
  109282. switch (this.blendMode) {
  109283. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  109284. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  109285. break;
  109286. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  109287. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  109288. break;
  109289. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  109290. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  109291. break;
  109292. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  109293. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  109294. break;
  109295. }
  109296. if (this.forceDepthWrite) {
  109297. this._engine.setDepthWrite(true);
  109298. }
  109299. // Bind source VAO
  109300. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  109301. // Render
  109302. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  109303. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  109304. }
  109305. // Switch VAOs
  109306. this._targetIndex++;
  109307. if (this._targetIndex === 2) {
  109308. this._targetIndex = 0;
  109309. }
  109310. // Switch buffers
  109311. var tmpBuffer = this._sourceBuffer;
  109312. this._sourceBuffer = this._targetBuffer;
  109313. this._targetBuffer = tmpBuffer;
  109314. return this._currentActiveCount;
  109315. };
  109316. /**
  109317. * Rebuilds the particle system
  109318. */
  109319. GPUParticleSystem.prototype.rebuild = function () {
  109320. this._initialize(true);
  109321. };
  109322. GPUParticleSystem.prototype._releaseBuffers = function () {
  109323. if (this._buffer0) {
  109324. this._buffer0.dispose();
  109325. this._buffer0 = null;
  109326. }
  109327. if (this._buffer1) {
  109328. this._buffer1.dispose();
  109329. this._buffer1 = null;
  109330. }
  109331. if (this._spriteBuffer) {
  109332. this._spriteBuffer.dispose();
  109333. this._spriteBuffer = null;
  109334. }
  109335. };
  109336. GPUParticleSystem.prototype._releaseVAOs = function () {
  109337. if (!this._updateVAO) {
  109338. return;
  109339. }
  109340. for (var index = 0; index < this._updateVAO.length; index++) {
  109341. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  109342. }
  109343. this._updateVAO = [];
  109344. for (var index = 0; index < this._renderVAO.length; index++) {
  109345. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  109346. }
  109347. this._renderVAO = [];
  109348. };
  109349. /**
  109350. * Disposes the particle system and free the associated resources
  109351. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  109352. */
  109353. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  109354. if (disposeTexture === void 0) { disposeTexture = true; }
  109355. var index = this._scene.particleSystems.indexOf(this);
  109356. if (index > -1) {
  109357. this._scene.particleSystems.splice(index, 1);
  109358. }
  109359. this._releaseBuffers();
  109360. this._releaseVAOs();
  109361. if (this._colorGradientsTexture) {
  109362. this._colorGradientsTexture.dispose();
  109363. this._colorGradientsTexture = null;
  109364. }
  109365. if (this._sizeGradientsTexture) {
  109366. this._sizeGradientsTexture.dispose();
  109367. this._sizeGradientsTexture = null;
  109368. }
  109369. if (this._angularSpeedGradientsTexture) {
  109370. this._angularSpeedGradientsTexture.dispose();
  109371. this._angularSpeedGradientsTexture = null;
  109372. }
  109373. if (this._velocityGradientsTexture) {
  109374. this._velocityGradientsTexture.dispose();
  109375. this._velocityGradientsTexture = null;
  109376. }
  109377. if (this._limitVelocityGradientsTexture) {
  109378. this._limitVelocityGradientsTexture.dispose();
  109379. this._limitVelocityGradientsTexture = null;
  109380. }
  109381. if (this._dragGradientsTexture) {
  109382. this._dragGradientsTexture.dispose();
  109383. this._dragGradientsTexture = null;
  109384. }
  109385. if (this._randomTexture) {
  109386. this._randomTexture.dispose();
  109387. this._randomTexture = null;
  109388. }
  109389. if (this._randomTexture2) {
  109390. this._randomTexture2.dispose();
  109391. this._randomTexture2 = null;
  109392. }
  109393. if (disposeTexture && this.particleTexture) {
  109394. this.particleTexture.dispose();
  109395. this.particleTexture = null;
  109396. }
  109397. if (disposeTexture && this.noiseTexture) {
  109398. this.noiseTexture.dispose();
  109399. this.noiseTexture = null;
  109400. }
  109401. // Callback
  109402. this.onDisposeObservable.notifyObservers(this);
  109403. this.onDisposeObservable.clear();
  109404. };
  109405. /**
  109406. * Clones the particle system.
  109407. * @param name The name of the cloned object
  109408. * @param newEmitter The new emitter to use
  109409. * @returns the cloned particle system
  109410. */
  109411. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  109412. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  109413. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  109414. if (newEmitter === undefined) {
  109415. newEmitter = this.emitter;
  109416. }
  109417. result.emitter = newEmitter;
  109418. if (this.particleTexture) {
  109419. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  109420. }
  109421. return result;
  109422. };
  109423. /**
  109424. * Serializes the particle system to a JSON object.
  109425. * @returns the JSON object
  109426. */
  109427. GPUParticleSystem.prototype.serialize = function () {
  109428. var serializationObject = {};
  109429. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  109430. serializationObject.activeParticleCount = this.activeParticleCount;
  109431. return serializationObject;
  109432. };
  109433. /**
  109434. * Parses a JSON object to create a GPU particle system.
  109435. * @param parsedParticleSystem The JSON object to parse
  109436. * @param scene The scene to create the particle system in
  109437. * @param rootUrl The root url to use to load external dependencies like texture
  109438. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  109439. * @returns the parsed GPU particle system
  109440. */
  109441. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  109442. if (doNotStart === void 0) { doNotStart = false; }
  109443. var name = parsedParticleSystem.name;
  109444. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  109445. if (parsedParticleSystem.activeParticleCount) {
  109446. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  109447. }
  109448. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  109449. // Auto start
  109450. if (parsedParticleSystem.preventAutoStart) {
  109451. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  109452. }
  109453. if (!doNotStart && !particleSystem.preventAutoStart) {
  109454. particleSystem.start();
  109455. }
  109456. return particleSystem;
  109457. };
  109458. return GPUParticleSystem;
  109459. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  109460. /***/ }),
  109461. /***/ "./Particles/index.ts":
  109462. /*!****************************!*\
  109463. !*** ./Particles/index.ts ***!
  109464. \****************************/
  109465. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  109466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109467. "use strict";
  109468. __webpack_require__.r(__webpack_exports__);
  109469. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  109470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  109471. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  109472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  109473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  109474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  109475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  109476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  109477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  109478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  109479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  109480. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  109481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  109482. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  109483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  109484. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  109485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  109486. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  109487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  109488. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  109489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  109490. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  109491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  109492. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  109493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  109494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  109495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  109496. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  109497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  109498. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  109499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  109500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  109501. /***/ }),
  109502. /***/ "./Particles/particle.ts":
  109503. /*!*******************************!*\
  109504. !*** ./Particles/particle.ts ***!
  109505. \*******************************/
  109506. /*! exports provided: Particle */
  109507. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109508. "use strict";
  109509. __webpack_require__.r(__webpack_exports__);
  109510. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  109511. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109512. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  109513. /**
  109514. * A particle represents one of the element emitted by a particle system.
  109515. * This is mainly define by its coordinates, direction, velocity and age.
  109516. */
  109517. var Particle = /** @class */ (function () {
  109518. /**
  109519. * Creates a new instance Particle
  109520. * @param particleSystem the particle system the particle belongs to
  109521. */
  109522. function Particle(
  109523. /**
  109524. * The particle system the particle belongs to.
  109525. */
  109526. particleSystem) {
  109527. this.particleSystem = particleSystem;
  109528. /**
  109529. * The world position of the particle in the scene.
  109530. */
  109531. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109532. /**
  109533. * The world direction of the particle in the scene.
  109534. */
  109535. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109536. /**
  109537. * The color of the particle.
  109538. */
  109539. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  109540. /**
  109541. * The color change of the particle per step.
  109542. */
  109543. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  109544. /**
  109545. * Defines how long will the life of the particle be.
  109546. */
  109547. this.lifeTime = 1.0;
  109548. /**
  109549. * The current age of the particle.
  109550. */
  109551. this.age = 0;
  109552. /**
  109553. * The current size of the particle.
  109554. */
  109555. this.size = 0;
  109556. /**
  109557. * The current scale of the particle.
  109558. */
  109559. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  109560. /**
  109561. * The current angle of the particle.
  109562. */
  109563. this.angle = 0;
  109564. /**
  109565. * Defines how fast is the angle changing.
  109566. */
  109567. this.angularSpeed = 0;
  109568. /**
  109569. * Defines the cell index used by the particle to be rendered from a sprite.
  109570. */
  109571. this.cellIndex = 0;
  109572. /** @hidden */
  109573. this._attachedSubEmitters = null;
  109574. /** @hidden */
  109575. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  109576. /** @hidden */
  109577. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  109578. /** @hidden */
  109579. this._currentSize1 = 0;
  109580. /** @hidden */
  109581. this._currentSize2 = 0;
  109582. /** @hidden */
  109583. this._currentAngularSpeed1 = 0;
  109584. /** @hidden */
  109585. this._currentAngularSpeed2 = 0;
  109586. /** @hidden */
  109587. this._currentVelocity1 = 0;
  109588. /** @hidden */
  109589. this._currentVelocity2 = 0;
  109590. /** @hidden */
  109591. this._currentLimitVelocity1 = 0;
  109592. /** @hidden */
  109593. this._currentLimitVelocity2 = 0;
  109594. /** @hidden */
  109595. this._currentDrag1 = 0;
  109596. /** @hidden */
  109597. this._currentDrag2 = 0;
  109598. this.id = Particle._Count++;
  109599. if (!this.particleSystem.isAnimationSheetEnabled) {
  109600. return;
  109601. }
  109602. this.updateCellInfoFromSystem();
  109603. }
  109604. Particle.prototype.updateCellInfoFromSystem = function () {
  109605. this.cellIndex = this.particleSystem.startSpriteCellID;
  109606. };
  109607. /**
  109608. * Defines how the sprite cell index is updated for the particle
  109609. */
  109610. Particle.prototype.updateCellIndex = function () {
  109611. var offsetAge = this.age;
  109612. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  109613. if (this.particleSystem.spriteRandomStartCell) {
  109614. if (this._randomCellOffset === undefined) {
  109615. this._randomCellOffset = Math.random() * this.lifeTime;
  109616. }
  109617. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  109618. changeSpeed = 1;
  109619. offsetAge = this._randomCellOffset;
  109620. }
  109621. else {
  109622. offsetAge += this._randomCellOffset;
  109623. }
  109624. }
  109625. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  109626. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  109627. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  109628. };
  109629. /** @hidden */
  109630. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  109631. if (subEmitter.particleSystem.emitter.position) {
  109632. var emitterMesh = subEmitter.particleSystem.emitter;
  109633. emitterMesh.position.copyFrom(this.position);
  109634. if (subEmitter.inheritDirection) {
  109635. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  109636. // Look at using Y as forward
  109637. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  109638. }
  109639. }
  109640. else {
  109641. var emitterPosition = subEmitter.particleSystem.emitter;
  109642. emitterPosition.copyFrom(this.position);
  109643. }
  109644. // Set inheritedVelocityOffset to be used when new particles are created
  109645. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  109646. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  109647. };
  109648. /** @hidden */
  109649. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  109650. var _this = this;
  109651. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  109652. this._attachedSubEmitters.forEach(function (subEmitter) {
  109653. _this._inheritParticleInfoToSubEmitter(subEmitter);
  109654. });
  109655. }
  109656. };
  109657. /** @hidden */
  109658. Particle.prototype._reset = function () {
  109659. this.age = 0;
  109660. this._currentColorGradient = null;
  109661. this._currentSizeGradient = null;
  109662. this._currentAngularSpeedGradient = null;
  109663. this._currentVelocityGradient = null;
  109664. this._currentLimitVelocityGradient = null;
  109665. this._currentDragGradient = null;
  109666. this.cellIndex = this.particleSystem.startSpriteCellID;
  109667. this._randomCellOffset = undefined;
  109668. };
  109669. /**
  109670. * Copy the properties of particle to another one.
  109671. * @param other the particle to copy the information to.
  109672. */
  109673. Particle.prototype.copyTo = function (other) {
  109674. other.position.copyFrom(this.position);
  109675. if (this._initialDirection) {
  109676. if (other._initialDirection) {
  109677. other._initialDirection.copyFrom(this._initialDirection);
  109678. }
  109679. else {
  109680. other._initialDirection = this._initialDirection.clone();
  109681. }
  109682. }
  109683. else {
  109684. other._initialDirection = null;
  109685. }
  109686. other.direction.copyFrom(this.direction);
  109687. other.color.copyFrom(this.color);
  109688. other.colorStep.copyFrom(this.colorStep);
  109689. other.lifeTime = this.lifeTime;
  109690. other.age = this.age;
  109691. other._randomCellOffset = this._randomCellOffset;
  109692. other.size = this.size;
  109693. other.scale.copyFrom(this.scale);
  109694. other.angle = this.angle;
  109695. other.angularSpeed = this.angularSpeed;
  109696. other.particleSystem = this.particleSystem;
  109697. other.cellIndex = this.cellIndex;
  109698. other.id = this.id;
  109699. other._attachedSubEmitters = this._attachedSubEmitters;
  109700. if (this._currentColorGradient) {
  109701. other._currentColorGradient = this._currentColorGradient;
  109702. other._currentColor1.copyFrom(this._currentColor1);
  109703. other._currentColor2.copyFrom(this._currentColor2);
  109704. }
  109705. if (this._currentSizeGradient) {
  109706. other._currentSizeGradient = this._currentSizeGradient;
  109707. other._currentSize1 = this._currentSize1;
  109708. other._currentSize2 = this._currentSize2;
  109709. }
  109710. if (this._currentAngularSpeedGradient) {
  109711. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  109712. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  109713. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  109714. }
  109715. if (this._currentVelocityGradient) {
  109716. other._currentVelocityGradient = this._currentVelocityGradient;
  109717. other._currentVelocity1 = this._currentVelocity1;
  109718. other._currentVelocity2 = this._currentVelocity2;
  109719. }
  109720. if (this._currentLimitVelocityGradient) {
  109721. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  109722. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  109723. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  109724. }
  109725. if (this._currentDragGradient) {
  109726. other._currentDragGradient = this._currentDragGradient;
  109727. other._currentDrag1 = this._currentDrag1;
  109728. other._currentDrag2 = this._currentDrag2;
  109729. }
  109730. if (this.particleSystem.isAnimationSheetEnabled) {
  109731. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  109732. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  109733. }
  109734. if (this.particleSystem.useRampGradients) {
  109735. other.remapData.copyFrom(this.remapData);
  109736. }
  109737. if (this._randomNoiseCoordinates1) {
  109738. if (other._randomNoiseCoordinates1) {
  109739. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  109740. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  109741. }
  109742. else {
  109743. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  109744. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  109745. }
  109746. }
  109747. };
  109748. Particle._Count = 0;
  109749. return Particle;
  109750. }());
  109751. /***/ }),
  109752. /***/ "./Particles/particleHelper.ts":
  109753. /*!*************************************!*\
  109754. !*** ./Particles/particleHelper.ts ***!
  109755. \*************************************/
  109756. /*! exports provided: ParticleHelper */
  109757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109758. "use strict";
  109759. __webpack_require__.r(__webpack_exports__);
  109760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  109761. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  109762. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109763. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  109764. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  109765. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  109766. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  109767. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  109768. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  109769. /**
  109770. * This class is made for on one-liner static method to help creating particle system set.
  109771. */
  109772. var ParticleHelper = /** @class */ (function () {
  109773. function ParticleHelper() {
  109774. }
  109775. /**
  109776. * Create a default particle system that you can tweak
  109777. * @param emitter defines the emitter to use
  109778. * @param capacity defines the system capacity (default is 500 particles)
  109779. * @param scene defines the hosting scene
  109780. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  109781. * @returns the new Particle system
  109782. */
  109783. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  109784. if (capacity === void 0) { capacity = 500; }
  109785. if (useGPU === void 0) { useGPU = false; }
  109786. var system;
  109787. if (useGPU) {
  109788. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  109789. }
  109790. else {
  109791. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  109792. }
  109793. system.emitter = emitter;
  109794. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  109795. system.createConeEmitter(0.1, Math.PI / 4);
  109796. // Particle color
  109797. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  109798. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  109799. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  109800. // Particle Size
  109801. system.minSize = 0.1;
  109802. system.maxSize = 0.1;
  109803. // Emission speed
  109804. system.minEmitPower = 2;
  109805. system.maxEmitPower = 2;
  109806. // Update speed
  109807. system.updateSpeed = 1 / 60;
  109808. system.emitRate = 30;
  109809. return system;
  109810. };
  109811. /**
  109812. * This is the main static method (one-liner) of this helper to create different particle systems
  109813. * @param type This string represents the type to the particle system to create
  109814. * @param scene The scene where the particle system should live
  109815. * @param gpu If the system will use gpu
  109816. * @returns the ParticleSystemSet created
  109817. */
  109818. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  109819. if (gpu === void 0) { gpu = false; }
  109820. if (!scene) {
  109821. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  109822. }
  109823. var token = {};
  109824. scene._addPendingData(token);
  109825. return new Promise(function (resolve, reject) {
  109826. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  109827. scene._removePendingData(token);
  109828. return reject("Particle system with GPU is not supported.");
  109829. }
  109830. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  109831. scene._removePendingData(token);
  109832. var newData = JSON.parse(data.toString());
  109833. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  109834. }, undefined, undefined, undefined, function () {
  109835. scene._removePendingData(token);
  109836. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  109837. });
  109838. });
  109839. };
  109840. /**
  109841. * Static function used to export a particle system to a ParticleSystemSet variable.
  109842. * Please note that the emitter shape is not exported
  109843. * @param systems defines the particle systems to export
  109844. * @returns the created particle system set
  109845. */
  109846. ParticleHelper.ExportSet = function (systems) {
  109847. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  109848. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  109849. var system = systems_1[_i];
  109850. set.systems.push(system);
  109851. }
  109852. return set;
  109853. };
  109854. /**
  109855. * Gets or sets base Assets URL
  109856. */
  109857. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  109858. return ParticleHelper;
  109859. }());
  109860. /***/ }),
  109861. /***/ "./Particles/particleSystem.ts":
  109862. /*!*************************************!*\
  109863. !*** ./Particles/particleSystem.ts ***!
  109864. \*************************************/
  109865. /*! exports provided: ParticleSystem */
  109866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109867. "use strict";
  109868. __webpack_require__.r(__webpack_exports__);
  109869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  109870. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  109871. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  109872. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  109873. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109874. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  109875. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  109876. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  109877. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  109878. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  109879. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  109880. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  109881. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  109882. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  109883. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  109884. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  109885. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  109886. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  109887. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  109888. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  109889. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  109890. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  109891. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  109892. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  109893. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  109894. /**
  109895. * This represents a particle system in Babylon.
  109896. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  109897. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  109898. * @example https://doc.babylonjs.com/babylon101/particles
  109899. */
  109900. var ParticleSystem = /** @class */ (function (_super) {
  109901. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  109902. /**
  109903. * Instantiates a particle system.
  109904. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  109905. * @param name The name of the particle system
  109906. * @param capacity The max number of particles alive at the same time
  109907. * @param scene The scene the particle system belongs to
  109908. * @param customEffect a custom effect used to change the way particles are rendered by default
  109909. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  109910. * @param epsilon Offset used to render the particles
  109911. */
  109912. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  109913. if (customEffect === void 0) { customEffect = null; }
  109914. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  109915. if (epsilon === void 0) { epsilon = 0.01; }
  109916. var _this = _super.call(this, name) || this;
  109917. /**
  109918. * @hidden
  109919. */
  109920. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  109921. /**
  109922. * An event triggered when the system is disposed
  109923. */
  109924. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  109925. _this._particles = new Array();
  109926. _this._stockParticles = new Array();
  109927. _this._newPartsExcess = 0;
  109928. _this._vertexBuffers = {};
  109929. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  109930. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  109931. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  109932. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  109933. _this._currentRenderId = -1;
  109934. _this._useInstancing = false;
  109935. _this._started = false;
  109936. _this._stopped = false;
  109937. _this._actualFrame = 0;
  109938. /** @hidden */
  109939. _this._currentEmitRate1 = 0;
  109940. /** @hidden */
  109941. _this._currentEmitRate2 = 0;
  109942. /** @hidden */
  109943. _this._currentStartSize1 = 0;
  109944. /** @hidden */
  109945. _this._currentStartSize2 = 0;
  109946. _this._rawTextureWidth = 256;
  109947. _this._useRampGradients = false;
  109948. /**
  109949. * @hidden
  109950. * If the particle systems emitter should be disposed when the particle system is disposed
  109951. */
  109952. _this._disposeEmitterOnDispose = false;
  109953. // start of sub system methods
  109954. /**
  109955. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  109956. * Its lifetime will start back at 0.
  109957. */
  109958. _this.recycleParticle = function (particle) {
  109959. // move particle from activeParticle list to stock particles
  109960. var lastParticle = _this._particles.pop();
  109961. if (lastParticle !== particle) {
  109962. lastParticle.copyTo(particle);
  109963. }
  109964. _this._stockParticles.push(lastParticle);
  109965. };
  109966. _this._createParticle = function () {
  109967. var particle;
  109968. if (_this._stockParticles.length !== 0) {
  109969. particle = _this._stockParticles.pop();
  109970. particle._reset();
  109971. }
  109972. else {
  109973. particle = new _particle__WEBPACK_IMPORTED_MODULE_16__["Particle"](_this);
  109974. }
  109975. // Attach emitters
  109976. if (_this._subEmitters && _this._subEmitters.length > 0) {
  109977. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  109978. particle._attachedSubEmitters = [];
  109979. subEmitters.forEach(function (subEmitter) {
  109980. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].ATTACHED) {
  109981. var newEmitter = subEmitter.clone();
  109982. particle._attachedSubEmitters.push(newEmitter);
  109983. newEmitter.particleSystem.start();
  109984. }
  109985. });
  109986. }
  109987. return particle;
  109988. };
  109989. _this._emitFromParticle = function (particle) {
  109990. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  109991. return;
  109992. }
  109993. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  109994. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  109995. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].END) {
  109996. var subSystem = subEmitter.clone();
  109997. particle._inheritParticleInfoToSubEmitter(subSystem);
  109998. subSystem.particleSystem._rootParticleSystem = _this;
  109999. _this.activeSubSystems.push(subSystem.particleSystem);
  110000. subSystem.particleSystem.start();
  110001. }
  110002. });
  110003. };
  110004. _this._capacity = capacity;
  110005. _this._epsilon = epsilon;
  110006. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  110007. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  110008. // Setup the default processing configuration to the scene.
  110009. _this._attachImageProcessingConfiguration(null);
  110010. _this._customEffect = customEffect;
  110011. _this._scene.particleSystems.push(_this);
  110012. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  110013. _this._createIndexBuffer();
  110014. _this._createVertexBuffers();
  110015. // Default emitter type
  110016. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  110017. // Update
  110018. _this.updateFunction = function (particles) {
  110019. var noiseTextureSize = null;
  110020. var noiseTextureData = null;
  110021. if (_this.noiseTexture) { // We need to get texture data back to CPU
  110022. noiseTextureSize = _this.noiseTexture.getSize();
  110023. noiseTextureData = (_this.noiseTexture.getContent());
  110024. }
  110025. var _loop_1 = function () {
  110026. particle = particles[index];
  110027. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  110028. var previousAge = particle.age;
  110029. particle.age += scaledUpdateSpeed;
  110030. // Evaluate step to death
  110031. if (particle.age > particle.lifeTime) {
  110032. var diff = particle.age - previousAge;
  110033. var oldDiff = particle.lifeTime - previousAge;
  110034. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  110035. particle.age = particle.lifeTime;
  110036. }
  110037. var ratio = particle.age / particle.lifeTime;
  110038. // Color
  110039. if (_this._colorGradients && _this._colorGradients.length > 0) {
  110040. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  110041. if (currentGradient !== particle._currentColorGradient) {
  110042. particle._currentColor1.copyFrom(particle._currentColor2);
  110043. nextGradient.getColorToRef(particle._currentColor2);
  110044. particle._currentColorGradient = currentGradient;
  110045. }
  110046. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  110047. });
  110048. }
  110049. else {
  110050. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  110051. particle.color.addInPlace(_this._scaledColorStep);
  110052. if (particle.color.a < 0) {
  110053. particle.color.a = 0;
  110054. }
  110055. }
  110056. // Angular speed
  110057. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  110058. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  110059. if (currentGradient !== particle._currentAngularSpeedGradient) {
  110060. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  110061. particle._currentAngularSpeed2 = nextGradient.getFactor();
  110062. particle._currentAngularSpeedGradient = currentGradient;
  110063. }
  110064. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  110065. });
  110066. }
  110067. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  110068. // Direction
  110069. var directionScale = scaledUpdateSpeed;
  110070. /// Velocity
  110071. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  110072. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  110073. if (currentGradient !== particle._currentVelocityGradient) {
  110074. particle._currentVelocity1 = particle._currentVelocity2;
  110075. particle._currentVelocity2 = nextGradient.getFactor();
  110076. particle._currentVelocityGradient = currentGradient;
  110077. }
  110078. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  110079. });
  110080. }
  110081. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  110082. /// Limit velocity
  110083. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  110084. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  110085. if (currentGradient !== particle._currentLimitVelocityGradient) {
  110086. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  110087. particle._currentLimitVelocity2 = nextGradient.getFactor();
  110088. particle._currentLimitVelocityGradient = currentGradient;
  110089. }
  110090. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  110091. var currentVelocity = particle.direction.length();
  110092. if (currentVelocity > limitVelocity) {
  110093. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  110094. }
  110095. });
  110096. }
  110097. /// Drag
  110098. if (_this._dragGradients && _this._dragGradients.length > 0) {
  110099. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  110100. if (currentGradient !== particle._currentDragGradient) {
  110101. particle._currentDrag1 = particle._currentDrag2;
  110102. particle._currentDrag2 = nextGradient.getFactor();
  110103. particle._currentDragGradient = currentGradient;
  110104. }
  110105. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  110106. _this._scaledDirection.scaleInPlace(1.0 - drag);
  110107. });
  110108. }
  110109. particle.position.addInPlace(_this._scaledDirection);
  110110. // Noise
  110111. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  110112. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  110113. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  110114. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  110115. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  110116. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  110117. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  110118. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  110119. particle.direction.addInPlace(scaledForce);
  110120. }
  110121. // Gravity
  110122. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  110123. particle.direction.addInPlace(_this._scaledGravity);
  110124. // Size
  110125. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  110126. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  110127. if (currentGradient !== particle._currentSizeGradient) {
  110128. particle._currentSize1 = particle._currentSize2;
  110129. particle._currentSize2 = nextGradient.getFactor();
  110130. particle._currentSizeGradient = currentGradient;
  110131. }
  110132. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  110133. });
  110134. }
  110135. // Remap data
  110136. if (_this._useRampGradients) {
  110137. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  110138. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  110139. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  110140. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  110141. particle.remapData.x = min;
  110142. particle.remapData.y = max - min;
  110143. });
  110144. }
  110145. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  110146. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  110147. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  110148. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  110149. particle.remapData.z = min;
  110150. particle.remapData.w = max - min;
  110151. });
  110152. }
  110153. }
  110154. if (_this._isAnimationSheetEnabled) {
  110155. particle.updateCellIndex();
  110156. }
  110157. // Update the position of the attached sub-emitters to match their attached particle
  110158. particle._inheritParticleInfoToSubEmitters();
  110159. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  110160. _this._emitFromParticle(particle);
  110161. if (particle._attachedSubEmitters) {
  110162. particle._attachedSubEmitters.forEach(function (subEmitter) {
  110163. subEmitter.particleSystem.disposeOnStop = true;
  110164. subEmitter.particleSystem.stop();
  110165. });
  110166. particle._attachedSubEmitters = null;
  110167. }
  110168. _this.recycleParticle(particle);
  110169. index--;
  110170. return "continue";
  110171. }
  110172. };
  110173. var particle;
  110174. for (var index = 0; index < particles.length; index++) {
  110175. _loop_1();
  110176. }
  110177. };
  110178. return _this;
  110179. }
  110180. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  110181. /**
  110182. * Sets a callback that will be triggered when the system is disposed
  110183. */
  110184. set: function (callback) {
  110185. if (this._onDisposeObserver) {
  110186. this.onDisposeObservable.remove(this._onDisposeObserver);
  110187. }
  110188. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  110189. },
  110190. enumerable: true,
  110191. configurable: true
  110192. });
  110193. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  110194. /** Gets or sets a boolean indicating that ramp gradients must be used
  110195. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  110196. */
  110197. get: function () {
  110198. return this._useRampGradients;
  110199. },
  110200. set: function (value) {
  110201. if (this._useRampGradients === value) {
  110202. return;
  110203. }
  110204. this._useRampGradients = value;
  110205. this._resetEffect();
  110206. },
  110207. enumerable: true,
  110208. configurable: true
  110209. });
  110210. Object.defineProperty(ParticleSystem.prototype, "particles", {
  110211. //end of Sub-emitter
  110212. /**
  110213. * Gets the current list of active particles
  110214. */
  110215. get: function () {
  110216. return this._particles;
  110217. },
  110218. enumerable: true,
  110219. configurable: true
  110220. });
  110221. /**
  110222. * Returns the string "ParticleSystem"
  110223. * @returns a string containing the class name
  110224. */
  110225. ParticleSystem.prototype.getClassName = function () {
  110226. return "ParticleSystem";
  110227. };
  110228. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  110229. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  110230. newGradient.gradient = gradient;
  110231. newGradient.factor1 = factor;
  110232. newGradient.factor2 = factor2;
  110233. factorGradients.push(newGradient);
  110234. factorGradients.sort(function (a, b) {
  110235. if (a.gradient < b.gradient) {
  110236. return -1;
  110237. }
  110238. else if (a.gradient > b.gradient) {
  110239. return 1;
  110240. }
  110241. return 0;
  110242. });
  110243. };
  110244. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  110245. if (!factorGradients) {
  110246. return;
  110247. }
  110248. var index = 0;
  110249. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  110250. var factorGradient = factorGradients_1[_i];
  110251. if (factorGradient.gradient === gradient) {
  110252. factorGradients.splice(index, 1);
  110253. break;
  110254. }
  110255. index++;
  110256. }
  110257. };
  110258. /**
  110259. * Adds a new life time gradient
  110260. * @param gradient defines the gradient to use (between 0 and 1)
  110261. * @param factor defines the life time factor to affect to the specified gradient
  110262. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110263. * @returns the current particle system
  110264. */
  110265. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  110266. if (!this._lifeTimeGradients) {
  110267. this._lifeTimeGradients = [];
  110268. }
  110269. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  110270. return this;
  110271. };
  110272. /**
  110273. * Remove a specific life time gradient
  110274. * @param gradient defines the gradient to remove
  110275. * @returns the current particle system
  110276. */
  110277. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  110278. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  110279. return this;
  110280. };
  110281. /**
  110282. * Adds a new size gradient
  110283. * @param gradient defines the gradient to use (between 0 and 1)
  110284. * @param factor defines the size factor to affect to the specified gradient
  110285. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110286. * @returns the current particle system
  110287. */
  110288. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  110289. if (!this._sizeGradients) {
  110290. this._sizeGradients = [];
  110291. }
  110292. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  110293. return this;
  110294. };
  110295. /**
  110296. * Remove a specific size gradient
  110297. * @param gradient defines the gradient to remove
  110298. * @returns the current particle system
  110299. */
  110300. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  110301. this._removeFactorGradient(this._sizeGradients, gradient);
  110302. return this;
  110303. };
  110304. /**
  110305. * Adds a new color remap gradient
  110306. * @param gradient defines the gradient to use (between 0 and 1)
  110307. * @param min defines the color remap minimal range
  110308. * @param max defines the color remap maximal range
  110309. * @returns the current particle system
  110310. */
  110311. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  110312. if (!this._colorRemapGradients) {
  110313. this._colorRemapGradients = [];
  110314. }
  110315. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  110316. return this;
  110317. };
  110318. /**
  110319. * Remove a specific color remap gradient
  110320. * @param gradient defines the gradient to remove
  110321. * @returns the current particle system
  110322. */
  110323. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  110324. this._removeFactorGradient(this._colorRemapGradients, gradient);
  110325. return this;
  110326. };
  110327. /**
  110328. * Adds a new alpha remap gradient
  110329. * @param gradient defines the gradient to use (between 0 and 1)
  110330. * @param min defines the alpha remap minimal range
  110331. * @param max defines the alpha remap maximal range
  110332. * @returns the current particle system
  110333. */
  110334. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  110335. if (!this._alphaRemapGradients) {
  110336. this._alphaRemapGradients = [];
  110337. }
  110338. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  110339. return this;
  110340. };
  110341. /**
  110342. * Remove a specific alpha remap gradient
  110343. * @param gradient defines the gradient to remove
  110344. * @returns the current particle system
  110345. */
  110346. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  110347. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  110348. return this;
  110349. };
  110350. /**
  110351. * Adds a new angular speed gradient
  110352. * @param gradient defines the gradient to use (between 0 and 1)
  110353. * @param factor defines the angular speed to affect to the specified gradient
  110354. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110355. * @returns the current particle system
  110356. */
  110357. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  110358. if (!this._angularSpeedGradients) {
  110359. this._angularSpeedGradients = [];
  110360. }
  110361. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  110362. return this;
  110363. };
  110364. /**
  110365. * Remove a specific angular speed gradient
  110366. * @param gradient defines the gradient to remove
  110367. * @returns the current particle system
  110368. */
  110369. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  110370. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  110371. return this;
  110372. };
  110373. /**
  110374. * Adds a new velocity gradient
  110375. * @param gradient defines the gradient to use (between 0 and 1)
  110376. * @param factor defines the velocity to affect to the specified gradient
  110377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110378. * @returns the current particle system
  110379. */
  110380. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  110381. if (!this._velocityGradients) {
  110382. this._velocityGradients = [];
  110383. }
  110384. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  110385. return this;
  110386. };
  110387. /**
  110388. * Remove a specific velocity gradient
  110389. * @param gradient defines the gradient to remove
  110390. * @returns the current particle system
  110391. */
  110392. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  110393. this._removeFactorGradient(this._velocityGradients, gradient);
  110394. return this;
  110395. };
  110396. /**
  110397. * Adds a new limit velocity gradient
  110398. * @param gradient defines the gradient to use (between 0 and 1)
  110399. * @param factor defines the limit velocity value to affect to the specified gradient
  110400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110401. * @returns the current particle system
  110402. */
  110403. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  110404. if (!this._limitVelocityGradients) {
  110405. this._limitVelocityGradients = [];
  110406. }
  110407. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  110408. return this;
  110409. };
  110410. /**
  110411. * Remove a specific limit velocity gradient
  110412. * @param gradient defines the gradient to remove
  110413. * @returns the current particle system
  110414. */
  110415. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  110416. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  110417. return this;
  110418. };
  110419. /**
  110420. * Adds a new drag gradient
  110421. * @param gradient defines the gradient to use (between 0 and 1)
  110422. * @param factor defines the drag value to affect to the specified gradient
  110423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110424. * @returns the current particle system
  110425. */
  110426. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  110427. if (!this._dragGradients) {
  110428. this._dragGradients = [];
  110429. }
  110430. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  110431. return this;
  110432. };
  110433. /**
  110434. * Remove a specific drag gradient
  110435. * @param gradient defines the gradient to remove
  110436. * @returns the current particle system
  110437. */
  110438. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  110439. this._removeFactorGradient(this._dragGradients, gradient);
  110440. return this;
  110441. };
  110442. /**
  110443. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  110444. * @param gradient defines the gradient to use (between 0 and 1)
  110445. * @param factor defines the emit rate value to affect to the specified gradient
  110446. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110447. * @returns the current particle system
  110448. */
  110449. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  110450. if (!this._emitRateGradients) {
  110451. this._emitRateGradients = [];
  110452. }
  110453. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  110454. return this;
  110455. };
  110456. /**
  110457. * Remove a specific emit rate gradient
  110458. * @param gradient defines the gradient to remove
  110459. * @returns the current particle system
  110460. */
  110461. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  110462. this._removeFactorGradient(this._emitRateGradients, gradient);
  110463. return this;
  110464. };
  110465. /**
  110466. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  110467. * @param gradient defines the gradient to use (between 0 and 1)
  110468. * @param factor defines the start size value to affect to the specified gradient
  110469. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110470. * @returns the current particle system
  110471. */
  110472. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  110473. if (!this._startSizeGradients) {
  110474. this._startSizeGradients = [];
  110475. }
  110476. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  110477. return this;
  110478. };
  110479. /**
  110480. * Remove a specific start size gradient
  110481. * @param gradient defines the gradient to remove
  110482. * @returns the current particle system
  110483. */
  110484. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  110485. this._removeFactorGradient(this._emitRateGradients, gradient);
  110486. return this;
  110487. };
  110488. ParticleSystem.prototype._createRampGradientTexture = function () {
  110489. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  110490. return;
  110491. }
  110492. var data = new Uint8Array(this._rawTextureWidth * 4);
  110493. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  110494. for (var x = 0; x < this._rawTextureWidth; x++) {
  110495. var ratio = x / this._rawTextureWidth;
  110496. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  110497. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  110498. data[x * 4] = tmpColor.r * 255;
  110499. data[x * 4 + 1] = tmpColor.g * 255;
  110500. data[x * 4 + 2] = tmpColor.b * 255;
  110501. data[x * 4 + 3] = 255;
  110502. });
  110503. }
  110504. this._rampGradientsTexture = _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__["RawTexture"].CreateRGBATexture(data, this._rawTextureWidth, 1, this._scene, false, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"].NEAREST_SAMPLINGMODE);
  110505. };
  110506. /**
  110507. * Gets the current list of ramp gradients.
  110508. * You must use addRampGradient and removeRampGradient to udpate this list
  110509. * @returns the list of ramp gradients
  110510. */
  110511. ParticleSystem.prototype.getRampGradients = function () {
  110512. return this._rampGradients;
  110513. };
  110514. /**
  110515. * Adds a new ramp gradient used to remap particle colors
  110516. * @param gradient defines the gradient to use (between 0 and 1)
  110517. * @param color defines the color to affect to the specified gradient
  110518. * @returns the current particle system
  110519. */
  110520. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  110521. if (!this._rampGradients) {
  110522. this._rampGradients = [];
  110523. }
  110524. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  110525. rampGradient.gradient = gradient;
  110526. rampGradient.color = color;
  110527. this._rampGradients.push(rampGradient);
  110528. this._rampGradients.sort(function (a, b) {
  110529. if (a.gradient < b.gradient) {
  110530. return -1;
  110531. }
  110532. else if (a.gradient > b.gradient) {
  110533. return 1;
  110534. }
  110535. return 0;
  110536. });
  110537. if (this._rampGradientsTexture) {
  110538. this._rampGradientsTexture.dispose();
  110539. this._rampGradientsTexture = null;
  110540. }
  110541. this._createRampGradientTexture();
  110542. return this;
  110543. };
  110544. /**
  110545. * Remove a specific ramp gradient
  110546. * @param gradient defines the gradient to remove
  110547. * @returns the current particle system
  110548. */
  110549. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  110550. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  110551. this._rampGradientsTexture = null;
  110552. if (this._rampGradients && this._rampGradients.length > 0) {
  110553. this._createRampGradientTexture();
  110554. }
  110555. return this;
  110556. };
  110557. /**
  110558. * Adds a new color gradient
  110559. * @param gradient defines the gradient to use (between 0 and 1)
  110560. * @param color1 defines the color to affect to the specified gradient
  110561. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  110562. * @returns this particle system
  110563. */
  110564. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  110565. if (!this._colorGradients) {
  110566. this._colorGradients = [];
  110567. }
  110568. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  110569. colorGradient.gradient = gradient;
  110570. colorGradient.color1 = color1;
  110571. colorGradient.color2 = color2;
  110572. this._colorGradients.push(colorGradient);
  110573. this._colorGradients.sort(function (a, b) {
  110574. if (a.gradient < b.gradient) {
  110575. return -1;
  110576. }
  110577. else if (a.gradient > b.gradient) {
  110578. return 1;
  110579. }
  110580. return 0;
  110581. });
  110582. return this;
  110583. };
  110584. /**
  110585. * Remove a specific color gradient
  110586. * @param gradient defines the gradient to remove
  110587. * @returns this particle system
  110588. */
  110589. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  110590. if (!this._colorGradients) {
  110591. return this;
  110592. }
  110593. var index = 0;
  110594. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  110595. var colorGradient = _a[_i];
  110596. if (colorGradient.gradient === gradient) {
  110597. this._colorGradients.splice(index, 1);
  110598. break;
  110599. }
  110600. index++;
  110601. }
  110602. return this;
  110603. };
  110604. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  110605. u = Math.abs(u) * 0.5 + 0.5;
  110606. v = Math.abs(v) * 0.5 + 0.5;
  110607. var wrappedU = ((u * width) % width) | 0;
  110608. var wrappedV = ((v * height) % height) | 0;
  110609. var position = (wrappedU + wrappedV * width) * 4;
  110610. return pixels[position] / 255;
  110611. };
  110612. ParticleSystem.prototype._reset = function () {
  110613. this._resetEffect();
  110614. };
  110615. ParticleSystem.prototype._resetEffect = function () {
  110616. if (this._vertexBuffer) {
  110617. this._vertexBuffer.dispose();
  110618. this._vertexBuffer = null;
  110619. }
  110620. if (this._spriteBuffer) {
  110621. this._spriteBuffer.dispose();
  110622. this._spriteBuffer = null;
  110623. }
  110624. this._createVertexBuffers();
  110625. };
  110626. ParticleSystem.prototype._createVertexBuffers = function () {
  110627. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  110628. if (this._isAnimationSheetEnabled) {
  110629. this._vertexBufferSize += 1;
  110630. }
  110631. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  110632. this._vertexBufferSize += 3;
  110633. }
  110634. if (this._useRampGradients) {
  110635. this._vertexBufferSize += 4;
  110636. }
  110637. var engine = this._scene.getEngine();
  110638. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  110639. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  110640. var dataOffset = 0;
  110641. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  110642. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  110643. dataOffset += 3;
  110644. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  110645. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  110646. dataOffset += 4;
  110647. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  110648. this._vertexBuffers["angle"] = options;
  110649. dataOffset += 1;
  110650. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  110651. this._vertexBuffers["size"] = size;
  110652. dataOffset += 2;
  110653. if (this._isAnimationSheetEnabled) {
  110654. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  110655. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  110656. dataOffset += 1;
  110657. }
  110658. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  110659. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  110660. this._vertexBuffers["direction"] = directionBuffer;
  110661. dataOffset += 3;
  110662. }
  110663. if (this._useRampGradients) {
  110664. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  110665. this._vertexBuffers["remapData"] = rampDataBuffer;
  110666. dataOffset += 4;
  110667. }
  110668. var offsets;
  110669. if (this._useInstancing) {
  110670. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  110671. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  110672. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  110673. }
  110674. else {
  110675. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  110676. dataOffset += 2;
  110677. }
  110678. this._vertexBuffers["offset"] = offsets;
  110679. };
  110680. ParticleSystem.prototype._createIndexBuffer = function () {
  110681. if (this._useInstancing) {
  110682. return;
  110683. }
  110684. var indices = [];
  110685. var index = 0;
  110686. for (var count = 0; count < this._capacity; count++) {
  110687. indices.push(index);
  110688. indices.push(index + 1);
  110689. indices.push(index + 2);
  110690. indices.push(index);
  110691. indices.push(index + 2);
  110692. indices.push(index + 3);
  110693. index += 4;
  110694. }
  110695. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  110696. };
  110697. /**
  110698. * Gets the maximum number of particles active at the same time.
  110699. * @returns The max number of active particles.
  110700. */
  110701. ParticleSystem.prototype.getCapacity = function () {
  110702. return this._capacity;
  110703. };
  110704. /**
  110705. * Gets whether there are still active particles in the system.
  110706. * @returns True if it is alive, otherwise false.
  110707. */
  110708. ParticleSystem.prototype.isAlive = function () {
  110709. return this._alive;
  110710. };
  110711. /**
  110712. * Gets if the system has been started. (Note: this will still be true after stop is called)
  110713. * @returns True if it has been started, otherwise false.
  110714. */
  110715. ParticleSystem.prototype.isStarted = function () {
  110716. return this._started;
  110717. };
  110718. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  110719. var _this = this;
  110720. this._subEmitters = new Array();
  110721. if (this.subEmitters) {
  110722. this.subEmitters.forEach(function (subEmitter) {
  110723. if (subEmitter instanceof ParticleSystem) {
  110724. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"](subEmitter)]);
  110725. }
  110726. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]) {
  110727. _this._subEmitters.push([subEmitter]);
  110728. }
  110729. else if (subEmitter instanceof Array) {
  110730. _this._subEmitters.push(subEmitter);
  110731. }
  110732. });
  110733. }
  110734. };
  110735. /**
  110736. * Starts the particle system and begins to emit
  110737. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  110738. */
  110739. ParticleSystem.prototype.start = function (delay) {
  110740. var _this = this;
  110741. if (delay === void 0) { delay = this.startDelay; }
  110742. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  110743. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  110744. }
  110745. if (delay) {
  110746. setTimeout(function () {
  110747. _this.start(0);
  110748. }, delay);
  110749. return;
  110750. }
  110751. // Convert the subEmitters field to the constant type field _subEmitters
  110752. this._prepareSubEmitterInternalArray();
  110753. this._started = true;
  110754. this._stopped = false;
  110755. this._actualFrame = 0;
  110756. if (this._subEmitters && this._subEmitters.length != 0) {
  110757. this.activeSubSystems = new Array();
  110758. }
  110759. // Reset emit gradient so it acts the same on every start
  110760. if (this._emitRateGradients) {
  110761. if (this._emitRateGradients.length > 0) {
  110762. this._currentEmitRateGradient = this._emitRateGradients[0];
  110763. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  110764. this._currentEmitRate2 = this._currentEmitRate1;
  110765. }
  110766. if (this._emitRateGradients.length > 1) {
  110767. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  110768. }
  110769. }
  110770. // Reset start size gradient so it acts the same on every start
  110771. if (this._startSizeGradients) {
  110772. if (this._startSizeGradients.length > 0) {
  110773. this._currentStartSizeGradient = this._startSizeGradients[0];
  110774. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  110775. this._currentStartSize2 = this._currentStartSize1;
  110776. }
  110777. if (this._startSizeGradients.length > 1) {
  110778. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  110779. }
  110780. }
  110781. if (this.preWarmCycles) {
  110782. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  110783. this.emitter.computeWorldMatrix(true);
  110784. }
  110785. var noiseTextureAsProcedural_1 = this.noiseTexture;
  110786. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  110787. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  110788. setTimeout(function () {
  110789. for (var index = 0; index < _this.preWarmCycles; index++) {
  110790. _this.animate(true);
  110791. noiseTextureAsProcedural_1.render();
  110792. }
  110793. });
  110794. });
  110795. }
  110796. else {
  110797. for (var index = 0; index < this.preWarmCycles; index++) {
  110798. this.animate(true);
  110799. }
  110800. }
  110801. }
  110802. // Animations
  110803. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  110804. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  110805. }
  110806. };
  110807. /**
  110808. * Stops the particle system.
  110809. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  110810. */
  110811. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  110812. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  110813. this._stopped = true;
  110814. if (stopSubEmitters) {
  110815. this._stopSubEmitters();
  110816. }
  110817. };
  110818. // animation sheet
  110819. /**
  110820. * Remove all active particles
  110821. */
  110822. ParticleSystem.prototype.reset = function () {
  110823. this._stockParticles = [];
  110824. this._particles = [];
  110825. };
  110826. /**
  110827. * @hidden (for internal use only)
  110828. */
  110829. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  110830. var offset = index * this._vertexBufferSize;
  110831. this._vertexData[offset++] = particle.position.x + this.worldOffset.x;
  110832. this._vertexData[offset++] = particle.position.y + this.worldOffset.y;
  110833. this._vertexData[offset++] = particle.position.z + this.worldOffset.z;
  110834. this._vertexData[offset++] = particle.color.r;
  110835. this._vertexData[offset++] = particle.color.g;
  110836. this._vertexData[offset++] = particle.color.b;
  110837. this._vertexData[offset++] = particle.color.a;
  110838. this._vertexData[offset++] = particle.angle;
  110839. this._vertexData[offset++] = particle.scale.x * particle.size;
  110840. this._vertexData[offset++] = particle.scale.y * particle.size;
  110841. if (this._isAnimationSheetEnabled) {
  110842. this._vertexData[offset++] = particle.cellIndex;
  110843. }
  110844. if (!this._isBillboardBased) {
  110845. if (particle._initialDirection) {
  110846. this._vertexData[offset++] = particle._initialDirection.x;
  110847. this._vertexData[offset++] = particle._initialDirection.y;
  110848. this._vertexData[offset++] = particle._initialDirection.z;
  110849. }
  110850. else {
  110851. this._vertexData[offset++] = particle.direction.x;
  110852. this._vertexData[offset++] = particle.direction.y;
  110853. this._vertexData[offset++] = particle.direction.z;
  110854. }
  110855. }
  110856. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  110857. this._vertexData[offset++] = particle.direction.x;
  110858. this._vertexData[offset++] = particle.direction.y;
  110859. this._vertexData[offset++] = particle.direction.z;
  110860. }
  110861. if (this._useRampGradients) {
  110862. this._vertexData[offset++] = particle.remapData.x;
  110863. this._vertexData[offset++] = particle.remapData.y;
  110864. this._vertexData[offset++] = particle.remapData.z;
  110865. this._vertexData[offset++] = particle.remapData.w;
  110866. }
  110867. if (!this._useInstancing) {
  110868. if (this._isAnimationSheetEnabled) {
  110869. if (offsetX === 0) {
  110870. offsetX = this._epsilon;
  110871. }
  110872. else if (offsetX === 1) {
  110873. offsetX = 1 - this._epsilon;
  110874. }
  110875. if (offsetY === 0) {
  110876. offsetY = this._epsilon;
  110877. }
  110878. else if (offsetY === 1) {
  110879. offsetY = 1 - this._epsilon;
  110880. }
  110881. }
  110882. this._vertexData[offset++] = offsetX;
  110883. this._vertexData[offset++] = offsetY;
  110884. }
  110885. };
  110886. ParticleSystem.prototype._stopSubEmitters = function () {
  110887. if (!this.activeSubSystems) {
  110888. return;
  110889. }
  110890. this.activeSubSystems.forEach(function (subSystem) {
  110891. subSystem.stop(true);
  110892. });
  110893. this.activeSubSystems = new Array();
  110894. };
  110895. ParticleSystem.prototype._removeFromRoot = function () {
  110896. if (!this._rootParticleSystem) {
  110897. return;
  110898. }
  110899. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  110900. if (index !== -1) {
  110901. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  110902. }
  110903. this._rootParticleSystem = null;
  110904. };
  110905. // End of sub system methods
  110906. ParticleSystem.prototype._update = function (newParticles) {
  110907. var _this = this;
  110908. // Update current
  110909. this._alive = this._particles.length > 0;
  110910. if (this.emitter.position) {
  110911. var emitterMesh = this.emitter;
  110912. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  110913. }
  110914. else {
  110915. var emitterPosition = this.emitter;
  110916. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  110917. }
  110918. this.updateFunction(this._particles);
  110919. // Add new ones
  110920. var particle;
  110921. var _loop_2 = function () {
  110922. if (this_1._particles.length === this_1._capacity) {
  110923. return "break";
  110924. }
  110925. particle = this_1._createParticle();
  110926. this_1._particles.push(particle);
  110927. // Emitter
  110928. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  110929. if (this_1.startPositionFunction) {
  110930. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  110931. }
  110932. else {
  110933. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  110934. }
  110935. if (this_1.startDirectionFunction) {
  110936. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  110937. }
  110938. else {
  110939. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  110940. }
  110941. if (emitPower === 0) {
  110942. if (!particle._initialDirection) {
  110943. particle._initialDirection = particle.direction.clone();
  110944. }
  110945. else {
  110946. particle._initialDirection.copyFrom(particle.direction);
  110947. }
  110948. }
  110949. else {
  110950. particle._initialDirection = null;
  110951. }
  110952. particle.direction.scaleInPlace(emitPower);
  110953. // Life time
  110954. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  110955. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  110956. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  110957. var factorGradient1 = currentGradient;
  110958. var factorGradient2 = nextGradient;
  110959. var lifeTime1 = factorGradient1.getFactor();
  110960. var lifeTime2 = factorGradient2.getFactor();
  110961. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  110962. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  110963. });
  110964. }
  110965. else {
  110966. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  110967. }
  110968. // Size
  110969. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  110970. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  110971. }
  110972. else {
  110973. particle._currentSizeGradient = this_1._sizeGradients[0];
  110974. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  110975. particle.size = particle._currentSize1;
  110976. if (this_1._sizeGradients.length > 1) {
  110977. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  110978. }
  110979. else {
  110980. particle._currentSize2 = particle._currentSize1;
  110981. }
  110982. }
  110983. // Size and scale
  110984. particle.scale.copyFromFloats(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minScaleX, this_1.maxScaleX), _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minScaleY, this_1.maxScaleY));
  110985. // Adjust scale by start size
  110986. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  110987. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  110988. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  110989. if (currentGradient !== _this._currentStartSizeGradient) {
  110990. _this._currentStartSize1 = _this._currentStartSize2;
  110991. _this._currentStartSize2 = nextGradient.getFactor();
  110992. _this._currentStartSizeGradient = currentGradient;
  110993. }
  110994. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  110995. particle.scale.scaleInPlace(value);
  110996. });
  110997. }
  110998. // Angle
  110999. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  111000. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  111001. }
  111002. else {
  111003. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  111004. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  111005. particle._currentAngularSpeed1 = particle.angularSpeed;
  111006. if (this_1._angularSpeedGradients.length > 1) {
  111007. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  111008. }
  111009. else {
  111010. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  111011. }
  111012. }
  111013. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  111014. // Velocity
  111015. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  111016. particle._currentVelocityGradient = this_1._velocityGradients[0];
  111017. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  111018. if (this_1._velocityGradients.length > 1) {
  111019. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  111020. }
  111021. else {
  111022. particle._currentVelocity2 = particle._currentVelocity1;
  111023. }
  111024. }
  111025. // Limit velocity
  111026. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  111027. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  111028. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  111029. if (this_1._limitVelocityGradients.length > 1) {
  111030. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  111031. }
  111032. else {
  111033. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  111034. }
  111035. }
  111036. // Drag
  111037. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  111038. particle._currentDragGradient = this_1._dragGradients[0];
  111039. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  111040. if (this_1._dragGradients.length > 1) {
  111041. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  111042. }
  111043. else {
  111044. particle._currentDrag2 = particle._currentDrag1;
  111045. }
  111046. }
  111047. // Color
  111048. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  111049. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  111050. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  111051. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  111052. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  111053. }
  111054. else {
  111055. particle._currentColorGradient = this_1._colorGradients[0];
  111056. particle._currentColorGradient.getColorToRef(particle.color);
  111057. particle._currentColor1.copyFrom(particle.color);
  111058. if (this_1._colorGradients.length > 1) {
  111059. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  111060. }
  111061. else {
  111062. particle._currentColor2.copyFrom(particle.color);
  111063. }
  111064. }
  111065. // Sheet
  111066. if (this_1._isAnimationSheetEnabled) {
  111067. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  111068. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  111069. }
  111070. // Inherited Velocity
  111071. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  111072. // Ramp
  111073. if (this_1._useRampGradients) {
  111074. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  111075. }
  111076. // Noise texture coordinates
  111077. if (this_1.noiseTexture) {
  111078. if (particle._randomNoiseCoordinates1) {
  111079. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  111080. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  111081. }
  111082. else {
  111083. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  111084. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  111085. }
  111086. }
  111087. // Update the position of the attached sub-emitters to match their attached particle
  111088. particle._inheritParticleInfoToSubEmitters();
  111089. };
  111090. var this_1 = this, step;
  111091. for (var index = 0; index < newParticles; index++) {
  111092. var state_1 = _loop_2();
  111093. if (state_1 === "break")
  111094. break;
  111095. }
  111096. };
  111097. /** @hidden */
  111098. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  111099. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  111100. if (isBillboardBased === void 0) { isBillboardBased = false; }
  111101. if (useRampGradients === void 0) { useRampGradients = false; }
  111102. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  111103. if (isAnimationSheetEnabled) {
  111104. attributeNamesOrOptions.push("cellIndex");
  111105. }
  111106. if (!isBillboardBased) {
  111107. attributeNamesOrOptions.push("direction");
  111108. }
  111109. if (useRampGradients) {
  111110. attributeNamesOrOptions.push("remapData");
  111111. }
  111112. return attributeNamesOrOptions;
  111113. };
  111114. /** @hidden */
  111115. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  111116. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  111117. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  111118. if (isAnimationSheetEnabled) {
  111119. effectCreationOption.push("particlesInfos");
  111120. }
  111121. return effectCreationOption;
  111122. };
  111123. /** @hidden */
  111124. ParticleSystem.prototype._getEffect = function (blendMode) {
  111125. if (this._customEffect) {
  111126. return this._customEffect;
  111127. }
  111128. var defines = [];
  111129. if (this._scene.clipPlane) {
  111130. defines.push("#define CLIPPLANE");
  111131. }
  111132. if (this._scene.clipPlane2) {
  111133. defines.push("#define CLIPPLANE2");
  111134. }
  111135. if (this._scene.clipPlane3) {
  111136. defines.push("#define CLIPPLANE3");
  111137. }
  111138. if (this._scene.clipPlane4) {
  111139. defines.push("#define CLIPPLANE4");
  111140. }
  111141. if (this._isAnimationSheetEnabled) {
  111142. defines.push("#define ANIMATESHEET");
  111143. }
  111144. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  111145. defines.push("#define BLENDMULTIPLYMODE");
  111146. }
  111147. if (this._useRampGradients) {
  111148. defines.push("#define RAMPGRADIENT");
  111149. }
  111150. if (this._isBillboardBased) {
  111151. defines.push("#define BILLBOARD");
  111152. switch (this.billboardMode) {
  111153. case ParticleSystem.BILLBOARDMODE_Y:
  111154. defines.push("#define BILLBOARDY");
  111155. break;
  111156. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  111157. defines.push("#define BILLBOARDSTRETCHED");
  111158. break;
  111159. case ParticleSystem.BILLBOARDMODE_ALL:
  111160. default:
  111161. break;
  111162. }
  111163. }
  111164. if (this._imageProcessingConfiguration) {
  111165. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  111166. defines.push(this._imageProcessingConfigurationDefines.toString());
  111167. }
  111168. // Effect
  111169. var join = defines.join("\n");
  111170. if (this._cachedDefines !== join) {
  111171. this._cachedDefines = join;
  111172. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  111173. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  111174. var samplers = ["diffuseSampler", "rampSampler"];
  111175. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  111176. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  111177. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  111178. }
  111179. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  111180. }
  111181. return this._effect;
  111182. };
  111183. /**
  111184. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111185. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  111186. */
  111187. ParticleSystem.prototype.animate = function (preWarmOnly) {
  111188. var _this = this;
  111189. if (preWarmOnly === void 0) { preWarmOnly = false; }
  111190. if (!this._started) {
  111191. return;
  111192. }
  111193. if (!preWarmOnly) {
  111194. // Check
  111195. if (!this.isReady()) {
  111196. return;
  111197. }
  111198. if (this._currentRenderId === this._scene.getFrameId()) {
  111199. return;
  111200. }
  111201. this._currentRenderId = this._scene.getFrameId();
  111202. }
  111203. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  111204. // Determine the number of particles we need to create
  111205. var newParticles;
  111206. if (this.manualEmitCount > -1) {
  111207. newParticles = this.manualEmitCount;
  111208. this._newPartsExcess = 0;
  111209. this.manualEmitCount = 0;
  111210. }
  111211. else {
  111212. var rate_1 = this.emitRate;
  111213. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  111214. var ratio = this._actualFrame / this.targetStopDuration;
  111215. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  111216. if (currentGradient !== _this._currentEmitRateGradient) {
  111217. _this._currentEmitRate1 = _this._currentEmitRate2;
  111218. _this._currentEmitRate2 = nextGradient.getFactor();
  111219. _this._currentEmitRateGradient = currentGradient;
  111220. }
  111221. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  111222. });
  111223. }
  111224. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  111225. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  111226. }
  111227. if (this._newPartsExcess > 1.0) {
  111228. newParticles += this._newPartsExcess >> 0;
  111229. this._newPartsExcess -= this._newPartsExcess >> 0;
  111230. }
  111231. this._alive = false;
  111232. if (!this._stopped) {
  111233. this._actualFrame += this._scaledUpdateSpeed;
  111234. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  111235. this.stop();
  111236. }
  111237. }
  111238. else {
  111239. newParticles = 0;
  111240. }
  111241. this._update(newParticles);
  111242. // Stopped?
  111243. if (this._stopped) {
  111244. if (!this._alive) {
  111245. this._started = false;
  111246. if (this.onAnimationEnd) {
  111247. this.onAnimationEnd();
  111248. }
  111249. if (this.disposeOnStop) {
  111250. this._scene._toBeDisposed.push(this);
  111251. }
  111252. }
  111253. }
  111254. if (!preWarmOnly) {
  111255. // Update VBO
  111256. var offset = 0;
  111257. for (var index = 0; index < this._particles.length; index++) {
  111258. var particle = this._particles[index];
  111259. this._appendParticleVertices(offset, particle);
  111260. offset += this._useInstancing ? 1 : 4;
  111261. }
  111262. if (this._vertexBuffer) {
  111263. this._vertexBuffer.update(this._vertexData);
  111264. }
  111265. }
  111266. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  111267. this.stop();
  111268. }
  111269. };
  111270. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  111271. this._appendParticleVertex(offset++, particle, 0, 0);
  111272. if (!this._useInstancing) {
  111273. this._appendParticleVertex(offset++, particle, 1, 0);
  111274. this._appendParticleVertex(offset++, particle, 1, 1);
  111275. this._appendParticleVertex(offset++, particle, 0, 1);
  111276. }
  111277. };
  111278. /**
  111279. * Rebuilds the particle system.
  111280. */
  111281. ParticleSystem.prototype.rebuild = function () {
  111282. this._createIndexBuffer();
  111283. if (this._vertexBuffer) {
  111284. this._vertexBuffer._rebuild();
  111285. }
  111286. };
  111287. /**
  111288. * Is this system ready to be used/rendered
  111289. * @return true if the system is ready
  111290. */
  111291. ParticleSystem.prototype.isReady = function () {
  111292. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  111293. return false;
  111294. }
  111295. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  111296. if (!this._getEffect(this.blendMode).isReady()) {
  111297. return false;
  111298. }
  111299. }
  111300. else {
  111301. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  111302. return false;
  111303. }
  111304. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  111305. return false;
  111306. }
  111307. }
  111308. return true;
  111309. };
  111310. ParticleSystem.prototype._render = function (blendMode) {
  111311. var effect = this._getEffect(blendMode);
  111312. var engine = this._scene.getEngine();
  111313. // Render
  111314. engine.enableEffect(effect);
  111315. var viewMatrix = this._scene.getViewMatrix();
  111316. effect.setTexture("diffuseSampler", this.particleTexture);
  111317. effect.setMatrix("view", viewMatrix);
  111318. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  111319. if (this._isAnimationSheetEnabled && this.particleTexture) {
  111320. var baseSize = this.particleTexture.getBaseSize();
  111321. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  111322. }
  111323. effect.setVector2("translationPivot", this.translationPivot);
  111324. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  111325. if (this._isBillboardBased) {
  111326. var camera = this._scene.activeCamera;
  111327. effect.setVector3("eyePosition", camera.globalPosition);
  111328. }
  111329. if (this._rampGradientsTexture) {
  111330. effect.setTexture("rampSampler", this._rampGradientsTexture);
  111331. }
  111332. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  111333. var invView = viewMatrix.clone();
  111334. invView.invert();
  111335. effect.setMatrix("invView", invView);
  111336. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  111337. }
  111338. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  111339. // image processing
  111340. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  111341. this._imageProcessingConfiguration.bind(effect);
  111342. }
  111343. // Draw order
  111344. switch (blendMode) {
  111345. case ParticleSystem.BLENDMODE_ADD:
  111346. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ADD);
  111347. break;
  111348. case ParticleSystem.BLENDMODE_ONEONE:
  111349. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ONEONE);
  111350. break;
  111351. case ParticleSystem.BLENDMODE_STANDARD:
  111352. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_COMBINE);
  111353. break;
  111354. case ParticleSystem.BLENDMODE_MULTIPLY:
  111355. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_MULTIPLY);
  111356. break;
  111357. }
  111358. if (this._useInstancing) {
  111359. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  111360. }
  111361. else {
  111362. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  111363. }
  111364. return this._particles.length;
  111365. };
  111366. /**
  111367. * Renders the particle system in its current state.
  111368. * @returns the current number of particles
  111369. */
  111370. ParticleSystem.prototype.render = function () {
  111371. // Check
  111372. if (!this.isReady() || !this._particles.length) {
  111373. return 0;
  111374. }
  111375. var engine = this._scene.getEngine();
  111376. engine.setState(false);
  111377. if (this.forceDepthWrite) {
  111378. engine.setDepthWrite(true);
  111379. }
  111380. var outparticles = 0;
  111381. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  111382. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  111383. }
  111384. outparticles = this._render(this.blendMode);
  111385. engine.unbindInstanceAttributes();
  111386. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_DISABLE);
  111387. return outparticles;
  111388. };
  111389. /**
  111390. * Disposes the particle system and free the associated resources
  111391. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111392. */
  111393. ParticleSystem.prototype.dispose = function (disposeTexture) {
  111394. if (disposeTexture === void 0) { disposeTexture = true; }
  111395. if (this._vertexBuffer) {
  111396. this._vertexBuffer.dispose();
  111397. this._vertexBuffer = null;
  111398. }
  111399. if (this._spriteBuffer) {
  111400. this._spriteBuffer.dispose();
  111401. this._spriteBuffer = null;
  111402. }
  111403. if (this._indexBuffer) {
  111404. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  111405. this._indexBuffer = null;
  111406. }
  111407. if (disposeTexture && this.particleTexture) {
  111408. this.particleTexture.dispose();
  111409. this.particleTexture = null;
  111410. }
  111411. if (disposeTexture && this.noiseTexture) {
  111412. this.noiseTexture.dispose();
  111413. this.noiseTexture = null;
  111414. }
  111415. if (this._rampGradientsTexture) {
  111416. this._rampGradientsTexture.dispose();
  111417. this._rampGradientsTexture = null;
  111418. }
  111419. this._removeFromRoot();
  111420. if (this._subEmitters && this._subEmitters.length) {
  111421. for (var index = 0; index < this._subEmitters.length; index++) {
  111422. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  111423. var subEmitter = _a[_i];
  111424. subEmitter.dispose();
  111425. }
  111426. }
  111427. this._subEmitters = [];
  111428. this.subEmitters = [];
  111429. }
  111430. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  111431. this.emitter.dispose(true);
  111432. }
  111433. // Remove from scene
  111434. var index = this._scene.particleSystems.indexOf(this);
  111435. if (index > -1) {
  111436. this._scene.particleSystems.splice(index, 1);
  111437. }
  111438. this._scene._activeParticleSystems.dispose();
  111439. // Callback
  111440. this.onDisposeObservable.notifyObservers(this);
  111441. this.onDisposeObservable.clear();
  111442. this.reset();
  111443. };
  111444. // Clone
  111445. /**
  111446. * Clones the particle system.
  111447. * @param name The name of the cloned object
  111448. * @param newEmitter The new emitter to use
  111449. * @returns the cloned particle system
  111450. */
  111451. ParticleSystem.prototype.clone = function (name, newEmitter) {
  111452. var custom = null;
  111453. var program = null;
  111454. if (this.customShader != null) {
  111455. program = this.customShader;
  111456. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  111457. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  111458. }
  111459. else if (this._customEffect) {
  111460. custom = this._customEffect;
  111461. }
  111462. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  111463. result.customShader = program;
  111464. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  111465. if (newEmitter === undefined) {
  111466. newEmitter = this.emitter;
  111467. }
  111468. result.noiseTexture = this.noiseTexture;
  111469. result.emitter = newEmitter;
  111470. if (this.particleTexture) {
  111471. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  111472. }
  111473. // Clone gradients
  111474. if (this._colorGradients) {
  111475. this._colorGradients.forEach(function (v) {
  111476. result.addColorGradient(v.gradient, v.color1, v.color2);
  111477. });
  111478. }
  111479. if (this._dragGradients) {
  111480. this._dragGradients.forEach(function (v) {
  111481. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  111482. });
  111483. }
  111484. if (this._angularSpeedGradients) {
  111485. this._angularSpeedGradients.forEach(function (v) {
  111486. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  111487. });
  111488. }
  111489. if (this._emitRateGradients) {
  111490. this._emitRateGradients.forEach(function (v) {
  111491. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  111492. });
  111493. }
  111494. if (this._lifeTimeGradients) {
  111495. this._lifeTimeGradients.forEach(function (v) {
  111496. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  111497. });
  111498. }
  111499. if (this._limitVelocityGradients) {
  111500. this._limitVelocityGradients.forEach(function (v) {
  111501. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  111502. });
  111503. }
  111504. if (this._sizeGradients) {
  111505. this._sizeGradients.forEach(function (v) {
  111506. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  111507. });
  111508. }
  111509. if (this._startSizeGradients) {
  111510. this._startSizeGradients.forEach(function (v) {
  111511. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  111512. });
  111513. }
  111514. if (this._velocityGradients) {
  111515. this._velocityGradients.forEach(function (v) {
  111516. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  111517. });
  111518. }
  111519. if (this._rampGradients) {
  111520. this._rampGradients.forEach(function (v) {
  111521. result.addRampGradient(v.gradient, v.color);
  111522. });
  111523. }
  111524. if (this._colorRemapGradients) {
  111525. this._colorRemapGradients.forEach(function (v) {
  111526. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  111527. });
  111528. }
  111529. if (this._alphaRemapGradients) {
  111530. this._alphaRemapGradients.forEach(function (v) {
  111531. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  111532. });
  111533. }
  111534. if (!this.preventAutoStart) {
  111535. result.start();
  111536. }
  111537. return result;
  111538. };
  111539. /**
  111540. * Serializes the particle system to a JSON object.
  111541. * @returns the JSON object
  111542. */
  111543. ParticleSystem.prototype.serialize = function () {
  111544. var serializationObject = {};
  111545. ParticleSystem._Serialize(serializationObject, this);
  111546. serializationObject.textureMask = this.textureMask.asArray();
  111547. serializationObject.customShader = this.customShader;
  111548. serializationObject.preventAutoStart = this.preventAutoStart;
  111549. // SubEmitters
  111550. if (this.subEmitters) {
  111551. serializationObject.subEmitters = [];
  111552. if (!this._subEmitters) {
  111553. this._prepareSubEmitterInternalArray();
  111554. }
  111555. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  111556. var subs = _a[_i];
  111557. var cell = [];
  111558. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  111559. var sub = subs_1[_b];
  111560. cell.push(sub.serialize());
  111561. }
  111562. serializationObject.subEmitters.push(cell);
  111563. }
  111564. }
  111565. return serializationObject;
  111566. };
  111567. /** @hidden */
  111568. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  111569. serializationObject.name = particleSystem.name;
  111570. serializationObject.id = particleSystem.id;
  111571. serializationObject.capacity = particleSystem.getCapacity();
  111572. // Emitter
  111573. if (particleSystem.emitter.position) {
  111574. var emitterMesh = particleSystem.emitter;
  111575. serializationObject.emitterId = emitterMesh.id;
  111576. }
  111577. else {
  111578. var emitterPosition = particleSystem.emitter;
  111579. serializationObject.emitter = emitterPosition.asArray();
  111580. }
  111581. // Emitter
  111582. if (particleSystem.particleEmitterType) {
  111583. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  111584. }
  111585. if (particleSystem.particleTexture) {
  111586. serializationObject.textureName = particleSystem.particleTexture.name;
  111587. serializationObject.invertY = particleSystem.particleTexture._invertY;
  111588. }
  111589. // Animations
  111590. _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  111591. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  111592. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  111593. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  111594. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  111595. // Particle system
  111596. serializationObject.startDelay = particleSystem.startDelay;
  111597. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  111598. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  111599. serializationObject.billboardMode = particleSystem.billboardMode;
  111600. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  111601. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  111602. serializationObject.minSize = particleSystem.minSize;
  111603. serializationObject.maxSize = particleSystem.maxSize;
  111604. serializationObject.minScaleX = particleSystem.minScaleX;
  111605. serializationObject.maxScaleX = particleSystem.maxScaleX;
  111606. serializationObject.minScaleY = particleSystem.minScaleY;
  111607. serializationObject.maxScaleY = particleSystem.maxScaleY;
  111608. serializationObject.minEmitPower = particleSystem.minEmitPower;
  111609. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  111610. serializationObject.minLifeTime = particleSystem.minLifeTime;
  111611. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  111612. serializationObject.emitRate = particleSystem.emitRate;
  111613. serializationObject.gravity = particleSystem.gravity.asArray();
  111614. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  111615. serializationObject.color1 = particleSystem.color1.asArray();
  111616. serializationObject.color2 = particleSystem.color2.asArray();
  111617. serializationObject.colorDead = particleSystem.colorDead.asArray();
  111618. serializationObject.updateSpeed = particleSystem.updateSpeed;
  111619. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  111620. serializationObject.blendMode = particleSystem.blendMode;
  111621. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  111622. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  111623. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  111624. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  111625. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  111626. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  111627. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  111628. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  111629. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  111630. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  111631. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  111632. var colorGradients = particleSystem.getColorGradients();
  111633. if (colorGradients) {
  111634. serializationObject.colorGradients = [];
  111635. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  111636. var colorGradient = colorGradients_1[_i];
  111637. var serializedGradient = {
  111638. gradient: colorGradient.gradient,
  111639. color1: colorGradient.color1.asArray()
  111640. };
  111641. if (colorGradient.color2) {
  111642. serializedGradient.color2 = colorGradient.color2.asArray();
  111643. }
  111644. serializationObject.colorGradients.push(serializedGradient);
  111645. }
  111646. }
  111647. var rampGradients = particleSystem.getRampGradients();
  111648. if (rampGradients) {
  111649. serializationObject.rampGradients = [];
  111650. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  111651. var rampGradient = rampGradients_1[_a];
  111652. var serializedGradient = {
  111653. gradient: rampGradient.gradient,
  111654. color: rampGradient.color.asArray()
  111655. };
  111656. serializationObject.rampGradients.push(serializedGradient);
  111657. }
  111658. serializationObject.useRampGradients = particleSystem.useRampGradients;
  111659. }
  111660. var colorRemapGradients = particleSystem.getColorRemapGradients();
  111661. if (colorRemapGradients) {
  111662. serializationObject.colorRemapGradients = [];
  111663. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  111664. var colorRemapGradient = colorRemapGradients_1[_b];
  111665. var serializedGradient = {
  111666. gradient: colorRemapGradient.gradient,
  111667. factor1: colorRemapGradient.factor1
  111668. };
  111669. if (colorRemapGradient.factor2 !== undefined) {
  111670. serializedGradient.factor2 = colorRemapGradient.factor2;
  111671. }
  111672. serializationObject.colorRemapGradients.push(serializedGradient);
  111673. }
  111674. }
  111675. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  111676. if (alphaRemapGradients) {
  111677. serializationObject.alphaRemapGradients = [];
  111678. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  111679. var alphaRemapGradient = alphaRemapGradients_1[_c];
  111680. var serializedGradient = {
  111681. gradient: alphaRemapGradient.gradient,
  111682. factor1: alphaRemapGradient.factor1
  111683. };
  111684. if (alphaRemapGradient.factor2 !== undefined) {
  111685. serializedGradient.factor2 = alphaRemapGradient.factor2;
  111686. }
  111687. serializationObject.alphaRemapGradients.push(serializedGradient);
  111688. }
  111689. }
  111690. var sizeGradients = particleSystem.getSizeGradients();
  111691. if (sizeGradients) {
  111692. serializationObject.sizeGradients = [];
  111693. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  111694. var sizeGradient = sizeGradients_1[_d];
  111695. var serializedGradient = {
  111696. gradient: sizeGradient.gradient,
  111697. factor1: sizeGradient.factor1
  111698. };
  111699. if (sizeGradient.factor2 !== undefined) {
  111700. serializedGradient.factor2 = sizeGradient.factor2;
  111701. }
  111702. serializationObject.sizeGradients.push(serializedGradient);
  111703. }
  111704. }
  111705. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  111706. if (angularSpeedGradients) {
  111707. serializationObject.angularSpeedGradients = [];
  111708. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  111709. var angularSpeedGradient = angularSpeedGradients_1[_e];
  111710. var serializedGradient = {
  111711. gradient: angularSpeedGradient.gradient,
  111712. factor1: angularSpeedGradient.factor1
  111713. };
  111714. if (angularSpeedGradient.factor2 !== undefined) {
  111715. serializedGradient.factor2 = angularSpeedGradient.factor2;
  111716. }
  111717. serializationObject.angularSpeedGradients.push(serializedGradient);
  111718. }
  111719. }
  111720. var velocityGradients = particleSystem.getVelocityGradients();
  111721. if (velocityGradients) {
  111722. serializationObject.velocityGradients = [];
  111723. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  111724. var velocityGradient = velocityGradients_1[_f];
  111725. var serializedGradient = {
  111726. gradient: velocityGradient.gradient,
  111727. factor1: velocityGradient.factor1
  111728. };
  111729. if (velocityGradient.factor2 !== undefined) {
  111730. serializedGradient.factor2 = velocityGradient.factor2;
  111731. }
  111732. serializationObject.velocityGradients.push(serializedGradient);
  111733. }
  111734. }
  111735. var dragGradients = particleSystem.getDragGradients();
  111736. if (dragGradients) {
  111737. serializationObject.dragyGradients = [];
  111738. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  111739. var dragGradient = dragGradients_1[_g];
  111740. var serializedGradient = {
  111741. gradient: dragGradient.gradient,
  111742. factor1: dragGradient.factor1
  111743. };
  111744. if (dragGradient.factor2 !== undefined) {
  111745. serializedGradient.factor2 = dragGradient.factor2;
  111746. }
  111747. serializationObject.dragGradients.push(serializedGradient);
  111748. }
  111749. }
  111750. var emitRateGradients = particleSystem.getEmitRateGradients();
  111751. if (emitRateGradients) {
  111752. serializationObject.emitRateGradients = [];
  111753. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  111754. var emitRateGradient = emitRateGradients_1[_h];
  111755. var serializedGradient = {
  111756. gradient: emitRateGradient.gradient,
  111757. factor1: emitRateGradient.factor1
  111758. };
  111759. if (emitRateGradient.factor2 !== undefined) {
  111760. serializedGradient.factor2 = emitRateGradient.factor2;
  111761. }
  111762. serializationObject.emitRateGradients.push(serializedGradient);
  111763. }
  111764. }
  111765. var startSizeGradients = particleSystem.getStartSizeGradients();
  111766. if (startSizeGradients) {
  111767. serializationObject.startSizeGradients = [];
  111768. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  111769. var startSizeGradient = startSizeGradients_1[_j];
  111770. var serializedGradient = {
  111771. gradient: startSizeGradient.gradient,
  111772. factor1: startSizeGradient.factor1
  111773. };
  111774. if (startSizeGradient.factor2 !== undefined) {
  111775. serializedGradient.factor2 = startSizeGradient.factor2;
  111776. }
  111777. serializationObject.startSizeGradients.push(serializedGradient);
  111778. }
  111779. }
  111780. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  111781. if (lifeTimeGradients) {
  111782. serializationObject.lifeTimeGradients = [];
  111783. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  111784. var lifeTimeGradient = lifeTimeGradients_1[_k];
  111785. var serializedGradient = {
  111786. gradient: lifeTimeGradient.gradient,
  111787. factor1: lifeTimeGradient.factor1
  111788. };
  111789. if (lifeTimeGradient.factor2 !== undefined) {
  111790. serializedGradient.factor2 = lifeTimeGradient.factor2;
  111791. }
  111792. serializationObject.lifeTimeGradients.push(serializedGradient);
  111793. }
  111794. }
  111795. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  111796. if (limitVelocityGradients) {
  111797. serializationObject.limitVelocityGradients = [];
  111798. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  111799. var limitVelocityGradient = limitVelocityGradients_1[_l];
  111800. var serializedGradient = {
  111801. gradient: limitVelocityGradient.gradient,
  111802. factor1: limitVelocityGradient.factor1
  111803. };
  111804. if (limitVelocityGradient.factor2 !== undefined) {
  111805. serializedGradient.factor2 = limitVelocityGradient.factor2;
  111806. }
  111807. serializationObject.limitVelocityGradients.push(serializedGradient);
  111808. }
  111809. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  111810. }
  111811. if (particleSystem.noiseTexture) {
  111812. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  111813. }
  111814. };
  111815. /** @hidden */
  111816. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  111817. // Texture
  111818. if (parsedParticleSystem.textureName) {
  111819. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  111820. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  111821. }
  111822. // Emitter
  111823. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  111824. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  111825. }
  111826. else if (parsedParticleSystem.emitterId) {
  111827. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  111828. }
  111829. else {
  111830. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  111831. }
  111832. // Misc.
  111833. if (parsedParticleSystem.renderingGroupId !== undefined) {
  111834. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  111835. }
  111836. if (parsedParticleSystem.isBillboardBased !== undefined) {
  111837. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  111838. }
  111839. if (parsedParticleSystem.billboardMode !== undefined) {
  111840. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  111841. }
  111842. // Animations
  111843. if (parsedParticleSystem.animations) {
  111844. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  111845. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  111846. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__["_TypeStore"].GetClass("BABYLON.Animation");
  111847. if (internalClass) {
  111848. particleSystem.animations.push(internalClass.Parse(parsedAnimation));
  111849. }
  111850. }
  111851. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  111852. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  111853. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  111854. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  111855. }
  111856. if (parsedParticleSystem.autoAnimate) {
  111857. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  111858. }
  111859. // Particle system
  111860. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  111861. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  111862. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  111863. particleSystem.minSize = parsedParticleSystem.minSize;
  111864. particleSystem.maxSize = parsedParticleSystem.maxSize;
  111865. if (parsedParticleSystem.minScaleX) {
  111866. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  111867. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  111868. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  111869. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  111870. }
  111871. if (parsedParticleSystem.preWarmCycles !== undefined) {
  111872. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  111873. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  111874. }
  111875. if (parsedParticleSystem.minInitialRotation !== undefined) {
  111876. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  111877. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  111878. }
  111879. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  111880. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  111881. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  111882. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  111883. particleSystem.emitRate = parsedParticleSystem.emitRate;
  111884. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  111885. if (parsedParticleSystem.noiseStrength) {
  111886. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  111887. }
  111888. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  111889. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  111890. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  111891. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  111892. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  111893. particleSystem.blendMode = parsedParticleSystem.blendMode;
  111894. if (parsedParticleSystem.colorGradients) {
  111895. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  111896. var colorGradient = _a[_i];
  111897. particleSystem.addColorGradient(colorGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(colorGradient.color1), colorGradient.color2 ? _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(colorGradient.color2) : undefined);
  111898. }
  111899. }
  111900. if (parsedParticleSystem.rampGradients) {
  111901. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  111902. var rampGradient = _c[_b];
  111903. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  111904. }
  111905. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  111906. }
  111907. if (parsedParticleSystem.colorRemapGradients) {
  111908. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  111909. var colorRemapGradient = _e[_d];
  111910. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  111911. }
  111912. }
  111913. if (parsedParticleSystem.alphaRemapGradients) {
  111914. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  111915. var alphaRemapGradient = _g[_f];
  111916. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  111917. }
  111918. }
  111919. if (parsedParticleSystem.sizeGradients) {
  111920. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  111921. var sizeGradient = _j[_h];
  111922. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  111923. }
  111924. }
  111925. if (parsedParticleSystem.sizeGradients) {
  111926. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  111927. var sizeGradient = _l[_k];
  111928. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  111929. }
  111930. }
  111931. if (parsedParticleSystem.angularSpeedGradients) {
  111932. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  111933. var angularSpeedGradient = _o[_m];
  111934. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  111935. }
  111936. }
  111937. if (parsedParticleSystem.velocityGradients) {
  111938. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  111939. var velocityGradient = _q[_p];
  111940. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  111941. }
  111942. }
  111943. if (parsedParticleSystem.dragGradients) {
  111944. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  111945. var dragGradient = _s[_r];
  111946. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  111947. }
  111948. }
  111949. if (parsedParticleSystem.emitRateGradients) {
  111950. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  111951. var emitRateGradient = _u[_t];
  111952. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  111953. }
  111954. }
  111955. if (parsedParticleSystem.startSizeGradients) {
  111956. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  111957. var startSizeGradient = _w[_v];
  111958. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  111959. }
  111960. }
  111961. if (parsedParticleSystem.lifeTimeGradients) {
  111962. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  111963. var lifeTimeGradient = _y[_x];
  111964. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  111965. }
  111966. }
  111967. if (parsedParticleSystem.limitVelocityGradients) {
  111968. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  111969. var limitVelocityGradient = _0[_z];
  111970. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  111971. }
  111972. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  111973. }
  111974. if (parsedParticleSystem.noiseTexture) {
  111975. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  111976. }
  111977. // Emitter
  111978. var emitterType;
  111979. if (parsedParticleSystem.particleEmitterType) {
  111980. switch (parsedParticleSystem.particleEmitterType.type) {
  111981. case "SphereParticleEmitter":
  111982. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereParticleEmitter"]();
  111983. break;
  111984. case "SphereDirectedParticleEmitter":
  111985. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereDirectedParticleEmitter"]();
  111986. break;
  111987. case "ConeEmitter":
  111988. case "ConeParticleEmitter":
  111989. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["ConeParticleEmitter"]();
  111990. break;
  111991. case "CylinderParticleEmitter":
  111992. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["CylinderParticleEmitter"]();
  111993. break;
  111994. case "HemisphericParticleEmitter":
  111995. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["HemisphericParticleEmitter"]();
  111996. break;
  111997. case "BoxEmitter":
  111998. case "BoxParticleEmitter":
  111999. default:
  112000. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  112001. break;
  112002. }
  112003. emitterType.parse(parsedParticleSystem.particleEmitterType);
  112004. }
  112005. else {
  112006. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  112007. emitterType.parse(parsedParticleSystem);
  112008. }
  112009. particleSystem.particleEmitterType = emitterType;
  112010. // Animation sheet
  112011. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  112012. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  112013. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  112014. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  112015. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  112016. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  112017. };
  112018. /**
  112019. * Parses a JSON object to create a particle system.
  112020. * @param parsedParticleSystem The JSON object to parse
  112021. * @param scene The scene to create the particle system in
  112022. * @param rootUrl The root url to use to load external dependencies like texture
  112023. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  112024. * @returns the Parsed particle system
  112025. */
  112026. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  112027. if (doNotStart === void 0) { doNotStart = false; }
  112028. var name = parsedParticleSystem.name;
  112029. var custom = null;
  112030. var program = null;
  112031. if (parsedParticleSystem.customShader) {
  112032. program = parsedParticleSystem.customShader;
  112033. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  112034. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  112035. }
  112036. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  112037. particleSystem.customShader = program;
  112038. if (parsedParticleSystem.id) {
  112039. particleSystem.id = parsedParticleSystem.id;
  112040. }
  112041. // SubEmitters
  112042. if (parsedParticleSystem.subEmitters) {
  112043. particleSystem.subEmitters = [];
  112044. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  112045. var cell = _a[_i];
  112046. var cellArray = [];
  112047. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  112048. var sub = cell_1[_b];
  112049. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"].Parse(sub, scene, rootUrl));
  112050. }
  112051. particleSystem.subEmitters.push(cellArray);
  112052. }
  112053. }
  112054. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  112055. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  112056. // Auto start
  112057. if (parsedParticleSystem.preventAutoStart) {
  112058. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  112059. }
  112060. if (!doNotStart && !particleSystem.preventAutoStart) {
  112061. particleSystem.start();
  112062. }
  112063. return particleSystem;
  112064. };
  112065. /**
  112066. * Billboard mode will only apply to Y axis
  112067. */
  112068. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  112069. /**
  112070. * Billboard mode will apply to all axes
  112071. */
  112072. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  112073. /**
  112074. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  112075. */
  112076. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  112077. return ParticleSystem;
  112078. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__["BaseParticleSystem"]));
  112079. _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  112080. /***/ }),
  112081. /***/ "./Particles/particleSystemComponent.ts":
  112082. /*!**********************************************!*\
  112083. !*** ./Particles/particleSystemComponent.ts ***!
  112084. \**********************************************/
  112085. /*! exports provided: _IDoNeedToBeInTheBuild */
  112086. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112087. "use strict";
  112088. __webpack_require__.r(__webpack_exports__);
  112089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  112090. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  112091. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  112092. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  112093. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  112094. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  112095. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  112096. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  112097. // Adds the parsers to the scene parsers.
  112098. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  112099. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  112100. if (!individualParser) {
  112101. return;
  112102. }
  112103. // Particles Systems
  112104. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  112105. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  112106. var parsedParticleSystem = parsedData.particleSystems[index];
  112107. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  112108. }
  112109. }
  112110. });
  112111. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  112112. if (parsedParticleSystem.activeParticleCount) {
  112113. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  112114. return ps;
  112115. }
  112116. else {
  112117. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  112118. return ps;
  112119. }
  112120. });
  112121. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  112122. if (uniformsNames === void 0) { uniformsNames = []; }
  112123. if (samplers === void 0) { samplers = []; }
  112124. if (defines === void 0) { defines = ""; }
  112125. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  112126. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  112127. if (defines.indexOf(" BILLBOARD") === -1) {
  112128. defines += "\n#define BILLBOARD\n";
  112129. }
  112130. if (samplers.indexOf("diffuseSampler") === -1) {
  112131. samplers.push("diffuseSampler");
  112132. }
  112133. return this.createEffect({
  112134. vertex: "particles",
  112135. fragmentElement: fragmentName
  112136. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  112137. };
  112138. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  112139. var results = new Array();
  112140. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  112141. var particleSystem = this.getScene().particleSystems[index];
  112142. if (particleSystem.emitter === this) {
  112143. results.push(particleSystem);
  112144. }
  112145. }
  112146. return results;
  112147. };
  112148. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  112149. var results = new Array();
  112150. var descendants = this.getDescendants();
  112151. descendants.push(this);
  112152. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  112153. var particleSystem = this.getScene().particleSystems[index];
  112154. var emitter = particleSystem.emitter;
  112155. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  112156. results.push(particleSystem);
  112157. }
  112158. }
  112159. return results;
  112160. };
  112161. /**
  112162. * @hidden
  112163. */
  112164. var _IDoNeedToBeInTheBuild = 42;
  112165. /***/ }),
  112166. /***/ "./Particles/particleSystemSet.ts":
  112167. /*!****************************************!*\
  112168. !*** ./Particles/particleSystemSet.ts ***!
  112169. \****************************************/
  112170. /*! exports provided: ParticleSystemSet */
  112171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112172. "use strict";
  112173. __webpack_require__.r(__webpack_exports__);
  112174. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  112175. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  112176. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  112177. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  112178. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  112179. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  112180. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  112181. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  112182. /** Internal class used to store shapes for emitters */
  112183. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  112184. function ParticleSystemSetEmitterCreationOptions() {
  112185. }
  112186. return ParticleSystemSetEmitterCreationOptions;
  112187. }());
  112188. /**
  112189. * Represents a set of particle systems working together to create a specific effect
  112190. */
  112191. var ParticleSystemSet = /** @class */ (function () {
  112192. function ParticleSystemSet() {
  112193. /**
  112194. * Gets the particle system list
  112195. */
  112196. this.systems = new Array();
  112197. }
  112198. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  112199. /**
  112200. * Gets the emitter node used with this set
  112201. */
  112202. get: function () {
  112203. return this._emitterNode;
  112204. },
  112205. enumerable: true,
  112206. configurable: true
  112207. });
  112208. /**
  112209. * Creates a new emitter mesh as a sphere
  112210. * @param options defines the options used to create the sphere
  112211. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  112212. * @param scene defines the hosting scene
  112213. */
  112214. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  112215. if (this._emitterNode) {
  112216. this._emitterNode.dispose();
  112217. }
  112218. this._emitterCreationOptions = {
  112219. kind: "Sphere",
  112220. options: options,
  112221. renderingGroupId: renderingGroupId
  112222. };
  112223. var emitterMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  112224. emitterMesh.renderingGroupId = renderingGroupId;
  112225. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  112226. material.emissiveColor = options.color;
  112227. emitterMesh.material = material;
  112228. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  112229. var system = _a[_i];
  112230. system.emitter = emitterMesh;
  112231. }
  112232. this._emitterNode = emitterMesh;
  112233. };
  112234. /**
  112235. * Starts all particle systems of the set
  112236. * @param emitter defines an optional mesh to use as emitter for the particle systems
  112237. */
  112238. ParticleSystemSet.prototype.start = function (emitter) {
  112239. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  112240. var system = _a[_i];
  112241. if (emitter) {
  112242. system.emitter = emitter;
  112243. }
  112244. system.start();
  112245. }
  112246. };
  112247. /**
  112248. * Release all associated resources
  112249. */
  112250. ParticleSystemSet.prototype.dispose = function () {
  112251. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  112252. var system = _a[_i];
  112253. system.dispose();
  112254. }
  112255. this.systems = [];
  112256. if (this._emitterNode) {
  112257. this._emitterNode.dispose();
  112258. this._emitterNode = null;
  112259. }
  112260. };
  112261. /**
  112262. * Serialize the set into a JSON compatible object
  112263. * @returns a JSON compatible representation of the set
  112264. */
  112265. ParticleSystemSet.prototype.serialize = function () {
  112266. var result = {};
  112267. result.systems = [];
  112268. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  112269. var system = _a[_i];
  112270. result.systems.push(system.serialize());
  112271. }
  112272. if (this._emitterNode) {
  112273. result.emitter = this._emitterCreationOptions;
  112274. }
  112275. return result;
  112276. };
  112277. /**
  112278. * Parse a new ParticleSystemSet from a serialized source
  112279. * @param data defines a JSON compatible representation of the set
  112280. * @param scene defines the hosting scene
  112281. * @param gpu defines if we want GPU particles or CPU particles
  112282. * @returns a new ParticleSystemSet
  112283. */
  112284. ParticleSystemSet.Parse = function (data, scene, gpu) {
  112285. if (gpu === void 0) { gpu = false; }
  112286. var result = new ParticleSystemSet();
  112287. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  112288. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  112289. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  112290. var system = _a[_i];
  112291. result.systems.push(gpu ? _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"].Parse(system, scene, rootUrl, true) : _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(system, scene, rootUrl, true));
  112292. }
  112293. if (data.emitter) {
  112294. var options = data.emitter.options;
  112295. switch (data.emitter.kind) {
  112296. case "Sphere":
  112297. result.setEmitterAsSphere({
  112298. diameter: options.diameter,
  112299. segments: options.segments,
  112300. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  112301. }, data.emitter.renderingGroupId, scene);
  112302. break;
  112303. }
  112304. }
  112305. return result;
  112306. };
  112307. return ParticleSystemSet;
  112308. }());
  112309. /***/ }),
  112310. /***/ "./Particles/solidParticle.ts":
  112311. /*!************************************!*\
  112312. !*** ./Particles/solidParticle.ts ***!
  112313. \************************************/
  112314. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  112315. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112316. "use strict";
  112317. __webpack_require__.r(__webpack_exports__);
  112318. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  112319. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  112320. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  112321. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  112322. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  112323. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  112324. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  112325. /**
  112326. * Represents one particle of a solid particle system.
  112327. */
  112328. var SolidParticle = /** @class */ (function () {
  112329. /**
  112330. * Creates a Solid Particle object.
  112331. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  112332. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  112333. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  112334. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  112335. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  112336. * @param shapeId (integer) is the model shape identifier in the SPS.
  112337. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  112338. * @param sps defines the sps it is associated to
  112339. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  112340. */
  112341. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  112342. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  112343. /**
  112344. * particle global index
  112345. */
  112346. this.idx = 0;
  112347. /**
  112348. * The color of the particle
  112349. */
  112350. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  112351. /**
  112352. * The world space position of the particle.
  112353. */
  112354. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112355. /**
  112356. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  112357. */
  112358. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112359. /**
  112360. * The scaling of the particle.
  112361. */
  112362. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  112363. /**
  112364. * The uvs of the particle.
  112365. */
  112366. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  112367. /**
  112368. * The current speed of the particle.
  112369. */
  112370. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112371. /**
  112372. * The pivot point in the particle local space.
  112373. */
  112374. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112375. /**
  112376. * Must the particle be translated from its pivot point in its local space ?
  112377. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  112378. * Default : false
  112379. */
  112380. this.translateFromPivot = false;
  112381. /**
  112382. * Is the particle active or not ?
  112383. */
  112384. this.alive = true;
  112385. /**
  112386. * Is the particle visible or not ?
  112387. */
  112388. this.isVisible = true;
  112389. /**
  112390. * Index of this particle in the global "positions" array (Internal use)
  112391. * @hidden
  112392. */
  112393. this._pos = 0;
  112394. /**
  112395. * @hidden Index of this particle in the global "indices" array (Internal use)
  112396. */
  112397. this._ind = 0;
  112398. /**
  112399. * ModelShape id of this particle
  112400. */
  112401. this.shapeId = 0;
  112402. /**
  112403. * Index of the particle in its shape id (Internal use)
  112404. */
  112405. this.idxInShape = 0;
  112406. /**
  112407. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  112408. */
  112409. this._stillInvisible = false;
  112410. /**
  112411. * @hidden Last computed particle rotation matrix
  112412. */
  112413. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  112414. /**
  112415. * Parent particle Id, if any.
  112416. * Default null.
  112417. */
  112418. this.parentId = null;
  112419. /**
  112420. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  112421. * The possible values are :
  112422. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112423. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112424. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112425. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112426. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112427. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  112428. * */
  112429. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  112430. /**
  112431. * @hidden Internal global position in the SPS.
  112432. */
  112433. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112434. this.idx = particleIndex;
  112435. this._pos = positionIndex;
  112436. this._ind = indiceIndex;
  112437. this._model = model;
  112438. this.shapeId = shapeId;
  112439. this.idxInShape = idxInShape;
  112440. this._sps = sps;
  112441. if (modelBoundingInfo) {
  112442. this._modelBoundingInfo = modelBoundingInfo;
  112443. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  112444. }
  112445. }
  112446. Object.defineProperty(SolidParticle.prototype, "scale", {
  112447. /**
  112448. * Legacy support, changed scale to scaling
  112449. */
  112450. get: function () {
  112451. return this.scaling;
  112452. },
  112453. /**
  112454. * Legacy support, changed scale to scaling
  112455. */
  112456. set: function (scale) {
  112457. this.scaling = scale;
  112458. },
  112459. enumerable: true,
  112460. configurable: true
  112461. });
  112462. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  112463. /**
  112464. * Legacy support, changed quaternion to rotationQuaternion
  112465. */
  112466. get: function () {
  112467. return this.rotationQuaternion;
  112468. },
  112469. /**
  112470. * Legacy support, changed quaternion to rotationQuaternion
  112471. */
  112472. set: function (q) {
  112473. this.rotationQuaternion = q;
  112474. },
  112475. enumerable: true,
  112476. configurable: true
  112477. });
  112478. /**
  112479. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  112480. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  112481. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  112482. * @returns true if it intersects
  112483. */
  112484. SolidParticle.prototype.intersectsMesh = function (target) {
  112485. if (!this._boundingInfo || !target._boundingInfo) {
  112486. return false;
  112487. }
  112488. if (this._sps._bSphereOnly) {
  112489. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  112490. }
  112491. return this._boundingInfo.intersects(target._boundingInfo, false);
  112492. };
  112493. /**
  112494. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  112495. * A particle is in the frustum if its bounding box intersects the frustum
  112496. * @param frustumPlanes defines the frustum to test
  112497. * @returns true if the particle is in the frustum planes
  112498. */
  112499. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  112500. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  112501. };
  112502. /**
  112503. * get the rotation matrix of the particle
  112504. * @hidden
  112505. */
  112506. SolidParticle.prototype.getRotationMatrix = function (m) {
  112507. var quaternion;
  112508. if (this.rotationQuaternion) {
  112509. quaternion = this.rotationQuaternion;
  112510. }
  112511. else {
  112512. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  112513. var rotation = this.rotation;
  112514. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  112515. }
  112516. quaternion.toRotationMatrix(m);
  112517. };
  112518. return SolidParticle;
  112519. }());
  112520. /**
  112521. * Represents the shape of the model used by one particle of a solid particle system.
  112522. * SPS internal tool, don't use it manually.
  112523. */
  112524. var ModelShape = /** @class */ (function () {
  112525. /**
  112526. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  112527. * SPS internal tool, don't use it manually.
  112528. * @hidden
  112529. */
  112530. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  112531. /**
  112532. * length of the shape in the model indices array (internal use)
  112533. * @hidden
  112534. */
  112535. this._indicesLength = 0;
  112536. this.shapeID = id;
  112537. this._shape = shape;
  112538. this._indicesLength = indicesLength;
  112539. this._shapeUV = shapeUV;
  112540. this._positionFunction = posFunction;
  112541. this._vertexFunction = vtxFunction;
  112542. }
  112543. return ModelShape;
  112544. }());
  112545. /**
  112546. * Represents a Depth Sorted Particle in the solid particle system.
  112547. */
  112548. var DepthSortedParticle = /** @class */ (function () {
  112549. function DepthSortedParticle() {
  112550. /**
  112551. * Index of the particle in the "indices" array
  112552. */
  112553. this.ind = 0;
  112554. /**
  112555. * Length of the particle shape in the "indices" array
  112556. */
  112557. this.indicesLength = 0;
  112558. /**
  112559. * Squared distance from the particle to the camera
  112560. */
  112561. this.sqDistance = 0.0;
  112562. }
  112563. return DepthSortedParticle;
  112564. }());
  112565. /***/ }),
  112566. /***/ "./Particles/solidParticleSystem.ts":
  112567. /*!******************************************!*\
  112568. !*** ./Particles/solidParticleSystem.ts ***!
  112569. \******************************************/
  112570. /*! exports provided: SolidParticleSystem */
  112571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112572. "use strict";
  112573. __webpack_require__.r(__webpack_exports__);
  112574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  112575. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  112576. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  112577. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  112578. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  112579. /* harmony import */ var _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  112580. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  112581. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  112582. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  112583. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  112584. /**
  112585. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  112586. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  112587. * The SPS is also a particle system. It provides some methods to manage the particles.
  112588. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  112589. *
  112590. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  112591. */
  112592. var SolidParticleSystem = /** @class */ (function () {
  112593. /**
  112594. * Creates a SPS (Solid Particle System) object.
  112595. * @param name (String) is the SPS name, this will be the underlying mesh name.
  112596. * @param scene (Scene) is the scene in which the SPS is added.
  112597. * @param options defines the options of the sps e.g.
  112598. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  112599. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  112600. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  112601. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  112602. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  112603. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  112604. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  112605. */
  112606. function SolidParticleSystem(name, scene, options) {
  112607. /**
  112608. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  112609. * Example : var p = SPS.particles[i];
  112610. */
  112611. this.particles = new Array();
  112612. /**
  112613. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  112614. */
  112615. this.nbParticles = 0;
  112616. /**
  112617. * If the particles must ever face the camera (default false). Useful for planar particles.
  112618. */
  112619. this.billboard = false;
  112620. /**
  112621. * Recompute normals when adding a shape
  112622. */
  112623. this.recomputeNormals = true;
  112624. /**
  112625. * This a counter ofr your own usage. It's not set by any SPS functions.
  112626. */
  112627. this.counter = 0;
  112628. /**
  112629. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  112630. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  112631. */
  112632. this.vars = {};
  112633. /**
  112634. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  112635. * @hidden
  112636. */
  112637. this._bSphereOnly = false;
  112638. /**
  112639. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  112640. * @hidden
  112641. */
  112642. this._bSphereRadiusFactor = 1.0;
  112643. this._positions = new Array();
  112644. this._indices = new Array();
  112645. this._normals = new Array();
  112646. this._colors = new Array();
  112647. this._uvs = new Array();
  112648. this._index = 0; // indices index
  112649. this._updatable = true;
  112650. this._pickable = false;
  112651. this._isVisibilityBoxLocked = false;
  112652. this._alwaysVisible = false;
  112653. this._depthSort = false;
  112654. this._shapeCounter = 0;
  112655. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  112656. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  112657. this._computeParticleColor = true;
  112658. this._computeParticleTexture = true;
  112659. this._computeParticleRotation = true;
  112660. this._computeParticleVertex = false;
  112661. this._computeBoundingBox = false;
  112662. this._depthSortParticles = true;
  112663. this._mustUnrotateFixedNormals = false;
  112664. this._particlesIntersect = false;
  112665. this._needs32Bits = false;
  112666. this.name = name;
  112667. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  112668. this._camera = scene.activeCamera;
  112669. this._pickable = options ? options.isPickable : false;
  112670. this._depthSort = options ? options.enableDepthSort : false;
  112671. this._particlesIntersect = options ? options.particleIntersection : false;
  112672. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  112673. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  112674. if (options && options.updatable !== undefined) {
  112675. this._updatable = options.updatable;
  112676. }
  112677. else {
  112678. this._updatable = true;
  112679. }
  112680. if (this._pickable) {
  112681. this.pickedParticles = [];
  112682. }
  112683. if (this._depthSort) {
  112684. this.depthSortedParticles = [];
  112685. }
  112686. }
  112687. /**
  112688. * Builds the SPS underlying mesh. Returns a standard Mesh.
  112689. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  112690. * @returns the created mesh
  112691. */
  112692. SolidParticleSystem.prototype.buildMesh = function () {
  112693. if (this.nbParticles === 0) {
  112694. var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  112695. this.addShape(triangle, 1);
  112696. triangle.dispose();
  112697. }
  112698. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  112699. this._positions32 = new Float32Array(this._positions);
  112700. this._uvs32 = new Float32Array(this._uvs);
  112701. this._colors32 = new Float32Array(this._colors);
  112702. if (this.recomputeNormals) {
  112703. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  112704. }
  112705. this._normals32 = new Float32Array(this._normals);
  112706. this._fixedNormal32 = new Float32Array(this._normals);
  112707. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  112708. this._unrotateFixedNormals();
  112709. }
  112710. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  112711. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  112712. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  112713. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  112714. if (this._uvs32.length > 0) {
  112715. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  112716. }
  112717. if (this._colors32.length > 0) {
  112718. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  112719. }
  112720. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  112721. vertexData.applyToMesh(mesh, this._updatable);
  112722. this.mesh = mesh;
  112723. this.mesh.isPickable = this._pickable;
  112724. // free memory
  112725. if (!this._depthSort) {
  112726. this._indices = null;
  112727. }
  112728. this._positions = null;
  112729. this._normals = null;
  112730. this._uvs = null;
  112731. this._colors = null;
  112732. if (!this._updatable) {
  112733. this.particles.length = 0;
  112734. }
  112735. return mesh;
  112736. };
  112737. /**
  112738. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  112739. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  112740. * Thus the particles generated from `digest()` have their property `position` set yet.
  112741. * @param mesh ( Mesh ) is the mesh to be digested
  112742. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  112743. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  112744. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  112745. * @returns the current SPS
  112746. */
  112747. SolidParticleSystem.prototype.digest = function (mesh, options) {
  112748. var size = (options && options.facetNb) || 1;
  112749. var number = (options && options.number) || 0;
  112750. var delta = (options && options.delta) || 0;
  112751. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  112752. var meshInd = mesh.getIndices();
  112753. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  112754. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  112755. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  112756. var f = 0; // facet counter
  112757. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  112758. // compute size from number
  112759. if (number) {
  112760. number = (number > totalFacets) ? totalFacets : number;
  112761. size = Math.round(totalFacets / number);
  112762. delta = 0;
  112763. }
  112764. else {
  112765. size = (size > totalFacets) ? totalFacets : size;
  112766. }
  112767. var facetPos = []; // submesh positions
  112768. var facetInd = []; // submesh indices
  112769. var facetUV = []; // submesh UV
  112770. var facetCol = []; // submesh colors
  112771. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112772. var sizeO = size;
  112773. while (f < totalFacets) {
  112774. size = sizeO + Math.floor((1 + delta) * Math.random());
  112775. if (f > totalFacets - size) {
  112776. size = totalFacets - f;
  112777. }
  112778. // reset temp arrays
  112779. facetPos.length = 0;
  112780. facetInd.length = 0;
  112781. facetUV.length = 0;
  112782. facetCol.length = 0;
  112783. // iterate over "size" facets
  112784. var fi = 0;
  112785. for (var j = f * 3; j < (f + size) * 3; j++) {
  112786. facetInd.push(fi);
  112787. var i = meshInd[j];
  112788. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  112789. if (meshUV) {
  112790. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  112791. }
  112792. if (meshCol) {
  112793. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  112794. }
  112795. fi++;
  112796. }
  112797. // create a model shape for each single particle
  112798. var idx = this.nbParticles;
  112799. var shape = this._posToShape(facetPos);
  112800. var shapeUV = this._uvsToShapeUV(facetUV);
  112801. // compute the barycenter of the shape
  112802. var v;
  112803. for (v = 0; v < shape.length; v++) {
  112804. barycenter.addInPlace(shape[v]);
  112805. }
  112806. barycenter.scaleInPlace(1 / shape.length);
  112807. // shift the shape from its barycenter to the origin
  112808. for (v = 0; v < shape.length; v++) {
  112809. shape[v].subtractInPlace(barycenter);
  112810. }
  112811. var bInfo;
  112812. if (this._particlesIntersect) {
  112813. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  112814. }
  112815. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  112816. // add the particle in the SPS
  112817. var currentPos = this._positions.length;
  112818. var currentInd = this._indices.length;
  112819. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  112820. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  112821. // initialize the particle position
  112822. this.particles[this.nbParticles].position.addInPlace(barycenter);
  112823. this._index += shape.length;
  112824. idx++;
  112825. this.nbParticles++;
  112826. this._shapeCounter++;
  112827. f += size;
  112828. }
  112829. return this;
  112830. };
  112831. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  112832. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  112833. var index = 0;
  112834. var idx = 0;
  112835. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  112836. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  112837. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  112838. for (var p = 0; p < this.particles.length; p++) {
  112839. var particle = this.particles[p];
  112840. var shape = particle._model._shape;
  112841. // computing the inverse of the rotation matrix from the quaternion
  112842. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  112843. if (particle.rotationQuaternion) {
  112844. particle.rotationQuaternion.conjugateToRef(quaternion);
  112845. }
  112846. else {
  112847. var rotation = particle.rotation;
  112848. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  112849. quaternion.conjugateInPlace();
  112850. }
  112851. quaternion.toRotationMatrix(invertedRotMatrix);
  112852. for (var pt = 0; pt < shape.length; pt++) {
  112853. idx = index + pt * 3;
  112854. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  112855. tmpNormal.toArray(this._fixedNormal32, idx);
  112856. }
  112857. index = idx + 3;
  112858. }
  112859. };
  112860. //reset copy
  112861. SolidParticleSystem.prototype._resetCopy = function () {
  112862. var copy = this._copy;
  112863. copy.position.setAll(0);
  112864. copy.rotation.setAll(0);
  112865. copy.rotationQuaternion = null;
  112866. copy.scaling.setAll(1);
  112867. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  112868. copy.color = null;
  112869. copy.translateFromPivot = false;
  112870. };
  112871. // _meshBuilder : inserts the shape model in the global SPS mesh
  112872. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  112873. var i;
  112874. var u = 0;
  112875. var c = 0;
  112876. var n = 0;
  112877. this._resetCopy();
  112878. var copy = this._copy;
  112879. if (options && options.positionFunction) { // call to custom positionFunction
  112880. options.positionFunction(copy, idx, idxInShape);
  112881. this._mustUnrotateFixedNormals = true;
  112882. }
  112883. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  112884. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  112885. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  112886. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  112887. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  112888. copy.getRotationMatrix(rotMatrix);
  112889. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  112890. if (copy.translateFromPivot) {
  112891. pivotBackTranslation.setAll(0.0);
  112892. }
  112893. else {
  112894. pivotBackTranslation.copyFrom(scaledPivot);
  112895. }
  112896. for (i = 0; i < shape.length; i++) {
  112897. tmpVertex.copyFrom(shape[i]);
  112898. if (options && options.vertexFunction) {
  112899. options.vertexFunction(copy, tmpVertex, i);
  112900. }
  112901. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  112902. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  112903. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  112904. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  112905. if (meshUV) {
  112906. var copyUvs = copy.uvs;
  112907. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  112908. u += 2;
  112909. }
  112910. if (copy.color) {
  112911. this._color = copy.color;
  112912. }
  112913. else {
  112914. var color = this._color;
  112915. if (meshCol && meshCol[c] !== undefined) {
  112916. color.r = meshCol[c];
  112917. color.g = meshCol[c + 1];
  112918. color.b = meshCol[c + 2];
  112919. color.a = meshCol[c + 3];
  112920. }
  112921. else {
  112922. color.r = 1.0;
  112923. color.g = 1.0;
  112924. color.b = 1.0;
  112925. color.a = 1.0;
  112926. }
  112927. }
  112928. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  112929. c += 4;
  112930. if (!this.recomputeNormals && meshNor) {
  112931. tmpVertex.x = meshNor[n];
  112932. tmpVertex.y = meshNor[n + 1];
  112933. tmpVertex.z = meshNor[n + 2];
  112934. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  112935. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  112936. n += 3;
  112937. }
  112938. }
  112939. for (i = 0; i < meshInd.length; i++) {
  112940. var current_ind = p + meshInd[i];
  112941. indices.push(current_ind);
  112942. if (current_ind > 65535) {
  112943. this._needs32Bits = true;
  112944. }
  112945. }
  112946. if (this._pickable) {
  112947. var nbfaces = meshInd.length / 3;
  112948. for (i = 0; i < nbfaces; i++) {
  112949. this.pickedParticles.push({ idx: idx, faceId: i });
  112950. }
  112951. }
  112952. if (this._depthSort) {
  112953. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  112954. }
  112955. return copy;
  112956. };
  112957. // returns a shape array from positions array
  112958. SolidParticleSystem.prototype._posToShape = function (positions) {
  112959. var shape = [];
  112960. for (var i = 0; i < positions.length; i += 3) {
  112961. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  112962. }
  112963. return shape;
  112964. };
  112965. // returns a shapeUV array from a Vector4 uvs
  112966. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  112967. var shapeUV = [];
  112968. if (uvs) {
  112969. for (var i = 0; i < uvs.length; i++) {
  112970. shapeUV.push(uvs[i]);
  112971. }
  112972. }
  112973. return shapeUV;
  112974. };
  112975. // adds a new particle object in the particles array
  112976. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  112977. if (bInfo === void 0) { bInfo = null; }
  112978. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  112979. this.particles.push(sp);
  112980. return sp;
  112981. };
  112982. /**
  112983. * Adds some particles to the SPS from the model shape. Returns the shape id.
  112984. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  112985. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  112986. * @param nb (positive integer) the number of particles to be created from this model
  112987. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  112988. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  112989. * @returns the number of shapes in the system
  112990. */
  112991. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  112992. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  112993. var meshInd = mesh.getIndices();
  112994. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  112995. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  112996. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  112997. var bbInfo;
  112998. if (this._particlesIntersect) {
  112999. bbInfo = mesh.getBoundingInfo();
  113000. }
  113001. var shape = this._posToShape(meshPos);
  113002. var shapeUV = this._uvsToShapeUV(meshUV);
  113003. var posfunc = options ? options.positionFunction : null;
  113004. var vtxfunc = options ? options.vertexFunction : null;
  113005. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  113006. // particles
  113007. var sp;
  113008. var currentCopy;
  113009. var idx = this.nbParticles;
  113010. for (var i = 0; i < nb; i++) {
  113011. var currentPos = this._positions.length;
  113012. var currentInd = this._indices.length;
  113013. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  113014. if (this._updatable) {
  113015. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  113016. sp.position.copyFrom(currentCopy.position);
  113017. sp.rotation.copyFrom(currentCopy.rotation);
  113018. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  113019. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  113020. }
  113021. if (currentCopy.color && sp.color) {
  113022. sp.color.copyFrom(currentCopy.color);
  113023. }
  113024. sp.scaling.copyFrom(currentCopy.scaling);
  113025. sp.uvs.copyFrom(currentCopy.uvs);
  113026. }
  113027. this._index += shape.length;
  113028. idx++;
  113029. }
  113030. this.nbParticles += nb;
  113031. this._shapeCounter++;
  113032. return this._shapeCounter - 1;
  113033. };
  113034. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  113035. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  113036. this._resetCopy();
  113037. var copy = this._copy;
  113038. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  113039. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  113040. }
  113041. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  113042. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  113043. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  113044. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  113045. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  113046. copy.getRotationMatrix(rotMatrix);
  113047. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  113048. if (copy.translateFromPivot) {
  113049. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  113050. }
  113051. else {
  113052. pivotBackTranslation.copyFrom(scaledPivot);
  113053. }
  113054. var shape = particle._model._shape;
  113055. for (var pt = 0; pt < shape.length; pt++) {
  113056. tmpVertex.copyFrom(shape[pt]);
  113057. if (particle._model._vertexFunction) {
  113058. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  113059. }
  113060. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  113061. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  113062. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  113063. }
  113064. particle.position.setAll(0.0);
  113065. particle.rotation.setAll(0.0);
  113066. particle.rotationQuaternion = null;
  113067. particle.scaling.setAll(1.0);
  113068. particle.uvs.setAll(0.0);
  113069. particle.pivot.setAll(0.0);
  113070. particle.translateFromPivot = false;
  113071. particle.parentId = null;
  113072. };
  113073. /**
  113074. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  113075. * @returns the SPS.
  113076. */
  113077. SolidParticleSystem.prototype.rebuildMesh = function () {
  113078. for (var p = 0; p < this.particles.length; p++) {
  113079. this._rebuildParticle(this.particles[p]);
  113080. }
  113081. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  113082. return this;
  113083. };
  113084. /**
  113085. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  113086. * This method calls `updateParticle()` for each particle of the SPS.
  113087. * For an animated SPS, it is usually called within the render loop.
  113088. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  113089. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  113090. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  113091. * @returns the SPS.
  113092. */
  113093. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  113094. if (start === void 0) { start = 0; }
  113095. if (end === void 0) { end = this.nbParticles - 1; }
  113096. if (update === void 0) { update = true; }
  113097. if (!this._updatable) {
  113098. return this;
  113099. }
  113100. // custom beforeUpdate
  113101. this.beforeUpdateParticles(start, end, update);
  113102. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  113103. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  113104. var mesh = this.mesh;
  113105. var colors32 = this._colors32;
  113106. var positions32 = this._positions32;
  113107. var normals32 = this._normals32;
  113108. var uvs32 = this._uvs32;
  113109. var indices32 = this._indices32;
  113110. var indices = this._indices;
  113111. var fixedNormal32 = this._fixedNormal32;
  113112. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  113113. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  113114. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  113115. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  113116. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  113117. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  113118. var camInvertedPosition = tempVectors[10].setAll(0);
  113119. // cases when the World Matrix is to be computed first
  113120. if (this.billboard || this._depthSort) {
  113121. this.mesh.computeWorldMatrix(true);
  113122. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  113123. }
  113124. // if the particles will always face the camera
  113125. if (this.billboard) {
  113126. // compute the camera position and un-rotate it by the current mesh rotation
  113127. var tmpVertex = tempVectors[0];
  113128. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  113129. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  113130. camAxisZ.normalize();
  113131. // same for camera up vector extracted from the cam view matrix
  113132. var view = this._camera.getViewMatrix(true);
  113133. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  113134. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  113135. camAxisY.normalize();
  113136. camAxisX.normalize();
  113137. }
  113138. // if depthSort, compute the camera global position in the mesh local system
  113139. if (this._depthSort) {
  113140. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  113141. }
  113142. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  113143. var idx = 0; // current position index in the global array positions32
  113144. var index = 0; // position start index in the global array positions32 of the current particle
  113145. var colidx = 0; // current color index in the global array colors32
  113146. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  113147. var uvidx = 0; // current uv index in the global array uvs32
  113148. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  113149. var pt = 0; // current index in the particle model shape
  113150. if (this.mesh.isFacetDataEnabled) {
  113151. this._computeBoundingBox = true;
  113152. }
  113153. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  113154. if (this._computeBoundingBox) {
  113155. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  113156. var boundingInfo = this.mesh._boundingInfo;
  113157. if (boundingInfo) {
  113158. minimum.copyFrom(boundingInfo.minimum);
  113159. maximum.copyFrom(boundingInfo.maximum);
  113160. }
  113161. }
  113162. }
  113163. // particle loop
  113164. index = this.particles[start]._pos;
  113165. var vpos = (index / 3) | 0;
  113166. colorIndex = vpos * 4;
  113167. uvIndex = vpos * 2;
  113168. for (var p = start; p <= end; p++) {
  113169. var particle = this.particles[p];
  113170. // call to custom user function to update the particle properties
  113171. this.updateParticle(particle);
  113172. var shape = particle._model._shape;
  113173. var shapeUV = particle._model._shapeUV;
  113174. var particleRotationMatrix = particle._rotationMatrix;
  113175. var particlePosition = particle.position;
  113176. var particleRotation = particle.rotation;
  113177. var particleScaling = particle.scaling;
  113178. var particleGlobalPosition = particle._globalPosition;
  113179. // camera-particle distance for depth sorting
  113180. if (this._depthSort && this._depthSortParticles) {
  113181. var dsp = this.depthSortedParticles[p];
  113182. dsp.ind = particle._ind;
  113183. dsp.indicesLength = particle._model._indicesLength;
  113184. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  113185. }
  113186. // skip the computations for inactive or already invisible particles
  113187. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  113188. // increment indexes for the next particle
  113189. pt = shape.length;
  113190. index += pt * 3;
  113191. colorIndex += pt * 4;
  113192. uvIndex += pt * 2;
  113193. continue;
  113194. }
  113195. if (particle.isVisible) {
  113196. particle._stillInvisible = false; // un-mark permanent invisibility
  113197. var scaledPivot = tempVectors[12];
  113198. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  113199. // particle rotation matrix
  113200. if (this.billboard) {
  113201. particleRotation.x = 0.0;
  113202. particleRotation.y = 0.0;
  113203. }
  113204. if (this._computeParticleRotation || this.billboard) {
  113205. particle.getRotationMatrix(rotMatrix);
  113206. }
  113207. var particleHasParent = (particle.parentId !== null);
  113208. if (particleHasParent) {
  113209. var parent_1 = this.particles[particle.parentId];
  113210. var parentRotationMatrix = parent_1._rotationMatrix;
  113211. var parentGlobalPosition = parent_1._globalPosition;
  113212. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  113213. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  113214. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  113215. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  113216. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  113217. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  113218. if (this._computeParticleRotation || this.billboard) {
  113219. var rotMatrixValues = rotMatrix.m;
  113220. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  113221. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  113222. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  113223. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  113224. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  113225. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  113226. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  113227. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  113228. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  113229. }
  113230. }
  113231. else {
  113232. particleGlobalPosition.x = particlePosition.x;
  113233. particleGlobalPosition.y = particlePosition.y;
  113234. particleGlobalPosition.z = particlePosition.z;
  113235. if (this._computeParticleRotation || this.billboard) {
  113236. var rotMatrixValues = rotMatrix.m;
  113237. particleRotationMatrix[0] = rotMatrixValues[0];
  113238. particleRotationMatrix[1] = rotMatrixValues[1];
  113239. particleRotationMatrix[2] = rotMatrixValues[2];
  113240. particleRotationMatrix[3] = rotMatrixValues[4];
  113241. particleRotationMatrix[4] = rotMatrixValues[5];
  113242. particleRotationMatrix[5] = rotMatrixValues[6];
  113243. particleRotationMatrix[6] = rotMatrixValues[8];
  113244. particleRotationMatrix[7] = rotMatrixValues[9];
  113245. particleRotationMatrix[8] = rotMatrixValues[10];
  113246. }
  113247. }
  113248. var pivotBackTranslation = tempVectors[11];
  113249. if (particle.translateFromPivot) {
  113250. pivotBackTranslation.setAll(0.0);
  113251. }
  113252. else {
  113253. pivotBackTranslation.copyFrom(scaledPivot);
  113254. }
  113255. // particle vertex loop
  113256. for (pt = 0; pt < shape.length; pt++) {
  113257. idx = index + pt * 3;
  113258. colidx = colorIndex + pt * 4;
  113259. uvidx = uvIndex + pt * 2;
  113260. var tmpVertex = tempVectors[0];
  113261. tmpVertex.copyFrom(shape[pt]);
  113262. if (this._computeParticleVertex) {
  113263. this.updateParticleVertex(particle, tmpVertex, pt);
  113264. }
  113265. // positions
  113266. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  113267. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  113268. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  113269. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  113270. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  113271. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  113272. rotatedX += pivotBackTranslation.x;
  113273. rotatedY += pivotBackTranslation.y;
  113274. rotatedZ += pivotBackTranslation.z;
  113275. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  113276. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  113277. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  113278. if (this._computeBoundingBox) {
  113279. minimum.minimizeInPlaceFromFloats(px, py, pz);
  113280. maximum.maximizeInPlaceFromFloats(px, py, pz);
  113281. }
  113282. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  113283. if (!this._computeParticleVertex) {
  113284. var normalx = fixedNormal32[idx];
  113285. var normaly = fixedNormal32[idx + 1];
  113286. var normalz = fixedNormal32[idx + 2];
  113287. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  113288. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  113289. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  113290. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  113291. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  113292. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  113293. }
  113294. if (this._computeParticleColor && particle.color) {
  113295. var color = particle.color;
  113296. var colors32_1 = this._colors32;
  113297. colors32_1[colidx] = color.r;
  113298. colors32_1[colidx + 1] = color.g;
  113299. colors32_1[colidx + 2] = color.b;
  113300. colors32_1[colidx + 3] = color.a;
  113301. }
  113302. if (this._computeParticleTexture) {
  113303. var uvs = particle.uvs;
  113304. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  113305. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  113306. }
  113307. }
  113308. }
  113309. // particle just set invisible : scaled to zero and positioned at the origin
  113310. else {
  113311. particle._stillInvisible = true; // mark the particle as invisible
  113312. for (pt = 0; pt < shape.length; pt++) {
  113313. idx = index + pt * 3;
  113314. colidx = colorIndex + pt * 4;
  113315. uvidx = uvIndex + pt * 2;
  113316. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  113317. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  113318. if (this._computeParticleColor && particle.color) {
  113319. var color = particle.color;
  113320. colors32[colidx] = color.r;
  113321. colors32[colidx + 1] = color.g;
  113322. colors32[colidx + 2] = color.b;
  113323. colors32[colidx + 3] = color.a;
  113324. }
  113325. if (this._computeParticleTexture) {
  113326. var uvs = particle.uvs;
  113327. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  113328. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  113329. }
  113330. }
  113331. }
  113332. // if the particle intersections must be computed : update the bbInfo
  113333. if (this._particlesIntersect) {
  113334. var bInfo = particle._boundingInfo;
  113335. var bBox = bInfo.boundingBox;
  113336. var bSphere = bInfo.boundingSphere;
  113337. var modelBoundingInfo = particle._modelBoundingInfo;
  113338. if (!this._bSphereOnly) {
  113339. // place, scale and rotate the particle bbox within the SPS local system, then update it
  113340. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  113341. var tempMin = tempVectors[1];
  113342. var tempMax = tempVectors[2];
  113343. tempMin.setAll(Number.MAX_VALUE);
  113344. tempMax.setAll(-Number.MAX_VALUE);
  113345. for (var b = 0; b < 8; b++) {
  113346. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  113347. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  113348. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  113349. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  113350. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  113351. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  113352. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  113353. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  113354. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  113355. tempMin.minimizeInPlaceFromFloats(x, y, z);
  113356. tempMax.maximizeInPlaceFromFloats(x, y, z);
  113357. }
  113358. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  113359. }
  113360. // place and scale the particle bouding sphere in the SPS local system, then update it
  113361. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  113362. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  113363. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  113364. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  113365. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  113366. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  113367. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  113368. }
  113369. // increment indexes for the next particle
  113370. index = idx + 3;
  113371. colorIndex = colidx + 4;
  113372. uvIndex = uvidx + 2;
  113373. }
  113374. // if the VBO must be updated
  113375. if (update) {
  113376. if (this._computeParticleColor) {
  113377. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  113378. }
  113379. if (this._computeParticleTexture) {
  113380. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  113381. }
  113382. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  113383. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  113384. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  113385. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  113386. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  113387. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  113388. for (var i = 0; i < normals32.length; i++) {
  113389. fixedNormal32[i] = normals32[i];
  113390. }
  113391. }
  113392. if (!mesh.areNormalsFrozen) {
  113393. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  113394. }
  113395. }
  113396. if (this._depthSort && this._depthSortParticles) {
  113397. var depthSortedParticles = this.depthSortedParticles;
  113398. depthSortedParticles.sort(depthSortFunction);
  113399. var dspl = depthSortedParticles.length;
  113400. var sid = 0;
  113401. for (var sorted = 0; sorted < dspl; sorted++) {
  113402. var lind = depthSortedParticles[sorted].indicesLength;
  113403. var sind = depthSortedParticles[sorted].ind;
  113404. for (var i = 0; i < lind; i++) {
  113405. indices32[sid] = indices[sind + i];
  113406. sid++;
  113407. }
  113408. }
  113409. mesh.updateIndices(indices32);
  113410. }
  113411. }
  113412. if (this._computeBoundingBox) {
  113413. if (mesh._boundingInfo) {
  113414. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  113415. }
  113416. else {
  113417. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  113418. }
  113419. }
  113420. this.afterUpdateParticles(start, end, update);
  113421. return this;
  113422. };
  113423. /**
  113424. * Disposes the SPS.
  113425. */
  113426. SolidParticleSystem.prototype.dispose = function () {
  113427. this.mesh.dispose();
  113428. this.vars = null;
  113429. // drop references to internal big arrays for the GC
  113430. this._positions = null;
  113431. this._indices = null;
  113432. this._normals = null;
  113433. this._uvs = null;
  113434. this._colors = null;
  113435. this._indices32 = null;
  113436. this._positions32 = null;
  113437. this._normals32 = null;
  113438. this._fixedNormal32 = null;
  113439. this._uvs32 = null;
  113440. this._colors32 = null;
  113441. this.pickedParticles = null;
  113442. };
  113443. /**
  113444. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  113445. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113446. * @returns the SPS.
  113447. */
  113448. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  113449. if (!this._isVisibilityBoxLocked) {
  113450. this.mesh.refreshBoundingInfo();
  113451. }
  113452. return this;
  113453. };
  113454. /**
  113455. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  113456. * @param size the size (float) of the visibility box
  113457. * note : this doesn't lock the SPS mesh bounding box.
  113458. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113459. */
  113460. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  113461. var vis = size / 2;
  113462. this.mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-vis, -vis, -vis), new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vis, vis, vis));
  113463. };
  113464. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  113465. /**
  113466. * Gets whether the SPS as always visible or not
  113467. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113468. */
  113469. get: function () {
  113470. return this._alwaysVisible;
  113471. },
  113472. /**
  113473. * Sets the SPS as always visible or not
  113474. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113475. */
  113476. set: function (val) {
  113477. this._alwaysVisible = val;
  113478. this.mesh.alwaysSelectAsActiveMesh = val;
  113479. },
  113480. enumerable: true,
  113481. configurable: true
  113482. });
  113483. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  113484. /**
  113485. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  113486. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113487. */
  113488. get: function () {
  113489. return this._isVisibilityBoxLocked;
  113490. },
  113491. /**
  113492. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  113493. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113494. */
  113495. set: function (val) {
  113496. this._isVisibilityBoxLocked = val;
  113497. var boundingInfo = this.mesh.getBoundingInfo();
  113498. boundingInfo.isLocked = val;
  113499. },
  113500. enumerable: true,
  113501. configurable: true
  113502. });
  113503. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  113504. /**
  113505. * Gets if `setParticles()` computes the particle rotations or not.
  113506. * Default value : true. The SPS is faster when it's set to false.
  113507. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  113508. */
  113509. get: function () {
  113510. return this._computeParticleRotation;
  113511. },
  113512. /**
  113513. * Tells to `setParticles()` to compute the particle rotations or not.
  113514. * Default value : true. The SPS is faster when it's set to false.
  113515. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  113516. */
  113517. set: function (val) {
  113518. this._computeParticleRotation = val;
  113519. },
  113520. enumerable: true,
  113521. configurable: true
  113522. });
  113523. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  113524. /**
  113525. * Gets if `setParticles()` computes the particle colors or not.
  113526. * Default value : true. The SPS is faster when it's set to false.
  113527. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  113528. */
  113529. get: function () {
  113530. return this._computeParticleColor;
  113531. },
  113532. /**
  113533. * Tells to `setParticles()` to compute the particle colors or not.
  113534. * Default value : true. The SPS is faster when it's set to false.
  113535. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  113536. */
  113537. set: function (val) {
  113538. this._computeParticleColor = val;
  113539. },
  113540. enumerable: true,
  113541. configurable: true
  113542. });
  113543. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  113544. /**
  113545. * Gets if `setParticles()` computes the particle textures or not.
  113546. * Default value : true. The SPS is faster when it's set to false.
  113547. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  113548. */
  113549. get: function () {
  113550. return this._computeParticleTexture;
  113551. },
  113552. set: function (val) {
  113553. this._computeParticleTexture = val;
  113554. },
  113555. enumerable: true,
  113556. configurable: true
  113557. });
  113558. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  113559. /**
  113560. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  113561. * Default value : false. The SPS is faster when it's set to false.
  113562. * Note : the particle custom vertex positions aren't stored values.
  113563. */
  113564. get: function () {
  113565. return this._computeParticleVertex;
  113566. },
  113567. /**
  113568. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  113569. * Default value : false. The SPS is faster when it's set to false.
  113570. * Note : the particle custom vertex positions aren't stored values.
  113571. */
  113572. set: function (val) {
  113573. this._computeParticleVertex = val;
  113574. },
  113575. enumerable: true,
  113576. configurable: true
  113577. });
  113578. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  113579. /**
  113580. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  113581. */
  113582. get: function () {
  113583. return this._computeBoundingBox;
  113584. },
  113585. /**
  113586. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  113587. */
  113588. set: function (val) {
  113589. this._computeBoundingBox = val;
  113590. },
  113591. enumerable: true,
  113592. configurable: true
  113593. });
  113594. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  113595. /**
  113596. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  113597. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  113598. * Default : `true`
  113599. */
  113600. get: function () {
  113601. return this._depthSortParticles;
  113602. },
  113603. /**
  113604. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  113605. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  113606. * Default : `true`
  113607. */
  113608. set: function (val) {
  113609. this._depthSortParticles = val;
  113610. },
  113611. enumerable: true,
  113612. configurable: true
  113613. });
  113614. // =======================================================================
  113615. // Particle behavior logic
  113616. // these following methods may be overwritten by the user to fit his needs
  113617. /**
  113618. * This function does nothing. It may be overwritten to set all the particle first values.
  113619. * The SPS doesn't call this function, you may have to call it by your own.
  113620. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  113621. */
  113622. SolidParticleSystem.prototype.initParticles = function () {
  113623. };
  113624. /**
  113625. * This function does nothing. It may be overwritten to recycle a particle.
  113626. * The SPS doesn't call this function, you may have to call it by your own.
  113627. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  113628. * @param particle The particle to recycle
  113629. * @returns the recycled particle
  113630. */
  113631. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  113632. return particle;
  113633. };
  113634. /**
  113635. * Updates a particle : this function should be overwritten by the user.
  113636. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  113637. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  113638. * @example : just set a particle position or velocity and recycle conditions
  113639. * @param particle The particle to update
  113640. * @returns the updated particle
  113641. */
  113642. SolidParticleSystem.prototype.updateParticle = function (particle) {
  113643. return particle;
  113644. };
  113645. /**
  113646. * Updates a vertex of a particle : it can be overwritten by the user.
  113647. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  113648. * @param particle the current particle
  113649. * @param vertex the current index of the current particle
  113650. * @param pt the index of the current vertex in the particle shape
  113651. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  113652. * @example : just set a vertex particle position
  113653. * @returns the updated vertex
  113654. */
  113655. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  113656. return vertex;
  113657. };
  113658. /**
  113659. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  113660. * This does nothing and may be overwritten by the user.
  113661. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  113662. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  113663. * @param update the boolean update value actually passed to setParticles()
  113664. */
  113665. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  113666. };
  113667. /**
  113668. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  113669. * This will be passed three parameters.
  113670. * This does nothing and may be overwritten by the user.
  113671. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  113672. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  113673. * @param update the boolean update value actually passed to setParticles()
  113674. */
  113675. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  113676. };
  113677. return SolidParticleSystem;
  113678. }());
  113679. /***/ }),
  113680. /***/ "./Particles/subEmitter.ts":
  113681. /*!*********************************!*\
  113682. !*** ./Particles/subEmitter.ts ***!
  113683. \*********************************/
  113684. /*! exports provided: SubEmitterType, SubEmitter */
  113685. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113686. "use strict";
  113687. __webpack_require__.r(__webpack_exports__);
  113688. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  113689. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  113690. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  113691. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  113692. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  113693. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  113694. /**
  113695. * Type of sub emitter
  113696. */
  113697. var SubEmitterType;
  113698. (function (SubEmitterType) {
  113699. /**
  113700. * Attached to the particle over it's lifetime
  113701. */
  113702. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  113703. /**
  113704. * Created when the particle dies
  113705. */
  113706. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  113707. })(SubEmitterType || (SubEmitterType = {}));
  113708. /**
  113709. * Sub emitter class used to emit particles from an existing particle
  113710. */
  113711. var SubEmitter = /** @class */ (function () {
  113712. /**
  113713. * Creates a sub emitter
  113714. * @param particleSystem the particle system to be used by the sub emitter
  113715. */
  113716. function SubEmitter(
  113717. /**
  113718. * the particle system to be used by the sub emitter
  113719. */
  113720. particleSystem) {
  113721. this.particleSystem = particleSystem;
  113722. /**
  113723. * Type of the submitter (Default: END)
  113724. */
  113725. this.type = SubEmitterType.END;
  113726. /**
  113727. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  113728. * Note: This only is supported when using an emitter of type Mesh
  113729. */
  113730. this.inheritDirection = false;
  113731. /**
  113732. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  113733. */
  113734. this.inheritedVelocityAmount = 0;
  113735. // Create mesh as emitter to support rotation
  113736. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  113737. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  113738. }
  113739. // Automatically dispose of subemitter when system is disposed
  113740. particleSystem.onDisposeObservable.add(function () {
  113741. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  113742. particleSystem.emitter.dispose();
  113743. }
  113744. });
  113745. }
  113746. /**
  113747. * Clones the sub emitter
  113748. * @returns the cloned sub emitter
  113749. */
  113750. SubEmitter.prototype.clone = function () {
  113751. // Clone particle system
  113752. var emitter = this.particleSystem.emitter;
  113753. if (!emitter) {
  113754. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  113755. }
  113756. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  113757. emitter = emitter.clone();
  113758. }
  113759. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  113760. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  113761. emitter.isVisible = false;
  113762. }
  113763. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  113764. // Clone properties
  113765. clone.type = this.type;
  113766. clone.inheritDirection = this.inheritDirection;
  113767. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  113768. clone.particleSystem._disposeEmitterOnDispose = true;
  113769. clone.particleSystem.disposeOnStop = true;
  113770. return clone;
  113771. };
  113772. /**
  113773. * Serialize current object to a JSON object
  113774. * @returns the serialized object
  113775. */
  113776. SubEmitter.prototype.serialize = function () {
  113777. var serializationObject = {};
  113778. serializationObject.type = this.type;
  113779. serializationObject.inheritDirection = this.inheritDirection;
  113780. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  113781. serializationObject.particleSystem = this.particleSystem.serialize();
  113782. return serializationObject;
  113783. };
  113784. /** @hidden */
  113785. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  113786. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("ParseParticle");
  113787. };
  113788. /**
  113789. * Creates a new SubEmitter from a serialized JSON version
  113790. * @param serializationObject defines the JSON object to read from
  113791. * @param scene defines the hosting scene
  113792. * @param rootUrl defines the rootUrl for data loading
  113793. * @returns a new SubEmitter
  113794. */
  113795. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  113796. var system = serializationObject.particleSystem;
  113797. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  113798. subEmitter.type = serializationObject.type;
  113799. subEmitter.inheritDirection = serializationObject.inheritDirection;
  113800. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  113801. subEmitter.particleSystem._isSubEmitter = true;
  113802. return subEmitter;
  113803. };
  113804. /** Release associated resources */
  113805. SubEmitter.prototype.dispose = function () {
  113806. this.particleSystem.dispose();
  113807. };
  113808. return SubEmitter;
  113809. }());
  113810. /***/ }),
  113811. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  113812. /*!*****************************************!*\
  113813. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  113814. \*****************************************/
  113815. /*! exports provided: AmmoJSPlugin */
  113816. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113817. "use strict";
  113818. __webpack_require__.r(__webpack_exports__);
  113819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  113820. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  113821. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  113822. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  113823. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  113824. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  113825. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  113826. /* harmony import */ var _Meshes_Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Meshes/Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  113827. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  113828. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  113829. /**
  113830. * AmmoJS Physics plugin
  113831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113832. * @see https://github.com/kripken/ammo.js/
  113833. */
  113834. var AmmoJSPlugin = /** @class */ (function () {
  113835. /**
  113836. * Initializes the ammoJS plugin
  113837. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  113838. * @param ammoInjection can be used to inject your own ammo reference
  113839. */
  113840. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  113841. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  113842. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  113843. var _this = this;
  113844. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  113845. /**
  113846. * Reference to the Ammo library
  113847. */
  113848. this.bjsAMMO = {};
  113849. /**
  113850. * Name of the plugin
  113851. */
  113852. this.name = "AmmoJSPlugin";
  113853. this._timeStep = 1 / 60;
  113854. this._fixedTimeStep = 1 / 60;
  113855. this._maxSteps = 5;
  113856. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  113857. this._tmpContactCallbackResult = false;
  113858. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  113859. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  113860. if (typeof ammoInjection === "function") {
  113861. ammoInjection(this.bjsAMMO);
  113862. }
  113863. else {
  113864. this.bjsAMMO = ammoInjection;
  113865. }
  113866. if (!this.isSupported()) {
  113867. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  113868. return;
  113869. }
  113870. // Initialize the physics world
  113871. this._collisionConfiguration = new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration();
  113872. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  113873. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  113874. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  113875. this._softBodySolver = new this.bjsAMMO.btDefaultSoftBodySolver();
  113876. this.world = new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration, this._softBodySolver);
  113877. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  113878. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  113879. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_8__["PhysicsRaycastResult"]();
  113880. // Create temp ammo variables
  113881. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  113882. this._tmpAmmoTransform.setIdentity();
  113883. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  113884. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  113885. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  113886. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  113887. this._tmpAmmoVectorD = new this.bjsAMMO.btVector3(0, 0, 0);
  113888. }
  113889. /**
  113890. * Sets the gravity of the physics world (m/(s^2))
  113891. * @param gravity Gravity to set
  113892. */
  113893. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  113894. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  113895. this.world.setGravity(this._tmpAmmoVectorA);
  113896. this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA);
  113897. };
  113898. /**
  113899. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  113900. * @param timeStep timestep to use in seconds
  113901. */
  113902. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  113903. this._timeStep = timeStep;
  113904. };
  113905. /**
  113906. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  113907. * @param fixedTimeStep fixedTimeStep to use in seconds
  113908. */
  113909. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  113910. this._fixedTimeStep = fixedTimeStep;
  113911. };
  113912. /**
  113913. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  113914. * @param maxSteps the maximum number of steps by the physics engine per frame
  113915. */
  113916. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  113917. this._maxSteps = maxSteps;
  113918. };
  113919. /**
  113920. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  113921. * @returns the current timestep in seconds
  113922. */
  113923. AmmoJSPlugin.prototype.getTimeStep = function () {
  113924. return this._timeStep;
  113925. };
  113926. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  113927. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  113928. this._tmpContactCallbackResult = false;
  113929. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  113930. return this._tmpContactCallbackResult;
  113931. };
  113932. // Ammo's collision events have some weird quirks
  113933. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  113934. // so only fire event if both contactTest and contactPairTest have a hit
  113935. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  113936. this._tmpContactCallbackResult = false;
  113937. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  113938. return this._tmpContactCallbackResult;
  113939. };
  113940. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  113941. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  113942. //
  113943. // When maxSteps is 0 do the entire simulation in one step
  113944. // When maxSteps is > 0, run up to maxStep times, if on the last step the (remaining step - fixedTimeStep) is < fixedTimeStep, the remainder will be used for the step. (eg. if remainder is 1.001 and fixedTimeStep is 1 the last step will be 1.001, if instead it did 2 steps (1, 0.001) issues occuered when having a tiny step in ammo)
  113945. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  113946. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  113947. if (timeStep === void 0) { timeStep = 1 / 60; }
  113948. if (maxSteps === void 0) { maxSteps = 10; }
  113949. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  113950. if (maxSteps == 0) {
  113951. this.world.stepSimulation(timeStep, 0);
  113952. }
  113953. else {
  113954. while (maxSteps > 0 && timeStep > 0) {
  113955. if (timeStep - fixedTimeStep < fixedTimeStep) {
  113956. this.world.stepSimulation(timeStep, 0);
  113957. timeStep = 0;
  113958. }
  113959. else {
  113960. timeStep -= fixedTimeStep;
  113961. this.world.stepSimulation(fixedTimeStep, 0);
  113962. }
  113963. maxSteps--;
  113964. }
  113965. }
  113966. };
  113967. /**
  113968. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  113969. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  113970. * After the step the babylon meshes are set to the position of the physics imposters
  113971. * @param delta amount of time to step forward
  113972. * @param impostors array of imposters to update before/after the step
  113973. */
  113974. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  113975. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  113976. var impostor = impostors_1[_i];
  113977. // Update physics world objects to match babylon world
  113978. if (!impostor.soft) {
  113979. impostor.beforeStep();
  113980. }
  113981. }
  113982. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  113983. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  113984. var mainImpostor = impostors_2[_a];
  113985. // After physics update make babylon world objects match physics world objects
  113986. if (mainImpostor.soft) {
  113987. this._afterSoftStep(mainImpostor);
  113988. }
  113989. else {
  113990. mainImpostor.afterStep();
  113991. }
  113992. // Handle collision event
  113993. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  113994. if (this._isImpostorInContact(mainImpostor)) {
  113995. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  113996. var collideCallback = _c[_b];
  113997. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  113998. var otherImpostor = _e[_d];
  113999. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  114000. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  114001. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  114002. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  114003. }
  114004. }
  114005. }
  114006. }
  114007. }
  114008. }
  114009. }
  114010. };
  114011. /**
  114012. * Update babylon mesh to match physics world object
  114013. * @param impostor imposter to match
  114014. */
  114015. AmmoJSPlugin.prototype._afterSoftStep = function (impostor) {
  114016. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].RopeImpostor) {
  114017. this._ropeStep(impostor);
  114018. }
  114019. else {
  114020. this._softbodyOrClothStep(impostor);
  114021. }
  114022. };
  114023. /**
  114024. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  114025. * @param impostor imposter to match
  114026. */
  114027. AmmoJSPlugin.prototype._ropeStep = function (impostor) {
  114028. var bodyVertices = impostor.physicsBody.get_m_nodes();
  114029. var nbVertices = bodyVertices.size();
  114030. var node;
  114031. var nodePositions;
  114032. var x, y, z;
  114033. var path = new Array();
  114034. for (var n = 0; n < nbVertices; n++) {
  114035. node = bodyVertices.at(n);
  114036. nodePositions = node.get_m_x();
  114037. x = nodePositions.x();
  114038. y = nodePositions.y();
  114039. z = nodePositions.z();
  114040. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](x, y, z));
  114041. }
  114042. var object = impostor.object;
  114043. var shape = impostor.getParam("shape");
  114044. if (impostor._isFromLine) {
  114045. impostor.object = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines("lines", { points: path, instance: object });
  114046. }
  114047. else {
  114048. impostor.object = _Meshes_Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_6__["ShapeBuilder"].ExtrudeShape("ext", { shape: shape, path: path, instance: object });
  114049. }
  114050. };
  114051. /**
  114052. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  114053. * @param impostor imposter to match
  114054. */
  114055. AmmoJSPlugin.prototype._softbodyOrClothStep = function (impostor) {
  114056. var normalDirection = (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ClothImpostor) ? 1 : -1;
  114057. var object = impostor.object;
  114058. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  114059. if (!vertexPositions) {
  114060. vertexPositions = [];
  114061. }
  114062. var vertexNormals = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  114063. if (!vertexNormals) {
  114064. vertexNormals = [];
  114065. }
  114066. var nbVertices = vertexPositions.length / 3;
  114067. var bodyVertices = impostor.physicsBody.get_m_nodes();
  114068. var node;
  114069. var nodePositions;
  114070. var nodeNormals;
  114071. var x, y, z;
  114072. var nx, ny, nz;
  114073. for (var n = 0; n < nbVertices; n++) {
  114074. node = bodyVertices.at(n);
  114075. nodePositions = node.get_m_x();
  114076. x = nodePositions.x();
  114077. y = nodePositions.y();
  114078. z = nodePositions.z() * normalDirection;
  114079. var nodeNormals = node.get_m_n();
  114080. nx = nodeNormals.x();
  114081. ny = nodeNormals.y();
  114082. nz = nodeNormals.z() * normalDirection;
  114083. vertexPositions[3 * n] = x;
  114084. vertexPositions[3 * n + 1] = y;
  114085. vertexPositions[3 * n + 2] = z;
  114086. vertexNormals[3 * n] = nx;
  114087. vertexNormals[3 * n + 1] = ny;
  114088. vertexNormals[3 * n + 2] = nz;
  114089. }
  114090. var vertex_data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  114091. vertex_data.positions = vertexPositions;
  114092. vertex_data.normals = vertexNormals;
  114093. vertex_data.uvs = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  114094. vertex_data.colors = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  114095. if (object && object.getIndices) {
  114096. vertex_data.indices = object.getIndices();
  114097. }
  114098. vertex_data.applyToMesh(object);
  114099. };
  114100. /**
  114101. * Applies an impulse on the imposter
  114102. * @param impostor imposter to apply impulse to
  114103. * @param force amount of force to be applied to the imposter
  114104. * @param contactPoint the location to apply the impulse on the imposter
  114105. */
  114106. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  114107. if (!impostor.soft) {
  114108. impostor.physicsBody.activate();
  114109. var worldPoint = this._tmpAmmoVectorA;
  114110. var impulse = this._tmpAmmoVectorB;
  114111. // Convert contactPoint into world space
  114112. if (impostor.object && impostor.object.getWorldMatrix) {
  114113. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  114114. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  114115. contactPoint = this._tmpVector;
  114116. }
  114117. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  114118. impulse.setValue(force.x, force.y, force.z);
  114119. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  114120. }
  114121. else {
  114122. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Cannot be applied to a soft body");
  114123. }
  114124. };
  114125. /**
  114126. * Applies a force on the imposter
  114127. * @param impostor imposter to apply force
  114128. * @param force amount of force to be applied to the imposter
  114129. * @param contactPoint the location to apply the force on the imposter
  114130. */
  114131. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  114132. if (!impostor.soft) {
  114133. impostor.physicsBody.activate();
  114134. var worldPoint = this._tmpAmmoVectorA;
  114135. var impulse = this._tmpAmmoVectorB;
  114136. // Convert contactPoint into world space
  114137. if (impostor.object && impostor.object.getWorldMatrix) {
  114138. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  114139. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  114140. contactPoint = this._tmpVector;
  114141. }
  114142. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  114143. impulse.setValue(force.x, force.y, force.z);
  114144. impostor.physicsBody.applyForce(impulse, worldPoint);
  114145. }
  114146. else {
  114147. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Cannot be applied to a soft body");
  114148. }
  114149. };
  114150. /**
  114151. * Creates a physics body using the plugin
  114152. * @param impostor the imposter to create the physics body on
  114153. */
  114154. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  114155. // Note: this method will not be called on child imposotrs for compound impostors
  114156. impostor._pluginData.toDispose = [];
  114157. //parent-child relationship
  114158. if (impostor.parent) {
  114159. if (impostor.physicsBody) {
  114160. this.removePhysicsBody(impostor);
  114161. impostor.forceUpdate();
  114162. }
  114163. return;
  114164. }
  114165. if (impostor.isBodyInitRequired()) {
  114166. var colShape = this._createShape(impostor);
  114167. var mass = impostor.getParam("mass");
  114168. impostor._pluginData.mass = mass;
  114169. if (impostor.soft) {
  114170. colShape.get_m_cfg().set_collisions(0x11);
  114171. colShape.get_m_cfg().set_kDP(impostor.getParam("damping"));
  114172. Ammo.castObject(colShape, Ammo.btCollisionObject).getCollisionShape().setMargin(impostor.getParam("margin"));
  114173. colShape.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  114174. this.world.addSoftBody(colShape, 1, -1);
  114175. impostor.physicsBody = colShape;
  114176. impostor._pluginData.toDispose.concat([colShape]);
  114177. this.setBodyPressure(impostor, 0);
  114178. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor) {
  114179. this.setBodyPressure(impostor, impostor.getParam("pressure"));
  114180. }
  114181. this.setBodyStiffness(impostor, impostor.getParam("stiffness"));
  114182. this.setBodyVelocityIterations(impostor, impostor.getParam("velocityIterations"));
  114183. this.setBodyPositionIterations(impostor, impostor.getParam("positionIterations"));
  114184. }
  114185. else {
  114186. var localInertia = new Ammo.btVector3(0, 0, 0);
  114187. var startTransform = new Ammo.btTransform();
  114188. startTransform.setIdentity();
  114189. if (mass !== 0) {
  114190. colShape.calculateLocalInertia(mass, localInertia);
  114191. }
  114192. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  114193. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  114194. startTransform.setOrigin(this._tmpAmmoVectorA);
  114195. startTransform.setRotation(this._tmpAmmoQuaternion);
  114196. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  114197. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  114198. var body = new Ammo.btRigidBody(rbInfo);
  114199. // Make objects kinematic if it's mass is 0
  114200. if (mass === 0) {
  114201. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  114202. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  114203. }
  114204. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  114205. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  114206. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  114207. }
  114208. this.world.addRigidBody(body);
  114209. impostor.physicsBody = body;
  114210. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  114211. }
  114212. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  114213. this.setBodyFriction(impostor, impostor.getParam("friction"));
  114214. }
  114215. };
  114216. /**
  114217. * Removes the physics body from the imposter and disposes of the body's memory
  114218. * @param impostor imposter to remove the physics body from
  114219. */
  114220. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  114221. var _this = this;
  114222. if (this.world) {
  114223. this.world.removeRigidBody(impostor.physicsBody);
  114224. if (impostor._pluginData) {
  114225. impostor._pluginData.toDispose.forEach(function (d) {
  114226. _this.bjsAMMO.destroy(d);
  114227. });
  114228. }
  114229. }
  114230. };
  114231. /**
  114232. * Generates a joint
  114233. * @param impostorJoint the imposter joint to create the joint with
  114234. */
  114235. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  114236. var mainBody = impostorJoint.mainImpostor.physicsBody;
  114237. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  114238. if (!mainBody || !connectedBody) {
  114239. return;
  114240. }
  114241. var jointData = impostorJoint.joint.jointData;
  114242. if (!jointData.mainPivot) {
  114243. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  114244. }
  114245. if (!jointData.connectedPivot) {
  114246. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  114247. }
  114248. var joint;
  114249. switch (impostorJoint.joint.type) {
  114250. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  114251. var distance = jointData.maxDistance;
  114252. if (distance) {
  114253. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  114254. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  114255. }
  114256. joint = new Ammo.btPoint2PointConstraint(mainBody, connectedBody, new Ammo.btVector3(jointData.mainPivot.x, jointData.mainPivot.y, jointData.mainPivot.z), new Ammo.btVector3(jointData.connectedPivot.x, jointData.connectedPivot.y, jointData.connectedPivot.z));
  114257. break;
  114258. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  114259. if (!jointData.mainAxis) {
  114260. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  114261. }
  114262. if (!jointData.connectedAxis) {
  114263. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  114264. }
  114265. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  114266. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  114267. joint = new Ammo.btHingeConstraint(mainBody, connectedBody, new Ammo.btVector3(jointData.mainPivot.x, jointData.mainPivot.y, jointData.mainPivot.z), new Ammo.btVector3(jointData.connectedPivot.x, jointData.connectedPivot.y, jointData.connectedPivot.z), mainAxis, connectedAxis);
  114268. break;
  114269. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  114270. joint = new Ammo.btPoint2PointConstraint(mainBody, connectedBody, new Ammo.btVector3(jointData.mainPivot.x, jointData.mainPivot.y, jointData.mainPivot.z), new Ammo.btVector3(jointData.connectedPivot.x, jointData.connectedPivot.y, jointData.connectedPivot.z));
  114271. break;
  114272. default:
  114273. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  114274. joint = new Ammo.btPoint2PointConstraint(mainBody, connectedBody, new Ammo.btVector3(jointData.mainPivot.x, jointData.mainPivot.y, jointData.mainPivot.z), new Ammo.btVector3(jointData.connectedPivot.x, jointData.connectedPivot.y, jointData.connectedPivot.z));
  114275. break;
  114276. }
  114277. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  114278. impostorJoint.joint.physicsJoint = joint;
  114279. };
  114280. /**
  114281. * Removes a joint
  114282. * @param impostorJoint the imposter joint to remove the joint from
  114283. */
  114284. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  114285. if (this.world) {
  114286. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  114287. }
  114288. };
  114289. // adds all verticies (including child verticies) to the triangle mesh
  114290. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  114291. var _this = this;
  114292. var triangleCount = 0;
  114293. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  114294. var indices = object.getIndices();
  114295. if (!indices) {
  114296. indices = [];
  114297. }
  114298. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  114299. if (!vertexPositions) {
  114300. vertexPositions = [];
  114301. }
  114302. object.computeWorldMatrix(false);
  114303. var faceCount = indices.length / 3;
  114304. for (var i = 0; i < faceCount; i++) {
  114305. var triPoints = [];
  114306. for (var point = 0; point < 3; point++) {
  114307. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[(indices[(i * 3) + point] * 3) + 0], vertexPositions[(indices[(i * 3) + point] * 3) + 1], vertexPositions[(indices[(i * 3) + point] * 3) + 2]);
  114308. // Adjust for initial scaling
  114309. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].ScalingToRef(object.scaling.x, object.scaling.y, object.scaling.z, this._tmpMatrix);
  114310. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, this._tmpMatrix);
  114311. var vec;
  114312. if (point == 0) {
  114313. vec = this._tmpAmmoVectorA;
  114314. }
  114315. else if (point == 1) {
  114316. vec = this._tmpAmmoVectorB;
  114317. }
  114318. else {
  114319. vec = this._tmpAmmoVectorC;
  114320. }
  114321. vec.setValue(v.x, v.y, v.z);
  114322. triPoints.push(vec);
  114323. }
  114324. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  114325. triangleCount++;
  114326. }
  114327. object.getChildMeshes().forEach(function (m) {
  114328. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  114329. });
  114330. }
  114331. return triangleCount;
  114332. };
  114333. /**
  114334. * Initialise the soft body vertices to match its object's (mesh) vertices
  114335. * Softbody vertices (nodes) are in world space and to match this
  114336. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  114337. * @param impostor to create the softbody for
  114338. */
  114339. AmmoJSPlugin.prototype._softVertexData = function (impostor) {
  114340. var object = impostor.object;
  114341. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  114342. var indices = object.getIndices();
  114343. if (!indices) {
  114344. indices = [];
  114345. }
  114346. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  114347. if (!vertexPositions) {
  114348. vertexPositions = [];
  114349. }
  114350. var vertexNormals = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  114351. if (!vertexNormals) {
  114352. vertexNormals = [];
  114353. }
  114354. object.computeWorldMatrix(false);
  114355. var newPoints = [];
  114356. var newNorms = [];
  114357. for (var i = 0; i < vertexPositions.length; i += 3) {
  114358. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[i], vertexPositions[i + 1], vertexPositions[i + 2]);
  114359. var n = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexNormals[i], vertexNormals[i + 1], vertexNormals[i + 2]);
  114360. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  114361. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(n, object.getWorldMatrix());
  114362. newPoints.push(v.x, v.y, v.z);
  114363. newNorms.push(n.x, n.y, n.z);
  114364. }
  114365. var vertex_data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  114366. vertex_data.positions = newPoints;
  114367. vertex_data.normals = newNorms;
  114368. vertex_data.uvs = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  114369. vertex_data.colors = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  114370. if (object && object.getIndices) {
  114371. vertex_data.indices = object.getIndices();
  114372. }
  114373. vertex_data.applyToMesh(object);
  114374. object.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  114375. object.rotationQuaternion = null;
  114376. object.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  114377. object.computeWorldMatrix(true);
  114378. return vertex_data;
  114379. }
  114380. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"].ExtractFromMesh(object);
  114381. };
  114382. /**
  114383. * Create an impostor's soft body
  114384. * @param impostor to create the softbody for
  114385. */
  114386. AmmoJSPlugin.prototype._createSoftbody = function (impostor) {
  114387. var object = impostor.object;
  114388. if (object && object.getIndices) {
  114389. var indices = object.getIndices();
  114390. if (!indices) {
  114391. indices = [];
  114392. }
  114393. var vertex_data = this._softVertexData(impostor);
  114394. var vertexPositions = vertex_data.positions;
  114395. var vertexNormals = vertex_data.normals;
  114396. if (vertexPositions === null || vertexNormals === null) {
  114397. return new Ammo.btCompoundShape();
  114398. }
  114399. else {
  114400. var triPoints = [];
  114401. var triNorms = [];
  114402. for (var i = 0; i < vertexPositions.length; i += 3) {
  114403. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[i], vertexPositions[i + 1], vertexPositions[i + 2]);
  114404. var n = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexNormals[i], vertexNormals[i + 1], vertexNormals[i + 2]);
  114405. triPoints.push(v.x, v.y, -v.z);
  114406. triNorms.push(n.x, n.y, -n.z);
  114407. }
  114408. var softBody = new Ammo.btSoftBodyHelpers().CreateFromTriMesh(this.world.getWorldInfo(), triPoints, object.getIndices(), indices.length / 3, true);
  114409. var nbVertices = vertexPositions.length / 3;
  114410. var bodyVertices = softBody.get_m_nodes();
  114411. var node;
  114412. var nodeNormals;
  114413. for (var i = 0; i < nbVertices; i++) {
  114414. node = bodyVertices.at(i);
  114415. var nodeNormals = node.get_m_n();
  114416. nodeNormals.setX(triNorms[3 * i]);
  114417. nodeNormals.setY(triNorms[3 * i + 1]);
  114418. nodeNormals.setZ(triNorms[3 * i + 2]);
  114419. }
  114420. return softBody;
  114421. }
  114422. }
  114423. };
  114424. /**
  114425. * Create cloth for an impostor
  114426. * @param impostor to create the softbody for
  114427. */
  114428. AmmoJSPlugin.prototype._createCloth = function (impostor) {
  114429. var object = impostor.object;
  114430. if (object && object.getIndices) {
  114431. var indices = object.getIndices();
  114432. if (!indices) {
  114433. indices = [];
  114434. }
  114435. var vertex_data = this._softVertexData(impostor);
  114436. var vertexPositions = vertex_data.positions;
  114437. var vertexNormals = vertex_data.normals;
  114438. if (vertexPositions === null || vertexNormals === null) {
  114439. return new Ammo.btCompoundShape();
  114440. }
  114441. else {
  114442. var len = vertexPositions.length;
  114443. var segments = Math.sqrt(len / 3);
  114444. impostor.segments = segments;
  114445. var segs = segments - 1;
  114446. this._tmpAmmoVectorA.setValue(vertexPositions[0], vertexPositions[1], vertexPositions[2]);
  114447. this._tmpAmmoVectorB.setValue(vertexPositions[3 * segs], vertexPositions[3 * segs + 1], vertexPositions[3 * segs + 2]);
  114448. this._tmpAmmoVectorD.setValue(vertexPositions[len - 3], vertexPositions[len - 2], vertexPositions[len - 1]);
  114449. this._tmpAmmoVectorC.setValue(vertexPositions[len - 3 - 3 * segs], vertexPositions[len - 2 - 3 * segs], vertexPositions[len - 1 - 3 * segs]);
  114450. var clothBody = new Ammo.btSoftBodyHelpers().CreatePatch(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, this._tmpAmmoVectorC, this._tmpAmmoVectorD, segments, segments, impostor.getParam("fixedPoints"), true);
  114451. return clothBody;
  114452. }
  114453. }
  114454. };
  114455. /**
  114456. * Create rope for an impostor
  114457. * @param impostor to create the softbody for
  114458. */
  114459. AmmoJSPlugin.prototype._createRope = function (impostor) {
  114460. var len;
  114461. var segments;
  114462. var vertex_data = this._softVertexData(impostor);
  114463. var vertexPositions = vertex_data.positions;
  114464. var vertexNormals = vertex_data.normals;
  114465. if (vertexPositions === null || vertexNormals === null) {
  114466. return new Ammo.btCompoundShape();
  114467. }
  114468. //force the mesh to be updatable
  114469. vertex_data.applyToMesh(impostor.object, true);
  114470. impostor._isFromLine = true;
  114471. // If in lines mesh all normals will be zero
  114472. var vertexSquared = vertexNormals.map(function (x) { return x * x; });
  114473. var reducer = function (accumulator, currentValue) { return accumulator + currentValue; };
  114474. var reduced = vertexSquared.reduce(reducer);
  114475. if (reduced === 0) { // line mesh
  114476. len = vertexPositions.length;
  114477. segments = len / 3 - 1;
  114478. this._tmpAmmoVectorA.setValue(vertexPositions[0], vertexPositions[1], vertexPositions[2]);
  114479. this._tmpAmmoVectorB.setValue(vertexPositions[len - 3], vertexPositions[len - 2], vertexPositions[len - 1]);
  114480. }
  114481. else { //extruded mesh
  114482. impostor._isFromLine = false;
  114483. var pathVectors = impostor.getParam("path");
  114484. var shape = impostor.getParam("shape");
  114485. if (shape === null) {
  114486. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("No shape available for extruded mesh");
  114487. return new Ammo.btCompoundShape();
  114488. }
  114489. if ((vertexPositions.length % (3 * pathVectors.length)) !== 0) {
  114490. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Path does not match extrusion");
  114491. return new Ammo.btCompoundShape();
  114492. }
  114493. len = pathVectors.length;
  114494. segments = len - 1;
  114495. this._tmpAmmoVectorA.setValue(pathVectors[0].x, pathVectors[0].y, pathVectors[0].z);
  114496. this._tmpAmmoVectorB.setValue(pathVectors[len - 1].x, pathVectors[len - 1].y, pathVectors[len - 1].z);
  114497. }
  114498. impostor.segments = segments;
  114499. var fixedPoints = impostor.getParam("fixedPoints");
  114500. fixedPoints = (fixedPoints > 3) ? 3 : fixedPoints;
  114501. var ropeBody = new Ammo.btSoftBodyHelpers().CreateRope(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, segments - 1, fixedPoints);
  114502. ropeBody.get_m_cfg().set_collisions(0x11);
  114503. return ropeBody;
  114504. };
  114505. // adds all verticies (including child verticies) to the convex hull shape
  114506. AmmoJSPlugin.prototype._addHullVerts = function (btConvexHullShape, topLevelObject, object) {
  114507. var _this = this;
  114508. var triangleCount = 0;
  114509. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  114510. var indices = object.getIndices();
  114511. if (!indices) {
  114512. indices = [];
  114513. }
  114514. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  114515. if (!vertexPositions) {
  114516. vertexPositions = [];
  114517. }
  114518. object.computeWorldMatrix(false);
  114519. var faceCount = indices.length / 3;
  114520. for (var i = 0; i < faceCount; i++) {
  114521. var triPoints = [];
  114522. for (var point = 0; point < 3; point++) {
  114523. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[(indices[(i * 3) + point] * 3) + 0], vertexPositions[(indices[(i * 3) + point] * 3) + 1], vertexPositions[(indices[(i * 3) + point] * 3) + 2]);
  114524. // Adjust for initial scaling
  114525. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].ScalingToRef(object.scaling.x, object.scaling.y, object.scaling.z, this._tmpMatrix);
  114526. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, this._tmpMatrix);
  114527. var vec;
  114528. if (point == 0) {
  114529. vec = this._tmpAmmoVectorA;
  114530. }
  114531. else if (point == 1) {
  114532. vec = this._tmpAmmoVectorB;
  114533. }
  114534. else {
  114535. vec = this._tmpAmmoVectorC;
  114536. }
  114537. vec.setValue(v.x, v.y, v.z);
  114538. triPoints.push(vec);
  114539. }
  114540. btConvexHullShape.addPoint(triPoints[0], true);
  114541. btConvexHullShape.addPoint(triPoints[1], true);
  114542. btConvexHullShape.addPoint(triPoints[2], true);
  114543. triangleCount++;
  114544. }
  114545. object.getChildMeshes().forEach(function (m) {
  114546. triangleCount += _this._addHullVerts(btConvexHullShape, topLevelObject, m);
  114547. });
  114548. }
  114549. return triangleCount;
  114550. };
  114551. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  114552. var _this = this;
  114553. if (ignoreChildren === void 0) { ignoreChildren = false; }
  114554. var object = impostor.object;
  114555. var returnValue;
  114556. var extendSize = impostor.getObjectExtendSize();
  114557. if (!ignoreChildren) {
  114558. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  114559. returnValue = new Ammo.btCompoundShape();
  114560. // Add shape of all children to the compound shape
  114561. var childrenAdded = 0;
  114562. meshChildren.forEach(function (childMesh) {
  114563. var childImpostor = childMesh.getPhysicsImpostor();
  114564. if (childImpostor) {
  114565. if (childImpostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor) {
  114566. throw "A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)";
  114567. }
  114568. var shape = _this._createShape(childImpostor);
  114569. // Position needs to be scaled based on parent's scaling
  114570. var parentMat = childMesh.parent.getWorldMatrix().clone();
  114571. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  114572. parentMat.decompose(s);
  114573. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  114574. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  114575. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  114576. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  114577. childImpostor.dispose();
  114578. childrenAdded++;
  114579. }
  114580. });
  114581. if (childrenAdded > 0) {
  114582. // Add parents shape as a child if present
  114583. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  114584. var shape = this._createShape(impostor, true);
  114585. if (shape) {
  114586. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  114587. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  114588. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  114589. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  114590. }
  114591. }
  114592. return returnValue;
  114593. }
  114594. else {
  114595. // If no children with impostors create the actual shape below instead
  114596. Ammo.destroy(returnValue);
  114597. returnValue = null;
  114598. }
  114599. }
  114600. switch (impostor.type) {
  114601. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  114602. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  114603. break;
  114604. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  114605. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  114606. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  114607. break;
  114608. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  114609. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  114610. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  114611. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  114612. break;
  114613. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  114614. if (impostor.getParam("mass") == 0) {
  114615. // Only create btBvhTriangleMeshShape impostor is static
  114616. // See https://pybullet.org/Bullet/phpBB3/viewtopic.php?t=7283
  114617. var tetraMesh = new Ammo.btTriangleMesh();
  114618. impostor._pluginData.toDispose.concat([tetraMesh]);
  114619. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  114620. if (triangeCount == 0) {
  114621. returnValue = new Ammo.btCompoundShape();
  114622. }
  114623. else {
  114624. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  114625. }
  114626. break;
  114627. }
  114628. // Otherwise create convexHullImpostor
  114629. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ConvexHullImpostor:
  114630. var convexMesh = new Ammo.btConvexHullShape();
  114631. var triangeCount = this._addHullVerts(convexMesh, object, object);
  114632. if (triangeCount == 0) {
  114633. // Cleanup Unused Convex Hull Shape
  114634. impostor._pluginData.toDispose.concat([convexMesh]);
  114635. returnValue = new Ammo.btCompoundShape();
  114636. }
  114637. else {
  114638. returnValue = convexMesh;
  114639. }
  114640. break;
  114641. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  114642. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  114643. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  114644. break;
  114645. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor:
  114646. // Only usable with a mesh that has sufficient and shared vertices
  114647. returnValue = this._createSoftbody(impostor);
  114648. break;
  114649. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ClothImpostor:
  114650. // Only usable with a ground mesh that has sufficient and shared vertices
  114651. returnValue = this._createCloth(impostor);
  114652. break;
  114653. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].RopeImpostor:
  114654. // Only usable with a line mesh or an extruded mesh that is updatable
  114655. returnValue = this._createRope(impostor);
  114656. break;
  114657. default:
  114658. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  114659. break;
  114660. }
  114661. return returnValue;
  114662. };
  114663. /**
  114664. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  114665. * @param impostor imposter containing the physics body and babylon object
  114666. */
  114667. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  114668. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  114669. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  114670. if (!impostor.object.rotationQuaternion) {
  114671. if (impostor.object.rotation) {
  114672. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  114673. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  114674. }
  114675. }
  114676. else {
  114677. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  114678. }
  114679. };
  114680. /**
  114681. * Sets the babylon object's position/rotation from the physics body's position/rotation
  114682. * @param impostor imposter containing the physics body and babylon object
  114683. * @param newPosition new position
  114684. * @param newRotation new rotation
  114685. */
  114686. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  114687. var trans = impostor.physicsBody.getWorldTransform();
  114688. // If rotation/position has changed update and activate riged body
  114689. if (trans.getOrigin().x() != newPosition.x ||
  114690. trans.getOrigin().y() != newPosition.y ||
  114691. trans.getOrigin().z() != newPosition.z ||
  114692. trans.getRotation().x() != newRotation.x ||
  114693. trans.getRotation().y() != newRotation.y ||
  114694. trans.getRotation().z() != newRotation.z ||
  114695. trans.getRotation().w() != newRotation.w) {
  114696. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  114697. trans.setOrigin(this._tmpAmmoVectorA);
  114698. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  114699. trans.setRotation(this._tmpAmmoQuaternion);
  114700. impostor.physicsBody.setWorldTransform(trans);
  114701. if (impostor.mass == 0) {
  114702. // Kinematic objects must be updated using motion state
  114703. var motionState = impostor.physicsBody.getMotionState();
  114704. if (motionState) {
  114705. motionState.setWorldTransform(trans);
  114706. }
  114707. }
  114708. else {
  114709. impostor.physicsBody.activate();
  114710. }
  114711. }
  114712. };
  114713. /**
  114714. * If this plugin is supported
  114715. * @returns true if its supported
  114716. */
  114717. AmmoJSPlugin.prototype.isSupported = function () {
  114718. return this.bjsAMMO !== undefined;
  114719. };
  114720. /**
  114721. * Sets the linear velocity of the physics body
  114722. * @param impostor imposter to set the velocity on
  114723. * @param velocity velocity to set
  114724. */
  114725. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  114726. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  114727. if (impostor.soft) {
  114728. impostor.physicsBody.linearVelocity(this._tmpAmmoVectorA);
  114729. }
  114730. else {
  114731. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  114732. }
  114733. };
  114734. /**
  114735. * Sets the angular velocity of the physics body
  114736. * @param impostor imposter to set the velocity on
  114737. * @param velocity velocity to set
  114738. */
  114739. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  114740. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  114741. if (impostor.soft) {
  114742. impostor.physicsBody.angularVelocity(this._tmpAmmoVectorA);
  114743. }
  114744. else {
  114745. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  114746. }
  114747. };
  114748. /**
  114749. * gets the linear velocity
  114750. * @param impostor imposter to get linear velocity from
  114751. * @returns linear velocity
  114752. */
  114753. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  114754. if (impostor.soft) {
  114755. var v = impostor.physicsBody.linearVelocity();
  114756. }
  114757. else {
  114758. var v = impostor.physicsBody.getLinearVelocity();
  114759. }
  114760. if (!v) {
  114761. return null;
  114762. }
  114763. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  114764. };
  114765. /**
  114766. * gets the angular velocity
  114767. * @param impostor imposter to get angular velocity from
  114768. * @returns angular velocity
  114769. */
  114770. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  114771. if (impostor.soft) {
  114772. var v = impostor.physicsBody.angularVelocity();
  114773. }
  114774. else {
  114775. var v = impostor.physicsBody.getAngularVelocity();
  114776. }
  114777. if (!v) {
  114778. return null;
  114779. }
  114780. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  114781. };
  114782. /**
  114783. * Sets the mass of physics body
  114784. * @param impostor imposter to set the mass on
  114785. * @param mass mass to set
  114786. */
  114787. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  114788. if (impostor.soft) {
  114789. impostor.physicsBody.setTotalMass(mass, false);
  114790. }
  114791. else {
  114792. impostor.physicsBody.setMassProps(mass);
  114793. }
  114794. impostor._pluginData.mass = mass;
  114795. };
  114796. /**
  114797. * Gets the mass of the physics body
  114798. * @param impostor imposter to get the mass from
  114799. * @returns mass
  114800. */
  114801. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  114802. return impostor._pluginData.mass || 0;
  114803. };
  114804. /**
  114805. * Gets friction of the impostor
  114806. * @param impostor impostor to get friction from
  114807. * @returns friction value
  114808. */
  114809. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  114810. return impostor._pluginData.friction || 0;
  114811. };
  114812. /**
  114813. * Sets friction of the impostor
  114814. * @param impostor impostor to set friction on
  114815. * @param friction friction value
  114816. */
  114817. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  114818. if (impostor.soft) {
  114819. impostor.physicsBody.get_m_cfg().set_kDF(friction);
  114820. }
  114821. else {
  114822. impostor.physicsBody.setFriction(friction);
  114823. }
  114824. impostor._pluginData.friction = friction;
  114825. };
  114826. /**
  114827. * Gets restitution of the impostor
  114828. * @param impostor impostor to get restitution from
  114829. * @returns restitution value
  114830. */
  114831. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  114832. return impostor._pluginData.restitution || 0;
  114833. };
  114834. /**
  114835. * Sets resitution of the impostor
  114836. * @param impostor impostor to set resitution on
  114837. * @param restitution resitution value
  114838. */
  114839. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  114840. impostor.physicsBody.setRestitution(restitution);
  114841. impostor._pluginData.restitution = restitution;
  114842. };
  114843. /**
  114844. * Gets pressure inside the impostor
  114845. * @param impostor impostor to get pressure from
  114846. * @returns pressure value
  114847. */
  114848. AmmoJSPlugin.prototype.getBodyPressure = function (impostor) {
  114849. if (!impostor.soft) {
  114850. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Pressure is not a property of a rigid body");
  114851. return 0;
  114852. }
  114853. return impostor._pluginData.pressure || 0;
  114854. };
  114855. /**
  114856. * Sets pressure inside a soft body impostor
  114857. * Cloth and rope must remain 0 pressure
  114858. * @param impostor impostor to set pressure on
  114859. * @param pressure pressure value
  114860. */
  114861. AmmoJSPlugin.prototype.setBodyPressure = function (impostor, pressure) {
  114862. if (impostor.soft) {
  114863. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor) {
  114864. impostor.physicsBody.get_m_cfg().set_kPR(pressure);
  114865. impostor._pluginData.pressure = pressure;
  114866. }
  114867. else {
  114868. impostor.physicsBody.get_m_cfg().set_kPR(0);
  114869. impostor._pluginData.pressure = 0;
  114870. }
  114871. }
  114872. else {
  114873. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Pressure can only be applied to a softbody");
  114874. }
  114875. };
  114876. /**
  114877. * Gets stiffness of the impostor
  114878. * @param impostor impostor to get stiffness from
  114879. * @returns pressure value
  114880. */
  114881. AmmoJSPlugin.prototype.getBodyStiffness = function (impostor) {
  114882. if (!impostor.soft) {
  114883. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Stiffness is not a property of a rigid body");
  114884. return 0;
  114885. }
  114886. return impostor._pluginData.stiffness || 0;
  114887. };
  114888. /**
  114889. * Sets stiffness of the impostor
  114890. * @param impostor impostor to set stiffness on
  114891. * @param stiffness stiffness value from 0 to 1
  114892. */
  114893. AmmoJSPlugin.prototype.setBodyStiffness = function (impostor, stiffness) {
  114894. if (impostor.soft) {
  114895. stiffness = stiffness < 0 ? 0 : stiffness;
  114896. stiffness = stiffness > 1 ? 1 : stiffness;
  114897. impostor.physicsBody.get_m_materials().at(0).set_m_kLST(stiffness);
  114898. impostor._pluginData.stiffness = stiffness;
  114899. }
  114900. else {
  114901. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Stiffness cannot be applied to a rigid body");
  114902. }
  114903. };
  114904. /**
  114905. * Gets velocityIterations of the impostor
  114906. * @param impostor impostor to get velocity iterations from
  114907. * @returns velocityIterations value
  114908. */
  114909. AmmoJSPlugin.prototype.getBodyVelocityIterations = function (impostor) {
  114910. if (!impostor.soft) {
  114911. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Velocity iterations is not a property of a rigid body");
  114912. return 0;
  114913. }
  114914. return impostor._pluginData.velocityIterations || 0;
  114915. };
  114916. /**
  114917. * Sets velocityIterations of the impostor
  114918. * @param impostor impostor to set velocity iterations on
  114919. * @param velocityIterations velocityIterations value
  114920. */
  114921. AmmoJSPlugin.prototype.setBodyVelocityIterations = function (impostor, velocityIterations) {
  114922. if (impostor.soft) {
  114923. velocityIterations = velocityIterations < 0 ? 0 : velocityIterations;
  114924. impostor.physicsBody.get_m_cfg().set_viterations(velocityIterations);
  114925. impostor._pluginData.velocityIterations = velocityIterations;
  114926. }
  114927. else {
  114928. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Velocity iterations cannot be applied to a rigid body");
  114929. }
  114930. };
  114931. /**
  114932. * Gets positionIterations of the impostor
  114933. * @param impostor impostor to get position iterations from
  114934. * @returns positionIterations value
  114935. */
  114936. AmmoJSPlugin.prototype.getBodyPositionIterations = function (impostor) {
  114937. if (!impostor.soft) {
  114938. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Position iterations is not a property of a rigid body");
  114939. return 0;
  114940. }
  114941. return impostor._pluginData.positionIterations || 0;
  114942. };
  114943. /**
  114944. * Sets positionIterations of the impostor
  114945. * @param impostor impostor to set position on
  114946. * @param positionIterations positionIterations value
  114947. */
  114948. AmmoJSPlugin.prototype.setBodyPositionIterations = function (impostor, positionIterations) {
  114949. if (impostor.soft) {
  114950. positionIterations = positionIterations < 0 ? 0 : positionIterations;
  114951. impostor.physicsBody.get_m_cfg().set_piterations(positionIterations);
  114952. impostor._pluginData.positionIterations = positionIterations;
  114953. }
  114954. else {
  114955. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Position iterations cannot be applied to a rigid body");
  114956. }
  114957. };
  114958. /**
  114959. * Append an anchor to a cloth object
  114960. * @param impostor is the cloth impostor to add anchor to
  114961. * @param otherImpostor is the rigid impostor to anchor to
  114962. * @param width ratio across width from 0 to 1
  114963. * @param height ratio up height from 0 to 1
  114964. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  114965. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114966. */
  114967. AmmoJSPlugin.prototype.appendAnchor = function (impostor, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies) {
  114968. if (influence === void 0) { influence = 1; }
  114969. if (noCollisionBetweenLinkedBodies === void 0) { noCollisionBetweenLinkedBodies = false; }
  114970. var segs = impostor.segments;
  114971. var nbAcross = Math.round((segs - 1) * width);
  114972. var nbUp = Math.round((segs - 1) * height);
  114973. var nbDown = segs - 1 - nbUp;
  114974. var node = nbAcross + segs * nbDown;
  114975. impostor.physicsBody.appendAnchor(node, otherImpostor.physicsBody, noCollisionBetweenLinkedBodies, influence);
  114976. };
  114977. /**
  114978. * Append an hook to a rope object
  114979. * @param impostor is the rope impostor to add hook to
  114980. * @param otherImpostor is the rigid impostor to hook to
  114981. * @param length ratio along the rope from 0 to 1
  114982. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  114983. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114984. */
  114985. AmmoJSPlugin.prototype.appendHook = function (impostor, otherImpostor, length, influence, noCollisionBetweenLinkedBodies) {
  114986. if (influence === void 0) { influence = 1; }
  114987. if (noCollisionBetweenLinkedBodies === void 0) { noCollisionBetweenLinkedBodies = false; }
  114988. var node = Math.round(impostor.segments * length);
  114989. impostor.physicsBody.appendAnchor(node, otherImpostor.physicsBody, noCollisionBetweenLinkedBodies, influence);
  114990. };
  114991. /**
  114992. * Sleeps the physics body and stops it from being active
  114993. * @param impostor impostor to sleep
  114994. */
  114995. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  114996. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  114997. };
  114998. /**
  114999. * Activates the physics body
  115000. * @param impostor impostor to activate
  115001. */
  115002. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  115003. impostor.physicsBody.activate();
  115004. };
  115005. /**
  115006. * Updates the distance parameters of the joint
  115007. * @param joint joint to update
  115008. * @param maxDistance maximum distance of the joint
  115009. * @param minDistance minimum distance of the joint
  115010. */
  115011. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  115012. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  115013. };
  115014. /**
  115015. * Sets a motor on the joint
  115016. * @param joint joint to set motor on
  115017. * @param speed speed of the motor
  115018. * @param maxForce maximum force of the motor
  115019. * @param motorIndex index of the motor
  115020. */
  115021. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  115022. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  115023. };
  115024. /**
  115025. * Sets the motors limit
  115026. * @param joint joint to set limit on
  115027. * @param upperLimit upper limit
  115028. * @param lowerLimit lower limit
  115029. */
  115030. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  115031. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  115032. };
  115033. /**
  115034. * Syncs the position and rotation of a mesh with the impostor
  115035. * @param mesh mesh to sync
  115036. * @param impostor impostor to update the mesh with
  115037. */
  115038. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  115039. var body = impostor.physicsBody;
  115040. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  115041. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  115042. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  115043. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  115044. if (mesh.rotationQuaternion) {
  115045. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  115046. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  115047. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  115048. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  115049. }
  115050. };
  115051. /**
  115052. * Gets the radius of the impostor
  115053. * @param impostor impostor to get radius from
  115054. * @returns the radius
  115055. */
  115056. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  115057. var exntend = impostor.getObjectExtendSize();
  115058. return exntend.x / 2;
  115059. };
  115060. /**
  115061. * Gets the box size of the impostor
  115062. * @param impostor impostor to get box size from
  115063. * @param result the resulting box size
  115064. */
  115065. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  115066. var exntend = impostor.getObjectExtendSize();
  115067. result.x = exntend.x;
  115068. result.y = exntend.y;
  115069. result.z = exntend.z;
  115070. };
  115071. /**
  115072. * Disposes of the impostor
  115073. */
  115074. AmmoJSPlugin.prototype.dispose = function () {
  115075. // Dispose of world
  115076. Ammo.destroy(this.world);
  115077. Ammo.destroy(this._solver);
  115078. Ammo.destroy(this._overlappingPairCache);
  115079. Ammo.destroy(this._dispatcher);
  115080. Ammo.destroy(this._collisionConfiguration);
  115081. // Dispose of tmp variables
  115082. Ammo.destroy(this._tmpAmmoVectorA);
  115083. Ammo.destroy(this._tmpAmmoVectorB);
  115084. Ammo.destroy(this._tmpAmmoVectorC);
  115085. Ammo.destroy(this._tmpAmmoTransform);
  115086. Ammo.destroy(this._tmpAmmoQuaternion);
  115087. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  115088. this.world = null;
  115089. };
  115090. /**
  115091. * Does a raycast in the physics world
  115092. * @param from when should the ray start?
  115093. * @param to when should the ray end?
  115094. * @returns PhysicsRaycastResult
  115095. */
  115096. AmmoJSPlugin.prototype.raycast = function (from, to) {
  115097. this._tmpAmmoVectorRCA = new this.bjsAMMO.btVector3(from.x, from.y, from.z);
  115098. this._tmpAmmoVectorRCB = new this.bjsAMMO.btVector3(to.x, to.y, to.z);
  115099. var rayCallback = new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB);
  115100. this.world.rayTest(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB, rayCallback);
  115101. this._raycastResult.reset(from, to);
  115102. if (rayCallback.hasHit()) {
  115103. // TODO: do we want/need the body? If so, set all the data
  115104. /*
  115105. var rigidBody = this.bjsAMMO.btRigidBody.prototype.upcast(
  115106. rayCallback.get_m_collisionObject()
  115107. );
  115108. var body = {};
  115109. */
  115110. this._raycastResult.setHitData({
  115111. x: rayCallback.get_m_hitNormalWorld().x(),
  115112. y: rayCallback.get_m_hitNormalWorld().y(),
  115113. z: rayCallback.get_m_hitNormalWorld().z(),
  115114. }, {
  115115. x: rayCallback.get_m_hitPointWorld().x(),
  115116. y: rayCallback.get_m_hitPointWorld().y(),
  115117. z: rayCallback.get_m_hitPointWorld().z(),
  115118. });
  115119. this._raycastResult.calculateHitDistance();
  115120. }
  115121. return this._raycastResult;
  115122. };
  115123. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  115124. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  115125. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  115126. return AmmoJSPlugin;
  115127. }());
  115128. /***/ }),
  115129. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  115130. /*!*******************************************!*\
  115131. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  115132. \*******************************************/
  115133. /*! exports provided: CannonJSPlugin */
  115134. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115135. "use strict";
  115136. __webpack_require__.r(__webpack_exports__);
  115137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  115138. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  115139. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  115140. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  115141. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  115142. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  115143. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  115144. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  115145. /** @hidden */
  115146. var CannonJSPlugin = /** @class */ (function () {
  115147. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  115148. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  115149. if (iterations === void 0) { iterations = 10; }
  115150. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  115151. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  115152. this.name = "CannonJSPlugin";
  115153. this._physicsMaterials = new Array();
  115154. this._fixedTimeStep = 1 / 60;
  115155. this._removeAfterStep = new Array();
  115156. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  115157. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  115158. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  115159. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  115160. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  115161. this.BJSCANNON = cannonInjection;
  115162. if (!this.isSupported()) {
  115163. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  115164. return;
  115165. }
  115166. this._extendNamespace();
  115167. this.world = new this.BJSCANNON.World();
  115168. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  115169. this.world.solver.iterations = iterations;
  115170. this._cannonRaycastResult = new this.BJSCANNON.RaycastResult();
  115171. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_6__["PhysicsRaycastResult"]();
  115172. }
  115173. CannonJSPlugin.prototype.setGravity = function (gravity) {
  115174. this.world.gravity.copy(gravity);
  115175. };
  115176. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  115177. this._fixedTimeStep = timeStep;
  115178. };
  115179. CannonJSPlugin.prototype.getTimeStep = function () {
  115180. return this._fixedTimeStep;
  115181. };
  115182. CannonJSPlugin.prototype.executeStep = function (delta) {
  115183. var _this = this;
  115184. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  115185. if (this._removeAfterStep.length > 0) {
  115186. this._removeAfterStep.forEach(function (impostor) {
  115187. _this.world.remove(impostor.physicsBody);
  115188. });
  115189. this._removeAfterStep = [];
  115190. }
  115191. };
  115192. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  115193. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  115194. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  115195. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  115196. };
  115197. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  115198. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  115199. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  115200. impostor.physicsBody.applyForce(impulse, worldPoint);
  115201. };
  115202. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  115203. //parent-child relationship. Does this impostor has a parent impostor?
  115204. if (impostor.parent) {
  115205. if (impostor.physicsBody) {
  115206. this.removePhysicsBody(impostor);
  115207. //TODO is that needed?
  115208. impostor.forceUpdate();
  115209. }
  115210. return;
  115211. }
  115212. //should a new body be created for this impostor?
  115213. if (impostor.isBodyInitRequired()) {
  115214. var shape = this._createShape(impostor);
  115215. //unregister events, if body is being changed
  115216. var oldBody = impostor.physicsBody;
  115217. if (oldBody) {
  115218. this.removePhysicsBody(impostor);
  115219. }
  115220. //create the body and material
  115221. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  115222. var bodyCreationObject = {
  115223. mass: impostor.getParam("mass"),
  115224. material: material
  115225. };
  115226. // A simple extend, in case native options were used.
  115227. var nativeOptions = impostor.getParam("nativeOptions");
  115228. for (var key in nativeOptions) {
  115229. if (nativeOptions.hasOwnProperty(key)) {
  115230. bodyCreationObject[key] = nativeOptions[key];
  115231. }
  115232. }
  115233. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  115234. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  115235. this.world.addEventListener("preStep", impostor.beforeStep);
  115236. this.world.addEventListener("postStep", impostor.afterStep);
  115237. impostor.physicsBody.addShape(shape);
  115238. this.world.add(impostor.physicsBody);
  115239. //try to keep the body moving in the right direction by taking old properties.
  115240. //Should be tested!
  115241. if (oldBody) {
  115242. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  115243. impostor.physicsBody[param].copy(oldBody[param]);
  115244. });
  115245. }
  115246. this._processChildMeshes(impostor);
  115247. }
  115248. //now update the body's transformation
  115249. this._updatePhysicsBodyTransformation(impostor);
  115250. };
  115251. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  115252. var _this = this;
  115253. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  115254. var currentRotation = mainImpostor.object.rotationQuaternion;
  115255. if (meshChildren.length) {
  115256. var processMesh = function (localPosition, mesh) {
  115257. if (!currentRotation || !mesh.rotationQuaternion) {
  115258. return;
  115259. }
  115260. var childImpostor = mesh.getPhysicsImpostor();
  115261. if (childImpostor) {
  115262. var parent = childImpostor.parent;
  115263. if (parent !== mainImpostor) {
  115264. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  115265. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  115266. if (childImpostor.physicsBody) {
  115267. _this.removePhysicsBody(childImpostor);
  115268. childImpostor.physicsBody = null;
  115269. }
  115270. childImpostor.parent = mainImpostor;
  115271. childImpostor.resetUpdateFlags();
  115272. mainImpostor.physicsBody.addShape(_this._createShape(childImpostor), new _this.BJSCANNON.Vec3(pPosition.x, pPosition.y, pPosition.z), new _this.BJSCANNON.Quaternion(localRotation.x, localRotation.y, localRotation.z, localRotation.w));
  115273. //Add the mass of the children.
  115274. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  115275. }
  115276. }
  115277. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  115278. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  115279. };
  115280. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  115281. }
  115282. };
  115283. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  115284. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  115285. this.world.removeEventListener("preStep", impostor.beforeStep);
  115286. this.world.removeEventListener("postStep", impostor.afterStep);
  115287. // Only remove the physics body after the physics step to avoid disrupting cannon's internal state
  115288. this._removeAfterStep.push(impostor);
  115289. };
  115290. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  115291. var mainBody = impostorJoint.mainImpostor.physicsBody;
  115292. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  115293. if (!mainBody || !connectedBody) {
  115294. return;
  115295. }
  115296. var constraint;
  115297. var jointData = impostorJoint.joint.jointData;
  115298. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  115299. var constraintData = {
  115300. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  115301. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  115302. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  115303. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  115304. maxForce: jointData.nativeParams.maxForce,
  115305. collideConnected: !!jointData.collision
  115306. };
  115307. switch (impostorJoint.joint.type) {
  115308. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  115309. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  115310. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  115311. break;
  115312. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  115313. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  115314. break;
  115315. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  115316. var springData = jointData;
  115317. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  115318. restLength: springData.length,
  115319. stiffness: springData.stiffness,
  115320. damping: springData.damping,
  115321. localAnchorA: constraintData.pivotA,
  115322. localAnchorB: constraintData.pivotB
  115323. });
  115324. break;
  115325. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  115326. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  115327. break;
  115328. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  115329. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  115330. default:
  115331. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  115332. break;
  115333. }
  115334. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  115335. constraint.collideConnected = !!jointData.collision;
  115336. impostorJoint.joint.physicsJoint = constraint;
  115337. //don't add spring as constraint, as it is not one.
  115338. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  115339. this.world.addConstraint(constraint);
  115340. }
  115341. else {
  115342. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  115343. constraint.applyForce();
  115344. };
  115345. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  115346. }
  115347. };
  115348. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  115349. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  115350. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  115351. }
  115352. else {
  115353. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  115354. }
  115355. };
  115356. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  115357. var index;
  115358. var mat;
  115359. for (index = 0; index < this._physicsMaterials.length; index++) {
  115360. mat = this._physicsMaterials[index];
  115361. if (mat.friction === friction && mat.restitution === restitution) {
  115362. return mat;
  115363. }
  115364. }
  115365. var currentMat = new this.BJSCANNON.Material(name);
  115366. currentMat.friction = friction;
  115367. currentMat.restitution = restitution;
  115368. this._physicsMaterials.push(currentMat);
  115369. return currentMat;
  115370. };
  115371. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  115372. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  115373. };
  115374. CannonJSPlugin.prototype._createShape = function (impostor) {
  115375. var object = impostor.object;
  115376. var returnValue;
  115377. var extendSize = impostor.getObjectExtendSize();
  115378. switch (impostor.type) {
  115379. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  115380. var radiusX = extendSize.x;
  115381. var radiusY = extendSize.y;
  115382. var radiusZ = extendSize.z;
  115383. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  115384. break;
  115385. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  115386. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  115387. var nativeParams = impostor.getParam("nativeOptions");
  115388. if (!nativeParams) {
  115389. nativeParams = {};
  115390. }
  115391. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  115392. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  115393. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y);
  115394. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  115395. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  115396. // Rotate 90 degrees as this shape is horizontal in cannon
  115397. var quat = new this.BJSCANNON.Quaternion();
  115398. quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
  115399. var translation = new this.BJSCANNON.Vec3(0, 0, 0);
  115400. returnValue.transformAllPoints(translation, quat);
  115401. break;
  115402. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  115403. var box = extendSize.scale(0.5);
  115404. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  115405. break;
  115406. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  115407. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  115408. returnValue = new this.BJSCANNON.Plane();
  115409. break;
  115410. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  115411. // should transform the vertex data to world coordinates!!
  115412. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  115413. var rawFaces = object.getIndices ? object.getIndices() : [];
  115414. if (!rawVerts) {
  115415. return;
  115416. }
  115417. // get only scale! so the object could transform correctly.
  115418. var oldPosition = object.position.clone();
  115419. var oldRotation = object.rotation && object.rotation.clone();
  115420. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  115421. object.position.copyFromFloats(0, 0, 0);
  115422. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  115423. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  115424. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  115425. var transform = object.computeWorldMatrix(true);
  115426. // convert rawVerts to object space
  115427. var temp = new Array();
  115428. var index;
  115429. for (index = 0; index < rawVerts.length; index += 3) {
  115430. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  115431. }
  115432. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  115433. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  115434. //now set back the transformation!
  115435. object.position.copyFrom(oldPosition);
  115436. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  115437. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  115438. break;
  115439. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  115440. var oldPosition2 = object.position.clone();
  115441. var oldRotation2 = object.rotation && object.rotation.clone();
  115442. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  115443. object.position.copyFromFloats(0, 0, 0);
  115444. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  115445. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  115446. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  115447. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  115448. returnValue = this._createHeightmap(object);
  115449. object.position.copyFrom(oldPosition2);
  115450. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  115451. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  115452. object.computeWorldMatrix(true);
  115453. break;
  115454. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  115455. returnValue = new this.BJSCANNON.Particle();
  115456. break;
  115457. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].NoImpostor:
  115458. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
  115459. break;
  115460. }
  115461. return returnValue;
  115462. };
  115463. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  115464. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  115465. var transform = object.computeWorldMatrix(true);
  115466. // convert rawVerts to object space
  115467. var temp = new Array();
  115468. var index;
  115469. for (index = 0; index < pos.length; index += 3) {
  115470. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  115471. }
  115472. pos = temp;
  115473. var matrix = new Array();
  115474. //For now pointDepth will not be used and will be automatically calculated.
  115475. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  115476. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  115477. var boundingInfo = object.getBoundingInfo();
  115478. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  115479. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  115480. var elementSize = dim * 2 / arraySize;
  115481. for (var i = 0; i < pos.length; i = i + 3) {
  115482. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  115483. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  115484. var y = -pos[i + 2] + minY;
  115485. if (!matrix[x]) {
  115486. matrix[x] = [];
  115487. }
  115488. if (!matrix[x][z]) {
  115489. matrix[x][z] = y;
  115490. }
  115491. matrix[x][z] = Math.max(y, matrix[x][z]);
  115492. }
  115493. for (var x = 0; x <= arraySize; ++x) {
  115494. if (!matrix[x]) {
  115495. var loc = 1;
  115496. while (!matrix[(x + loc) % arraySize]) {
  115497. loc++;
  115498. }
  115499. matrix[x] = matrix[(x + loc) % arraySize].slice();
  115500. //console.log("missing x", x);
  115501. }
  115502. for (var z = 0; z <= arraySize; ++z) {
  115503. if (!matrix[x][z]) {
  115504. var loc = 1;
  115505. var newValue;
  115506. while (newValue === undefined) {
  115507. newValue = matrix[x][(z + loc++) % arraySize];
  115508. }
  115509. matrix[x][z] = newValue;
  115510. }
  115511. }
  115512. }
  115513. var shape = new this.BJSCANNON.Heightfield(matrix, {
  115514. elementSize: elementSize
  115515. });
  115516. //For future reference, needed for body transformation
  115517. shape.minY = minY;
  115518. return shape;
  115519. };
  115520. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  115521. var object = impostor.object;
  115522. //make sure it is updated...
  115523. object.computeWorldMatrix && object.computeWorldMatrix(true);
  115524. // The delta between the mesh position and the mesh bounding box center
  115525. var bInfo = object.getBoundingInfo();
  115526. if (!bInfo) {
  115527. return;
  115528. }
  115529. var center = impostor.getObjectCenter();
  115530. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  115531. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  115532. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  115533. this._tmpPosition.copyFrom(center);
  115534. var quaternion = object.rotationQuaternion;
  115535. if (!quaternion) {
  115536. return;
  115537. }
  115538. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  115539. //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron
  115540. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  115541. //-90 DEG in X, precalculated
  115542. quaternion = quaternion.multiply(this._minus90X);
  115543. //Invert! (Precalculated, 90 deg in X)
  115544. //No need to clone. this will never change.
  115545. impostor.setDeltaRotation(this._plus90X);
  115546. }
  115547. //If it is a heightfield, if should be centered.
  115548. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  115549. var mesh = object;
  115550. var boundingInfo = mesh.getBoundingInfo();
  115551. //calculate the correct body position:
  115552. var rotationQuaternion = mesh.rotationQuaternion;
  115553. mesh.rotationQuaternion = this._tmpUnityRotation;
  115554. mesh.computeWorldMatrix(true);
  115555. //get original center with no rotation
  115556. var c = center.clone();
  115557. var oldPivot = mesh.getPivotMatrix();
  115558. if (oldPivot) {
  115559. // create a copy the pivot Matrix as it is modified in place
  115560. oldPivot = oldPivot.clone();
  115561. }
  115562. else {
  115563. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  115564. }
  115565. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  115566. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  115567. mesh.setPreTransformMatrix(p);
  115568. mesh.computeWorldMatrix(true);
  115569. //calculate the translation
  115570. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  115571. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  115572. //add it inverted to the delta
  115573. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  115574. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  115575. //rotation is back
  115576. mesh.rotationQuaternion = rotationQuaternion;
  115577. mesh.setPreTransformMatrix(oldPivot);
  115578. mesh.computeWorldMatrix(true);
  115579. }
  115580. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  115581. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  115582. //this._tmpPosition.copyFrom(object.position);
  115583. }
  115584. impostor.setDeltaPosition(this._tmpDeltaPosition);
  115585. //Now update the impostor object
  115586. impostor.physicsBody.position.copy(this._tmpPosition);
  115587. impostor.physicsBody.quaternion.copy(quaternion);
  115588. };
  115589. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  115590. impostor.object.position.copyFrom(impostor.physicsBody.position);
  115591. if (impostor.object.rotationQuaternion) {
  115592. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  115593. }
  115594. };
  115595. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  115596. impostor.physicsBody.position.copy(newPosition);
  115597. impostor.physicsBody.quaternion.copy(newRotation);
  115598. };
  115599. CannonJSPlugin.prototype.isSupported = function () {
  115600. return this.BJSCANNON !== undefined;
  115601. };
  115602. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  115603. impostor.physicsBody.velocity.copy(velocity);
  115604. };
  115605. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  115606. impostor.physicsBody.angularVelocity.copy(velocity);
  115607. };
  115608. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  115609. var v = impostor.physicsBody.velocity;
  115610. if (!v) {
  115611. return null;
  115612. }
  115613. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  115614. };
  115615. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  115616. var v = impostor.physicsBody.angularVelocity;
  115617. if (!v) {
  115618. return null;
  115619. }
  115620. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  115621. };
  115622. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  115623. impostor.physicsBody.mass = mass;
  115624. impostor.physicsBody.updateMassProperties();
  115625. };
  115626. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  115627. return impostor.physicsBody.mass;
  115628. };
  115629. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  115630. return impostor.physicsBody.material.friction;
  115631. };
  115632. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  115633. impostor.physicsBody.material.friction = friction;
  115634. };
  115635. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  115636. return impostor.physicsBody.material.restitution;
  115637. };
  115638. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  115639. impostor.physicsBody.material.restitution = restitution;
  115640. };
  115641. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  115642. impostor.physicsBody.sleep();
  115643. };
  115644. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  115645. impostor.physicsBody.wakeUp();
  115646. };
  115647. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  115648. joint.physicsJoint.distance = maxDistance;
  115649. };
  115650. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  115651. // if (!motorIndex) {
  115652. // joint.physicsJoint.enableMotor();
  115653. // }
  115654. // }
  115655. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  115656. // if (!motorIndex) {
  115657. // joint.physicsJoint.disableMotor();
  115658. // }
  115659. // }
  115660. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  115661. if (!motorIndex) {
  115662. joint.physicsJoint.enableMotor();
  115663. joint.physicsJoint.setMotorSpeed(speed);
  115664. if (maxForce) {
  115665. this.setLimit(joint, maxForce);
  115666. }
  115667. }
  115668. };
  115669. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  115670. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  115671. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  115672. };
  115673. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  115674. var body = impostor.physicsBody;
  115675. mesh.position.x = body.position.x;
  115676. mesh.position.y = body.position.y;
  115677. mesh.position.z = body.position.z;
  115678. if (mesh.rotationQuaternion) {
  115679. mesh.rotationQuaternion.x = body.quaternion.x;
  115680. mesh.rotationQuaternion.y = body.quaternion.y;
  115681. mesh.rotationQuaternion.z = body.quaternion.z;
  115682. mesh.rotationQuaternion.w = body.quaternion.w;
  115683. }
  115684. };
  115685. CannonJSPlugin.prototype.getRadius = function (impostor) {
  115686. var shape = impostor.physicsBody.shapes[0];
  115687. return shape.boundingSphereRadius;
  115688. };
  115689. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  115690. var shape = impostor.physicsBody.shapes[0];
  115691. result.x = shape.halfExtents.x * 2;
  115692. result.y = shape.halfExtents.y * 2;
  115693. result.z = shape.halfExtents.z * 2;
  115694. };
  115695. CannonJSPlugin.prototype.dispose = function () {
  115696. };
  115697. CannonJSPlugin.prototype._extendNamespace = function () {
  115698. //this will force cannon to execute at least one step when using interpolation
  115699. var step_tmp1 = new this.BJSCANNON.Vec3();
  115700. var Engine = this.BJSCANNON;
  115701. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  115702. maxSubSteps = maxSubSteps || 10;
  115703. timeSinceLastCalled = timeSinceLastCalled || 0;
  115704. if (timeSinceLastCalled === 0) {
  115705. this.internalStep(dt);
  115706. this.time += dt;
  115707. }
  115708. else {
  115709. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  115710. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  115711. var t0 = performance.now();
  115712. for (var i = 0; i !== internalSteps; i++) {
  115713. this.internalStep(dt);
  115714. if (performance.now() - t0 > dt * 1000) {
  115715. break;
  115716. }
  115717. }
  115718. this.time += timeSinceLastCalled;
  115719. var h = this.time % dt;
  115720. var h_div_dt = h / dt;
  115721. var interpvelo = step_tmp1;
  115722. var bodies = this.bodies;
  115723. for (var j = 0; j !== bodies.length; j++) {
  115724. var b = bodies[j];
  115725. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  115726. b.position.vsub(b.previousPosition, interpvelo);
  115727. interpvelo.scale(h_div_dt, interpvelo);
  115728. b.position.vadd(interpvelo, b.interpolatedPosition);
  115729. }
  115730. else {
  115731. b.interpolatedPosition.copy(b.position);
  115732. b.interpolatedQuaternion.copy(b.quaternion);
  115733. }
  115734. }
  115735. }
  115736. };
  115737. };
  115738. /**
  115739. * Does a raycast in the physics world
  115740. * @param from when should the ray start?
  115741. * @param to when should the ray end?
  115742. * @returns PhysicsRaycastResult
  115743. */
  115744. CannonJSPlugin.prototype.raycast = function (from, to) {
  115745. this._cannonRaycastResult.reset();
  115746. this.world.raycastClosest(from, to, {}, this._cannonRaycastResult);
  115747. this._raycastResult.reset(from, to);
  115748. if (this._cannonRaycastResult.hasHit) {
  115749. // TODO: do we also want to get the body it hit?
  115750. this._raycastResult.setHitData({
  115751. x: this._cannonRaycastResult.hitNormalWorld.x,
  115752. y: this._cannonRaycastResult.hitNormalWorld.y,
  115753. z: this._cannonRaycastResult.hitNormalWorld.z,
  115754. }, {
  115755. x: this._cannonRaycastResult.hitPointWorld.x,
  115756. y: this._cannonRaycastResult.hitPointWorld.y,
  115757. z: this._cannonRaycastResult.hitPointWorld.z,
  115758. });
  115759. this._raycastResult.setHitDistance(this._cannonRaycastResult.distance);
  115760. }
  115761. return this._raycastResult;
  115762. };
  115763. return CannonJSPlugin;
  115764. }());
  115765. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  115766. /***/ }),
  115767. /***/ "./Physics/Plugins/index.ts":
  115768. /*!**********************************!*\
  115769. !*** ./Physics/Plugins/index.ts ***!
  115770. \**********************************/
  115771. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  115772. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115773. "use strict";
  115774. __webpack_require__.r(__webpack_exports__);
  115775. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  115776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  115777. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  115778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  115779. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  115780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  115781. /***/ }),
  115782. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  115783. /*!*****************************************!*\
  115784. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  115785. \*****************************************/
  115786. /*! exports provided: OimoJSPlugin */
  115787. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115788. "use strict";
  115789. __webpack_require__.r(__webpack_exports__);
  115790. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  115791. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  115792. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  115793. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  115794. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  115795. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  115796. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  115797. /** @hidden */
  115798. var OimoJSPlugin = /** @class */ (function () {
  115799. function OimoJSPlugin(iterations, oimoInjection) {
  115800. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  115801. this.name = "OimoJSPlugin";
  115802. this._tmpImpostorsArray = [];
  115803. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  115804. this.BJSOIMO = oimoInjection;
  115805. this.world = new this.BJSOIMO.World({
  115806. iterations: iterations
  115807. });
  115808. this.world.clear();
  115809. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_5__["PhysicsRaycastResult"]();
  115810. }
  115811. OimoJSPlugin.prototype.setGravity = function (gravity) {
  115812. this.world.gravity.copy(gravity);
  115813. };
  115814. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  115815. this.world.timeStep = timeStep;
  115816. };
  115817. OimoJSPlugin.prototype.getTimeStep = function () {
  115818. return this.world.timeStep;
  115819. };
  115820. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  115821. var _this = this;
  115822. impostors.forEach(function (impostor) {
  115823. impostor.beforeStep();
  115824. });
  115825. this.world.step();
  115826. impostors.forEach(function (impostor) {
  115827. impostor.afterStep();
  115828. //update the ordered impostors array
  115829. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  115830. });
  115831. //check for collisions
  115832. var contact = this.world.contacts;
  115833. while (contact !== null) {
  115834. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  115835. contact = contact.next;
  115836. continue;
  115837. }
  115838. //is this body colliding with any other? get the impostor
  115839. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  115840. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  115841. if (!mainImpostor || !collidingImpostor) {
  115842. contact = contact.next;
  115843. continue;
  115844. }
  115845. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  115846. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  115847. contact = contact.next;
  115848. }
  115849. };
  115850. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  115851. var mass = impostor.physicsBody.mass;
  115852. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  115853. };
  115854. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  115855. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  115856. this.applyImpulse(impostor, force, contactPoint);
  115857. };
  115858. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  115859. var _this = this;
  115860. //parent-child relationship. Does this impostor has a parent impostor?
  115861. if (impostor.parent) {
  115862. if (impostor.physicsBody) {
  115863. this.removePhysicsBody(impostor);
  115864. //TODO is that needed?
  115865. impostor.forceUpdate();
  115866. }
  115867. return;
  115868. }
  115869. if (impostor.isBodyInitRequired()) {
  115870. var bodyConfig = {
  115871. name: impostor.uniqueId,
  115872. //Oimo must have mass, also for static objects.
  115873. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  115874. size: [],
  115875. type: [],
  115876. pos: [],
  115877. posShape: [],
  115878. rot: [],
  115879. rotShape: [],
  115880. move: impostor.getParam("mass") !== 0,
  115881. density: impostor.getParam("mass"),
  115882. friction: impostor.getParam("friction"),
  115883. restitution: impostor.getParam("restitution"),
  115884. //Supporting older versions of Oimo
  115885. world: this.world
  115886. };
  115887. var impostors = [impostor];
  115888. var addToArray = function (parent) {
  115889. if (!parent.getChildMeshes) {
  115890. return;
  115891. }
  115892. parent.getChildMeshes().forEach(function (m) {
  115893. if (m.physicsImpostor) {
  115894. impostors.push(m.physicsImpostor);
  115895. //m.physicsImpostor._init();
  115896. }
  115897. });
  115898. };
  115899. addToArray(impostor.object);
  115900. var checkWithEpsilon_1 = function (value) {
  115901. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  115902. };
  115903. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  115904. impostors.forEach(function (i) {
  115905. if (!i.object.rotationQuaternion) {
  115906. return;
  115907. }
  115908. //get the correct bounding box
  115909. var oldQuaternion = i.object.rotationQuaternion;
  115910. globalQuaternion_1 = oldQuaternion.clone();
  115911. var rot = oldQuaternion.toEulerAngles();
  115912. var extendSize = i.getObjectExtendSize();
  115913. var radToDeg = 57.295779513082320876;
  115914. if (i === impostor) {
  115915. var center = impostor.getObjectCenter();
  115916. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  115917. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  115918. //Can also use Array.prototype.push.apply
  115919. bodyConfig.pos.push(center.x);
  115920. bodyConfig.pos.push(center.y);
  115921. bodyConfig.pos.push(center.z);
  115922. bodyConfig.posShape.push(0, 0, 0);
  115923. bodyConfig.rotShape.push(0, 0, 0);
  115924. }
  115925. else {
  115926. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  115927. bodyConfig.posShape.push(localPosition.x);
  115928. bodyConfig.posShape.push(localPosition.y);
  115929. bodyConfig.posShape.push(localPosition.z);
  115930. bodyConfig.pos.push(0, 0, 0);
  115931. bodyConfig.rotShape.push(rot.x * radToDeg);
  115932. bodyConfig.rotShape.push(rot.y * radToDeg);
  115933. bodyConfig.rotShape.push(rot.z * radToDeg);
  115934. }
  115935. // register mesh
  115936. switch (i.type) {
  115937. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  115938. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  115939. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  115940. var radiusX = extendSize.x;
  115941. var radiusY = extendSize.y;
  115942. var radiusZ = extendSize.z;
  115943. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  115944. bodyConfig.type.push('sphere');
  115945. //due to the way oimo works with compounds, add 3 times
  115946. bodyConfig.size.push(size);
  115947. bodyConfig.size.push(size);
  115948. bodyConfig.size.push(size);
  115949. break;
  115950. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  115951. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  115952. var sizeY = checkWithEpsilon_1(extendSize.y);
  115953. bodyConfig.type.push('cylinder');
  115954. bodyConfig.size.push(sizeX);
  115955. bodyConfig.size.push(sizeY);
  115956. //due to the way oimo works with compounds, add one more value.
  115957. bodyConfig.size.push(sizeY);
  115958. break;
  115959. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  115960. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  115961. default:
  115962. var sizeX = checkWithEpsilon_1(extendSize.x);
  115963. var sizeY = checkWithEpsilon_1(extendSize.y);
  115964. var sizeZ = checkWithEpsilon_1(extendSize.z);
  115965. bodyConfig.type.push('box');
  115966. //if (i === impostor) {
  115967. bodyConfig.size.push(sizeX);
  115968. bodyConfig.size.push(sizeY);
  115969. bodyConfig.size.push(sizeZ);
  115970. //} else {
  115971. // bodyConfig.size.push(0,0,0);
  115972. //}
  115973. break;
  115974. }
  115975. //actually not needed, but hey...
  115976. i.object.rotationQuaternion = oldQuaternion;
  115977. });
  115978. impostor.physicsBody = this.world.add(bodyConfig);
  115979. // set the quaternion, ignoring the previously defined (euler) rotation
  115980. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  115981. // update with delta 0, so the body will reveive the new rotation.
  115982. impostor.physicsBody.updatePosition(0);
  115983. }
  115984. else {
  115985. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  115986. }
  115987. impostor.setDeltaPosition(this._tmpPositionVector);
  115988. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  115989. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  115990. };
  115991. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  115992. //impostor.physicsBody.dispose();
  115993. //Same as : (older oimo versions)
  115994. this.world.removeRigidBody(impostor.physicsBody);
  115995. };
  115996. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  115997. var mainBody = impostorJoint.mainImpostor.physicsBody;
  115998. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  115999. if (!mainBody || !connectedBody) {
  116000. return;
  116001. }
  116002. var jointData = impostorJoint.joint.jointData;
  116003. var options = jointData.nativeParams || {};
  116004. var type;
  116005. var nativeJointData = {
  116006. body1: mainBody,
  116007. body2: connectedBody,
  116008. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  116009. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  116010. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  116011. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  116012. min: options.min,
  116013. max: options.max,
  116014. collision: options.collision || jointData.collision,
  116015. spring: options.spring,
  116016. //supporting older version of Oimo
  116017. world: this.world
  116018. };
  116019. switch (impostorJoint.joint.type) {
  116020. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  116021. type = "jointBall";
  116022. break;
  116023. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  116024. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  116025. var springData = jointData;
  116026. nativeJointData.min = springData.length || nativeJointData.min;
  116027. //Max should also be set, just make sure it is at least min
  116028. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  116029. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  116030. type = "jointDistance";
  116031. nativeJointData.max = jointData.maxDistance;
  116032. break;
  116033. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  116034. type = "jointPrisme";
  116035. break;
  116036. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  116037. type = "jointSlide";
  116038. break;
  116039. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  116040. type = "jointWheel";
  116041. break;
  116042. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  116043. default:
  116044. type = "jointHinge";
  116045. break;
  116046. }
  116047. nativeJointData.type = type;
  116048. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  116049. };
  116050. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  116051. //Bug in Oimo prevents us from disposing a joint in the playground
  116052. //joint.joint.physicsJoint.dispose();
  116053. //So we will bruteforce it!
  116054. try {
  116055. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  116056. }
  116057. catch (e) {
  116058. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  116059. }
  116060. };
  116061. OimoJSPlugin.prototype.isSupported = function () {
  116062. return this.BJSOIMO !== undefined;
  116063. };
  116064. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  116065. if (!impostor.physicsBody.sleeping) {
  116066. //TODO check that
  116067. /*if (impostor.physicsBody.shapes.next) {
  116068. var parentShape = this._getLastShape(impostor.physicsBody);
  116069. impostor.object.position.copyFrom(parentShape.position);
  116070. console.log(parentShape.position);
  116071. } else {*/
  116072. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  116073. //}
  116074. if (impostor.object.rotationQuaternion) {
  116075. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  116076. }
  116077. }
  116078. };
  116079. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  116080. var body = impostor.physicsBody;
  116081. body.position.copy(newPosition);
  116082. body.orientation.copy(newRotation);
  116083. body.syncShapes();
  116084. body.awake();
  116085. };
  116086. /*private _getLastShape(body: any): any {
  116087. var lastShape = body.shapes;
  116088. while (lastShape.next) {
  116089. lastShape = lastShape.next;
  116090. }
  116091. return lastShape;
  116092. }*/
  116093. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  116094. impostor.physicsBody.linearVelocity.copy(velocity);
  116095. };
  116096. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  116097. impostor.physicsBody.angularVelocity.copy(velocity);
  116098. };
  116099. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  116100. var v = impostor.physicsBody.linearVelocity;
  116101. if (!v) {
  116102. return null;
  116103. }
  116104. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  116105. };
  116106. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  116107. var v = impostor.physicsBody.angularVelocity;
  116108. if (!v) {
  116109. return null;
  116110. }
  116111. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  116112. };
  116113. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  116114. var staticBody = mass === 0;
  116115. //this will actually set the body's density and not its mass.
  116116. //But this is how oimo treats the mass variable.
  116117. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  116118. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  116119. };
  116120. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  116121. return impostor.physicsBody.shapes.density;
  116122. };
  116123. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  116124. return impostor.physicsBody.shapes.friction;
  116125. };
  116126. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  116127. impostor.physicsBody.shapes.friction = friction;
  116128. };
  116129. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  116130. return impostor.physicsBody.shapes.restitution;
  116131. };
  116132. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  116133. impostor.physicsBody.shapes.restitution = restitution;
  116134. };
  116135. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  116136. impostor.physicsBody.sleep();
  116137. };
  116138. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  116139. impostor.physicsBody.awake();
  116140. };
  116141. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  116142. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  116143. if (minDistance !== void 0) {
  116144. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  116145. }
  116146. };
  116147. OimoJSPlugin.prototype.setMotor = function (joint, speed, force, motorIndex) {
  116148. if (force !== undefined) {
  116149. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter");
  116150. }
  116151. else {
  116152. force = 1e6;
  116153. }
  116154. speed *= -1;
  116155. //TODO separate rotational and transational motors.
  116156. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  116157. if (motor) {
  116158. motor.setMotor(speed, force);
  116159. }
  116160. };
  116161. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  116162. //TODO separate rotational and transational motors.
  116163. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  116164. if (motor) {
  116165. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  116166. }
  116167. };
  116168. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  116169. var body = impostor.physicsBody;
  116170. mesh.position.x = body.position.x;
  116171. mesh.position.y = body.position.y;
  116172. mesh.position.z = body.position.z;
  116173. if (mesh.rotationQuaternion) {
  116174. mesh.rotationQuaternion.x = body.orientation.x;
  116175. mesh.rotationQuaternion.y = body.orientation.y;
  116176. mesh.rotationQuaternion.z = body.orientation.z;
  116177. mesh.rotationQuaternion.w = body.orientation.s;
  116178. }
  116179. };
  116180. OimoJSPlugin.prototype.getRadius = function (impostor) {
  116181. return impostor.physicsBody.shapes.radius;
  116182. };
  116183. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  116184. var shape = impostor.physicsBody.shapes;
  116185. result.x = shape.halfWidth * 2;
  116186. result.y = shape.halfHeight * 2;
  116187. result.z = shape.halfDepth * 2;
  116188. };
  116189. OimoJSPlugin.prototype.dispose = function () {
  116190. this.world.clear();
  116191. };
  116192. /**
  116193. * Does a raycast in the physics world
  116194. * @param from when should the ray start?
  116195. * @param to when should the ray end?
  116196. * @returns PhysicsRaycastResult
  116197. */
  116198. OimoJSPlugin.prototype.raycast = function (from, to) {
  116199. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("raycast is not currently supported by the Oimo physics plugin");
  116200. this._raycastResult.reset(from, to);
  116201. return this._raycastResult;
  116202. };
  116203. return OimoJSPlugin;
  116204. }());
  116205. /***/ }),
  116206. /***/ "./Physics/index.ts":
  116207. /*!**************************!*\
  116208. !*** ./Physics/index.ts ***!
  116209. \**************************/
  116210. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  116211. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116212. "use strict";
  116213. __webpack_require__.r(__webpack_exports__);
  116214. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  116215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  116216. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  116217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  116218. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  116219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  116220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEventOptions"]; });
  116221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEventOptions"]; });
  116222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEventOptions"]; });
  116223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  116224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  116225. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  116226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  116227. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  116228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  116229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  116230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  116231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  116232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  116233. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  116234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  116235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  116236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  116237. /***/ }),
  116238. /***/ "./Physics/physicsEngine.ts":
  116239. /*!**********************************!*\
  116240. !*** ./Physics/physicsEngine.ts ***!
  116241. \**********************************/
  116242. /*! exports provided: PhysicsEngine */
  116243. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116244. "use strict";
  116245. __webpack_require__.r(__webpack_exports__);
  116246. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  116247. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116248. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  116249. /**
  116250. * Class used to control physics engine
  116251. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116252. */
  116253. var PhysicsEngine = /** @class */ (function () {
  116254. /**
  116255. * Creates a new Physics Engine
  116256. * @param gravity defines the gravity vector used by the simulation
  116257. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  116258. */
  116259. function PhysicsEngine(gravity, _physicsPlugin) {
  116260. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  116261. this._physicsPlugin = _physicsPlugin;
  116262. this._impostors = [];
  116263. this._joints = [];
  116264. if (!this._physicsPlugin.isSupported()) {
  116265. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  116266. + "Please make sure it is included.");
  116267. }
  116268. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  116269. this.setGravity(gravity);
  116270. this.setTimeStep();
  116271. }
  116272. /**
  116273. * Factory used to create the default physics plugin.
  116274. * @returns The default physics plugin
  116275. */
  116276. PhysicsEngine.DefaultPluginFactory = function () {
  116277. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__["_DevTools"].WarnImport("CannonJSPlugin");
  116278. };
  116279. /**
  116280. * Sets the gravity vector used by the simulation
  116281. * @param gravity defines the gravity vector to use
  116282. */
  116283. PhysicsEngine.prototype.setGravity = function (gravity) {
  116284. this.gravity = gravity;
  116285. this._physicsPlugin.setGravity(this.gravity);
  116286. };
  116287. /**
  116288. * Set the time step of the physics engine.
  116289. * Default is 1/60.
  116290. * To slow it down, enter 1/600 for example.
  116291. * To speed it up, 1/30
  116292. * @param newTimeStep defines the new timestep to apply to this world.
  116293. */
  116294. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  116295. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  116296. this._physicsPlugin.setTimeStep(newTimeStep);
  116297. };
  116298. /**
  116299. * Get the time step of the physics engine.
  116300. * @returns the current time step
  116301. */
  116302. PhysicsEngine.prototype.getTimeStep = function () {
  116303. return this._physicsPlugin.getTimeStep();
  116304. };
  116305. /**
  116306. * Release all resources
  116307. */
  116308. PhysicsEngine.prototype.dispose = function () {
  116309. this._impostors.forEach(function (impostor) {
  116310. impostor.dispose();
  116311. });
  116312. this._physicsPlugin.dispose();
  116313. };
  116314. /**
  116315. * Gets the name of the current physics plugin
  116316. * @returns the name of the plugin
  116317. */
  116318. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  116319. return this._physicsPlugin.name;
  116320. };
  116321. /**
  116322. * Adding a new impostor for the impostor tracking.
  116323. * This will be done by the impostor itself.
  116324. * @param impostor the impostor to add
  116325. */
  116326. PhysicsEngine.prototype.addImpostor = function (impostor) {
  116327. impostor.uniqueId = this._impostors.push(impostor);
  116328. //if no parent, generate the body
  116329. if (!impostor.parent) {
  116330. this._physicsPlugin.generatePhysicsBody(impostor);
  116331. }
  116332. };
  116333. /**
  116334. * Remove an impostor from the engine.
  116335. * This impostor and its mesh will not longer be updated by the physics engine.
  116336. * @param impostor the impostor to remove
  116337. */
  116338. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  116339. var index = this._impostors.indexOf(impostor);
  116340. if (index > -1) {
  116341. var removed = this._impostors.splice(index, 1);
  116342. //Is it needed?
  116343. if (removed.length) {
  116344. this.getPhysicsPlugin().removePhysicsBody(impostor);
  116345. }
  116346. }
  116347. };
  116348. /**
  116349. * Add a joint to the physics engine
  116350. * @param mainImpostor defines the main impostor to which the joint is added.
  116351. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  116352. * @param joint defines the joint that will connect both impostors.
  116353. */
  116354. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  116355. var impostorJoint = {
  116356. mainImpostor: mainImpostor,
  116357. connectedImpostor: connectedImpostor,
  116358. joint: joint
  116359. };
  116360. joint.physicsPlugin = this._physicsPlugin;
  116361. this._joints.push(impostorJoint);
  116362. this._physicsPlugin.generateJoint(impostorJoint);
  116363. };
  116364. /**
  116365. * Removes a joint from the simulation
  116366. * @param mainImpostor defines the impostor used with the joint
  116367. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  116368. * @param joint defines the joint to remove
  116369. */
  116370. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  116371. var matchingJoints = this._joints.filter(function (impostorJoint) {
  116372. return (impostorJoint.connectedImpostor === connectedImpostor
  116373. && impostorJoint.joint === joint
  116374. && impostorJoint.mainImpostor === mainImpostor);
  116375. });
  116376. if (matchingJoints.length) {
  116377. this._physicsPlugin.removeJoint(matchingJoints[0]);
  116378. //TODO remove it from the list as well
  116379. }
  116380. };
  116381. /**
  116382. * Called by the scene. No need to call it.
  116383. * @param delta defines the timespam between frames
  116384. */
  116385. PhysicsEngine.prototype._step = function (delta) {
  116386. var _this = this;
  116387. //check if any mesh has no body / requires an update
  116388. this._impostors.forEach(function (impostor) {
  116389. if (impostor.isBodyInitRequired()) {
  116390. _this._physicsPlugin.generatePhysicsBody(impostor);
  116391. }
  116392. });
  116393. if (delta > 0.1) {
  116394. delta = 0.1;
  116395. }
  116396. else if (delta <= 0) {
  116397. delta = 1.0 / 60.0;
  116398. }
  116399. this._physicsPlugin.executeStep(delta, this._impostors);
  116400. };
  116401. /**
  116402. * Gets the current plugin used to run the simulation
  116403. * @returns current plugin
  116404. */
  116405. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  116406. return this._physicsPlugin;
  116407. };
  116408. /**
  116409. * Gets the list of physic impostors
  116410. * @returns an array of PhysicsImpostor
  116411. */
  116412. PhysicsEngine.prototype.getImpostors = function () {
  116413. return this._impostors;
  116414. };
  116415. /**
  116416. * Gets the impostor for a physics enabled object
  116417. * @param object defines the object impersonated by the impostor
  116418. * @returns the PhysicsImpostor or null if not found
  116419. */
  116420. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  116421. for (var i = 0; i < this._impostors.length; ++i) {
  116422. if (this._impostors[i].object === object) {
  116423. return this._impostors[i];
  116424. }
  116425. }
  116426. return null;
  116427. };
  116428. /**
  116429. * Gets the impostor for a physics body object
  116430. * @param body defines physics body used by the impostor
  116431. * @returns the PhysicsImpostor or null if not found
  116432. */
  116433. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  116434. for (var i = 0; i < this._impostors.length; ++i) {
  116435. if (this._impostors[i].physicsBody === body) {
  116436. return this._impostors[i];
  116437. }
  116438. }
  116439. return null;
  116440. };
  116441. /**
  116442. * Does a raycast in the physics world
  116443. * @param from when should the ray start?
  116444. * @param to when should the ray end?
  116445. * @returns PhysicsRaycastResult
  116446. */
  116447. PhysicsEngine.prototype.raycast = function (from, to) {
  116448. return this._physicsPlugin.raycast(from, to);
  116449. };
  116450. /**
  116451. * Global value used to control the smallest number supported by the simulation
  116452. */
  116453. PhysicsEngine.Epsilon = 0.001;
  116454. return PhysicsEngine;
  116455. }());
  116456. /***/ }),
  116457. /***/ "./Physics/physicsEngineComponent.ts":
  116458. /*!*******************************************!*\
  116459. !*** ./Physics/physicsEngineComponent.ts ***!
  116460. \*******************************************/
  116461. /*! exports provided: PhysicsEngineSceneComponent */
  116462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116463. "use strict";
  116464. __webpack_require__.r(__webpack_exports__);
  116465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  116466. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  116467. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  116468. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  116469. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  116470. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  116471. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  116472. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  116473. /**
  116474. * Gets the current physics engine
  116475. * @returns a IPhysicsEngine or null if none attached
  116476. */
  116477. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  116478. return this._physicsEngine;
  116479. };
  116480. /**
  116481. * Enables physics to the current scene
  116482. * @param gravity defines the scene's gravity for the physics engine
  116483. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  116484. * @return a boolean indicating if the physics engine was initialized
  116485. */
  116486. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  116487. if (gravity === void 0) { gravity = null; }
  116488. if (this._physicsEngine) {
  116489. return true;
  116490. }
  116491. // Register the component to the scene
  116492. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  116493. if (!component) {
  116494. component = new PhysicsEngineSceneComponent(this);
  116495. this._addComponent(component);
  116496. }
  116497. try {
  116498. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  116499. return true;
  116500. }
  116501. catch (e) {
  116502. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  116503. return false;
  116504. }
  116505. };
  116506. /**
  116507. * Disables and disposes the physics engine associated with the scene
  116508. */
  116509. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  116510. if (!this._physicsEngine) {
  116511. return;
  116512. }
  116513. this._physicsEngine.dispose();
  116514. this._physicsEngine = null;
  116515. };
  116516. /**
  116517. * Gets a boolean indicating if there is an active physics engine
  116518. * @returns a boolean indicating if there is an active physics engine
  116519. */
  116520. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  116521. return this._physicsEngine !== undefined;
  116522. };
  116523. /**
  116524. * Deletes a physics compound impostor
  116525. * @param compound defines the compound to delete
  116526. */
  116527. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  116528. var mesh = compound.parts[0].mesh;
  116529. if (mesh.physicsImpostor) {
  116530. mesh.physicsImpostor.dispose( /*true*/);
  116531. mesh.physicsImpostor = null;
  116532. }
  116533. };
  116534. /** @hidden */
  116535. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  116536. if (this._physicsEngine) {
  116537. this.onBeforePhysicsObservable.notifyObservers(this);
  116538. this._physicsEngine._step(step / 1000);
  116539. this.onAfterPhysicsObservable.notifyObservers(this);
  116540. }
  116541. };
  116542. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  116543. get: function () {
  116544. return this._physicsImpostor;
  116545. },
  116546. set: function (value) {
  116547. var _this = this;
  116548. if (this._physicsImpostor === value) {
  116549. return;
  116550. }
  116551. if (this._disposePhysicsObserver) {
  116552. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  116553. }
  116554. this._physicsImpostor = value;
  116555. if (value) {
  116556. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  116557. // Physics
  116558. if (_this.physicsImpostor) {
  116559. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  116560. _this.physicsImpostor = null;
  116561. }
  116562. });
  116563. }
  116564. },
  116565. enumerable: true,
  116566. configurable: true
  116567. });
  116568. /**
  116569. * Gets the current physics impostor
  116570. * @see http://doc.babylonjs.com/features/physics_engine
  116571. * @returns a physics impostor or null
  116572. */
  116573. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  116574. return this.physicsImpostor;
  116575. };
  116576. /**
  116577. * Apply a physic impulse to the mesh
  116578. * @param force defines the force to apply
  116579. * @param contactPoint defines where to apply the force
  116580. * @returns the current mesh
  116581. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116582. */
  116583. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  116584. if (!this.physicsImpostor) {
  116585. return this;
  116586. }
  116587. this.physicsImpostor.applyImpulse(force, contactPoint);
  116588. return this;
  116589. };
  116590. /**
  116591. * Creates a physic joint between two meshes
  116592. * @param otherMesh defines the other mesh to use
  116593. * @param pivot1 defines the pivot to use on this mesh
  116594. * @param pivot2 defines the pivot to use on the other mesh
  116595. * @param options defines additional options (can be plugin dependent)
  116596. * @returns the current mesh
  116597. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  116598. */
  116599. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  116600. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  116601. return this;
  116602. }
  116603. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  116604. mainPivot: pivot1,
  116605. connectedPivot: pivot2,
  116606. nativeParams: options
  116607. });
  116608. return this;
  116609. };
  116610. /**
  116611. * Defines the physics engine scene component responsible to manage a physics engine
  116612. */
  116613. var PhysicsEngineSceneComponent = /** @class */ (function () {
  116614. /**
  116615. * Creates a new instance of the component for the given scene
  116616. * @param scene Defines the scene to register the component in
  116617. */
  116618. function PhysicsEngineSceneComponent(scene) {
  116619. var _this = this;
  116620. /**
  116621. * The component name helpful to identify the component in the list of scene components.
  116622. */
  116623. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  116624. this.scene = scene;
  116625. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  116626. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  116627. // Replace the function used to get the deterministic frame time
  116628. this.scene.getDeterministicFrameTime = function () {
  116629. if (_this.scene._physicsEngine) {
  116630. return _this.scene._physicsEngine.getTimeStep() * 1000;
  116631. }
  116632. return 1000.0 / 60.0;
  116633. };
  116634. }
  116635. /**
  116636. * Registers the component in a given scene
  116637. */
  116638. PhysicsEngineSceneComponent.prototype.register = function () {
  116639. };
  116640. /**
  116641. * Rebuilds the elements related to this component in case of
  116642. * context lost for instance.
  116643. */
  116644. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  116645. // Nothing to do for this component
  116646. };
  116647. /**
  116648. * Disposes the component and the associated ressources
  116649. */
  116650. PhysicsEngineSceneComponent.prototype.dispose = function () {
  116651. this.scene.onBeforePhysicsObservable.clear();
  116652. this.scene.onAfterPhysicsObservable.clear();
  116653. if (this.scene._physicsEngine) {
  116654. this.scene.disablePhysicsEngine();
  116655. }
  116656. };
  116657. return PhysicsEngineSceneComponent;
  116658. }());
  116659. /***/ }),
  116660. /***/ "./Physics/physicsHelper.ts":
  116661. /*!**********************************!*\
  116662. !*** ./Physics/physicsHelper.ts ***!
  116663. \**********************************/
  116664. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  116665. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116666. "use strict";
  116667. __webpack_require__.r(__webpack_exports__);
  116668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  116669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return PhysicsRadialExplosionEventOptions; });
  116670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return PhysicsUpdraftEventOptions; });
  116671. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return PhysicsVortexEventOptions; });
  116672. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  116673. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  116674. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116675. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  116676. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116677. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  116678. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  116679. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  116680. /**
  116681. * A helper for physics simulations
  116682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116683. */
  116684. var PhysicsHelper = /** @class */ (function () {
  116685. /**
  116686. * Initializes the Physics helper
  116687. * @param scene Babylon.js scene
  116688. */
  116689. function PhysicsHelper(scene) {
  116690. this._scene = scene;
  116691. this._physicsEngine = this._scene.getPhysicsEngine();
  116692. if (!this._physicsEngine) {
  116693. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  116694. return;
  116695. }
  116696. }
  116697. /**
  116698. * Applies a radial explosion impulse
  116699. * @param origin the origin of the explosion
  116700. * @param radiusOrEventOptions the radius or the options of radial explosion
  116701. * @param strength the explosion strength
  116702. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116703. * @returns A physics radial explosion event, or null
  116704. */
  116705. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radiusOrEventOptions, strength, falloff) {
  116706. if (!this._physicsEngine) {
  116707. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  116708. return null;
  116709. }
  116710. var impostors = this._physicsEngine.getImpostors();
  116711. if (impostors.length === 0) {
  116712. return null;
  116713. }
  116714. if (typeof radiusOrEventOptions === 'number') {
  116715. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  116716. radiusOrEventOptions.radius = radiusOrEventOptions;
  116717. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  116718. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  116719. }
  116720. var event = new PhysicsRadialExplosionEvent(this._scene, radiusOrEventOptions);
  116721. var affectedImpostorsWithData = Array();
  116722. impostors.forEach(function (impostor) {
  116723. var impostorHitData = event.getImpostorHitData(impostor, origin);
  116724. if (!impostorHitData) {
  116725. return;
  116726. }
  116727. impostor.applyImpulse(impostorHitData.force, impostorHitData.contactPoint);
  116728. affectedImpostorsWithData.push({
  116729. impostor: impostor,
  116730. hitData: impostorHitData,
  116731. });
  116732. });
  116733. event.triggerAffectedImpostorsCallback(affectedImpostorsWithData);
  116734. event.dispose(false);
  116735. return event;
  116736. };
  116737. /**
  116738. * Applies a radial explosion force
  116739. * @param origin the origin of the explosion
  116740. * @param radiusOrEventOptions the radius or the options of radial explosion
  116741. * @param strength the explosion strength
  116742. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116743. * @returns A physics radial explosion event, or null
  116744. */
  116745. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radiusOrEventOptions, strength, falloff) {
  116746. if (!this._physicsEngine) {
  116747. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  116748. return null;
  116749. }
  116750. var impostors = this._physicsEngine.getImpostors();
  116751. if (impostors.length === 0) {
  116752. return null;
  116753. }
  116754. if (typeof radiusOrEventOptions === 'number') {
  116755. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  116756. radiusOrEventOptions.radius = radiusOrEventOptions;
  116757. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  116758. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  116759. }
  116760. var event = new PhysicsRadialExplosionEvent(this._scene, radiusOrEventOptions);
  116761. var affectedImpostorsWithData = Array();
  116762. impostors.forEach(function (impostor) {
  116763. var impostorHitData = event.getImpostorHitData(impostor, origin);
  116764. if (!impostorHitData) {
  116765. return;
  116766. }
  116767. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  116768. affectedImpostorsWithData.push({
  116769. impostor: impostor,
  116770. hitData: impostorHitData,
  116771. });
  116772. });
  116773. event.triggerAffectedImpostorsCallback(affectedImpostorsWithData);
  116774. event.dispose(false);
  116775. return event;
  116776. };
  116777. /**
  116778. * Creates a gravitational field
  116779. * @param origin the origin of the explosion
  116780. * @param radiusOrEventOptions the radius or the options of radial explosion
  116781. * @param strength the explosion strength
  116782. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116783. * @returns A physics gravitational field event, or null
  116784. */
  116785. PhysicsHelper.prototype.gravitationalField = function (origin, radiusOrEventOptions, strength, falloff) {
  116786. if (!this._physicsEngine) {
  116787. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  116788. return null;
  116789. }
  116790. var impostors = this._physicsEngine.getImpostors();
  116791. if (impostors.length === 0) {
  116792. return null;
  116793. }
  116794. if (typeof radiusOrEventOptions === 'number') {
  116795. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  116796. radiusOrEventOptions.radius = radiusOrEventOptions;
  116797. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  116798. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  116799. }
  116800. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radiusOrEventOptions);
  116801. event.dispose(false);
  116802. return event;
  116803. };
  116804. /**
  116805. * Creates a physics updraft event
  116806. * @param origin the origin of the updraft
  116807. * @param radiusOrEventOptions the radius or the options of the updraft
  116808. * @param strength the strength of the updraft
  116809. * @param height the height of the updraft
  116810. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  116811. * @returns A physics updraft event, or null
  116812. */
  116813. PhysicsHelper.prototype.updraft = function (origin, radiusOrEventOptions, strength, height, updraftMode) {
  116814. if (!this._physicsEngine) {
  116815. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  116816. return null;
  116817. }
  116818. if (this._physicsEngine.getImpostors().length === 0) {
  116819. return null;
  116820. }
  116821. if (typeof radiusOrEventOptions === 'number') {
  116822. radiusOrEventOptions = new PhysicsUpdraftEventOptions();
  116823. radiusOrEventOptions.radius = radiusOrEventOptions;
  116824. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  116825. radiusOrEventOptions.height = height || radiusOrEventOptions.height;
  116826. radiusOrEventOptions.updraftMode = updraftMode || radiusOrEventOptions.updraftMode;
  116827. }
  116828. var event = new PhysicsUpdraftEvent(this._scene, origin, radiusOrEventOptions);
  116829. event.dispose(false);
  116830. return event;
  116831. };
  116832. /**
  116833. * Creates a physics vortex event
  116834. * @param origin the of the vortex
  116835. * @param radiusOrEventOptions the radius or the options of the vortex
  116836. * @param strength the strength of the vortex
  116837. * @param height the height of the vortex
  116838. * @returns a Physics vortex event, or null
  116839. * A physics vortex event or null
  116840. */
  116841. PhysicsHelper.prototype.vortex = function (origin, radiusOrEventOptions, strength, height) {
  116842. if (!this._physicsEngine) {
  116843. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  116844. return null;
  116845. }
  116846. if (this._physicsEngine.getImpostors().length === 0) {
  116847. return null;
  116848. }
  116849. if (typeof radiusOrEventOptions === 'number') {
  116850. radiusOrEventOptions = new PhysicsVortexEventOptions();
  116851. radiusOrEventOptions.radius = radiusOrEventOptions;
  116852. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  116853. radiusOrEventOptions.height = height || radiusOrEventOptions.height;
  116854. }
  116855. var event = new PhysicsVortexEvent(this._scene, origin, radiusOrEventOptions);
  116856. event.dispose(false);
  116857. return event;
  116858. };
  116859. return PhysicsHelper;
  116860. }());
  116861. /**
  116862. * Represents a physics radial explosion event
  116863. */
  116864. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  116865. /**
  116866. * Initializes a radial explosioin event
  116867. * @param _scene BabylonJS scene
  116868. * @param _options The options for the vortex event
  116869. */
  116870. function PhysicsRadialExplosionEvent(_scene, _options) {
  116871. this._scene = _scene;
  116872. this._options = _options;
  116873. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  116874. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsRadialExplosionEventOptions()), this._options);
  116875. }
  116876. /**
  116877. * Returns the data related to the radial explosion event (sphere).
  116878. * @returns The radial explosion event data
  116879. */
  116880. PhysicsRadialExplosionEvent.prototype.getData = function () {
  116881. this._dataFetched = true;
  116882. return {
  116883. sphere: this._sphere,
  116884. };
  116885. };
  116886. /**
  116887. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  116888. * @param impostor A physics imposter
  116889. * @param origin the origin of the explosion
  116890. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  116891. */
  116892. PhysicsRadialExplosionEvent.prototype.getImpostorHitData = function (impostor, origin) {
  116893. if (impostor.mass === 0) {
  116894. return null;
  116895. }
  116896. if (!this._intersectsWithSphere(impostor, origin, this._options.radius)) {
  116897. return null;
  116898. }
  116899. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  116900. return null;
  116901. }
  116902. var impostorObjectCenter = impostor.getObjectCenter();
  116903. var direction = impostorObjectCenter.subtract(origin);
  116904. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, this._options.radius);
  116905. var hit = ray.intersectsMesh(impostor.object);
  116906. var contactPoint = hit.pickedPoint;
  116907. if (!contactPoint) {
  116908. return null;
  116909. }
  116910. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Distance(origin, contactPoint);
  116911. if (distanceFromOrigin > this._options.radius) {
  116912. return null;
  116913. }
  116914. var multiplier = this._options.falloff === PhysicsRadialImpulseFalloff.Constant
  116915. ? this._options.strength
  116916. : this._options.strength * (1 - (distanceFromOrigin / this._options.radius));
  116917. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  116918. return { force: force, contactPoint: contactPoint, distanceFromOrigin: distanceFromOrigin };
  116919. };
  116920. /**
  116921. * Triggers affecterd impostors callbacks
  116922. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  116923. */
  116924. PhysicsRadialExplosionEvent.prototype.triggerAffectedImpostorsCallback = function (affectedImpostorsWithData) {
  116925. if (this._options.affectedImpostorsCallback) {
  116926. this._options.affectedImpostorsCallback(affectedImpostorsWithData);
  116927. }
  116928. };
  116929. /**
  116930. * Disposes the sphere.
  116931. * @param force Specifies if the sphere should be disposed by force
  116932. */
  116933. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  116934. var _this = this;
  116935. if (force === void 0) { force = true; }
  116936. if (force) {
  116937. this._sphere.dispose();
  116938. }
  116939. else {
  116940. setTimeout(function () {
  116941. if (!_this._dataFetched) {
  116942. _this._sphere.dispose();
  116943. }
  116944. }, 0);
  116945. }
  116946. };
  116947. /*** Helpers ***/
  116948. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  116949. if (!this._sphere) {
  116950. this._sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere("radialExplosionEventSphere", this._options.sphere, this._scene);
  116951. this._sphere.isVisible = false;
  116952. }
  116953. };
  116954. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  116955. var impostorObject = impostor.object;
  116956. this._prepareSphere();
  116957. this._sphere.position = origin;
  116958. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * 2, radius * 2, radius * 2);
  116959. this._sphere._updateBoundingInfo();
  116960. this._sphere.computeWorldMatrix(true);
  116961. return this._sphere.intersectsMesh(impostorObject, true);
  116962. };
  116963. return PhysicsRadialExplosionEvent;
  116964. }());
  116965. /**
  116966. * Represents a gravitational field event
  116967. */
  116968. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  116969. /**
  116970. * Initializes the physics gravitational field event
  116971. * @param _physicsHelper A physics helper
  116972. * @param _scene BabylonJS scene
  116973. * @param _origin The origin position of the gravitational field event
  116974. * @param _options The options for the vortex event
  116975. */
  116976. function PhysicsGravitationalFieldEvent(_physicsHelper, _scene, _origin, _options) {
  116977. this._physicsHelper = _physicsHelper;
  116978. this._scene = _scene;
  116979. this._origin = _origin;
  116980. this._options = _options;
  116981. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  116982. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsRadialExplosionEventOptions()), this._options);
  116983. this._tickCallback = this._tick.bind(this);
  116984. this._options.strength = this._options.strength * -1;
  116985. }
  116986. /**
  116987. * Returns the data related to the gravitational field event (sphere).
  116988. * @returns A gravitational field event
  116989. */
  116990. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  116991. this._dataFetched = true;
  116992. return {
  116993. sphere: this._sphere,
  116994. };
  116995. };
  116996. /**
  116997. * Enables the gravitational field.
  116998. */
  116999. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  117000. this._tickCallback.call(this);
  117001. this._scene.registerBeforeRender(this._tickCallback);
  117002. };
  117003. /**
  117004. * Disables the gravitational field.
  117005. */
  117006. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  117007. this._scene.unregisterBeforeRender(this._tickCallback);
  117008. };
  117009. /**
  117010. * Disposes the sphere.
  117011. * @param force The force to dispose from the gravitational field event
  117012. */
  117013. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  117014. var _this = this;
  117015. if (force === void 0) { force = true; }
  117016. if (force) {
  117017. this._sphere.dispose();
  117018. }
  117019. else {
  117020. setTimeout(function () {
  117021. if (!_this._dataFetched) {
  117022. _this._sphere.dispose();
  117023. }
  117024. }, 0);
  117025. }
  117026. };
  117027. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  117028. // Since the params won't change, we fetch the event only once
  117029. if (this._sphere) {
  117030. this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  117031. }
  117032. else {
  117033. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  117034. if (radialExplosionEvent) {
  117035. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  117036. }
  117037. }
  117038. };
  117039. return PhysicsGravitationalFieldEvent;
  117040. }());
  117041. /**
  117042. * Represents a physics updraft event
  117043. */
  117044. var PhysicsUpdraftEvent = /** @class */ (function () {
  117045. /**
  117046. * Initializes the physics updraft event
  117047. * @param _scene BabylonJS scene
  117048. * @param _origin The origin position of the updraft
  117049. * @param _options The options for the updraft event
  117050. */
  117051. function PhysicsUpdraftEvent(_scene, _origin, _options) {
  117052. this._scene = _scene;
  117053. this._origin = _origin;
  117054. this._options = _options;
  117055. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // the most upper part of the cylinder
  117056. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  117057. this._cylinderPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  117058. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  117059. this._physicsEngine = this._scene.getPhysicsEngine();
  117060. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsUpdraftEventOptions()), this._options);
  117061. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height / 2, 0), this._cylinderPosition);
  117062. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height, 0), this._originTop);
  117063. if (this._options.updraftMode === PhysicsUpdraftMode.Perpendicular) {
  117064. this._originDirection = this._origin.subtract(this._originTop).normalize();
  117065. }
  117066. this._tickCallback = this._tick.bind(this);
  117067. this._prepareCylinder();
  117068. }
  117069. /**
  117070. * Returns the data related to the updraft event (cylinder).
  117071. * @returns A physics updraft event
  117072. */
  117073. PhysicsUpdraftEvent.prototype.getData = function () {
  117074. this._dataFetched = true;
  117075. return {
  117076. cylinder: this._cylinder,
  117077. };
  117078. };
  117079. /**
  117080. * Enables the updraft.
  117081. */
  117082. PhysicsUpdraftEvent.prototype.enable = function () {
  117083. this._tickCallback.call(this);
  117084. this._scene.registerBeforeRender(this._tickCallback);
  117085. };
  117086. /**
  117087. * Disables the updraft.
  117088. */
  117089. PhysicsUpdraftEvent.prototype.disable = function () {
  117090. this._scene.unregisterBeforeRender(this._tickCallback);
  117091. };
  117092. /**
  117093. * Disposes the cylinder.
  117094. * @param force Specifies if the updraft should be disposed by force
  117095. */
  117096. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  117097. var _this = this;
  117098. if (force === void 0) { force = true; }
  117099. if (!this._cylinder) {
  117100. return;
  117101. }
  117102. if (force) {
  117103. this._cylinder.dispose();
  117104. }
  117105. else {
  117106. setTimeout(function () {
  117107. if (!_this._dataFetched) {
  117108. _this._cylinder.dispose();
  117109. }
  117110. }, 0);
  117111. }
  117112. };
  117113. PhysicsUpdraftEvent.prototype.getImpostorHitData = function (impostor) {
  117114. if (impostor.mass === 0) {
  117115. return null;
  117116. }
  117117. if (!this._intersectsWithCylinder(impostor)) {
  117118. return null;
  117119. }
  117120. var impostorObjectCenter = impostor.getObjectCenter();
  117121. if (this._options.updraftMode === PhysicsUpdraftMode.Perpendicular) {
  117122. var direction = this._originDirection;
  117123. }
  117124. else {
  117125. var direction = impostorObjectCenter.subtract(this._originTop);
  117126. }
  117127. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Distance(this._origin, impostorObjectCenter);
  117128. var multiplier = this._options.strength * -1;
  117129. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  117130. return { force: force, contactPoint: impostorObjectCenter, distanceFromOrigin: distanceFromOrigin };
  117131. };
  117132. PhysicsUpdraftEvent.prototype._tick = function () {
  117133. var _this = this;
  117134. this._physicsEngine.getImpostors().forEach(function (impostor) {
  117135. var impostorHitData = _this.getImpostorHitData(impostor);
  117136. if (!impostorHitData) {
  117137. return;
  117138. }
  117139. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  117140. });
  117141. };
  117142. /*** Helpers ***/
  117143. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  117144. if (!this._cylinder) {
  117145. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("updraftEventCylinder", {
  117146. height: this._options.height,
  117147. diameter: this._options.radius * 2,
  117148. }, this._scene);
  117149. this._cylinder.isVisible = false;
  117150. }
  117151. };
  117152. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  117153. var impostorObject = impostor.object;
  117154. this._cylinder.position = this._cylinderPosition;
  117155. return this._cylinder.intersectsMesh(impostorObject, true);
  117156. };
  117157. return PhysicsUpdraftEvent;
  117158. }());
  117159. /**
  117160. * Represents a physics vortex event
  117161. */
  117162. var PhysicsVortexEvent = /** @class */ (function () {
  117163. /**
  117164. * Initializes the physics vortex event
  117165. * @param _scene The BabylonJS scene
  117166. * @param _origin The origin position of the vortex
  117167. * @param _options The options for the vortex event
  117168. */
  117169. function PhysicsVortexEvent(_scene, _origin, _options) {
  117170. this._scene = _scene;
  117171. this._origin = _origin;
  117172. this._options = _options;
  117173. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // the most upper part of the cylinder
  117174. this._cylinderPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  117175. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  117176. this._physicsEngine = this._scene.getPhysicsEngine();
  117177. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsVortexEventOptions()), this._options);
  117178. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height / 2, 0), this._cylinderPosition);
  117179. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height, 0), this._originTop);
  117180. this._tickCallback = this._tick.bind(this);
  117181. this._prepareCylinder();
  117182. }
  117183. /**
  117184. * Returns the data related to the vortex event (cylinder).
  117185. * @returns The physics vortex event data
  117186. */
  117187. PhysicsVortexEvent.prototype.getData = function () {
  117188. this._dataFetched = true;
  117189. return {
  117190. cylinder: this._cylinder,
  117191. };
  117192. };
  117193. /**
  117194. * Enables the vortex.
  117195. */
  117196. PhysicsVortexEvent.prototype.enable = function () {
  117197. this._tickCallback.call(this);
  117198. this._scene.registerBeforeRender(this._tickCallback);
  117199. };
  117200. /**
  117201. * Disables the cortex.
  117202. */
  117203. PhysicsVortexEvent.prototype.disable = function () {
  117204. this._scene.unregisterBeforeRender(this._tickCallback);
  117205. };
  117206. /**
  117207. * Disposes the sphere.
  117208. * @param force
  117209. */
  117210. PhysicsVortexEvent.prototype.dispose = function (force) {
  117211. var _this = this;
  117212. if (force === void 0) { force = true; }
  117213. if (force) {
  117214. this._cylinder.dispose();
  117215. }
  117216. else {
  117217. setTimeout(function () {
  117218. if (!_this._dataFetched) {
  117219. _this._cylinder.dispose();
  117220. }
  117221. }, 0);
  117222. }
  117223. };
  117224. PhysicsVortexEvent.prototype.getImpostorHitData = function (impostor) {
  117225. if (impostor.mass === 0) {
  117226. return null;
  117227. }
  117228. if (!this._intersectsWithCylinder(impostor)) {
  117229. return null;
  117230. }
  117231. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  117232. return null;
  117233. }
  117234. var impostorObjectCenter = impostor.getObjectCenter();
  117235. var originOnPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](this._origin.x, impostorObjectCenter.y, this._origin.z); // the distance to the origin as if both objects were on a plane (Y-axis)
  117236. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  117237. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](originOnPlane, originToImpostorDirection, this._options.radius);
  117238. var hit = ray.intersectsMesh(impostor.object);
  117239. var contactPoint = hit.pickedPoint;
  117240. if (!contactPoint) {
  117241. return null;
  117242. }
  117243. var absoluteDistanceFromOrigin = hit.distance / this._options.radius;
  117244. var directionToOrigin = contactPoint.normalize();
  117245. if (absoluteDistanceFromOrigin > this._options.centripetalForceThreshold) {
  117246. directionToOrigin = directionToOrigin.negate();
  117247. }
  117248. if (absoluteDistanceFromOrigin > this._options.centripetalForceThreshold) {
  117249. var forceX = directionToOrigin.x * this._options.centripetalForceMultiplier;
  117250. var forceY = directionToOrigin.y * this._options.updraftForceMultiplier;
  117251. var forceZ = directionToOrigin.z * this._options.centripetalForceMultiplier;
  117252. }
  117253. else {
  117254. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  117255. var forceX = (perpendicularDirection.x + directionToOrigin.x) * this._options.centrifugalForceMultiplier;
  117256. var forceY = this._originTop.y * this._options.updraftForceMultiplier;
  117257. var forceZ = (perpendicularDirection.z + directionToOrigin.z) * this._options.centrifugalForceMultiplier;
  117258. }
  117259. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](forceX, forceY, forceZ);
  117260. force = force.multiplyByFloats(this._options.strength, this._options.strength, this._options.strength);
  117261. return { force: force, contactPoint: impostorObjectCenter, distanceFromOrigin: absoluteDistanceFromOrigin };
  117262. };
  117263. PhysicsVortexEvent.prototype._tick = function () {
  117264. var _this = this;
  117265. this._physicsEngine.getImpostors().forEach(function (impostor) {
  117266. var impostorHitData = _this.getImpostorHitData(impostor);
  117267. if (!impostorHitData) {
  117268. return;
  117269. }
  117270. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  117271. });
  117272. };
  117273. /*** Helpers ***/
  117274. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  117275. if (!this._cylinder) {
  117276. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("vortexEventCylinder", {
  117277. height: this._options.height,
  117278. diameter: this._options.radius * 2,
  117279. }, this._scene);
  117280. this._cylinder.isVisible = false;
  117281. }
  117282. };
  117283. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  117284. var impostorObject = impostor.object;
  117285. this._cylinder.position = this._cylinderPosition;
  117286. return this._cylinder.intersectsMesh(impostorObject, true);
  117287. };
  117288. return PhysicsVortexEvent;
  117289. }());
  117290. /**
  117291. * Options fot the radial explosion event
  117292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117293. */
  117294. var PhysicsRadialExplosionEventOptions = /** @class */ (function () {
  117295. function PhysicsRadialExplosionEventOptions() {
  117296. /**
  117297. * The radius of the sphere for the radial explosion.
  117298. */
  117299. this.radius = 5;
  117300. /**
  117301. * The strenth of the explosion.
  117302. */
  117303. this.strength = 10;
  117304. /**
  117305. * The strenght of the force in correspondence to the distance of the affected object
  117306. */
  117307. this.falloff = PhysicsRadialImpulseFalloff.Constant;
  117308. /**
  117309. * Sphere options for the radial explosion.
  117310. */
  117311. this.sphere = { segments: 32, diameter: 1 };
  117312. }
  117313. return PhysicsRadialExplosionEventOptions;
  117314. }());
  117315. /**
  117316. * Options fot the updraft event
  117317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117318. */
  117319. var PhysicsUpdraftEventOptions = /** @class */ (function () {
  117320. function PhysicsUpdraftEventOptions() {
  117321. /**
  117322. * The radius of the cylinder for the vortex
  117323. */
  117324. this.radius = 5;
  117325. /**
  117326. * The strenth of the updraft.
  117327. */
  117328. this.strength = 10;
  117329. /**
  117330. * The height of the cylinder for the updraft.
  117331. */
  117332. this.height = 10;
  117333. /**
  117334. * The mode for the the updraft.
  117335. */
  117336. this.updraftMode = PhysicsUpdraftMode.Center;
  117337. }
  117338. return PhysicsUpdraftEventOptions;
  117339. }());
  117340. /**
  117341. * Options fot the vortex event
  117342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117343. */
  117344. var PhysicsVortexEventOptions = /** @class */ (function () {
  117345. function PhysicsVortexEventOptions() {
  117346. /**
  117347. * The radius of the cylinder for the vortex
  117348. */
  117349. this.radius = 5;
  117350. /**
  117351. * The strenth of the vortex.
  117352. */
  117353. this.strength = 10;
  117354. /**
  117355. * The height of the cylinder for the vortex.
  117356. */
  117357. this.height = 10;
  117358. /**
  117359. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  117360. */
  117361. this.centripetalForceThreshold = 0.7;
  117362. /**
  117363. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  117364. */
  117365. this.centripetalForceMultiplier = 5;
  117366. /**
  117367. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  117368. */
  117369. this.centrifugalForceMultiplier = 0.5;
  117370. /**
  117371. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  117372. */
  117373. this.updraftForceMultiplier = 0.02;
  117374. }
  117375. return PhysicsVortexEventOptions;
  117376. }());
  117377. /**
  117378. * The strenght of the force in correspondence to the distance of the affected object
  117379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117380. */
  117381. var PhysicsRadialImpulseFalloff;
  117382. (function (PhysicsRadialImpulseFalloff) {
  117383. /** Defines that impulse is constant in strength across it's whole radius */
  117384. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  117385. /** Defines that impulse gets weaker if it's further from the origin */
  117386. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  117387. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  117388. /**
  117389. * The strength of the force in correspondence to the distance of the affected object
  117390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117391. */
  117392. var PhysicsUpdraftMode;
  117393. (function (PhysicsUpdraftMode) {
  117394. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  117395. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  117396. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  117397. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  117398. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  117399. /***/ }),
  117400. /***/ "./Physics/physicsImpostor.ts":
  117401. /*!************************************!*\
  117402. !*** ./Physics/physicsImpostor.ts ***!
  117403. \************************************/
  117404. /*! exports provided: PhysicsImpostor */
  117405. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117406. "use strict";
  117407. __webpack_require__.r(__webpack_exports__);
  117408. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  117409. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  117410. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  117411. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117412. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  117413. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  117414. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  117415. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  117416. return new PhysicsImpostor(physicObject, jsonObject.physicsImpostor, {
  117417. mass: jsonObject.physicsMass,
  117418. friction: jsonObject.physicsFriction,
  117419. restitution: jsonObject.physicsRestitution
  117420. }, scene);
  117421. };
  117422. /**
  117423. * Represents a physics imposter
  117424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117425. */
  117426. var PhysicsImpostor = /** @class */ (function () {
  117427. /**
  117428. * Initializes the physics imposter
  117429. * @param object The physics-enabled object used as the physics imposter
  117430. * @param type The type of the physics imposter
  117431. * @param _options The options for the physics imposter
  117432. * @param _scene The Babylon scene
  117433. */
  117434. function PhysicsImpostor(
  117435. /**
  117436. * The physics-enabled object used as the physics imposter
  117437. */
  117438. object,
  117439. /**
  117440. * The type of the physics imposter
  117441. */
  117442. type, _options, _scene) {
  117443. if (_options === void 0) { _options = { mass: 0 }; }
  117444. var _this = this;
  117445. this.object = object;
  117446. this.type = type;
  117447. this._options = _options;
  117448. this._scene = _scene;
  117449. /** @hidden */
  117450. this._pluginData = {};
  117451. this._bodyUpdateRequired = false;
  117452. this._onBeforePhysicsStepCallbacks = new Array();
  117453. this._onAfterPhysicsStepCallbacks = new Array();
  117454. /** @hidden */
  117455. this._onPhysicsCollideCallbacks = [];
  117456. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  117457. this._isDisposed = false;
  117458. /**
  117459. * @hidden
  117460. */
  117461. this.soft = false;
  117462. /**
  117463. * @hidden
  117464. */
  117465. this.segments = 0;
  117466. //temp variables for parent rotation calculations
  117467. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  117468. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  117469. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  117470. /**
  117471. * this function is executed by the physics engine.
  117472. */
  117473. this.beforeStep = function () {
  117474. if (!_this._physicsEngine) {
  117475. return;
  117476. }
  117477. _this.object.translate(_this._deltaPosition, -1);
  117478. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  117479. _this.object.computeWorldMatrix(false);
  117480. if (_this.object.parent && _this.object.rotationQuaternion) {
  117481. _this.getParentsRotation();
  117482. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  117483. }
  117484. else {
  117485. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  117486. }
  117487. if (!_this._options.disableBidirectionalTransformation) {
  117488. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  117489. }
  117490. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  117491. func(_this);
  117492. });
  117493. };
  117494. /**
  117495. * this function is executed by the physics engine
  117496. */
  117497. this.afterStep = function () {
  117498. if (!_this._physicsEngine) {
  117499. return;
  117500. }
  117501. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  117502. func(_this);
  117503. });
  117504. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  117505. // object has now its world rotation. needs to be converted to local.
  117506. if (_this.object.parent && _this.object.rotationQuaternion) {
  117507. _this.getParentsRotation();
  117508. _this._tmpQuat.conjugateInPlace();
  117509. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  117510. }
  117511. // take the position set and make it the absolute position of this object.
  117512. _this.object.setAbsolutePosition(_this.object.position);
  117513. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  117514. _this.object.translate(_this._deltaPosition, 1);
  117515. };
  117516. /**
  117517. * Legacy collision detection event support
  117518. */
  117519. this.onCollideEvent = null;
  117520. /**
  117521. * event and body object due to cannon's event-based architecture.
  117522. */
  117523. this.onCollide = function (e) {
  117524. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  117525. return;
  117526. }
  117527. if (!_this._physicsEngine) {
  117528. return;
  117529. }
  117530. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  117531. if (otherImpostor) {
  117532. // Legacy collision detection event support
  117533. if (_this.onCollideEvent) {
  117534. _this.onCollideEvent(_this, otherImpostor);
  117535. }
  117536. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  117537. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  117538. }).forEach(function (obj) {
  117539. obj.callback(_this, otherImpostor);
  117540. });
  117541. }
  117542. };
  117543. //sanity check!
  117544. if (!this.object) {
  117545. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  117546. return;
  117547. }
  117548. // Legacy support for old syntax.
  117549. if (!this._scene && object.getScene) {
  117550. this._scene = object.getScene();
  117551. }
  117552. if (!this._scene) {
  117553. return;
  117554. }
  117555. if (this.type > 100) {
  117556. this.soft = true;
  117557. }
  117558. this._physicsEngine = this._scene.getPhysicsEngine();
  117559. if (!this._physicsEngine) {
  117560. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  117561. }
  117562. else {
  117563. //set the object's quaternion, if not set
  117564. if (!this.object.rotationQuaternion) {
  117565. if (this.object.rotation) {
  117566. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  117567. }
  117568. else {
  117569. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  117570. }
  117571. }
  117572. //default options params
  117573. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  117574. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  117575. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  117576. if (this.soft) {
  117577. //softbody mass must be above 0;
  117578. this._options.mass = this._options.mass > 0 ? this._options.mass : 1;
  117579. this._options.pressure = (_options.pressure === void 0) ? 200 : _options.pressure;
  117580. this._options.stiffness = (_options.stiffness === void 0) ? 1 : _options.stiffness;
  117581. this._options.velocityIterations = (_options.velocityIterations === void 0) ? 20 : _options.velocityIterations;
  117582. this._options.positionIterations = (_options.positionIterations === void 0) ? 20 : _options.positionIterations;
  117583. this._options.fixedPoints = (_options.fixedPoints === void 0) ? 0 : _options.fixedPoints;
  117584. this._options.margin = (_options.margin === void 0) ? 0 : _options.margin;
  117585. this._options.damping = (_options.damping === void 0) ? 0 : _options.damping;
  117586. this._options.path = (_options.path === void 0) ? null : _options.path;
  117587. this._options.shape = (_options.shape === void 0) ? null : _options.shape;
  117588. }
  117589. this._joints = [];
  117590. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  117591. if (!this.object.parent || this._options.ignoreParent) {
  117592. this._init();
  117593. }
  117594. else if (this.object.parent.physicsImpostor) {
  117595. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  117596. }
  117597. }
  117598. }
  117599. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  117600. /**
  117601. * Specifies if the physics imposter is disposed
  117602. */
  117603. get: function () {
  117604. return this._isDisposed;
  117605. },
  117606. enumerable: true,
  117607. configurable: true
  117608. });
  117609. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  117610. /**
  117611. * Gets the mass of the physics imposter
  117612. */
  117613. get: function () {
  117614. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  117615. },
  117616. set: function (value) {
  117617. this.setMass(value);
  117618. },
  117619. enumerable: true,
  117620. configurable: true
  117621. });
  117622. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  117623. /**
  117624. * Gets the coefficient of friction
  117625. */
  117626. get: function () {
  117627. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  117628. },
  117629. /**
  117630. * Sets the coefficient of friction
  117631. */
  117632. set: function (value) {
  117633. if (!this._physicsEngine) {
  117634. return;
  117635. }
  117636. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  117637. },
  117638. enumerable: true,
  117639. configurable: true
  117640. });
  117641. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  117642. /**
  117643. * Gets the coefficient of restitution
  117644. */
  117645. get: function () {
  117646. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  117647. },
  117648. /**
  117649. * Sets the coefficient of restitution
  117650. */
  117651. set: function (value) {
  117652. if (!this._physicsEngine) {
  117653. return;
  117654. }
  117655. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  117656. },
  117657. enumerable: true,
  117658. configurable: true
  117659. });
  117660. Object.defineProperty(PhysicsImpostor.prototype, "pressure", {
  117661. /**
  117662. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  117663. */
  117664. get: function () {
  117665. if (!this._physicsEngine) {
  117666. return 0;
  117667. }
  117668. var plugin = this._physicsEngine.getPhysicsPlugin();
  117669. if (!plugin.setBodyPressure) {
  117670. return 0;
  117671. }
  117672. return plugin.getBodyPressure(this);
  117673. },
  117674. /**
  117675. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  117676. */
  117677. set: function (value) {
  117678. if (!this._physicsEngine) {
  117679. return;
  117680. }
  117681. var plugin = this._physicsEngine.getPhysicsPlugin();
  117682. if (!plugin.setBodyPressure) {
  117683. return;
  117684. }
  117685. plugin.setBodyPressure(this, value);
  117686. },
  117687. enumerable: true,
  117688. configurable: true
  117689. });
  117690. Object.defineProperty(PhysicsImpostor.prototype, "stiffness", {
  117691. /**
  117692. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  117693. */
  117694. get: function () {
  117695. if (!this._physicsEngine) {
  117696. return 0;
  117697. }
  117698. var plugin = this._physicsEngine.getPhysicsPlugin();
  117699. if (!plugin.getBodyStiffness) {
  117700. return 0;
  117701. }
  117702. return plugin.getBodyStiffness(this);
  117703. },
  117704. /**
  117705. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  117706. */
  117707. set: function (value) {
  117708. if (!this._physicsEngine) {
  117709. return;
  117710. }
  117711. var plugin = this._physicsEngine.getPhysicsPlugin();
  117712. if (!plugin.setBodyStiffness) {
  117713. return;
  117714. }
  117715. plugin.setBodyStiffness(this, value);
  117716. },
  117717. enumerable: true,
  117718. configurable: true
  117719. });
  117720. Object.defineProperty(PhysicsImpostor.prototype, "velocityIterations", {
  117721. /**
  117722. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  117723. */
  117724. get: function () {
  117725. if (!this._physicsEngine) {
  117726. return 0;
  117727. }
  117728. var plugin = this._physicsEngine.getPhysicsPlugin();
  117729. if (!plugin.getBodyVelocityIterations) {
  117730. return 0;
  117731. }
  117732. return plugin.getBodyVelocityIterations(this);
  117733. },
  117734. /**
  117735. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  117736. */
  117737. set: function (value) {
  117738. if (!this._physicsEngine) {
  117739. return;
  117740. }
  117741. var plugin = this._physicsEngine.getPhysicsPlugin();
  117742. if (!plugin.setBodyVelocityIterations) {
  117743. return;
  117744. }
  117745. plugin.setBodyVelocityIterations(this, value);
  117746. },
  117747. enumerable: true,
  117748. configurable: true
  117749. });
  117750. Object.defineProperty(PhysicsImpostor.prototype, "positionIterations", {
  117751. /**
  117752. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  117753. */
  117754. get: function () {
  117755. if (!this._physicsEngine) {
  117756. return 0;
  117757. }
  117758. var plugin = this._physicsEngine.getPhysicsPlugin();
  117759. if (!plugin.getBodyPositionIterations) {
  117760. return 0;
  117761. }
  117762. return plugin.getBodyPositionIterations(this);
  117763. },
  117764. /**
  117765. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  117766. */
  117767. set: function (value) {
  117768. if (!this._physicsEngine) {
  117769. return;
  117770. }
  117771. var plugin = this._physicsEngine.getPhysicsPlugin();
  117772. if (!plugin.setBodyPositionIterations) {
  117773. return;
  117774. }
  117775. plugin.setBodyPositionIterations(this, value);
  117776. },
  117777. enumerable: true,
  117778. configurable: true
  117779. });
  117780. /**
  117781. * This function will completly initialize this impostor.
  117782. * It will create a new body - but only if this mesh has no parent.
  117783. * If it has, this impostor will not be used other than to define the impostor
  117784. * of the child mesh.
  117785. * @hidden
  117786. */
  117787. PhysicsImpostor.prototype._init = function () {
  117788. if (!this._physicsEngine) {
  117789. return;
  117790. }
  117791. this._physicsEngine.removeImpostor(this);
  117792. this.physicsBody = null;
  117793. this._parent = this._parent || this._getPhysicsParent();
  117794. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  117795. this._physicsEngine.addImpostor(this);
  117796. }
  117797. };
  117798. PhysicsImpostor.prototype._getPhysicsParent = function () {
  117799. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  117800. var parentMesh = this.object.parent;
  117801. return parentMesh.physicsImpostor;
  117802. }
  117803. return null;
  117804. };
  117805. /**
  117806. * Should a new body be generated.
  117807. * @returns boolean specifying if body initialization is required
  117808. */
  117809. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  117810. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  117811. };
  117812. /**
  117813. * Sets the updated scaling
  117814. * @param updated Specifies if the scaling is updated
  117815. */
  117816. PhysicsImpostor.prototype.setScalingUpdated = function () {
  117817. this.forceUpdate();
  117818. };
  117819. /**
  117820. * Force a regeneration of this or the parent's impostor's body.
  117821. * Use under cautious - This will remove all joints already implemented.
  117822. */
  117823. PhysicsImpostor.prototype.forceUpdate = function () {
  117824. this._init();
  117825. if (this.parent && !this._options.ignoreParent) {
  117826. this.parent.forceUpdate();
  117827. }
  117828. };
  117829. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  117830. /*public get mesh(): AbstractMesh {
  117831. return this._mesh;
  117832. }*/
  117833. /**
  117834. * Gets the body that holds this impostor. Either its own, or its parent.
  117835. */
  117836. get: function () {
  117837. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  117838. },
  117839. /**
  117840. * Set the physics body. Used mainly by the physics engine/plugin
  117841. */
  117842. set: function (physicsBody) {
  117843. if (this._physicsBody && this._physicsEngine) {
  117844. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  117845. }
  117846. this._physicsBody = physicsBody;
  117847. this.resetUpdateFlags();
  117848. },
  117849. enumerable: true,
  117850. configurable: true
  117851. });
  117852. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  117853. /**
  117854. * Get the parent of the physics imposter
  117855. * @returns Physics imposter or null
  117856. */
  117857. get: function () {
  117858. return !this._options.ignoreParent && this._parent ? this._parent : null;
  117859. },
  117860. /**
  117861. * Sets the parent of the physics imposter
  117862. */
  117863. set: function (value) {
  117864. this._parent = value;
  117865. },
  117866. enumerable: true,
  117867. configurable: true
  117868. });
  117869. /**
  117870. * Resets the update flags
  117871. */
  117872. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  117873. this._bodyUpdateRequired = false;
  117874. };
  117875. /**
  117876. * Gets the object extend size
  117877. * @returns the object extend size
  117878. */
  117879. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  117880. if (this.object.getBoundingInfo) {
  117881. var q = this.object.rotationQuaternion;
  117882. //reset rotation
  117883. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  117884. //calculate the world matrix with no rotation
  117885. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  117886. var boundingInfo = this.object.getBoundingInfo();
  117887. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  117888. //bring back the rotation
  117889. this.object.rotationQuaternion = q;
  117890. //calculate the world matrix with the new rotation
  117891. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  117892. return size;
  117893. }
  117894. else {
  117895. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  117896. }
  117897. };
  117898. /**
  117899. * Gets the object center
  117900. * @returns The object center
  117901. */
  117902. PhysicsImpostor.prototype.getObjectCenter = function () {
  117903. if (this.object.getBoundingInfo) {
  117904. var boundingInfo = this.object.getBoundingInfo();
  117905. return boundingInfo.boundingBox.centerWorld;
  117906. }
  117907. else {
  117908. return this.object.position;
  117909. }
  117910. };
  117911. /**
  117912. * Get a specific parametes from the options parameter
  117913. * @param paramName The object parameter name
  117914. * @returns The object parameter
  117915. */
  117916. PhysicsImpostor.prototype.getParam = function (paramName) {
  117917. return this._options[paramName];
  117918. };
  117919. /**
  117920. * Sets a specific parameter in the options given to the physics plugin
  117921. * @param paramName The parameter name
  117922. * @param value The value of the parameter
  117923. */
  117924. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  117925. this._options[paramName] = value;
  117926. this._bodyUpdateRequired = true;
  117927. };
  117928. /**
  117929. * Specifically change the body's mass option. Won't recreate the physics body object
  117930. * @param mass The mass of the physics imposter
  117931. */
  117932. PhysicsImpostor.prototype.setMass = function (mass) {
  117933. if (this.getParam("mass") !== mass) {
  117934. this.setParam("mass", mass);
  117935. }
  117936. if (this._physicsEngine) {
  117937. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  117938. }
  117939. };
  117940. /**
  117941. * Gets the linear velocity
  117942. * @returns linear velocity or null
  117943. */
  117944. PhysicsImpostor.prototype.getLinearVelocity = function () {
  117945. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  117946. };
  117947. /**
  117948. * Sets the linear velocity
  117949. * @param velocity linear velocity or null
  117950. */
  117951. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  117952. if (this._physicsEngine) {
  117953. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  117954. }
  117955. };
  117956. /**
  117957. * Gets the angular velocity
  117958. * @returns angular velocity or null
  117959. */
  117960. PhysicsImpostor.prototype.getAngularVelocity = function () {
  117961. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  117962. };
  117963. /**
  117964. * Sets the angular velocity
  117965. * @param velocity The velocity or null
  117966. */
  117967. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  117968. if (this._physicsEngine) {
  117969. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  117970. }
  117971. };
  117972. /**
  117973. * Execute a function with the physics plugin native code
  117974. * Provide a function the will have two variables - the world object and the physics body object
  117975. * @param func The function to execute with the physics plugin native code
  117976. */
  117977. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  117978. if (this._physicsEngine) {
  117979. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  117980. }
  117981. };
  117982. /**
  117983. * Register a function that will be executed before the physics world is stepping forward
  117984. * @param func The function to execute before the physics world is stepped forward
  117985. */
  117986. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  117987. this._onBeforePhysicsStepCallbacks.push(func);
  117988. };
  117989. /**
  117990. * Unregister a function that will be executed before the physics world is stepping forward
  117991. * @param func The function to execute before the physics world is stepped forward
  117992. */
  117993. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  117994. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  117995. if (index > -1) {
  117996. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  117997. }
  117998. else {
  117999. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  118000. }
  118001. };
  118002. /**
  118003. * Register a function that will be executed after the physics step
  118004. * @param func The function to execute after physics step
  118005. */
  118006. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  118007. this._onAfterPhysicsStepCallbacks.push(func);
  118008. };
  118009. /**
  118010. * Unregisters a function that will be executed after the physics step
  118011. * @param func The function to execute after physics step
  118012. */
  118013. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  118014. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  118015. if (index > -1) {
  118016. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  118017. }
  118018. else {
  118019. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  118020. }
  118021. };
  118022. /**
  118023. * register a function that will be executed when this impostor collides against a different body
  118024. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  118025. * @param func Callback that is executed on collision
  118026. */
  118027. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  118028. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  118029. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  118030. };
  118031. /**
  118032. * Unregisters the physics imposter on contact
  118033. * @param collideAgainst The physics object to collide against
  118034. * @param func Callback to execute on collision
  118035. */
  118036. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  118037. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  118038. var index = -1;
  118039. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  118040. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  118041. // chcek the arrays match
  118042. var sameList = cbDef.otherImpostors.every(function (impostor) {
  118043. return collidedAgainstList.indexOf(impostor) > -1;
  118044. });
  118045. if (sameList) {
  118046. index = idx;
  118047. }
  118048. return sameList;
  118049. }
  118050. return false;
  118051. });
  118052. if (found) {
  118053. this._onPhysicsCollideCallbacks.splice(index, 1);
  118054. }
  118055. else {
  118056. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  118057. }
  118058. };
  118059. /**
  118060. * Get the parent rotation
  118061. * @returns The parent rotation
  118062. */
  118063. PhysicsImpostor.prototype.getParentsRotation = function () {
  118064. var parent = this.object.parent;
  118065. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  118066. while (parent) {
  118067. if (parent.rotationQuaternion) {
  118068. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  118069. }
  118070. else {
  118071. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  118072. }
  118073. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  118074. parent = parent.parent;
  118075. }
  118076. return this._tmpQuat;
  118077. };
  118078. /**
  118079. * Apply a force
  118080. * @param force The force to apply
  118081. * @param contactPoint The contact point for the force
  118082. * @returns The physics imposter
  118083. */
  118084. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  118085. if (this._physicsEngine) {
  118086. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  118087. }
  118088. return this;
  118089. };
  118090. /**
  118091. * Apply an impulse
  118092. * @param force The impulse force
  118093. * @param contactPoint The contact point for the impulse force
  118094. * @returns The physics imposter
  118095. */
  118096. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  118097. if (this._physicsEngine) {
  118098. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  118099. }
  118100. return this;
  118101. };
  118102. /**
  118103. * A help function to create a joint
  118104. * @param otherImpostor A physics imposter used to create a joint
  118105. * @param jointType The type of joint
  118106. * @param jointData The data for the joint
  118107. * @returns The physics imposter
  118108. */
  118109. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  118110. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_5__["PhysicsJoint"](jointType, jointData);
  118111. this.addJoint(otherImpostor, joint);
  118112. return this;
  118113. };
  118114. /**
  118115. * Add a joint to this impostor with a different impostor
  118116. * @param otherImpostor A physics imposter used to add a joint
  118117. * @param joint The joint to add
  118118. * @returns The physics imposter
  118119. */
  118120. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  118121. this._joints.push({
  118122. otherImpostor: otherImpostor,
  118123. joint: joint
  118124. });
  118125. if (this._physicsEngine) {
  118126. this._physicsEngine.addJoint(this, otherImpostor, joint);
  118127. }
  118128. return this;
  118129. };
  118130. /**
  118131. * Add an anchor to a cloth impostor
  118132. * @param otherImpostor rigid impostor to anchor to
  118133. * @param width ratio across width from 0 to 1
  118134. * @param height ratio up height from 0 to 1
  118135. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118136. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  118137. * @returns impostor the soft imposter
  118138. */
  118139. PhysicsImpostor.prototype.addAnchor = function (otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies) {
  118140. if (!this._physicsEngine) {
  118141. return this;
  118142. }
  118143. var plugin = this._physicsEngine.getPhysicsPlugin();
  118144. if (!plugin.appendAnchor) {
  118145. return this;
  118146. }
  118147. if (this._physicsEngine) {
  118148. plugin.appendAnchor(this, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies);
  118149. }
  118150. return this;
  118151. };
  118152. /**
  118153. * Add a hook to a rope impostor
  118154. * @param otherImpostor rigid impostor to anchor to
  118155. * @param length ratio across rope from 0 to 1
  118156. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  118157. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118158. * @returns impostor the rope imposter
  118159. */
  118160. PhysicsImpostor.prototype.addHook = function (otherImpostor, length, influence, noCollisionBetweenLinkedBodies) {
  118161. if (!this._physicsEngine) {
  118162. return this;
  118163. }
  118164. var plugin = this._physicsEngine.getPhysicsPlugin();
  118165. if (!plugin.appendAnchor) {
  118166. return this;
  118167. }
  118168. if (this._physicsEngine) {
  118169. plugin.appendHook(this, otherImpostor, length, influence, noCollisionBetweenLinkedBodies);
  118170. }
  118171. return this;
  118172. };
  118173. /**
  118174. * Will keep this body still, in a sleep mode.
  118175. * @returns the physics imposter
  118176. */
  118177. PhysicsImpostor.prototype.sleep = function () {
  118178. if (this._physicsEngine) {
  118179. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  118180. }
  118181. return this;
  118182. };
  118183. /**
  118184. * Wake the body up.
  118185. * @returns The physics imposter
  118186. */
  118187. PhysicsImpostor.prototype.wakeUp = function () {
  118188. if (this._physicsEngine) {
  118189. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  118190. }
  118191. return this;
  118192. };
  118193. /**
  118194. * Clones the physics imposter
  118195. * @param newObject The physics imposter clones to this physics-enabled object
  118196. * @returns A nullable physics imposter
  118197. */
  118198. PhysicsImpostor.prototype.clone = function (newObject) {
  118199. if (!newObject) {
  118200. return null;
  118201. }
  118202. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  118203. };
  118204. /**
  118205. * Disposes the physics imposter
  118206. */
  118207. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  118208. var _this = this;
  118209. //no dispose if no physics engine is available.
  118210. if (!this._physicsEngine) {
  118211. return;
  118212. }
  118213. this._joints.forEach(function (j) {
  118214. if (_this._physicsEngine) {
  118215. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  118216. }
  118217. });
  118218. //dispose the physics body
  118219. this._physicsEngine.removeImpostor(this);
  118220. if (this.parent) {
  118221. this.parent.forceUpdate();
  118222. }
  118223. else {
  118224. /*this._object.getChildMeshes().forEach(function(mesh) {
  118225. if (mesh.physicsImpostor) {
  118226. if (disposeChildren) {
  118227. mesh.physicsImpostor.dispose();
  118228. mesh.physicsImpostor = null;
  118229. }
  118230. }
  118231. })*/
  118232. }
  118233. this._isDisposed = true;
  118234. };
  118235. /**
  118236. * Sets the delta position
  118237. * @param position The delta position amount
  118238. */
  118239. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  118240. this._deltaPosition.copyFrom(position);
  118241. };
  118242. /**
  118243. * Sets the delta rotation
  118244. * @param rotation The delta rotation amount
  118245. */
  118246. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  118247. if (!this._deltaRotation) {
  118248. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  118249. }
  118250. this._deltaRotation.copyFrom(rotation);
  118251. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  118252. };
  118253. /**
  118254. * Gets the box size of the physics imposter and stores the result in the input parameter
  118255. * @param result Stores the box size
  118256. * @returns The physics imposter
  118257. */
  118258. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  118259. if (this._physicsEngine) {
  118260. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  118261. }
  118262. return this;
  118263. };
  118264. /**
  118265. * Gets the radius of the physics imposter
  118266. * @returns Radius of the physics imposter
  118267. */
  118268. PhysicsImpostor.prototype.getRadius = function () {
  118269. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  118270. };
  118271. /**
  118272. * Sync a bone with this impostor
  118273. * @param bone The bone to sync to the impostor.
  118274. * @param boneMesh The mesh that the bone is influencing.
  118275. * @param jointPivot The pivot of the joint / bone in local space.
  118276. * @param distToJoint Optional distance from the impostor to the joint.
  118277. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  118278. */
  118279. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  118280. var tempVec = PhysicsImpostor._tmpVecs[0];
  118281. var mesh = this.object;
  118282. if (mesh.rotationQuaternion) {
  118283. if (adjustRotation) {
  118284. var tempQuat = PhysicsImpostor._tmpQuat;
  118285. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  118286. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  118287. }
  118288. else {
  118289. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  118290. }
  118291. }
  118292. tempVec.x = 0;
  118293. tempVec.y = 0;
  118294. tempVec.z = 0;
  118295. if (jointPivot) {
  118296. tempVec.x = jointPivot.x;
  118297. tempVec.y = jointPivot.y;
  118298. tempVec.z = jointPivot.z;
  118299. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  118300. if (distToJoint === undefined || distToJoint === null) {
  118301. distToJoint = jointPivot.length();
  118302. }
  118303. tempVec.x *= distToJoint;
  118304. tempVec.y *= distToJoint;
  118305. tempVec.z *= distToJoint;
  118306. }
  118307. if (bone.getParent()) {
  118308. tempVec.addInPlace(mesh.getAbsolutePosition());
  118309. bone.setAbsolutePosition(tempVec, boneMesh);
  118310. }
  118311. else {
  118312. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  118313. boneMesh.position.x -= tempVec.x;
  118314. boneMesh.position.y -= tempVec.y;
  118315. boneMesh.position.z -= tempVec.z;
  118316. }
  118317. };
  118318. /**
  118319. * Sync impostor to a bone
  118320. * @param bone The bone that the impostor will be synced to.
  118321. * @param boneMesh The mesh that the bone is influencing.
  118322. * @param jointPivot The pivot of the joint / bone in local space.
  118323. * @param distToJoint Optional distance from the impostor to the joint.
  118324. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  118325. * @param boneAxis Optional vector3 axis the bone is aligned with
  118326. */
  118327. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  118328. var mesh = this.object;
  118329. if (mesh.rotationQuaternion) {
  118330. if (adjustRotation) {
  118331. var tempQuat = PhysicsImpostor._tmpQuat;
  118332. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  118333. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  118334. }
  118335. else {
  118336. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  118337. }
  118338. }
  118339. var pos = PhysicsImpostor._tmpVecs[0];
  118340. var boneDir = PhysicsImpostor._tmpVecs[1];
  118341. if (!boneAxis) {
  118342. boneAxis = PhysicsImpostor._tmpVecs[2];
  118343. boneAxis.x = 0;
  118344. boneAxis.y = 1;
  118345. boneAxis.z = 0;
  118346. }
  118347. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  118348. bone.getAbsolutePositionToRef(boneMesh, pos);
  118349. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  118350. distToJoint = jointPivot.length();
  118351. }
  118352. if (distToJoint !== undefined && distToJoint !== null) {
  118353. pos.x += boneDir.x * distToJoint;
  118354. pos.y += boneDir.y * distToJoint;
  118355. pos.z += boneDir.z * distToJoint;
  118356. }
  118357. mesh.setAbsolutePosition(pos);
  118358. };
  118359. /**
  118360. * The default object size of the imposter
  118361. */
  118362. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  118363. /**
  118364. * The identity quaternion of the imposter
  118365. */
  118366. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  118367. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  118368. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  118369. //Impostor types
  118370. /**
  118371. * No-Imposter type
  118372. */
  118373. PhysicsImpostor.NoImpostor = 0;
  118374. /**
  118375. * Sphere-Imposter type
  118376. */
  118377. PhysicsImpostor.SphereImpostor = 1;
  118378. /**
  118379. * Box-Imposter type
  118380. */
  118381. PhysicsImpostor.BoxImpostor = 2;
  118382. /**
  118383. * Plane-Imposter type
  118384. */
  118385. PhysicsImpostor.PlaneImpostor = 3;
  118386. /**
  118387. * Mesh-imposter type
  118388. */
  118389. PhysicsImpostor.MeshImpostor = 4;
  118390. /**
  118391. * Cylinder-Imposter type
  118392. */
  118393. PhysicsImpostor.CylinderImpostor = 7;
  118394. /**
  118395. * Particle-Imposter type
  118396. */
  118397. PhysicsImpostor.ParticleImpostor = 8;
  118398. /**
  118399. * Heightmap-Imposter type
  118400. */
  118401. PhysicsImpostor.HeightmapImpostor = 9;
  118402. /**
  118403. * ConvexHull-Impostor type (Ammo.js plugin only)
  118404. */
  118405. PhysicsImpostor.ConvexHullImpostor = 10;
  118406. /**
  118407. * Rope-Imposter type
  118408. */
  118409. PhysicsImpostor.RopeImpostor = 101;
  118410. /**
  118411. * Cloth-Imposter type
  118412. */
  118413. PhysicsImpostor.ClothImpostor = 102;
  118414. /**
  118415. * Softbody-Imposter type
  118416. */
  118417. PhysicsImpostor.SoftbodyImpostor = 103;
  118418. return PhysicsImpostor;
  118419. }());
  118420. /***/ }),
  118421. /***/ "./Physics/physicsJoint.ts":
  118422. /*!*********************************!*\
  118423. !*** ./Physics/physicsJoint.ts ***!
  118424. \*********************************/
  118425. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  118426. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118427. "use strict";
  118428. __webpack_require__.r(__webpack_exports__);
  118429. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  118430. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  118431. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  118432. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  118433. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  118434. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118435. /**
  118436. * This is a holder class for the physics joint created by the physics plugin
  118437. * It holds a set of functions to control the underlying joint
  118438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118439. */
  118440. var PhysicsJoint = /** @class */ (function () {
  118441. /**
  118442. * Initializes the physics joint
  118443. * @param type The type of the physics joint
  118444. * @param jointData The data for the physics joint
  118445. */
  118446. function PhysicsJoint(
  118447. /**
  118448. * The type of the physics joint
  118449. */
  118450. type,
  118451. /**
  118452. * The data for the physics joint
  118453. */
  118454. jointData) {
  118455. this.type = type;
  118456. this.jointData = jointData;
  118457. jointData.nativeParams = jointData.nativeParams || {};
  118458. }
  118459. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  118460. /**
  118461. * Gets the physics joint
  118462. */
  118463. get: function () {
  118464. return this._physicsJoint;
  118465. },
  118466. /**
  118467. * Sets the physics joint
  118468. */
  118469. set: function (newJoint) {
  118470. if (this._physicsJoint) {
  118471. //remove from the wolrd
  118472. }
  118473. this._physicsJoint = newJoint;
  118474. },
  118475. enumerable: true,
  118476. configurable: true
  118477. });
  118478. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  118479. /**
  118480. * Sets the physics plugin
  118481. */
  118482. set: function (physicsPlugin) {
  118483. this._physicsPlugin = physicsPlugin;
  118484. },
  118485. enumerable: true,
  118486. configurable: true
  118487. });
  118488. /**
  118489. * Execute a function that is physics-plugin specific.
  118490. * @param {Function} func the function that will be executed.
  118491. * It accepts two parameters: the physics world and the physics joint
  118492. */
  118493. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  118494. func(this._physicsPlugin.world, this._physicsJoint);
  118495. };
  118496. //TODO check if the native joints are the same
  118497. //Joint Types
  118498. /**
  118499. * Distance-Joint type
  118500. */
  118501. PhysicsJoint.DistanceJoint = 0;
  118502. /**
  118503. * Hinge-Joint type
  118504. */
  118505. PhysicsJoint.HingeJoint = 1;
  118506. /**
  118507. * Ball-and-Socket joint type
  118508. */
  118509. PhysicsJoint.BallAndSocketJoint = 2;
  118510. /**
  118511. * Wheel-Joint type
  118512. */
  118513. PhysicsJoint.WheelJoint = 3;
  118514. /**
  118515. * Slider-Joint type
  118516. */
  118517. PhysicsJoint.SliderJoint = 4;
  118518. //OIMO
  118519. /**
  118520. * Prismatic-Joint type
  118521. */
  118522. PhysicsJoint.PrismaticJoint = 5;
  118523. //
  118524. /**
  118525. * Universal-Joint type
  118526. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  118527. */
  118528. PhysicsJoint.UniversalJoint = 6;
  118529. /**
  118530. * Hinge-Joint 2 type
  118531. */
  118532. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  118533. //Cannon
  118534. /**
  118535. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  118536. */
  118537. PhysicsJoint.PointToPointJoint = 8;
  118538. //Cannon only at the moment
  118539. /**
  118540. * Spring-Joint type
  118541. */
  118542. PhysicsJoint.SpringJoint = 9;
  118543. /**
  118544. * Lock-Joint type
  118545. */
  118546. PhysicsJoint.LockJoint = 10;
  118547. return PhysicsJoint;
  118548. }());
  118549. /**
  118550. * A class representing a physics distance joint
  118551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118552. */
  118553. var DistanceJoint = /** @class */ (function (_super) {
  118554. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  118555. /**
  118556. *
  118557. * @param jointData The data for the Distance-Joint
  118558. */
  118559. function DistanceJoint(jointData) {
  118560. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  118561. }
  118562. /**
  118563. * Update the predefined distance.
  118564. * @param maxDistance The maximum preferred distance
  118565. * @param minDistance The minimum preferred distance
  118566. */
  118567. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  118568. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  118569. };
  118570. return DistanceJoint;
  118571. }(PhysicsJoint));
  118572. /**
  118573. * Represents a Motor-Enabled Joint
  118574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118575. */
  118576. var MotorEnabledJoint = /** @class */ (function (_super) {
  118577. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  118578. /**
  118579. * Initializes the Motor-Enabled Joint
  118580. * @param type The type of the joint
  118581. * @param jointData The physica joint data for the joint
  118582. */
  118583. function MotorEnabledJoint(type, jointData) {
  118584. return _super.call(this, type, jointData) || this;
  118585. }
  118586. /**
  118587. * Set the motor values.
  118588. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118589. * @param force the force to apply
  118590. * @param maxForce max force for this motor.
  118591. */
  118592. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  118593. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  118594. };
  118595. /**
  118596. * Set the motor's limits.
  118597. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118598. * @param upperLimit The upper limit of the motor
  118599. * @param lowerLimit The lower limit of the motor
  118600. */
  118601. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  118602. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  118603. };
  118604. return MotorEnabledJoint;
  118605. }(PhysicsJoint));
  118606. /**
  118607. * This class represents a single physics Hinge-Joint
  118608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118609. */
  118610. var HingeJoint = /** @class */ (function (_super) {
  118611. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  118612. /**
  118613. * Initializes the Hinge-Joint
  118614. * @param jointData The joint data for the Hinge-Joint
  118615. */
  118616. function HingeJoint(jointData) {
  118617. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  118618. }
  118619. /**
  118620. * Set the motor values.
  118621. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118622. * @param {number} force the force to apply
  118623. * @param {number} maxForce max force for this motor.
  118624. */
  118625. HingeJoint.prototype.setMotor = function (force, maxForce) {
  118626. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  118627. };
  118628. /**
  118629. * Set the motor's limits.
  118630. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118631. * @param upperLimit The upper limit of the motor
  118632. * @param lowerLimit The lower limit of the motor
  118633. */
  118634. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  118635. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  118636. };
  118637. return HingeJoint;
  118638. }(MotorEnabledJoint));
  118639. /**
  118640. * This class represents a dual hinge physics joint (same as wheel joint)
  118641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118642. */
  118643. var Hinge2Joint = /** @class */ (function (_super) {
  118644. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  118645. /**
  118646. * Initializes the Hinge2-Joint
  118647. * @param jointData The joint data for the Hinge2-Joint
  118648. */
  118649. function Hinge2Joint(jointData) {
  118650. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  118651. }
  118652. /**
  118653. * Set the motor values.
  118654. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118655. * @param {number} targetSpeed the speed the motor is to reach
  118656. * @param {number} maxForce max force for this motor.
  118657. * @param {motorIndex} the motor's index, 0 or 1.
  118658. */
  118659. Hinge2Joint.prototype.setMotor = function (targetSpeed, maxForce, motorIndex) {
  118660. if (motorIndex === void 0) { motorIndex = 0; }
  118661. this._physicsPlugin.setMotor(this, targetSpeed || 0, maxForce, motorIndex);
  118662. };
  118663. /**
  118664. * Set the motor limits.
  118665. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118666. * @param {number} upperLimit the upper limit
  118667. * @param {number} lowerLimit lower limit
  118668. * @param {motorIndex} the motor's index, 0 or 1.
  118669. */
  118670. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  118671. if (motorIndex === void 0) { motorIndex = 0; }
  118672. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  118673. };
  118674. return Hinge2Joint;
  118675. }(MotorEnabledJoint));
  118676. /***/ }),
  118677. /***/ "./Physics/physicsRaycastResult.ts":
  118678. /*!*****************************************!*\
  118679. !*** ./Physics/physicsRaycastResult.ts ***!
  118680. \*****************************************/
  118681. /*! exports provided: PhysicsRaycastResult */
  118682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118683. "use strict";
  118684. __webpack_require__.r(__webpack_exports__);
  118685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRaycastResult", function() { return PhysicsRaycastResult; });
  118686. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118687. /**
  118688. * Holds the data for the raycast result
  118689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118690. */
  118691. var PhysicsRaycastResult = /** @class */ (function () {
  118692. function PhysicsRaycastResult() {
  118693. this._hasHit = false;
  118694. this._hitDistance = 0;
  118695. this._hitNormalWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  118696. this._hitPointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  118697. this._rayFromWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  118698. this._rayToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  118699. }
  118700. Object.defineProperty(PhysicsRaycastResult.prototype, "hasHit", {
  118701. /**
  118702. * Gets if there was a hit
  118703. */
  118704. get: function () {
  118705. return this._hasHit;
  118706. },
  118707. enumerable: true,
  118708. configurable: true
  118709. });
  118710. Object.defineProperty(PhysicsRaycastResult.prototype, "hitDistance", {
  118711. /**
  118712. * Gets the distance from the hit
  118713. */
  118714. get: function () {
  118715. return this._hitDistance;
  118716. },
  118717. enumerable: true,
  118718. configurable: true
  118719. });
  118720. Object.defineProperty(PhysicsRaycastResult.prototype, "hitNormalWorld", {
  118721. /**
  118722. * Gets the hit normal/direction in the world
  118723. */
  118724. get: function () {
  118725. return this._hitNormalWorld;
  118726. },
  118727. enumerable: true,
  118728. configurable: true
  118729. });
  118730. Object.defineProperty(PhysicsRaycastResult.prototype, "hitPointWorld", {
  118731. /**
  118732. * Gets the hit point in the world
  118733. */
  118734. get: function () {
  118735. return this._hitPointWorld;
  118736. },
  118737. enumerable: true,
  118738. configurable: true
  118739. });
  118740. Object.defineProperty(PhysicsRaycastResult.prototype, "rayFromWorld", {
  118741. /**
  118742. * Gets the ray "start point" of the ray in the world
  118743. */
  118744. get: function () {
  118745. return this._rayFromWorld;
  118746. },
  118747. enumerable: true,
  118748. configurable: true
  118749. });
  118750. Object.defineProperty(PhysicsRaycastResult.prototype, "rayToWorld", {
  118751. /**
  118752. * Gets the ray "end point" of the ray in the world
  118753. */
  118754. get: function () {
  118755. return this._rayToWorld;
  118756. },
  118757. enumerable: true,
  118758. configurable: true
  118759. });
  118760. /**
  118761. * Sets the hit data (normal & point in world space)
  118762. * @param hitNormalWorld defines the normal in world space
  118763. * @param hitPointWorld defines the point in world space
  118764. */
  118765. PhysicsRaycastResult.prototype.setHitData = function (hitNormalWorld, hitPointWorld) {
  118766. this._hasHit = true;
  118767. this._hitNormalWorld = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](hitNormalWorld.x, hitNormalWorld.y, hitNormalWorld.z);
  118768. this._hitPointWorld = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](hitPointWorld.x, hitPointWorld.y, hitPointWorld.z);
  118769. };
  118770. /**
  118771. * Sets the distance from the start point to the hit point
  118772. * @param distance
  118773. */
  118774. PhysicsRaycastResult.prototype.setHitDistance = function (distance) {
  118775. this._hitDistance = distance;
  118776. };
  118777. /**
  118778. * Calculates the distance manually
  118779. */
  118780. PhysicsRaycastResult.prototype.calculateHitDistance = function () {
  118781. this._hitDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._rayFromWorld, this._hitPointWorld);
  118782. };
  118783. /**
  118784. * Resets all the values to default
  118785. * @param from The from point on world space
  118786. * @param to The to point on world space
  118787. */
  118788. PhysicsRaycastResult.prototype.reset = function (from, to) {
  118789. if (from === void 0) { from = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  118790. if (to === void 0) { to = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  118791. this._rayFromWorld = from;
  118792. this._rayToWorld = to;
  118793. this._hasHit = false;
  118794. this._hitDistance = 0;
  118795. this._hitNormalWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  118796. this._hitPointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  118797. };
  118798. return PhysicsRaycastResult;
  118799. }());
  118800. /***/ }),
  118801. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  118802. /*!****************************************************************************!*\
  118803. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  118804. \****************************************************************************/
  118805. /*! exports provided: DefaultRenderingPipeline */
  118806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118807. "use strict";
  118808. __webpack_require__.r(__webpack_exports__);
  118809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  118810. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118811. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  118812. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  118813. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118814. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  118815. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  118816. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  118817. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  118818. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  118819. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  118820. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  118821. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  118822. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  118823. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  118824. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  118825. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  118826. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  118827. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  118828. /**
  118829. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  118830. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118831. */
  118832. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  118833. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  118834. /**
  118835. * @constructor
  118836. * @param name - The rendering pipeline name (default: "")
  118837. * @param hdr - If high dynamic range textures should be used (default: true)
  118838. * @param scene - The scene linked to this pipeline (default: the last created scene)
  118839. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  118840. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  118841. */
  118842. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  118843. if (name === void 0) { name = ""; }
  118844. if (hdr === void 0) { hdr = true; }
  118845. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  118846. if (automaticBuild === void 0) { automaticBuild = true; }
  118847. var _this = _super.call(this, scene.getEngine(), name) || this;
  118848. _this._camerasToBeAttached = [];
  118849. /**
  118850. * ID of the sharpen post process,
  118851. */
  118852. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  118853. /**
  118854. * @ignore
  118855. * ID of the image processing post process;
  118856. */
  118857. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  118858. /**
  118859. * @ignore
  118860. * ID of the Fast Approximate Anti-Aliasing post process;
  118861. */
  118862. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  118863. /**
  118864. * ID of the chromatic aberration post process,
  118865. */
  118866. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  118867. /**
  118868. * ID of the grain post process
  118869. */
  118870. _this.GrainPostProcessId = "GrainPostProcessEffect";
  118871. /**
  118872. * Glow post process which adds a glow to emissive areas of the image
  118873. */
  118874. _this._glowLayer = null;
  118875. /**
  118876. * Animations which can be used to tweak settings over a period of time
  118877. */
  118878. _this.animations = [];
  118879. _this._imageProcessingConfigurationObserver = null;
  118880. // Values
  118881. _this._sharpenEnabled = false;
  118882. _this._bloomEnabled = false;
  118883. _this._depthOfFieldEnabled = false;
  118884. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  118885. _this._fxaaEnabled = false;
  118886. _this._imageProcessingEnabled = true;
  118887. _this._bloomScale = 0.5;
  118888. _this._chromaticAberrationEnabled = false;
  118889. _this._grainEnabled = false;
  118890. _this._buildAllowed = true;
  118891. _this._resizeObserver = null;
  118892. _this._hardwareScaleLevel = 1.0;
  118893. _this._bloomKernel = 64;
  118894. /**
  118895. * Specifies the weight of the bloom in the final rendering
  118896. */
  118897. _this._bloomWeight = 0.15;
  118898. /**
  118899. * Specifies the luma threshold for the area that will be blurred by the bloom
  118900. */
  118901. _this._bloomThreshold = 0.9;
  118902. _this._samples = 1;
  118903. _this._hasCleared = false;
  118904. _this._prevPostProcess = null;
  118905. _this._prevPrevPostProcess = null;
  118906. _this._depthOfFieldSceneObserver = null;
  118907. _this._cameras = cameras || scene.cameras;
  118908. _this._cameras = _this._cameras.slice();
  118909. _this._camerasToBeAttached = _this._cameras.slice();
  118910. _this._buildAllowed = automaticBuild;
  118911. // Initialize
  118912. _this._scene = scene;
  118913. var caps = _this._scene.getEngine().getCaps();
  118914. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  118915. // Misc
  118916. if (_this._hdr) {
  118917. if (caps.textureHalfFloatRender) {
  118918. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  118919. }
  118920. else if (caps.textureFloatRender) {
  118921. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  118922. }
  118923. }
  118924. else {
  118925. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  118926. }
  118927. // Attach
  118928. scene.postProcessRenderPipelineManager.addPipeline(_this);
  118929. var engine = _this._scene.getEngine();
  118930. // Create post processes before hand so they can be modified before enabled.
  118931. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  118932. _this.sharpen = new _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__["SharpenPostProcess"]("sharpen", 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, _this._defaultPipelineTextureType, true);
  118933. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  118934. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  118935. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  118936. _this.chromaticAberration = new _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__["ChromaticAberrationPostProcess"]("ChromaticAberration", engine.getRenderWidth(), engine.getRenderHeight(), 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, _this._defaultPipelineTextureType, true);
  118937. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  118938. _this.grain = new _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__["GrainPostProcess"]("Grain", 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, _this._defaultPipelineTextureType, true);
  118939. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  118940. _this._resizeObserver = engine.onResizeObservable.add(function () {
  118941. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  118942. _this.bloomKernel = _this.bloomKernel;
  118943. });
  118944. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  118945. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  118946. });
  118947. _this._buildPipeline();
  118948. return _this;
  118949. }
  118950. Object.defineProperty(DefaultRenderingPipeline.prototype, "scene", {
  118951. /**
  118952. * Gets active scene
  118953. */
  118954. get: function () {
  118955. return this._scene;
  118956. },
  118957. enumerable: true,
  118958. configurable: true
  118959. });
  118960. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  118961. get: function () {
  118962. return this._sharpenEnabled;
  118963. },
  118964. /**
  118965. * Enable or disable the sharpen process from the pipeline
  118966. */
  118967. set: function (enabled) {
  118968. if (this._sharpenEnabled === enabled) {
  118969. return;
  118970. }
  118971. this._sharpenEnabled = enabled;
  118972. this._buildPipeline();
  118973. },
  118974. enumerable: true,
  118975. configurable: true
  118976. });
  118977. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  118978. /**
  118979. * Specifies the size of the bloom blur kernel, relative to the final output size
  118980. */
  118981. get: function () {
  118982. return this._bloomKernel;
  118983. },
  118984. set: function (value) {
  118985. this._bloomKernel = value;
  118986. this.bloom.kernel = value / this._hardwareScaleLevel;
  118987. },
  118988. enumerable: true,
  118989. configurable: true
  118990. });
  118991. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  118992. get: function () {
  118993. return this._bloomWeight;
  118994. },
  118995. /**
  118996. * The strength of the bloom.
  118997. */
  118998. set: function (value) {
  118999. if (this._bloomWeight === value) {
  119000. return;
  119001. }
  119002. this.bloom.weight = value;
  119003. this._bloomWeight = value;
  119004. },
  119005. enumerable: true,
  119006. configurable: true
  119007. });
  119008. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  119009. get: function () {
  119010. return this._bloomThreshold;
  119011. },
  119012. /**
  119013. * The strength of the bloom.
  119014. */
  119015. set: function (value) {
  119016. if (this._bloomThreshold === value) {
  119017. return;
  119018. }
  119019. this.bloom.threshold = value;
  119020. this._bloomThreshold = value;
  119021. },
  119022. enumerable: true,
  119023. configurable: true
  119024. });
  119025. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  119026. get: function () {
  119027. return this._bloomScale;
  119028. },
  119029. /**
  119030. * The scale of the bloom, lower value will provide better performance.
  119031. */
  119032. set: function (value) {
  119033. if (this._bloomScale === value) {
  119034. return;
  119035. }
  119036. this._bloomScale = value;
  119037. // recreate bloom and dispose old as this setting is not dynamic
  119038. this._rebuildBloom();
  119039. this._buildPipeline();
  119040. },
  119041. enumerable: true,
  119042. configurable: true
  119043. });
  119044. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  119045. get: function () {
  119046. return this._bloomEnabled;
  119047. },
  119048. /**
  119049. * Enable or disable the bloom from the pipeline
  119050. */
  119051. set: function (enabled) {
  119052. if (this._bloomEnabled === enabled) {
  119053. return;
  119054. }
  119055. this._bloomEnabled = enabled;
  119056. this._buildPipeline();
  119057. },
  119058. enumerable: true,
  119059. configurable: true
  119060. });
  119061. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  119062. // recreate bloom and dispose old as this setting is not dynamic
  119063. var oldBloom = this.bloom;
  119064. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  119065. this.bloom.threshold = oldBloom.threshold;
  119066. for (var i = 0; i < this._cameras.length; i++) {
  119067. oldBloom.disposeEffects(this._cameras[i]);
  119068. }
  119069. };
  119070. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  119071. /**
  119072. * If the depth of field is enabled.
  119073. */
  119074. get: function () {
  119075. return this._depthOfFieldEnabled;
  119076. },
  119077. set: function (enabled) {
  119078. if (this._depthOfFieldEnabled === enabled) {
  119079. return;
  119080. }
  119081. this._depthOfFieldEnabled = enabled;
  119082. this._buildPipeline();
  119083. },
  119084. enumerable: true,
  119085. configurable: true
  119086. });
  119087. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  119088. /**
  119089. * Blur level of the depth of field effect. (Higher blur will effect performance)
  119090. */
  119091. get: function () {
  119092. return this._depthOfFieldBlurLevel;
  119093. },
  119094. set: function (value) {
  119095. if (this._depthOfFieldBlurLevel === value) {
  119096. return;
  119097. }
  119098. this._depthOfFieldBlurLevel = value;
  119099. // recreate dof and dispose old as this setting is not dynamic
  119100. var oldDof = this.depthOfField;
  119101. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  119102. this.depthOfField.focalLength = oldDof.focalLength;
  119103. this.depthOfField.focusDistance = oldDof.focusDistance;
  119104. this.depthOfField.fStop = oldDof.fStop;
  119105. this.depthOfField.lensSize = oldDof.lensSize;
  119106. for (var i = 0; i < this._cameras.length; i++) {
  119107. oldDof.disposeEffects(this._cameras[i]);
  119108. }
  119109. this._buildPipeline();
  119110. },
  119111. enumerable: true,
  119112. configurable: true
  119113. });
  119114. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  119115. get: function () {
  119116. return this._fxaaEnabled;
  119117. },
  119118. /**
  119119. * If the anti aliasing is enabled.
  119120. */
  119121. set: function (enabled) {
  119122. if (this._fxaaEnabled === enabled) {
  119123. return;
  119124. }
  119125. this._fxaaEnabled = enabled;
  119126. this._buildPipeline();
  119127. },
  119128. enumerable: true,
  119129. configurable: true
  119130. });
  119131. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  119132. get: function () {
  119133. return this._samples;
  119134. },
  119135. /**
  119136. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119137. */
  119138. set: function (sampleCount) {
  119139. if (this._samples === sampleCount) {
  119140. return;
  119141. }
  119142. this._samples = sampleCount;
  119143. this._buildPipeline();
  119144. },
  119145. enumerable: true,
  119146. configurable: true
  119147. });
  119148. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  119149. get: function () {
  119150. return this._imageProcessingEnabled;
  119151. },
  119152. /**
  119153. * If image processing is enabled.
  119154. */
  119155. set: function (enabled) {
  119156. if (this._imageProcessingEnabled === enabled) {
  119157. return;
  119158. }
  119159. this._imageProcessingEnabled = enabled;
  119160. this._buildPipeline();
  119161. },
  119162. enumerable: true,
  119163. configurable: true
  119164. });
  119165. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  119166. get: function () {
  119167. return this._glowLayer != null;
  119168. },
  119169. /**
  119170. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  119171. */
  119172. set: function (enabled) {
  119173. if (enabled && !this._glowLayer) {
  119174. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  119175. }
  119176. else if (!enabled && this._glowLayer) {
  119177. this._glowLayer.dispose();
  119178. this._glowLayer = null;
  119179. }
  119180. },
  119181. enumerable: true,
  119182. configurable: true
  119183. });
  119184. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  119185. get: function () {
  119186. return this._chromaticAberrationEnabled;
  119187. },
  119188. /**
  119189. * Enable or disable the chromaticAberration process from the pipeline
  119190. */
  119191. set: function (enabled) {
  119192. if (this._chromaticAberrationEnabled === enabled) {
  119193. return;
  119194. }
  119195. this._chromaticAberrationEnabled = enabled;
  119196. this._buildPipeline();
  119197. },
  119198. enumerable: true,
  119199. configurable: true
  119200. });
  119201. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  119202. get: function () {
  119203. return this._grainEnabled;
  119204. },
  119205. /**
  119206. * Enable or disable the grain process from the pipeline
  119207. */
  119208. set: function (enabled) {
  119209. if (this._grainEnabled === enabled) {
  119210. return;
  119211. }
  119212. this._grainEnabled = enabled;
  119213. this._buildPipeline();
  119214. },
  119215. enumerable: true,
  119216. configurable: true
  119217. });
  119218. /**
  119219. * Get the class name
  119220. * @returns "DefaultRenderingPipeline"
  119221. */
  119222. DefaultRenderingPipeline.prototype.getClassName = function () {
  119223. return "DefaultRenderingPipeline";
  119224. };
  119225. /**
  119226. * Force the compilation of the entire pipeline.
  119227. */
  119228. DefaultRenderingPipeline.prototype.prepare = function () {
  119229. var previousState = this._buildAllowed;
  119230. this._buildAllowed = true;
  119231. this._buildPipeline();
  119232. this._buildAllowed = previousState;
  119233. };
  119234. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  119235. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  119236. if (this._hasCleared) {
  119237. postProcess.autoClear = false;
  119238. }
  119239. else {
  119240. postProcess.autoClear = true;
  119241. this._scene.autoClear = false;
  119242. this._hasCleared = true;
  119243. }
  119244. if (!skipTextureSharing) {
  119245. if (this._prevPrevPostProcess) {
  119246. postProcess.shareOutputWith(this._prevPrevPostProcess);
  119247. }
  119248. else {
  119249. postProcess.useOwnOutput();
  119250. }
  119251. if (this._prevPostProcess) {
  119252. this._prevPrevPostProcess = this._prevPostProcess;
  119253. }
  119254. this._prevPostProcess = postProcess;
  119255. }
  119256. };
  119257. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  119258. var _this = this;
  119259. if (!this._buildAllowed) {
  119260. return;
  119261. }
  119262. this._scene.autoClear = true;
  119263. var engine = this._scene.getEngine();
  119264. this._disposePostProcesses();
  119265. if (this._cameras !== null) {
  119266. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  119267. // get back cameras to be used to reattach pipeline
  119268. this._cameras = this._camerasToBeAttached.slice();
  119269. }
  119270. this._reset();
  119271. this._prevPostProcess = null;
  119272. this._prevPrevPostProcess = null;
  119273. this._hasCleared = false;
  119274. if (this.depthOfFieldEnabled) {
  119275. // Multi camera suport
  119276. if (this._cameras.length > 1) {
  119277. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  119278. var camera = _a[_i];
  119279. var depthRenderer = this._scene.enableDepthRenderer(camera);
  119280. depthRenderer.useOnlyInActiveCamera = true;
  119281. }
  119282. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  119283. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  119284. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  119285. }
  119286. });
  119287. }
  119288. else {
  119289. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  119290. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  119291. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  119292. }
  119293. if (!this.depthOfField._isReady()) {
  119294. this.depthOfField._updateEffects();
  119295. }
  119296. this.addEffect(this.depthOfField);
  119297. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  119298. }
  119299. else {
  119300. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  119301. }
  119302. if (this.bloomEnabled) {
  119303. if (!this.bloom._isReady()) {
  119304. this.bloom._updateEffects();
  119305. }
  119306. this.addEffect(this.bloom);
  119307. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  119308. }
  119309. if (this._imageProcessingEnabled) {
  119310. this.imageProcessing = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__["ImageProcessingPostProcess"]("imageProcessing", 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
  119311. if (this._hdr) {
  119312. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  119313. this._setAutoClearAndTextureSharing(this.imageProcessing);
  119314. }
  119315. else {
  119316. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  119317. }
  119318. }
  119319. if (this.sharpenEnabled) {
  119320. if (!this.sharpen.isReady()) {
  119321. this.sharpen.updateEffect();
  119322. }
  119323. this.addEffect(this._sharpenEffect);
  119324. this._setAutoClearAndTextureSharing(this.sharpen);
  119325. }
  119326. if (this.grainEnabled) {
  119327. if (!this.grain.isReady()) {
  119328. this.grain.updateEffect();
  119329. }
  119330. this.addEffect(this._grainEffect);
  119331. this._setAutoClearAndTextureSharing(this.grain);
  119332. }
  119333. if (this.chromaticAberrationEnabled) {
  119334. if (!this.chromaticAberration.isReady()) {
  119335. this.chromaticAberration.updateEffect();
  119336. }
  119337. this.addEffect(this._chromaticAberrationEffect);
  119338. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  119339. }
  119340. if (this.fxaaEnabled) {
  119341. this.fxaa = new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__["FxaaPostProcess"]("fxaa", 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
  119342. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  119343. this._setAutoClearAndTextureSharing(this.fxaa, true);
  119344. }
  119345. if (this._cameras !== null) {
  119346. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  119347. }
  119348. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  119349. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  119350. }
  119351. };
  119352. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  119353. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  119354. for (var i = 0; i < this._cameras.length; i++) {
  119355. var camera = this._cameras[i];
  119356. if (this.imageProcessing) {
  119357. this.imageProcessing.dispose(camera);
  119358. }
  119359. if (this.fxaa) {
  119360. this.fxaa.dispose(camera);
  119361. }
  119362. // These are created in the constructor and should not be disposed on every pipeline change
  119363. if (disposeNonRecreated) {
  119364. if (this.sharpen) {
  119365. this.sharpen.dispose(camera);
  119366. }
  119367. if (this.depthOfField) {
  119368. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  119369. this.depthOfField.disposeEffects(camera);
  119370. }
  119371. if (this.bloom) {
  119372. this.bloom.disposeEffects(camera);
  119373. }
  119374. if (this.chromaticAberration) {
  119375. this.chromaticAberration.dispose(camera);
  119376. }
  119377. if (this.grain) {
  119378. this.grain.dispose(camera);
  119379. }
  119380. if (this._glowLayer) {
  119381. this._glowLayer.dispose();
  119382. }
  119383. }
  119384. }
  119385. this.imageProcessing = null;
  119386. this.fxaa = null;
  119387. if (disposeNonRecreated) {
  119388. this.sharpen = null;
  119389. this._sharpenEffect = null;
  119390. this.depthOfField = null;
  119391. this.bloom = null;
  119392. this.chromaticAberration = null;
  119393. this._chromaticAberrationEffect = null;
  119394. this.grain = null;
  119395. this._grainEffect = null;
  119396. this._glowLayer = null;
  119397. }
  119398. };
  119399. /**
  119400. * Adds a camera to the pipeline
  119401. * @param camera the camera to be added
  119402. */
  119403. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  119404. this._camerasToBeAttached.push(camera);
  119405. this._buildPipeline();
  119406. };
  119407. /**
  119408. * Removes a camera from the pipeline
  119409. * @param camera the camera to remove
  119410. */
  119411. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  119412. var index = this._camerasToBeAttached.indexOf(camera);
  119413. this._camerasToBeAttached.splice(index, 1);
  119414. this._buildPipeline();
  119415. };
  119416. /**
  119417. * Dispose of the pipeline and stop all post processes
  119418. */
  119419. DefaultRenderingPipeline.prototype.dispose = function () {
  119420. this._disposePostProcesses(true);
  119421. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  119422. this._scene.autoClear = true;
  119423. if (this._resizeObserver) {
  119424. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  119425. this._resizeObserver = null;
  119426. }
  119427. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  119428. _super.prototype.dispose.call(this);
  119429. };
  119430. /**
  119431. * Serialize the rendering pipeline (Used when exporting)
  119432. * @returns the serialized object
  119433. */
  119434. DefaultRenderingPipeline.prototype.serialize = function () {
  119435. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  119436. serializationObject.customType = "DefaultRenderingPipeline";
  119437. return serializationObject;
  119438. };
  119439. /**
  119440. * Parse the serialized pipeline
  119441. * @param source Source pipeline.
  119442. * @param scene The scene to load the pipeline to.
  119443. * @param rootUrl The URL of the serialized pipeline.
  119444. * @returns An instantiated pipeline from the serialized object.
  119445. */
  119446. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  119447. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  119448. };
  119449. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119450. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119451. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  119452. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119453. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119454. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  119455. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119456. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119457. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  119458. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119459. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119460. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  119461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119463. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  119464. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119465. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119466. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  119467. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119468. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119469. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  119470. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119471. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119472. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  119473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119475. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  119476. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119477. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119478. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  119479. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119480. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119481. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  119482. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119483. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119484. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  119485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119486. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119487. ], DefaultRenderingPipeline.prototype, "samples", null);
  119488. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119489. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119490. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  119491. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119492. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119493. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  119494. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119495. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119496. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  119497. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119498. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119499. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  119500. return DefaultRenderingPipeline;
  119501. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  119502. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  119503. /***/ }),
  119504. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  119505. /*!*********************************************************!*\
  119506. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  119507. \*********************************************************/
  119508. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  119509. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119510. "use strict";
  119511. __webpack_require__.r(__webpack_exports__);
  119512. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  119513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  119514. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  119515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  119516. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  119517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  119518. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  119519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  119520. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  119521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  119522. /***/ }),
  119523. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  119524. /*!*************************************************************************!*\
  119525. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  119526. \*************************************************************************/
  119527. /*! exports provided: LensRenderingPipeline */
  119528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119529. "use strict";
  119530. __webpack_require__.r(__webpack_exports__);
  119531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  119532. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119533. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119534. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  119535. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  119536. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  119537. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  119538. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  119539. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  119540. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  119541. /**
  119542. * BABYLON.JS Chromatic Aberration GLSL Shader
  119543. * Author: Olivier Guyot
  119544. * Separates very slightly R, G and B colors on the edges of the screen
  119545. * Inspired by Francois Tarlier & Martins Upitis
  119546. */
  119547. var LensRenderingPipeline = /** @class */ (function (_super) {
  119548. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  119549. /**
  119550. * @constructor
  119551. *
  119552. * Effect parameters are as follow:
  119553. * {
  119554. * chromatic_aberration: number; // from 0 to x (1 for realism)
  119555. * edge_blur: number; // from 0 to x (1 for realism)
  119556. * distortion: number; // from 0 to x (1 for realism)
  119557. * grain_amount: number; // from 0 to 1
  119558. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  119559. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  119560. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  119561. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  119562. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  119563. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  119564. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  119565. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  119566. * }
  119567. * Note: if an effect parameter is unset, effect is disabled
  119568. *
  119569. * @param name The rendering pipeline name
  119570. * @param parameters - An object containing all parameters (see above)
  119571. * @param scene The scene linked to this pipeline
  119572. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  119573. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119574. */
  119575. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  119576. if (ratio === void 0) { ratio = 1.0; }
  119577. var _this = _super.call(this, scene.getEngine(), name) || this;
  119578. // Lens effects can be of the following:
  119579. // - chromatic aberration (slight shift of RGB colors)
  119580. // - blur on the edge of the lens
  119581. // - lens distortion
  119582. // - depth-of-field blur & highlights enhancing
  119583. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  119584. // - grain effect (noise or custom texture)
  119585. // Two additional texture samplers are needed:
  119586. // - depth map (for depth-of-field)
  119587. // - grain texture
  119588. /**
  119589. * @ignore
  119590. * The chromatic aberration PostProcess id in the pipeline
  119591. */
  119592. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  119593. /**
  119594. * @ignore
  119595. * The highlights enhancing PostProcess id in the pipeline
  119596. */
  119597. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  119598. /**
  119599. * @ignore
  119600. * The depth-of-field PostProcess id in the pipeline
  119601. */
  119602. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  119603. _this._pentagonBokehIsEnabled = false;
  119604. _this._scene = scene;
  119605. // Fetch texture samplers
  119606. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  119607. if (parameters.grain_texture) {
  119608. _this._grainTexture = parameters.grain_texture;
  119609. }
  119610. else {
  119611. _this._createGrainTexture();
  119612. }
  119613. // save parameters
  119614. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  119615. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  119616. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  119617. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  119618. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  119619. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  119620. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  119621. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  119622. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  119623. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  119624. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  119625. // Create effects
  119626. _this._createChromaticAberrationPostProcess(ratio);
  119627. _this._createHighlightsPostProcess(ratio);
  119628. _this._createDepthOfFieldPostProcess(ratio / 4);
  119629. // Set up pipeline
  119630. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  119631. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  119632. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  119633. if (_this._highlightsGain === -1) {
  119634. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  119635. }
  119636. // Finish
  119637. scene.postProcessRenderPipelineManager.addPipeline(_this);
  119638. if (cameras) {
  119639. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  119640. }
  119641. return _this;
  119642. }
  119643. /**
  119644. * Get the class name
  119645. * @returns "LensRenderingPipeline"
  119646. */
  119647. LensRenderingPipeline.prototype.getClassName = function () {
  119648. return "LensRenderingPipeline";
  119649. };
  119650. Object.defineProperty(LensRenderingPipeline.prototype, "scene", {
  119651. // Properties
  119652. /**
  119653. * Gets associated scene
  119654. */
  119655. get: function () {
  119656. return this._scene;
  119657. },
  119658. enumerable: true,
  119659. configurable: true
  119660. });
  119661. Object.defineProperty(LensRenderingPipeline.prototype, "edgeBlur", {
  119662. /**
  119663. * Gets or sets the edge blur
  119664. */
  119665. get: function () {
  119666. return this._edgeBlur;
  119667. },
  119668. set: function (value) {
  119669. this.setEdgeBlur(value);
  119670. },
  119671. enumerable: true,
  119672. configurable: true
  119673. });
  119674. Object.defineProperty(LensRenderingPipeline.prototype, "grainAmount", {
  119675. /**
  119676. * Gets or sets the grain amount
  119677. */
  119678. get: function () {
  119679. return this._grainAmount;
  119680. },
  119681. set: function (value) {
  119682. this.setGrainAmount(value);
  119683. },
  119684. enumerable: true,
  119685. configurable: true
  119686. });
  119687. Object.defineProperty(LensRenderingPipeline.prototype, "chromaticAberration", {
  119688. /**
  119689. * Gets or sets the chromatic aberration amount
  119690. */
  119691. get: function () {
  119692. return this._chromaticAberration;
  119693. },
  119694. set: function (value) {
  119695. this.setChromaticAberration(value);
  119696. },
  119697. enumerable: true,
  119698. configurable: true
  119699. });
  119700. Object.defineProperty(LensRenderingPipeline.prototype, "dofAperture", {
  119701. /**
  119702. * Gets or sets the depth of field aperture
  119703. */
  119704. get: function () {
  119705. return this._dofAperture;
  119706. },
  119707. set: function (value) {
  119708. this.setAperture(value);
  119709. },
  119710. enumerable: true,
  119711. configurable: true
  119712. });
  119713. Object.defineProperty(LensRenderingPipeline.prototype, "edgeDistortion", {
  119714. /**
  119715. * Gets or sets the edge distortion
  119716. */
  119717. get: function () {
  119718. return this._distortion;
  119719. },
  119720. set: function (value) {
  119721. this.setEdgeDistortion(value);
  119722. },
  119723. enumerable: true,
  119724. configurable: true
  119725. });
  119726. Object.defineProperty(LensRenderingPipeline.prototype, "dofDistortion", {
  119727. /**
  119728. * Gets or sets the depth of field distortion
  119729. */
  119730. get: function () {
  119731. return this._dofDistance;
  119732. },
  119733. set: function (value) {
  119734. this.setFocusDistance(value);
  119735. },
  119736. enumerable: true,
  119737. configurable: true
  119738. });
  119739. Object.defineProperty(LensRenderingPipeline.prototype, "darkenOutOfFocus", {
  119740. /**
  119741. * Gets or sets the darken out of focus amount
  119742. */
  119743. get: function () {
  119744. return this._dofDarken;
  119745. },
  119746. set: function (value) {
  119747. this.setDarkenOutOfFocus(value);
  119748. },
  119749. enumerable: true,
  119750. configurable: true
  119751. });
  119752. Object.defineProperty(LensRenderingPipeline.prototype, "blurNoise", {
  119753. /**
  119754. * Gets or sets a boolean indicating if blur noise is enabled
  119755. */
  119756. get: function () {
  119757. return this._blurNoise;
  119758. },
  119759. set: function (value) {
  119760. this._blurNoise = value;
  119761. },
  119762. enumerable: true,
  119763. configurable: true
  119764. });
  119765. Object.defineProperty(LensRenderingPipeline.prototype, "pentagonBokeh", {
  119766. /**
  119767. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  119768. */
  119769. get: function () {
  119770. return this._pentagonBokehIsEnabled;
  119771. },
  119772. set: function (value) {
  119773. if (value) {
  119774. this.enablePentagonBokeh();
  119775. }
  119776. else {
  119777. this.disablePentagonBokeh();
  119778. }
  119779. },
  119780. enumerable: true,
  119781. configurable: true
  119782. });
  119783. Object.defineProperty(LensRenderingPipeline.prototype, "highlightsGain", {
  119784. /**
  119785. * Gets or sets the highlight grain amount
  119786. */
  119787. get: function () {
  119788. return this._highlightsGain;
  119789. },
  119790. set: function (value) {
  119791. this.setHighlightsGain(value);
  119792. },
  119793. enumerable: true,
  119794. configurable: true
  119795. });
  119796. Object.defineProperty(LensRenderingPipeline.prototype, "highlightsThreshold", {
  119797. /**
  119798. * Gets or sets the highlight threshold
  119799. */
  119800. get: function () {
  119801. return this._highlightsThreshold;
  119802. },
  119803. set: function (value) {
  119804. this.setHighlightsThreshold(value);
  119805. },
  119806. enumerable: true,
  119807. configurable: true
  119808. });
  119809. // public methods (self explanatory)
  119810. /**
  119811. * Sets the amount of blur at the edges
  119812. * @param amount blur amount
  119813. */
  119814. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  119815. /**
  119816. * Sets edge blur to 0
  119817. */
  119818. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  119819. /**
  119820. * Sets the amout of grain
  119821. * @param amount Amount of grain
  119822. */
  119823. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  119824. /**
  119825. * Set grain amount to 0
  119826. */
  119827. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  119828. /**
  119829. * Sets the chromatic aberration amount
  119830. * @param amount amount of chromatic aberration
  119831. */
  119832. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  119833. /**
  119834. * Sets chromatic aberration amount to 0
  119835. */
  119836. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  119837. /**
  119838. * Sets the EdgeDistortion amount
  119839. * @param amount amount of EdgeDistortion
  119840. */
  119841. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  119842. /**
  119843. * Sets edge distortion to 0
  119844. */
  119845. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  119846. /**
  119847. * Sets the FocusDistance amount
  119848. * @param amount amount of FocusDistance
  119849. */
  119850. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  119851. /**
  119852. * Disables depth of field
  119853. */
  119854. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  119855. /**
  119856. * Sets the Aperture amount
  119857. * @param amount amount of Aperture
  119858. */
  119859. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  119860. /**
  119861. * Sets the DarkenOutOfFocus amount
  119862. * @param amount amount of DarkenOutOfFocus
  119863. */
  119864. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  119865. /**
  119866. * Creates a pentagon bokeh effect
  119867. */
  119868. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  119869. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  119870. this._pentagonBokehIsEnabled = true;
  119871. };
  119872. /**
  119873. * Disables the pentagon bokeh effect
  119874. */
  119875. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  119876. this._pentagonBokehIsEnabled = false;
  119877. this._highlightsPostProcess.updateEffect();
  119878. };
  119879. /**
  119880. * Enables noise blur
  119881. */
  119882. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  119883. /**
  119884. * Disables noise blur
  119885. */
  119886. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  119887. /**
  119888. * Sets the HighlightsGain amount
  119889. * @param amount amount of HighlightsGain
  119890. */
  119891. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  119892. this._highlightsGain = amount;
  119893. };
  119894. /**
  119895. * Sets the HighlightsThreshold amount
  119896. * @param amount amount of HighlightsThreshold
  119897. */
  119898. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  119899. if (this._highlightsGain === -1) {
  119900. this._highlightsGain = 1.0;
  119901. }
  119902. this._highlightsThreshold = amount;
  119903. };
  119904. /**
  119905. * Disables highlights
  119906. */
  119907. LensRenderingPipeline.prototype.disableHighlights = function () {
  119908. this._highlightsGain = -1;
  119909. };
  119910. /**
  119911. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  119912. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  119913. */
  119914. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  119915. if (disableDepthRender === void 0) { disableDepthRender = false; }
  119916. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  119917. this._chromaticAberrationPostProcess = null;
  119918. this._highlightsPostProcess = null;
  119919. this._depthOfFieldPostProcess = null;
  119920. this._grainTexture.dispose();
  119921. if (disableDepthRender) {
  119922. this._scene.disableDepthRenderer();
  119923. }
  119924. };
  119925. // colors shifting and distortion
  119926. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  119927. var _this = this;
  119928. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  119929. [], // samplers
  119930. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  119931. this._chromaticAberrationPostProcess.onApply = function (effect) {
  119932. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  119933. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  119934. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  119935. effect.setFloat('radialIntensity', 1);
  119936. effect.setFloat2('direction', 17, 17);
  119937. effect.setFloat2('centerPosition', 0.5, 0.5);
  119938. };
  119939. };
  119940. // highlights enhancing
  119941. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  119942. var _this = this;
  119943. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  119944. [], // samplers
  119945. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  119946. this._highlightsPostProcess.onApply = function (effect) {
  119947. effect.setFloat('gain', _this._highlightsGain);
  119948. effect.setFloat('threshold', _this._highlightsThreshold);
  119949. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  119950. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  119951. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  119952. };
  119953. };
  119954. // colors shifting and distortion
  119955. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  119956. var _this = this;
  119957. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  119958. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  119959. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  119960. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  119961. this._depthOfFieldPostProcess.onApply = function (effect) {
  119962. effect.setTexture("depthSampler", _this._depthTexture);
  119963. effect.setTexture("grainSampler", _this._grainTexture);
  119964. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  119965. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  119966. effect.setFloat('grain_amount', _this._grainAmount);
  119967. effect.setBool('blur_noise', _this._blurNoise);
  119968. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  119969. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  119970. effect.setFloat('distortion', _this._distortion);
  119971. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  119972. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  119973. effect.setFloat('aperture', _this._dofAperture);
  119974. effect.setFloat('darken', _this._dofDarken);
  119975. effect.setFloat('edge_blur', _this._edgeBlur);
  119976. effect.setBool('highlights', (_this._highlightsGain !== -1));
  119977. if (_this._scene.activeCamera) {
  119978. effect.setFloat('near', _this._scene.activeCamera.minZ);
  119979. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  119980. }
  119981. };
  119982. };
  119983. // creates a black and white random noise texture, 512x512
  119984. LensRenderingPipeline.prototype._createGrainTexture = function () {
  119985. var size = 512;
  119986. this._grainTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__["DynamicTexture"]("LensNoiseTexture", size, this._scene, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  119987. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  119988. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  119989. var context = this._grainTexture.getContext();
  119990. var rand = function (min, max) {
  119991. return Math.random() * (max - min) + min;
  119992. };
  119993. var value;
  119994. for (var x = 0; x < size; x++) {
  119995. for (var y = 0; y < size; y++) {
  119996. value = Math.floor(rand(0.42, 0.58) * 255);
  119997. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  119998. context.fillRect(x, y, 1, 1);
  119999. }
  120000. }
  120001. this._grainTexture.update(false);
  120002. };
  120003. return LensRenderingPipeline;
  120004. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  120005. /***/ }),
  120006. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  120007. /*!**************************************************************************!*\
  120008. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  120009. \**************************************************************************/
  120010. /*! exports provided: SSAO2RenderingPipeline */
  120011. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120012. "use strict";
  120013. __webpack_require__.r(__webpack_exports__);
  120014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  120015. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120016. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  120017. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  120018. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  120019. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120020. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  120021. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  120022. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  120023. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  120024. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  120025. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  120026. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  120027. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  120028. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  120029. /**
  120030. * Render pipeline to produce ssao effect
  120031. */
  120032. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  120033. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  120034. /**
  120035. * @constructor
  120036. * @param name The rendering pipeline name
  120037. * @param scene The scene linked to this pipeline
  120038. * @param ratio The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, blurRatio: 1.0 }
  120039. * @param cameras The array of cameras that the rendering pipeline will be attached to
  120040. */
  120041. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  120042. var _this = _super.call(this, scene.getEngine(), name) || this;
  120043. // Members
  120044. /**
  120045. * @ignore
  120046. * The PassPostProcess id in the pipeline that contains the original scene color
  120047. */
  120048. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  120049. /**
  120050. * @ignore
  120051. * The SSAO PostProcess id in the pipeline
  120052. */
  120053. _this.SSAORenderEffect = "SSAORenderEffect";
  120054. /**
  120055. * @ignore
  120056. * The horizontal blur PostProcess id in the pipeline
  120057. */
  120058. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  120059. /**
  120060. * @ignore
  120061. * The vertical blur PostProcess id in the pipeline
  120062. */
  120063. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  120064. /**
  120065. * @ignore
  120066. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  120067. */
  120068. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  120069. /**
  120070. * The output strength of the SSAO post-process. Default value is 1.0.
  120071. */
  120072. _this.totalStrength = 1.0;
  120073. /**
  120074. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  120075. */
  120076. _this.maxZ = 100.0;
  120077. /**
  120078. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  120079. */
  120080. _this.minZAspect = 0.2;
  120081. _this._samples = 8;
  120082. _this._textureSamples = 1;
  120083. _this._expensiveBlur = true;
  120084. /**
  120085. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  120086. */
  120087. _this.radius = 2.0;
  120088. /**
  120089. * The base color of the SSAO post-process
  120090. * The final result is "base + ssao" between [0, 1]
  120091. */
  120092. _this.base = 0;
  120093. _this._firstUpdate = true;
  120094. _this._bits = new Uint32Array(1);
  120095. _this._scene = scene;
  120096. _this._ratio = ratio;
  120097. if (!_this.isSupported) {
  120098. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  120099. return _this;
  120100. }
  120101. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  120102. var blurRatio = _this._ratio.blurRatio || ratio;
  120103. // Set up assets
  120104. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  120105. _this._createRandomTexture();
  120106. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  120107. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  120108. _this._originalColorPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__["PassPostProcess"]("SSAOOriginalSceneColor", 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
  120109. _this._originalColorPostProcess.samples = _this.textureSamples;
  120110. _this._createSSAOPostProcess(1.0);
  120111. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  120112. _this._createSSAOCombinePostProcess(blurRatio);
  120113. // Set up pipeline
  120114. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  120115. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  120116. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  120117. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  120118. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  120119. // Finish
  120120. scene.postProcessRenderPipelineManager.addPipeline(_this);
  120121. if (cameras) {
  120122. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  120123. }
  120124. return _this;
  120125. }
  120126. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  120127. get: function () {
  120128. return this._samples;
  120129. },
  120130. /**
  120131. * Number of samples used for the SSAO calculations. Default value is 8
  120132. */
  120133. set: function (n) {
  120134. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  120135. this._samples = n;
  120136. this._sampleSphere = this._generateHemisphere();
  120137. this._firstUpdate = true;
  120138. },
  120139. enumerable: true,
  120140. configurable: true
  120141. });
  120142. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  120143. get: function () {
  120144. return this._textureSamples;
  120145. },
  120146. /**
  120147. * Number of samples to use for antialiasing
  120148. */
  120149. set: function (n) {
  120150. this._textureSamples = n;
  120151. this._originalColorPostProcess.samples = n;
  120152. this._blurHPostProcess.samples = n;
  120153. this._blurVPostProcess.samples = n;
  120154. this._ssaoPostProcess.samples = n;
  120155. this._ssaoCombinePostProcess.samples = n;
  120156. },
  120157. enumerable: true,
  120158. configurable: true
  120159. });
  120160. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  120161. get: function () {
  120162. return this._expensiveBlur;
  120163. },
  120164. /**
  120165. * If bilateral blur should be used
  120166. */
  120167. set: function (b) {
  120168. this._blurHPostProcess.updateEffect("#define BILATERAL_BLUR\n#define BILATERAL_BLUR_H\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  120169. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  120170. this._expensiveBlur = b;
  120171. this._firstUpdate = true;
  120172. },
  120173. enumerable: true,
  120174. configurable: true
  120175. });
  120176. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  120177. /**
  120178. * Support test.
  120179. */
  120180. get: function () {
  120181. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  120182. if (!engine) {
  120183. return false;
  120184. }
  120185. return engine.getCaps().drawBuffersExtension;
  120186. },
  120187. enumerable: true,
  120188. configurable: true
  120189. });
  120190. Object.defineProperty(SSAO2RenderingPipeline.prototype, "scene", {
  120191. /**
  120192. * Gets active scene
  120193. */
  120194. get: function () {
  120195. return this._scene;
  120196. },
  120197. enumerable: true,
  120198. configurable: true
  120199. });
  120200. // Public Methods
  120201. /**
  120202. * Get the class name
  120203. * @returns "SSAO2RenderingPipeline"
  120204. */
  120205. SSAO2RenderingPipeline.prototype.getClassName = function () {
  120206. return "SSAO2RenderingPipeline";
  120207. };
  120208. /**
  120209. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  120210. */
  120211. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  120212. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  120213. for (var i = 0; i < this._scene.cameras.length; i++) {
  120214. var camera = this._scene.cameras[i];
  120215. this._originalColorPostProcess.dispose(camera);
  120216. this._ssaoPostProcess.dispose(camera);
  120217. this._blurHPostProcess.dispose(camera);
  120218. this._blurVPostProcess.dispose(camera);
  120219. this._ssaoCombinePostProcess.dispose(camera);
  120220. }
  120221. this._randomTexture.dispose();
  120222. if (disableGeometryBufferRenderer) {
  120223. this._scene.disableGeometryBufferRenderer();
  120224. }
  120225. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  120226. _super.prototype.dispose.call(this);
  120227. };
  120228. // Private Methods
  120229. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  120230. var _this = this;
  120231. this._samplerOffsets = [];
  120232. var expensive = this.expensiveBlur;
  120233. for (var i = -8; i < 8; i++) {
  120234. this._samplerOffsets.push(i * 2 + 0.5);
  120235. }
  120236. this._blurHPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("BlurH", "ssao2", ["outSize", "samplerOffsets", "near", "far", "radius"], ["depthSampler"], ssaoRatio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define BILATERAL_BLUR\n#define BILATERAL_BLUR_H\n#define SAMPLES 16\n#define EXPENSIVE " + (expensive ? "1" : "0") + "\n");
  120237. this._blurHPostProcess.onApply = function (effect) {
  120238. if (!_this._scene.activeCamera) {
  120239. return;
  120240. }
  120241. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  120242. effect.setFloat("near", _this._scene.activeCamera.minZ);
  120243. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  120244. effect.setFloat("radius", _this.radius);
  120245. effect.setTexture("depthSampler", _this._depthTexture);
  120246. if (_this._firstUpdate) {
  120247. effect.setArray("samplerOffsets", _this._samplerOffsets);
  120248. }
  120249. };
  120250. this._blurVPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("BlurV", "ssao2", ["outSize", "samplerOffsets", "near", "far", "radius"], ["depthSampler"], blurRatio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define BILATERAL_BLUR\n#define BILATERAL_BLUR_V\n#define SAMPLES 16\n#define EXPENSIVE " + (expensive ? "1" : "0") + "\n");
  120251. this._blurVPostProcess.onApply = function (effect) {
  120252. if (!_this._scene.activeCamera) {
  120253. return;
  120254. }
  120255. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  120256. effect.setFloat("near", _this._scene.activeCamera.minZ);
  120257. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  120258. effect.setFloat("radius", _this.radius);
  120259. effect.setTexture("depthSampler", _this._depthTexture);
  120260. if (_this._firstUpdate) {
  120261. effect.setArray("samplerOffsets", _this._samplerOffsets);
  120262. _this._firstUpdate = false;
  120263. }
  120264. };
  120265. this._blurHPostProcess.samples = this.textureSamples;
  120266. this._blurVPostProcess.samples = this.textureSamples;
  120267. };
  120268. /** @hidden */
  120269. SSAO2RenderingPipeline.prototype._rebuild = function () {
  120270. this._firstUpdate = true;
  120271. _super.prototype._rebuild.call(this);
  120272. };
  120273. //Van der Corput radical inverse
  120274. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  120275. this._bits[0] = i;
  120276. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  120277. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  120278. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  120279. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  120280. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  120281. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  120282. };
  120283. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  120284. return [i / n, this._radicalInverse_VdC(i)];
  120285. };
  120286. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  120287. var phi = v * 2.0 * Math.PI;
  120288. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  120289. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  120290. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  120291. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  120292. };
  120293. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  120294. var numSamples = this.samples;
  120295. var result = [];
  120296. var vector;
  120297. var i = 0;
  120298. while (i < numSamples) {
  120299. if (numSamples < 16) {
  120300. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  120301. }
  120302. else {
  120303. var rand = this._hammersley(i, numSamples);
  120304. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  120305. }
  120306. result.push(vector.x, vector.y, vector.z);
  120307. i++;
  120308. }
  120309. return result;
  120310. };
  120311. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  120312. var _this = this;
  120313. var numSamples = this.samples;
  120314. this._sampleSphere = this._generateHemisphere();
  120315. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  120316. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  120317. "base", "range", "projection", "near", "far", "texelSize",
  120318. "xViewport", "yViewport", "maxZ", "minZAspect"
  120319. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  120320. this._ssaoPostProcess.onApply = function (effect) {
  120321. if (_this._firstUpdate) {
  120322. effect.setArray3("sampleSphere", _this._sampleSphere);
  120323. effect.setFloat("randTextureTiles", 32.0);
  120324. }
  120325. if (!_this._scene.activeCamera) {
  120326. return;
  120327. }
  120328. effect.setFloat("samplesFactor", 1 / _this.samples);
  120329. effect.setFloat("totalStrength", _this.totalStrength);
  120330. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  120331. effect.setFloat("radius", _this.radius);
  120332. effect.setFloat("maxZ", _this.maxZ);
  120333. effect.setFloat("minZAspect", _this.minZAspect);
  120334. effect.setFloat("base", _this.base);
  120335. effect.setFloat("near", _this._scene.activeCamera.minZ);
  120336. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  120337. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  120338. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  120339. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  120340. effect.setTexture("textureSampler", _this._depthTexture);
  120341. effect.setTexture("normalSampler", _this._normalTexture);
  120342. effect.setTexture("randomSampler", _this._randomTexture);
  120343. };
  120344. this._ssaoPostProcess.samples = this.textureSamples;
  120345. };
  120346. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  120347. var _this = this;
  120348. this._ssaoCombinePostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssaoCombine", "ssaoCombine", [], ["originalColor", "viewport"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  120349. this._ssaoCombinePostProcess.onApply = function (effect) {
  120350. var viewport = _this._scene.activeCamera.viewport;
  120351. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  120352. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  120353. };
  120354. this._ssaoCombinePostProcess.samples = this.textureSamples;
  120355. };
  120356. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  120357. var size = 128;
  120358. this._randomTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__["DynamicTexture"]("SSAORandomTexture", size, this._scene, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE);
  120359. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  120360. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  120361. var context = this._randomTexture.getContext();
  120362. var rand = function (min, max) {
  120363. return Math.random() * (max - min) + min;
  120364. };
  120365. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  120366. for (var x = 0; x < size; x++) {
  120367. for (var y = 0; y < size; y++) {
  120368. randVector.x = rand(0.0, 1.0);
  120369. randVector.y = rand(0.0, 1.0);
  120370. randVector.z = 0.0;
  120371. randVector.normalize();
  120372. randVector.scaleInPlace(255);
  120373. randVector.x = Math.floor(randVector.x);
  120374. randVector.y = Math.floor(randVector.y);
  120375. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  120376. context.fillRect(x, y, 1, 1);
  120377. }
  120378. }
  120379. this._randomTexture.update(false);
  120380. };
  120381. /**
  120382. * Serialize the rendering pipeline (Used when exporting)
  120383. * @returns the serialized object
  120384. */
  120385. SSAO2RenderingPipeline.prototype.serialize = function () {
  120386. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  120387. serializationObject.customType = "SSAO2RenderingPipeline";
  120388. return serializationObject;
  120389. };
  120390. /**
  120391. * Parse the serialized pipeline
  120392. * @param source Source pipeline.
  120393. * @param scene The scene to load the pipeline to.
  120394. * @param rootUrl The URL of the serialized pipeline.
  120395. * @returns An instantiated pipeline from the serialized object.
  120396. */
  120397. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  120398. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  120399. };
  120400. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120401. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120402. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  120403. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120404. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120405. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  120406. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120407. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120408. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  120409. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120410. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  120411. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  120412. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120413. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  120414. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  120415. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120416. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120417. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  120418. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120419. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  120420. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  120421. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120422. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120423. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  120424. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120425. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120426. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  120427. return SSAO2RenderingPipeline;
  120428. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  120429. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  120430. /***/ }),
  120431. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  120432. /*!*************************************************************************!*\
  120433. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  120434. \*************************************************************************/
  120435. /*! exports provided: SSAORenderingPipeline */
  120436. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120437. "use strict";
  120438. __webpack_require__.r(__webpack_exports__);
  120439. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  120440. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120441. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  120442. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120443. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  120444. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  120445. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  120446. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  120447. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  120448. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  120449. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  120450. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  120451. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  120452. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  120453. /**
  120454. * Render pipeline to produce ssao effect
  120455. */
  120456. var SSAORenderingPipeline = /** @class */ (function (_super) {
  120457. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  120458. /**
  120459. * @constructor
  120460. * @param name - The rendering pipeline name
  120461. * @param scene - The scene linked to this pipeline
  120462. * @param ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, combineRatio: 1.0 }
  120463. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  120464. */
  120465. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  120466. var _this = _super.call(this, scene.getEngine(), name) || this;
  120467. // Members
  120468. /**
  120469. * @ignore
  120470. * The PassPostProcess id in the pipeline that contains the original scene color
  120471. */
  120472. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  120473. /**
  120474. * @ignore
  120475. * The SSAO PostProcess id in the pipeline
  120476. */
  120477. _this.SSAORenderEffect = "SSAORenderEffect";
  120478. /**
  120479. * @ignore
  120480. * The horizontal blur PostProcess id in the pipeline
  120481. */
  120482. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  120483. /**
  120484. * @ignore
  120485. * The vertical blur PostProcess id in the pipeline
  120486. */
  120487. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  120488. /**
  120489. * @ignore
  120490. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  120491. */
  120492. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  120493. /**
  120494. * The output strength of the SSAO post-process. Default value is 1.0.
  120495. */
  120496. _this.totalStrength = 1.0;
  120497. /**
  120498. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  120499. */
  120500. _this.radius = 0.0001;
  120501. /**
  120502. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  120503. * Must not be equal to fallOff and superior to fallOff.
  120504. * Default value is 0.0075
  120505. */
  120506. _this.area = 0.0075;
  120507. /**
  120508. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  120509. * Must not be equal to area and inferior to area.
  120510. * Default value is 0.000001
  120511. */
  120512. _this.fallOff = 0.000001;
  120513. /**
  120514. * The base color of the SSAO post-process
  120515. * The final result is "base + ssao" between [0, 1]
  120516. */
  120517. _this.base = 0.5;
  120518. _this._firstUpdate = true;
  120519. _this._scene = scene;
  120520. // Set up assets
  120521. _this._createRandomTexture();
  120522. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  120523. var ssaoRatio = ratio.ssaoRatio || ratio;
  120524. var combineRatio = ratio.combineRatio || ratio;
  120525. _this._originalColorPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__["PassPostProcess"]("SSAOOriginalSceneColor", combineRatio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
  120526. _this._createSSAOPostProcess(ssaoRatio);
  120527. _this._createBlurPostProcess(ssaoRatio);
  120528. _this._createSSAOCombinePostProcess(combineRatio);
  120529. // Set up pipeline
  120530. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  120531. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  120532. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  120533. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  120534. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  120535. // Finish
  120536. scene.postProcessRenderPipelineManager.addPipeline(_this);
  120537. if (cameras) {
  120538. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  120539. }
  120540. return _this;
  120541. }
  120542. Object.defineProperty(SSAORenderingPipeline.prototype, "scene", {
  120543. /**
  120544. * Gets active scene
  120545. */
  120546. get: function () {
  120547. return this._scene;
  120548. },
  120549. enumerable: true,
  120550. configurable: true
  120551. });
  120552. // Public Methods
  120553. /**
  120554. * Get the class name
  120555. * @returns "SSAORenderingPipeline"
  120556. */
  120557. SSAORenderingPipeline.prototype.getClassName = function () {
  120558. return "SSAORenderingPipeline";
  120559. };
  120560. /**
  120561. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  120562. */
  120563. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  120564. if (disableDepthRender === void 0) { disableDepthRender = false; }
  120565. for (var i = 0; i < this._scene.cameras.length; i++) {
  120566. var camera = this._scene.cameras[i];
  120567. this._originalColorPostProcess.dispose(camera);
  120568. this._ssaoPostProcess.dispose(camera);
  120569. this._blurHPostProcess.dispose(camera);
  120570. this._blurVPostProcess.dispose(camera);
  120571. this._ssaoCombinePostProcess.dispose(camera);
  120572. }
  120573. this._randomTexture.dispose();
  120574. if (disableDepthRender) {
  120575. this._scene.disableDepthRenderer();
  120576. }
  120577. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  120578. _super.prototype.dispose.call(this);
  120579. };
  120580. // Private Methods
  120581. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  120582. var _this = this;
  120583. var size = 16;
  120584. this._blurHPostProcess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__["BlurPostProcess"]("BlurH", new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 0), size, ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, _Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  120585. this._blurVPostProcess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__["BlurPostProcess"]("BlurV", new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 1), size, ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, _Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  120586. this._blurHPostProcess.onActivateObservable.add(function () {
  120587. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  120588. _this._blurHPostProcess.kernel = size * dw;
  120589. });
  120590. this._blurVPostProcess.onActivateObservable.add(function () {
  120591. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  120592. _this._blurVPostProcess.kernel = size * dw;
  120593. });
  120594. };
  120595. /** @hidden */
  120596. SSAORenderingPipeline.prototype._rebuild = function () {
  120597. this._firstUpdate = true;
  120598. _super.prototype._rebuild.call(this);
  120599. };
  120600. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  120601. var _this = this;
  120602. var numSamples = 16;
  120603. var sampleSphere = [
  120604. 0.5381, 0.1856, -0.4319,
  120605. 0.1379, 0.2486, 0.4430,
  120606. 0.3371, 0.5679, -0.0057,
  120607. -0.6999, -0.0451, -0.0019,
  120608. 0.0689, -0.1598, -0.8547,
  120609. 0.0560, 0.0069, -0.1843,
  120610. -0.0146, 0.1402, 0.0762,
  120611. 0.0100, -0.1924, -0.0344,
  120612. -0.3577, -0.5301, -0.4358,
  120613. -0.3169, 0.1063, 0.0158,
  120614. 0.0103, -0.5869, 0.0046,
  120615. -0.0897, -0.4940, 0.3287,
  120616. 0.7119, -0.0154, -0.0918,
  120617. -0.0533, 0.0596, -0.5411,
  120618. 0.0352, -0.0631, 0.5460,
  120619. -0.4776, 0.2847, -0.0271
  120620. ];
  120621. var samplesFactor = 1.0 / numSamples;
  120622. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  120623. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  120624. "area", "fallOff", "base", "range", "viewport"
  120625. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  120626. this._ssaoPostProcess.onApply = function (effect) {
  120627. if (_this._firstUpdate) {
  120628. effect.setArray3("sampleSphere", sampleSphere);
  120629. effect.setFloat("samplesFactor", samplesFactor);
  120630. effect.setFloat("randTextureTiles", 4.0);
  120631. }
  120632. effect.setFloat("totalStrength", _this.totalStrength);
  120633. effect.setFloat("radius", _this.radius);
  120634. effect.setFloat("area", _this.area);
  120635. effect.setFloat("fallOff", _this.fallOff);
  120636. effect.setFloat("base", _this.base);
  120637. effect.setTexture("textureSampler", _this._depthTexture);
  120638. effect.setTexture("randomSampler", _this._randomTexture);
  120639. };
  120640. };
  120641. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  120642. var _this = this;
  120643. this._ssaoCombinePostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssaoCombine", "ssaoCombine", [], ["originalColor", "viewport"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  120644. this._ssaoCombinePostProcess.onApply = function (effect) {
  120645. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  120646. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  120647. };
  120648. };
  120649. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  120650. var size = 512;
  120651. this._randomTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]("SSAORandomTexture", size, this._scene, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].TRILINEAR_SAMPLINGMODE);
  120652. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  120653. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  120654. var context = this._randomTexture.getContext();
  120655. var rand = function (min, max) {
  120656. return Math.random() * (max - min) + min;
  120657. };
  120658. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  120659. for (var x = 0; x < size; x++) {
  120660. for (var y = 0; y < size; y++) {
  120661. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  120662. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  120663. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  120664. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  120665. context.fillRect(x, y, 1, 1);
  120666. }
  120667. }
  120668. this._randomTexture.update(false);
  120669. };
  120670. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120671. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  120672. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  120673. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120674. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  120675. ], SSAORenderingPipeline.prototype, "radius", void 0);
  120676. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120677. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  120678. ], SSAORenderingPipeline.prototype, "area", void 0);
  120679. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120680. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  120681. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  120682. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120683. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  120684. ], SSAORenderingPipeline.prototype, "base", void 0);
  120685. return SSAORenderingPipeline;
  120686. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  120687. /***/ }),
  120688. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  120689. /*!*****************************************************************************!*\
  120690. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  120691. \*****************************************************************************/
  120692. /*! exports provided: StandardRenderingPipeline */
  120693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120694. "use strict";
  120695. __webpack_require__.r(__webpack_exports__);
  120696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  120697. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120698. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  120699. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  120700. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  120701. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  120702. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120703. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  120704. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  120705. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  120706. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  120707. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  120708. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  120709. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  120710. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  120711. /**
  120712. * Standard rendering pipeline
  120713. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  120714. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  120715. */
  120716. var StandardRenderingPipeline = /** @class */ (function (_super) {
  120717. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  120718. /**
  120719. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  120720. * @constructor
  120721. * @param name The rendering pipeline name
  120722. * @param scene The scene linked to this pipeline
  120723. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  120724. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  120725. * @param cameras The array of cameras that the rendering pipeline will be attached to
  120726. */
  120727. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  120728. if (originalPostProcess === void 0) { originalPostProcess = null; }
  120729. var _this = _super.call(this, scene.getEngine(), name) || this;
  120730. /**
  120731. * Post-process used to down scale an image x4
  120732. */
  120733. _this.downSampleX4PostProcess = null;
  120734. /**
  120735. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  120736. */
  120737. _this.brightPassPostProcess = null;
  120738. /**
  120739. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  120740. */
  120741. _this.blurHPostProcesses = [];
  120742. /**
  120743. * Post-process array storing all the vertical blur post-processes used by the pipeline
  120744. */
  120745. _this.blurVPostProcesses = [];
  120746. /**
  120747. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  120748. */
  120749. _this.textureAdderPostProcess = null;
  120750. /**
  120751. * Post-process used to create volumetric lighting effect
  120752. */
  120753. _this.volumetricLightPostProcess = null;
  120754. /**
  120755. * Post-process used to smooth the previous volumetric light post-process on the X axis
  120756. */
  120757. _this.volumetricLightSmoothXPostProcess = null;
  120758. /**
  120759. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  120760. */
  120761. _this.volumetricLightSmoothYPostProcess = null;
  120762. /**
  120763. * Post-process used to merge the volumetric light effect and the real scene color
  120764. */
  120765. _this.volumetricLightMergePostProces = null;
  120766. /**
  120767. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  120768. */
  120769. _this.volumetricLightFinalPostProcess = null;
  120770. /**
  120771. * Base post-process used to calculate the average luminance of the final image for HDR
  120772. */
  120773. _this.luminancePostProcess = null;
  120774. /**
  120775. * Post-processes used to create down sample post-processes in order to get
  120776. * the average luminance of the final image for HDR
  120777. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  120778. */
  120779. _this.luminanceDownSamplePostProcesses = [];
  120780. /**
  120781. * Post-process used to create a HDR effect (light adaptation)
  120782. */
  120783. _this.hdrPostProcess = null;
  120784. /**
  120785. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  120786. */
  120787. _this.textureAdderFinalPostProcess = null;
  120788. /**
  120789. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  120790. */
  120791. _this.lensFlareFinalPostProcess = null;
  120792. /**
  120793. * Post-process used to merge the final HDR post-process and the real scene color
  120794. */
  120795. _this.hdrFinalPostProcess = null;
  120796. /**
  120797. * Post-process used to create a lens flare effect
  120798. */
  120799. _this.lensFlarePostProcess = null;
  120800. /**
  120801. * Post-process that merges the result of the lens flare post-process and the real scene color
  120802. */
  120803. _this.lensFlareComposePostProcess = null;
  120804. /**
  120805. * Post-process used to create a motion blur effect
  120806. */
  120807. _this.motionBlurPostProcess = null;
  120808. /**
  120809. * Post-process used to create a depth of field effect
  120810. */
  120811. _this.depthOfFieldPostProcess = null;
  120812. /**
  120813. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  120814. */
  120815. _this.fxaaPostProcess = null;
  120816. // Values
  120817. /**
  120818. * Represents the brightness threshold in order to configure the illuminated surfaces
  120819. */
  120820. _this.brightThreshold = 1.0;
  120821. /**
  120822. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  120823. */
  120824. _this.blurWidth = 512.0;
  120825. /**
  120826. * Sets if the blur for highlighted surfaces must be only horizontal
  120827. */
  120828. _this.horizontalBlur = false;
  120829. /**
  120830. * Texture used typically to simulate "dirty" on camera lens
  120831. */
  120832. _this.lensTexture = null;
  120833. /**
  120834. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  120835. */
  120836. _this.volumetricLightCoefficient = 0.2;
  120837. /**
  120838. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  120839. */
  120840. _this.volumetricLightPower = 4.0;
  120841. /**
  120842. * Used the set the blur intensity to smooth the volumetric lights
  120843. */
  120844. _this.volumetricLightBlurScale = 64.0;
  120845. /**
  120846. * Light (spot or directional) used to generate the volumetric lights rays
  120847. * The source light must have a shadow generate so the pipeline can get its
  120848. * depth map
  120849. */
  120850. _this.sourceLight = null;
  120851. /**
  120852. * For eye adaptation, represents the minimum luminance the eye can see
  120853. */
  120854. _this.hdrMinimumLuminance = 1.0;
  120855. /**
  120856. * For eye adaptation, represents the decrease luminance speed
  120857. */
  120858. _this.hdrDecreaseRate = 0.5;
  120859. /**
  120860. * For eye adaptation, represents the increase luminance speed
  120861. */
  120862. _this.hdrIncreaseRate = 0.5;
  120863. /**
  120864. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  120865. */
  120866. _this.lensColorTexture = null;
  120867. /**
  120868. * The overall strengh for the lens flare effect
  120869. */
  120870. _this.lensFlareStrength = 20.0;
  120871. /**
  120872. * Dispersion coefficient for lens flare ghosts
  120873. */
  120874. _this.lensFlareGhostDispersal = 1.4;
  120875. /**
  120876. * Main lens flare halo width
  120877. */
  120878. _this.lensFlareHaloWidth = 0.7;
  120879. /**
  120880. * Based on the lens distortion effect, defines how much the lens flare result
  120881. * is distorted
  120882. */
  120883. _this.lensFlareDistortionStrength = 16.0;
  120884. /**
  120885. * Lens star texture must be used to simulate rays on the flares and is available
  120886. * in the documentation
  120887. */
  120888. _this.lensStarTexture = null;
  120889. /**
  120890. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  120891. * flare effect by taking account of the dirt texture
  120892. */
  120893. _this.lensFlareDirtTexture = null;
  120894. /**
  120895. * Represents the focal length for the depth of field effect
  120896. */
  120897. _this.depthOfFieldDistance = 10.0;
  120898. /**
  120899. * Represents the blur intensity for the blurred part of the depth of field effect
  120900. */
  120901. _this.depthOfFieldBlurWidth = 64.0;
  120902. /**
  120903. * For motion blur, defines how much the image is blurred by the movement
  120904. */
  120905. _this.motionStrength = 1.0;
  120906. /**
  120907. * List of animations for the pipeline (IAnimatable implementation)
  120908. */
  120909. _this.animations = [];
  120910. _this._currentDepthOfFieldSource = null;
  120911. _this._fixedExposure = 1.0;
  120912. _this._currentExposure = 1.0;
  120913. _this._hdrAutoExposure = false;
  120914. _this._hdrCurrentLuminance = 1.0;
  120915. // Getters and setters
  120916. _this._bloomEnabled = false;
  120917. _this._depthOfFieldEnabled = false;
  120918. _this._vlsEnabled = false;
  120919. _this._lensFlareEnabled = false;
  120920. _this._hdrEnabled = false;
  120921. _this._motionBlurEnabled = false;
  120922. _this._fxaaEnabled = false;
  120923. _this._motionBlurSamples = 64.0;
  120924. _this._volumetricLightStepsCount = 50.0;
  120925. _this._samples = 1;
  120926. _this._cameras = cameras || [];
  120927. // Initialize
  120928. _this._scene = scene;
  120929. _this._basePostProcess = originalPostProcess;
  120930. _this._ratio = ratio;
  120931. // Misc
  120932. _this._floatTextureType = scene.getEngine().getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  120933. // Finish
  120934. scene.postProcessRenderPipelineManager.addPipeline(_this);
  120935. _this._buildPipeline();
  120936. return _this;
  120937. }
  120938. Object.defineProperty(StandardRenderingPipeline.prototype, "exposure", {
  120939. /**
  120940. * Gets the overall exposure used by the pipeline
  120941. */
  120942. get: function () {
  120943. return this._fixedExposure;
  120944. },
  120945. /**
  120946. * Sets the overall exposure used by the pipeline
  120947. */
  120948. set: function (value) {
  120949. this._fixedExposure = value;
  120950. this._currentExposure = value;
  120951. },
  120952. enumerable: true,
  120953. configurable: true
  120954. });
  120955. Object.defineProperty(StandardRenderingPipeline.prototype, "hdrAutoExposure", {
  120956. /**
  120957. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120958. */
  120959. get: function () {
  120960. return this._hdrAutoExposure;
  120961. },
  120962. /**
  120963. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120964. */
  120965. set: function (value) {
  120966. this._hdrAutoExposure = value;
  120967. if (this.hdrPostProcess) {
  120968. var defines = ["#define HDR"];
  120969. if (value) {
  120970. defines.push("#define AUTO_EXPOSURE");
  120971. }
  120972. this.hdrPostProcess.updateEffect(defines.join("\n"));
  120973. }
  120974. },
  120975. enumerable: true,
  120976. configurable: true
  120977. });
  120978. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  120979. /**
  120980. * @ignore
  120981. * Specifies if the bloom pipeline is enabled
  120982. */
  120983. get: function () {
  120984. return this._bloomEnabled;
  120985. },
  120986. set: function (enabled) {
  120987. if (this._bloomEnabled === enabled) {
  120988. return;
  120989. }
  120990. this._bloomEnabled = enabled;
  120991. this._buildPipeline();
  120992. },
  120993. enumerable: true,
  120994. configurable: true
  120995. });
  120996. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  120997. /**
  120998. * @ignore
  120999. * Specifies if the depth of field pipeline is enabed
  121000. */
  121001. get: function () {
  121002. return this._depthOfFieldEnabled;
  121003. },
  121004. set: function (enabled) {
  121005. if (this._depthOfFieldEnabled === enabled) {
  121006. return;
  121007. }
  121008. this._depthOfFieldEnabled = enabled;
  121009. this._buildPipeline();
  121010. },
  121011. enumerable: true,
  121012. configurable: true
  121013. });
  121014. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  121015. /**
  121016. * @ignore
  121017. * Specifies if the lens flare pipeline is enabed
  121018. */
  121019. get: function () {
  121020. return this._lensFlareEnabled;
  121021. },
  121022. set: function (enabled) {
  121023. if (this._lensFlareEnabled === enabled) {
  121024. return;
  121025. }
  121026. this._lensFlareEnabled = enabled;
  121027. this._buildPipeline();
  121028. },
  121029. enumerable: true,
  121030. configurable: true
  121031. });
  121032. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  121033. /**
  121034. * @ignore
  121035. * Specifies if the HDR pipeline is enabled
  121036. */
  121037. get: function () {
  121038. return this._hdrEnabled;
  121039. },
  121040. set: function (enabled) {
  121041. if (this._hdrEnabled === enabled) {
  121042. return;
  121043. }
  121044. this._hdrEnabled = enabled;
  121045. this._buildPipeline();
  121046. },
  121047. enumerable: true,
  121048. configurable: true
  121049. });
  121050. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  121051. /**
  121052. * @ignore
  121053. * Specifies if the volumetric lights scattering effect is enabled
  121054. */
  121055. get: function () {
  121056. return this._vlsEnabled;
  121057. },
  121058. set: function (enabled) {
  121059. if (this._vlsEnabled === enabled) {
  121060. return;
  121061. }
  121062. if (enabled) {
  121063. var geometry = this._scene.enableGeometryBufferRenderer();
  121064. if (!geometry) {
  121065. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  121066. return;
  121067. }
  121068. }
  121069. this._vlsEnabled = enabled;
  121070. this._buildPipeline();
  121071. },
  121072. enumerable: true,
  121073. configurable: true
  121074. });
  121075. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  121076. /**
  121077. * @ignore
  121078. * Specifies if the motion blur effect is enabled
  121079. */
  121080. get: function () {
  121081. return this._motionBlurEnabled;
  121082. },
  121083. set: function (enabled) {
  121084. if (this._motionBlurEnabled === enabled) {
  121085. return;
  121086. }
  121087. this._motionBlurEnabled = enabled;
  121088. this._buildPipeline();
  121089. },
  121090. enumerable: true,
  121091. configurable: true
  121092. });
  121093. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  121094. /**
  121095. * Specifies if anti-aliasing is enabled
  121096. */
  121097. get: function () {
  121098. return this._fxaaEnabled;
  121099. },
  121100. set: function (enabled) {
  121101. if (this._fxaaEnabled === enabled) {
  121102. return;
  121103. }
  121104. this._fxaaEnabled = enabled;
  121105. this._buildPipeline();
  121106. },
  121107. enumerable: true,
  121108. configurable: true
  121109. });
  121110. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  121111. /**
  121112. * Specifies the number of steps used to calculate the volumetric lights
  121113. * Typically in interval [50, 200]
  121114. */
  121115. get: function () {
  121116. return this._volumetricLightStepsCount;
  121117. },
  121118. set: function (count) {
  121119. if (this.volumetricLightPostProcess) {
  121120. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  121121. }
  121122. this._volumetricLightStepsCount = count;
  121123. },
  121124. enumerable: true,
  121125. configurable: true
  121126. });
  121127. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  121128. /**
  121129. * Specifies the number of samples used for the motion blur effect
  121130. * Typically in interval [16, 64]
  121131. */
  121132. get: function () {
  121133. return this._motionBlurSamples;
  121134. },
  121135. set: function (samples) {
  121136. if (this.motionBlurPostProcess) {
  121137. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  121138. }
  121139. this._motionBlurSamples = samples;
  121140. },
  121141. enumerable: true,
  121142. configurable: true
  121143. });
  121144. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  121145. /**
  121146. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  121147. */
  121148. get: function () {
  121149. return this._samples;
  121150. },
  121151. set: function (sampleCount) {
  121152. if (this._samples === sampleCount) {
  121153. return;
  121154. }
  121155. this._samples = sampleCount;
  121156. this._buildPipeline();
  121157. },
  121158. enumerable: true,
  121159. configurable: true
  121160. });
  121161. StandardRenderingPipeline.prototype._buildPipeline = function () {
  121162. var _this = this;
  121163. var ratio = this._ratio;
  121164. var scene = this._scene;
  121165. this._disposePostProcesses();
  121166. this._reset();
  121167. // Create pass post-process
  121168. if (!this._basePostProcess) {
  121169. this.originalPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDRPass", "standard", [], [], ratio, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define PASS_POST_PROCESS", this._floatTextureType);
  121170. this.originalPostProcess.onApply = function () {
  121171. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  121172. };
  121173. }
  121174. else {
  121175. this.originalPostProcess = this._basePostProcess;
  121176. }
  121177. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  121178. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  121179. }
  121180. this._currentDepthOfFieldSource = this.originalPostProcess;
  121181. if (this._bloomEnabled) {
  121182. // Create down sample X4 post-process
  121183. this._createDownSampleX4PostProcess(scene, ratio / 2);
  121184. // Create bright pass post-process
  121185. this._createBrightPassPostProcess(scene, ratio / 2);
  121186. // Create gaussian blur post-processes (down sampling blurs)
  121187. this._createBlurPostProcesses(scene, ratio / 4, 1);
  121188. // Create texture adder post-process
  121189. this._createTextureAdderPostProcess(scene, ratio);
  121190. // Create depth-of-field source post-process
  121191. this.textureAdderFinalPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDRDepthOfFieldSource", "standard", [], [], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define PASS_POST_PROCESS", _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  121192. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  121193. }
  121194. if (this._vlsEnabled) {
  121195. // Create volumetric light
  121196. this._createVolumetricLightPostProcess(scene, ratio);
  121197. // Create volumetric light final post-process
  121198. this.volumetricLightFinalPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDRVLSFinal", "standard", [], [], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define PASS_POST_PROCESS", _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  121199. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  121200. }
  121201. if (this._lensFlareEnabled) {
  121202. // Create lens flare post-process
  121203. this._createLensFlarePostProcess(scene, ratio);
  121204. // Create depth-of-field source post-process post lens-flare and disable it now
  121205. this.lensFlareFinalPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDRPostLensFlareDepthOfFieldSource", "standard", [], [], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define PASS_POST_PROCESS", _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  121206. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  121207. }
  121208. if (this._hdrEnabled) {
  121209. // Create luminance
  121210. this._createLuminancePostProcesses(scene, this._floatTextureType);
  121211. // Create HDR
  121212. this._createHdrPostProcess(scene, ratio);
  121213. // Create depth-of-field source post-process post hdr and disable it now
  121214. this.hdrFinalPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDRPostHDReDepthOfFieldSource", "standard", [], [], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define PASS_POST_PROCESS", _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  121215. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  121216. }
  121217. if (this._depthOfFieldEnabled) {
  121218. // Create gaussian blur used by depth-of-field
  121219. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  121220. // Create depth-of-field post-process
  121221. this._createDepthOfFieldPostProcess(scene, ratio);
  121222. }
  121223. if (this._motionBlurEnabled) {
  121224. // Create motion blur post-process
  121225. this._createMotionBlurPostProcess(scene, ratio);
  121226. }
  121227. if (this._fxaaEnabled) {
  121228. // Create fxaa post-process
  121229. this.fxaaPostProcess = new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__["FxaaPostProcess"]("fxaa", 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  121230. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  121231. }
  121232. if (this._cameras !== null) {
  121233. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  121234. }
  121235. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  121236. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  121237. }
  121238. };
  121239. // Down Sample X4 Post-Processs
  121240. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  121241. var _this = this;
  121242. var downSampleX4Offsets = new Array(32);
  121243. this.downSampleX4PostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDRDownSampleX4", "standard", ["dsOffsets"], [], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define DOWN_SAMPLE_X4", _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  121244. this.downSampleX4PostProcess.onApply = function (effect) {
  121245. var id = 0;
  121246. var width = _this.downSampleX4PostProcess.width;
  121247. var height = _this.downSampleX4PostProcess.height;
  121248. for (var i = -2; i < 2; i++) {
  121249. for (var j = -2; j < 2; j++) {
  121250. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  121251. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  121252. id += 2;
  121253. }
  121254. }
  121255. effect.setArray2("dsOffsets", downSampleX4Offsets);
  121256. };
  121257. // Add to pipeline
  121258. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  121259. };
  121260. // Brightpass Post-Process
  121261. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  121262. var _this = this;
  121263. var brightOffsets = new Array(8);
  121264. this.brightPassPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDRBrightPass", "standard", ["dsOffsets", "brightThreshold"], [], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define BRIGHT_PASS", _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  121265. this.brightPassPostProcess.onApply = function (effect) {
  121266. var sU = (1.0 / _this.brightPassPostProcess.width);
  121267. var sV = (1.0 / _this.brightPassPostProcess.height);
  121268. brightOffsets[0] = -0.5 * sU;
  121269. brightOffsets[1] = 0.5 * sV;
  121270. brightOffsets[2] = 0.5 * sU;
  121271. brightOffsets[3] = 0.5 * sV;
  121272. brightOffsets[4] = -0.5 * sU;
  121273. brightOffsets[5] = -0.5 * sV;
  121274. brightOffsets[6] = 0.5 * sU;
  121275. brightOffsets[7] = -0.5 * sV;
  121276. effect.setArray2("dsOffsets", brightOffsets);
  121277. effect.setFloat("brightThreshold", _this.brightThreshold);
  121278. };
  121279. // Add to pipeline
  121280. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  121281. };
  121282. // Create blur H&V post-processes
  121283. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  121284. var _this = this;
  121285. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  121286. var engine = scene.getEngine();
  121287. var blurX = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__["BlurPostProcess"]("HDRBlurH" + "_" + indice, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 0), this[blurWidthKey], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  121288. var blurY = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__["BlurPostProcess"]("HDRBlurV" + "_" + indice, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 1), this[blurWidthKey], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  121289. blurX.onActivateObservable.add(function () {
  121290. var dw = blurX.width / engine.getRenderWidth();
  121291. blurX.kernel = _this[blurWidthKey] * dw;
  121292. });
  121293. blurY.onActivateObservable.add(function () {
  121294. var dw = blurY.height / engine.getRenderHeight();
  121295. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  121296. });
  121297. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  121298. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  121299. this.blurHPostProcesses.push(blurX);
  121300. this.blurVPostProcesses.push(blurY);
  121301. };
  121302. // Create texture adder post-process
  121303. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  121304. var _this = this;
  121305. this.textureAdderPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDRTextureAdder", "standard", ["exposure"], ["otherSampler", "lensSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define TEXTURE_ADDER", _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  121306. this.textureAdderPostProcess.onApply = function (effect) {
  121307. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  121308. effect.setTexture("lensSampler", _this.lensTexture);
  121309. effect.setFloat("exposure", _this._currentExposure);
  121310. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  121311. };
  121312. // Add to pipeline
  121313. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  121314. };
  121315. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  121316. var _this = this;
  121317. var geometryRenderer = scene.enableGeometryBufferRenderer();
  121318. geometryRenderer.enablePosition = true;
  121319. var geometry = geometryRenderer.getGBuffer();
  121320. // Base post-process
  121321. this.volumetricLightPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDRVLS", "standard", ["shadowViewProjection", "cameraPosition", "sunDirection", "sunColor", "scatteringCoefficient", "scatteringPower", "depthValues"], ["shadowMapSampler", "positionSampler"], ratio / 8, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define VLS\n#define NB_STEPS " + this._volumetricLightStepsCount.toFixed(1));
  121322. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  121323. this.volumetricLightPostProcess.onApply = function (effect) {
  121324. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  121325. var generator = _this.sourceLight.getShadowGenerator();
  121326. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  121327. effect.setTexture("positionSampler", geometry.textures[2]);
  121328. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  121329. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  121330. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  121331. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  121332. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  121333. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  121334. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  121335. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  121336. effect.setVector2("depthValues", depthValues);
  121337. }
  121338. };
  121339. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  121340. // Smooth
  121341. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  121342. // Merge
  121343. this.volumetricLightMergePostProces = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDRVLSMerge", "standard", [], ["originalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define VLSMERGE");
  121344. this.volumetricLightMergePostProces.onApply = function (effect) {
  121345. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  121346. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  121347. };
  121348. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  121349. };
  121350. // Create luminance
  121351. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  121352. var _this = this;
  121353. // Create luminance
  121354. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  121355. this.luminancePostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDRLuminance", "standard", ["lumOffsets"], [], { width: size, height: size }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define LUMINANCE", textureType);
  121356. var offsets = [];
  121357. this.luminancePostProcess.onApply = function (effect) {
  121358. var sU = (1.0 / _this.luminancePostProcess.width);
  121359. var sV = (1.0 / _this.luminancePostProcess.height);
  121360. offsets[0] = -0.5 * sU;
  121361. offsets[1] = 0.5 * sV;
  121362. offsets[2] = 0.5 * sU;
  121363. offsets[3] = 0.5 * sV;
  121364. offsets[4] = -0.5 * sU;
  121365. offsets[5] = -0.5 * sV;
  121366. offsets[6] = 0.5 * sU;
  121367. offsets[7] = -0.5 * sV;
  121368. effect.setArray2("lumOffsets", offsets);
  121369. };
  121370. // Add to pipeline
  121371. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  121372. // Create down sample luminance
  121373. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  121374. var size = Math.pow(3, i);
  121375. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  121376. if (i === 0) {
  121377. defines += "#define FINAL_DOWN_SAMPLER";
  121378. }
  121379. var postProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDRLuminanceDownSample" + i, "standard", ["dsOffsets", "halfDestPixelSize"], [], { width: size, height: size }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, defines, textureType);
  121380. this.luminanceDownSamplePostProcesses.push(postProcess);
  121381. }
  121382. // Create callbacks and add effects
  121383. var lastLuminance = this.luminancePostProcess;
  121384. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  121385. var downSampleOffsets = new Array(18);
  121386. pp.onApply = function (effect) {
  121387. if (!lastLuminance) {
  121388. return;
  121389. }
  121390. var id = 0;
  121391. for (var x = -1; x < 2; x++) {
  121392. for (var y = -1; y < 2; y++) {
  121393. downSampleOffsets[id] = x / lastLuminance.width;
  121394. downSampleOffsets[id + 1] = y / lastLuminance.height;
  121395. id += 2;
  121396. }
  121397. }
  121398. effect.setArray2("dsOffsets", downSampleOffsets);
  121399. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  121400. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  121401. lastLuminance = _this.luminancePostProcess;
  121402. }
  121403. else {
  121404. lastLuminance = pp;
  121405. }
  121406. };
  121407. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  121408. pp.onAfterRender = function () {
  121409. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  121410. var bit_shift = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0);
  121411. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  121412. };
  121413. }
  121414. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  121415. });
  121416. };
  121417. // Create HDR post-process
  121418. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  121419. var _this = this;
  121420. var defines = ["#define HDR"];
  121421. if (this._hdrAutoExposure) {
  121422. defines.push("#define AUTO_EXPOSURE");
  121423. }
  121424. this.hdrPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDR", "standard", ["averageLuminance"], ["textureAdderSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, defines.join("\n"), _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  121425. var outputLiminance = 1;
  121426. var time = 0;
  121427. var lastTime = 0;
  121428. this.hdrPostProcess.onApply = function (effect) {
  121429. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  121430. time += scene.getEngine().getDeltaTime();
  121431. if (outputLiminance < 0) {
  121432. outputLiminance = _this._hdrCurrentLuminance;
  121433. }
  121434. else {
  121435. var dt = (lastTime - time) / 1000.0;
  121436. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  121437. outputLiminance += _this.hdrDecreaseRate * dt;
  121438. }
  121439. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  121440. outputLiminance -= _this.hdrIncreaseRate * dt;
  121441. }
  121442. else {
  121443. outputLiminance = _this._hdrCurrentLuminance;
  121444. }
  121445. }
  121446. if (_this.hdrAutoExposure) {
  121447. _this._currentExposure = _this._fixedExposure / outputLiminance;
  121448. }
  121449. else {
  121450. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  121451. effect.setFloat("averageLuminance", outputLiminance);
  121452. }
  121453. lastTime = time;
  121454. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  121455. };
  121456. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  121457. };
  121458. // Create lens flare post-process
  121459. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  121460. var _this = this;
  121461. this.lensFlarePostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDRLensFlare", "standard", ["strength", "ghostDispersal", "haloWidth", "resolution", "distortionStrength"], ["lensColorSampler"], ratio / 2, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define LENS_FLARE", _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  121462. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  121463. this._createBlurPostProcesses(scene, ratio / 4, 2);
  121464. this.lensFlareComposePostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDRLensFlareCompose", "standard", ["lensStarMatrix"], ["otherSampler", "lensDirtSampler", "lensStarSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define LENS_FLARE_COMPOSE", _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  121465. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  121466. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  121467. // Lens flare
  121468. this.lensFlarePostProcess.onApply = function (effect) {
  121469. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  121470. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  121471. effect.setFloat("strength", _this.lensFlareStrength);
  121472. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  121473. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  121474. // Shift
  121475. resolution.x = _this.lensFlarePostProcess.width;
  121476. resolution.y = _this.lensFlarePostProcess.height;
  121477. effect.setVector2("resolution", resolution);
  121478. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  121479. };
  121480. // Compose
  121481. var scaleBias1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromValues(2.0, 0.0, -1.0, 0.0, 0.0, 2.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
  121482. var scaleBias2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromValues(0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
  121483. this.lensFlareComposePostProcess.onApply = function (effect) {
  121484. if (!_this._scene.activeCamera) {
  121485. return;
  121486. }
  121487. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  121488. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  121489. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  121490. // Lens start rotation matrix
  121491. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  121492. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  121493. var camRot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(camerax.toVector3(), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1.0, 0.0, 0.0)) + _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(cameraz.toVector3(), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.0, 0.0, 1.0));
  121494. camRot *= 4.0;
  121495. var starRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromValues(Math.cos(camRot) * 0.5, -Math.sin(camRot), 0.0, 0.0, Math.sin(camRot), Math.cos(camRot) * 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
  121496. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  121497. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  121498. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  121499. };
  121500. };
  121501. // Create depth-of-field post-process
  121502. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  121503. var _this = this;
  121504. this.depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDRDepthOfField", "standard", ["distance"], ["otherSampler", "depthSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define DEPTH_OF_FIELD", _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  121505. this.depthOfFieldPostProcess.onApply = function (effect) {
  121506. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  121507. effect.setTexture("depthSampler", _this._getDepthTexture());
  121508. effect.setFloat("distance", _this.depthOfFieldDistance);
  121509. };
  121510. // Add to pipeline
  121511. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  121512. };
  121513. // Create motion blur post-process
  121514. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  121515. var _this = this;
  121516. this.motionBlurPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDRMotionBlur", "standard", ["inverseViewProjection", "prevViewProjection", "screenSize", "motionScale", "motionStrength"], ["depthSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + this.motionBlurSamples.toFixed(1), _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  121517. var motionScale = 0;
  121518. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  121519. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  121520. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  121521. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  121522. this.motionBlurPostProcess.onApply = function (effect) {
  121523. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  121524. viewProjection.invertToRef(invViewProjection);
  121525. effect.setMatrix("inverseViewProjection", invViewProjection);
  121526. effect.setMatrix("prevViewProjection", prevViewProjection);
  121527. prevViewProjection = viewProjection;
  121528. screenSize.x = _this.motionBlurPostProcess.width;
  121529. screenSize.y = _this.motionBlurPostProcess.height;
  121530. effect.setVector2("screenSize", screenSize);
  121531. motionScale = scene.getEngine().getFps() / 60.0;
  121532. effect.setFloat("motionScale", motionScale);
  121533. effect.setFloat("motionStrength", _this.motionStrength);
  121534. effect.setTexture("depthSampler", _this._getDepthTexture());
  121535. };
  121536. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  121537. };
  121538. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  121539. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  121540. var renderer = this._scene.enableGeometryBufferRenderer();
  121541. return renderer.getGBuffer().textures[0];
  121542. }
  121543. return this._scene.enableDepthRenderer().getDepthMap();
  121544. };
  121545. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  121546. for (var i = 0; i < this._cameras.length; i++) {
  121547. var camera = this._cameras[i];
  121548. if (this.originalPostProcess) {
  121549. this.originalPostProcess.dispose(camera);
  121550. }
  121551. if (this.downSampleX4PostProcess) {
  121552. this.downSampleX4PostProcess.dispose(camera);
  121553. }
  121554. if (this.brightPassPostProcess) {
  121555. this.brightPassPostProcess.dispose(camera);
  121556. }
  121557. if (this.textureAdderPostProcess) {
  121558. this.textureAdderPostProcess.dispose(camera);
  121559. }
  121560. if (this.textureAdderFinalPostProcess) {
  121561. this.textureAdderFinalPostProcess.dispose(camera);
  121562. }
  121563. if (this.volumetricLightPostProcess) {
  121564. this.volumetricLightPostProcess.dispose(camera);
  121565. }
  121566. if (this.volumetricLightSmoothXPostProcess) {
  121567. this.volumetricLightSmoothXPostProcess.dispose(camera);
  121568. }
  121569. if (this.volumetricLightSmoothYPostProcess) {
  121570. this.volumetricLightSmoothYPostProcess.dispose(camera);
  121571. }
  121572. if (this.volumetricLightMergePostProces) {
  121573. this.volumetricLightMergePostProces.dispose(camera);
  121574. }
  121575. if (this.volumetricLightFinalPostProcess) {
  121576. this.volumetricLightFinalPostProcess.dispose(camera);
  121577. }
  121578. if (this.lensFlarePostProcess) {
  121579. this.lensFlarePostProcess.dispose(camera);
  121580. }
  121581. if (this.lensFlareComposePostProcess) {
  121582. this.lensFlareComposePostProcess.dispose(camera);
  121583. }
  121584. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  121585. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  121586. }
  121587. if (this.luminancePostProcess) {
  121588. this.luminancePostProcess.dispose(camera);
  121589. }
  121590. if (this.hdrPostProcess) {
  121591. this.hdrPostProcess.dispose(camera);
  121592. }
  121593. if (this.hdrFinalPostProcess) {
  121594. this.hdrFinalPostProcess.dispose(camera);
  121595. }
  121596. if (this.depthOfFieldPostProcess) {
  121597. this.depthOfFieldPostProcess.dispose(camera);
  121598. }
  121599. if (this.motionBlurPostProcess) {
  121600. this.motionBlurPostProcess.dispose(camera);
  121601. }
  121602. if (this.fxaaPostProcess) {
  121603. this.fxaaPostProcess.dispose(camera);
  121604. }
  121605. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  121606. this.blurHPostProcesses[j].dispose(camera);
  121607. }
  121608. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  121609. this.blurVPostProcesses[j].dispose(camera);
  121610. }
  121611. }
  121612. this.originalPostProcess = null;
  121613. this.downSampleX4PostProcess = null;
  121614. this.brightPassPostProcess = null;
  121615. this.textureAdderPostProcess = null;
  121616. this.textureAdderFinalPostProcess = null;
  121617. this.volumetricLightPostProcess = null;
  121618. this.volumetricLightSmoothXPostProcess = null;
  121619. this.volumetricLightSmoothYPostProcess = null;
  121620. this.volumetricLightMergePostProces = null;
  121621. this.volumetricLightFinalPostProcess = null;
  121622. this.lensFlarePostProcess = null;
  121623. this.lensFlareComposePostProcess = null;
  121624. this.luminancePostProcess = null;
  121625. this.hdrPostProcess = null;
  121626. this.hdrFinalPostProcess = null;
  121627. this.depthOfFieldPostProcess = null;
  121628. this.motionBlurPostProcess = null;
  121629. this.fxaaPostProcess = null;
  121630. this.luminanceDownSamplePostProcesses = [];
  121631. this.blurHPostProcesses = [];
  121632. this.blurVPostProcesses = [];
  121633. };
  121634. /**
  121635. * Dispose of the pipeline and stop all post processes
  121636. */
  121637. StandardRenderingPipeline.prototype.dispose = function () {
  121638. this._disposePostProcesses();
  121639. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  121640. _super.prototype.dispose.call(this);
  121641. };
  121642. /**
  121643. * Serialize the rendering pipeline (Used when exporting)
  121644. * @returns the serialized object
  121645. */
  121646. StandardRenderingPipeline.prototype.serialize = function () {
  121647. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  121648. if (this.sourceLight) {
  121649. serializationObject.sourceLightId = this.sourceLight.id;
  121650. }
  121651. serializationObject.customType = "StandardRenderingPipeline";
  121652. return serializationObject;
  121653. };
  121654. /**
  121655. * Parse the serialized pipeline
  121656. * @param source Source pipeline.
  121657. * @param scene The scene to load the pipeline to.
  121658. * @param rootUrl The URL of the serialized pipeline.
  121659. * @returns An instantiated pipeline from the serialized object.
  121660. */
  121661. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  121662. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  121663. if (source.sourceLightId) {
  121664. p.sourceLight = scene.getLightByID(source.sourceLightId);
  121665. }
  121666. return p;
  121667. };
  121668. /**
  121669. * Luminance steps
  121670. */
  121671. StandardRenderingPipeline.LuminanceSteps = 6;
  121672. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121673. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121674. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  121675. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121677. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  121678. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121679. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121680. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  121681. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121682. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121683. ], StandardRenderingPipeline.prototype, "exposure", null);
  121684. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121685. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  121686. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  121687. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121688. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121689. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  121690. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121691. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121692. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  121693. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121694. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121695. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  121696. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121697. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121698. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  121699. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121700. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121701. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  121702. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121703. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121704. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  121705. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121706. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121707. ], StandardRenderingPipeline.prototype, "hdrAutoExposure", null);
  121708. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121709. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  121710. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  121711. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121712. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121713. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  121714. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121715. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121716. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  121717. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121718. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121719. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  121720. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121721. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121722. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  121723. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121724. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  121725. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  121726. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121727. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  121728. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  121729. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121730. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121731. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  121732. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121733. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121734. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  121735. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121736. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121737. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  121738. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121739. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121740. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  121741. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121742. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121743. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  121744. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121745. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121746. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  121747. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121748. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121749. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  121750. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121751. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121752. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  121753. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121754. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121755. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  121756. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121757. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121758. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  121759. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121760. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121761. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  121762. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121763. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121764. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  121765. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121766. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121767. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  121768. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121769. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121770. ], StandardRenderingPipeline.prototype, "samples", null);
  121771. return StandardRenderingPipeline;
  121772. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  121773. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  121774. /***/ }),
  121775. /***/ "./PostProcesses/RenderPipeline/index.ts":
  121776. /*!***********************************************!*\
  121777. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  121778. \***********************************************/
  121779. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  121780. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121781. "use strict";
  121782. __webpack_require__.r(__webpack_exports__);
  121783. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  121784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  121785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  121786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  121787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  121788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  121789. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  121790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  121791. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  121792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  121793. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  121794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  121795. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  121796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  121797. /***/ }),
  121798. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  121799. /*!*****************************************************************!*\
  121800. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  121801. \*****************************************************************/
  121802. /*! exports provided: PostProcessRenderEffect */
  121803. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121804. "use strict";
  121805. __webpack_require__.r(__webpack_exports__);
  121806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  121807. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  121808. /**
  121809. * This represents a set of one or more post processes in Babylon.
  121810. * A post process can be used to apply a shader to a texture after it is rendered.
  121811. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121812. */
  121813. var PostProcessRenderEffect = /** @class */ (function () {
  121814. /**
  121815. * Instantiates a post process render effect.
  121816. * A post process can be used to apply a shader to a texture after it is rendered.
  121817. * @param engine The engine the effect is tied to
  121818. * @param name The name of the effect
  121819. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  121820. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  121821. */
  121822. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  121823. this._name = name;
  121824. this._singleInstance = singleInstance || true;
  121825. this._getPostProcesses = getPostProcesses;
  121826. this._cameras = {};
  121827. this._indicesForCamera = {};
  121828. this._postProcesses = {};
  121829. }
  121830. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  121831. /**
  121832. * Checks if all the post processes in the effect are supported.
  121833. */
  121834. get: function () {
  121835. for (var index in this._postProcesses) {
  121836. if (this._postProcesses.hasOwnProperty(index)) {
  121837. var pps = this._postProcesses[index];
  121838. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  121839. if (!pps[ppIndex].isSupported) {
  121840. return false;
  121841. }
  121842. }
  121843. }
  121844. }
  121845. return true;
  121846. },
  121847. enumerable: true,
  121848. configurable: true
  121849. });
  121850. /**
  121851. * Updates the current state of the effect
  121852. * @hidden
  121853. */
  121854. PostProcessRenderEffect.prototype._update = function () {
  121855. };
  121856. /**
  121857. * Attaches the effect on cameras
  121858. * @param cameras The camera to attach to.
  121859. * @hidden
  121860. */
  121861. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  121862. var _this = this;
  121863. var cameraKey;
  121864. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  121865. if (!cams) {
  121866. return;
  121867. }
  121868. for (var i = 0; i < cams.length; i++) {
  121869. var camera = cams[i];
  121870. var cameraName = camera.name;
  121871. if (this._singleInstance) {
  121872. cameraKey = 0;
  121873. }
  121874. else {
  121875. cameraKey = cameraName;
  121876. }
  121877. if (!this._postProcesses[cameraKey]) {
  121878. var postProcess = this._getPostProcesses();
  121879. if (postProcess) {
  121880. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  121881. }
  121882. }
  121883. if (!this._indicesForCamera[cameraName]) {
  121884. this._indicesForCamera[cameraName] = [];
  121885. }
  121886. this._postProcesses[cameraKey].forEach(function (postProcess) {
  121887. var index = camera.attachPostProcess(postProcess);
  121888. _this._indicesForCamera[cameraName].push(index);
  121889. });
  121890. if (!this._cameras[cameraName]) {
  121891. this._cameras[cameraName] = camera;
  121892. }
  121893. }
  121894. };
  121895. /**
  121896. * Detatches the effect on cameras
  121897. * @param cameras The camera to detatch from.
  121898. * @hidden
  121899. */
  121900. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  121901. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  121902. if (!cams) {
  121903. return;
  121904. }
  121905. for (var i = 0; i < cams.length; i++) {
  121906. var camera = cams[i];
  121907. var cameraName = camera.name;
  121908. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  121909. if (postProcesses) {
  121910. postProcesses.forEach(function (postProcess) {
  121911. camera.detachPostProcess(postProcess);
  121912. });
  121913. }
  121914. if (this._cameras[cameraName]) {
  121915. this._cameras[cameraName] = null;
  121916. }
  121917. }
  121918. };
  121919. /**
  121920. * Enables the effect on given cameras
  121921. * @param cameras The camera to enable.
  121922. * @hidden
  121923. */
  121924. PostProcessRenderEffect.prototype._enable = function (cameras) {
  121925. var _this = this;
  121926. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  121927. if (!cams) {
  121928. return;
  121929. }
  121930. for (var i = 0; i < cams.length; i++) {
  121931. var camera = cams[i];
  121932. var cameraName = camera.name;
  121933. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  121934. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  121935. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  121936. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  121937. });
  121938. }
  121939. }
  121940. }
  121941. };
  121942. /**
  121943. * Disables the effect on the given cameras
  121944. * @param cameras The camera to disable.
  121945. * @hidden
  121946. */
  121947. PostProcessRenderEffect.prototype._disable = function (cameras) {
  121948. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  121949. if (!cams) {
  121950. return;
  121951. }
  121952. for (var i = 0; i < cams.length; i++) {
  121953. var camera = cams[i];
  121954. var cameraName = camera.name;
  121955. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  121956. camera.detachPostProcess(postProcess);
  121957. });
  121958. }
  121959. };
  121960. /**
  121961. * Gets a list of the post processes contained in the effect.
  121962. * @param camera The camera to get the post processes on.
  121963. * @returns The list of the post processes in the effect.
  121964. */
  121965. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  121966. if (this._singleInstance) {
  121967. return this._postProcesses[0];
  121968. }
  121969. else {
  121970. if (!camera) {
  121971. return null;
  121972. }
  121973. return this._postProcesses[camera.name];
  121974. }
  121975. };
  121976. return PostProcessRenderEffect;
  121977. }());
  121978. /***/ }),
  121979. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  121980. /*!*******************************************************************!*\
  121981. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  121982. \*******************************************************************/
  121983. /*! exports provided: PostProcessRenderPipeline */
  121984. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121985. "use strict";
  121986. __webpack_require__.r(__webpack_exports__);
  121987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  121988. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121989. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  121990. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  121991. /**
  121992. * PostProcessRenderPipeline
  121993. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121994. */
  121995. var PostProcessRenderPipeline = /** @class */ (function () {
  121996. /**
  121997. * Initializes a PostProcessRenderPipeline
  121998. * @param engine engine to add the pipeline to
  121999. * @param name name of the pipeline
  122000. */
  122001. function PostProcessRenderPipeline(engine, name) {
  122002. this.engine = engine;
  122003. this._name = name;
  122004. this._renderEffects = {};
  122005. this._renderEffectsForIsolatedPass = new Array();
  122006. this._cameras = [];
  122007. }
  122008. Object.defineProperty(PostProcessRenderPipeline.prototype, "name", {
  122009. /**
  122010. * Gets pipeline name
  122011. */
  122012. get: function () {
  122013. return this._name;
  122014. },
  122015. enumerable: true,
  122016. configurable: true
  122017. });
  122018. /**
  122019. * Gets the class name
  122020. * @returns "PostProcessRenderPipeline"
  122021. */
  122022. PostProcessRenderPipeline.prototype.getClassName = function () {
  122023. return "PostProcessRenderPipeline";
  122024. };
  122025. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  122026. /**
  122027. * If all the render effects in the pipeline are supported
  122028. */
  122029. get: function () {
  122030. for (var renderEffectName in this._renderEffects) {
  122031. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  122032. if (!this._renderEffects[renderEffectName].isSupported) {
  122033. return false;
  122034. }
  122035. }
  122036. }
  122037. return true;
  122038. },
  122039. enumerable: true,
  122040. configurable: true
  122041. });
  122042. /**
  122043. * Adds an effect to the pipeline
  122044. * @param renderEffect the effect to add
  122045. */
  122046. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  122047. this._renderEffects[renderEffect._name] = renderEffect;
  122048. };
  122049. // private
  122050. /** @hidden */
  122051. PostProcessRenderPipeline.prototype._rebuild = function () {
  122052. };
  122053. /** @hidden */
  122054. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  122055. var renderEffects = this._renderEffects[renderEffectName];
  122056. if (!renderEffects) {
  122057. return;
  122058. }
  122059. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  122060. };
  122061. /** @hidden */
  122062. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  122063. var renderEffects = this._renderEffects[renderEffectName];
  122064. if (!renderEffects) {
  122065. return;
  122066. }
  122067. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  122068. };
  122069. /** @hidden */
  122070. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  122071. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  122072. if (!cams) {
  122073. return;
  122074. }
  122075. var indicesToDelete = [];
  122076. var i;
  122077. for (i = 0; i < cams.length; i++) {
  122078. var camera = cams[i];
  122079. var cameraName = camera.name;
  122080. if (this._cameras.indexOf(camera) === -1) {
  122081. this._cameras[cameraName] = camera;
  122082. }
  122083. else if (unique) {
  122084. indicesToDelete.push(i);
  122085. }
  122086. }
  122087. for (i = 0; i < indicesToDelete.length; i++) {
  122088. cameras.splice(indicesToDelete[i], 1);
  122089. }
  122090. for (var renderEffectName in this._renderEffects) {
  122091. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  122092. this._renderEffects[renderEffectName]._attachCameras(cams);
  122093. }
  122094. }
  122095. };
  122096. /** @hidden */
  122097. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  122098. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  122099. if (!cams) {
  122100. return;
  122101. }
  122102. for (var renderEffectName in this._renderEffects) {
  122103. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  122104. this._renderEffects[renderEffectName]._detachCameras(cams);
  122105. }
  122106. }
  122107. for (var i = 0; i < cams.length; i++) {
  122108. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  122109. }
  122110. };
  122111. /** @hidden */
  122112. PostProcessRenderPipeline.prototype._update = function () {
  122113. for (var renderEffectName in this._renderEffects) {
  122114. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  122115. this._renderEffects[renderEffectName]._update();
  122116. }
  122117. }
  122118. for (var i = 0; i < this._cameras.length; i++) {
  122119. var cameraName = this._cameras[i].name;
  122120. if (this._renderEffectsForIsolatedPass[cameraName]) {
  122121. this._renderEffectsForIsolatedPass[cameraName]._update();
  122122. }
  122123. }
  122124. };
  122125. /** @hidden */
  122126. PostProcessRenderPipeline.prototype._reset = function () {
  122127. this._renderEffects = {};
  122128. this._renderEffectsForIsolatedPass = new Array();
  122129. };
  122130. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  122131. // Set samples of the very first post process to 4 to enable native anti-aliasing in browsers that support webGL 2.0 (See: https://github.com/BabylonJS/Babylon.js/issues/3754)
  122132. var effectKeys = Object.keys(this._renderEffects);
  122133. if (this.engine.webGLVersion === 1) {
  122134. return false;
  122135. }
  122136. if (effectKeys.length > 0) {
  122137. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  122138. if (postProcesses) {
  122139. postProcesses[0].samples = sampleCount;
  122140. }
  122141. }
  122142. return true;
  122143. };
  122144. /**
  122145. * Disposes of the pipeline
  122146. */
  122147. PostProcessRenderPipeline.prototype.dispose = function () {
  122148. // Must be implemented by children
  122149. };
  122150. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122151. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  122152. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  122153. return PostProcessRenderPipeline;
  122154. }());
  122155. /***/ }),
  122156. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  122157. /*!**************************************************************************!*\
  122158. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  122159. \**************************************************************************/
  122160. /*! exports provided: PostProcessRenderPipelineManager */
  122161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122162. "use strict";
  122163. __webpack_require__.r(__webpack_exports__);
  122164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  122165. /**
  122166. * PostProcessRenderPipelineManager class
  122167. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122168. */
  122169. var PostProcessRenderPipelineManager = /** @class */ (function () {
  122170. /**
  122171. * Initializes a PostProcessRenderPipelineManager
  122172. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122173. */
  122174. function PostProcessRenderPipelineManager() {
  122175. this._renderPipelines = {};
  122176. }
  122177. Object.defineProperty(PostProcessRenderPipelineManager.prototype, "supportedPipelines", {
  122178. /**
  122179. * Gets the list of supported render pipelines
  122180. */
  122181. get: function () {
  122182. var result = [];
  122183. for (var renderPipelineName in this._renderPipelines) {
  122184. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  122185. var pipeline = this._renderPipelines[renderPipelineName];
  122186. if (pipeline.isSupported) {
  122187. result.push(pipeline);
  122188. }
  122189. }
  122190. }
  122191. return result;
  122192. },
  122193. enumerable: true,
  122194. configurable: true
  122195. });
  122196. /**
  122197. * Adds a pipeline to the manager
  122198. * @param renderPipeline The pipeline to add
  122199. */
  122200. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  122201. this._renderPipelines[renderPipeline._name] = renderPipeline;
  122202. };
  122203. /**
  122204. * Attaches a camera to the pipeline
  122205. * @param renderPipelineName The name of the pipeline to attach to
  122206. * @param cameras the camera to attach
  122207. * @param unique if the camera can be attached multiple times to the pipeline
  122208. */
  122209. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  122210. if (unique === void 0) { unique = false; }
  122211. var renderPipeline = this._renderPipelines[renderPipelineName];
  122212. if (!renderPipeline) {
  122213. return;
  122214. }
  122215. renderPipeline._attachCameras(cameras, unique);
  122216. };
  122217. /**
  122218. * Detaches a camera from the pipeline
  122219. * @param renderPipelineName The name of the pipeline to detach from
  122220. * @param cameras the camera to detach
  122221. */
  122222. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  122223. var renderPipeline = this._renderPipelines[renderPipelineName];
  122224. if (!renderPipeline) {
  122225. return;
  122226. }
  122227. renderPipeline._detachCameras(cameras);
  122228. };
  122229. /**
  122230. * Enables an effect by name on a pipeline
  122231. * @param renderPipelineName the name of the pipeline to enable the effect in
  122232. * @param renderEffectName the name of the effect to enable
  122233. * @param cameras the cameras that the effect should be enabled on
  122234. */
  122235. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  122236. var renderPipeline = this._renderPipelines[renderPipelineName];
  122237. if (!renderPipeline) {
  122238. return;
  122239. }
  122240. renderPipeline._enableEffect(renderEffectName, cameras);
  122241. };
  122242. /**
  122243. * Disables an effect by name on a pipeline
  122244. * @param renderPipelineName the name of the pipeline to disable the effect in
  122245. * @param renderEffectName the name of the effect to disable
  122246. * @param cameras the cameras that the effect should be disabled on
  122247. */
  122248. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  122249. var renderPipeline = this._renderPipelines[renderPipelineName];
  122250. if (!renderPipeline) {
  122251. return;
  122252. }
  122253. renderPipeline._disableEffect(renderEffectName, cameras);
  122254. };
  122255. /**
  122256. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  122257. */
  122258. PostProcessRenderPipelineManager.prototype.update = function () {
  122259. for (var renderPipelineName in this._renderPipelines) {
  122260. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  122261. var pipeline = this._renderPipelines[renderPipelineName];
  122262. if (!pipeline.isSupported) {
  122263. pipeline.dispose();
  122264. delete this._renderPipelines[renderPipelineName];
  122265. }
  122266. else {
  122267. pipeline._update();
  122268. }
  122269. }
  122270. }
  122271. };
  122272. /** @hidden */
  122273. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  122274. for (var renderPipelineName in this._renderPipelines) {
  122275. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  122276. var pipeline = this._renderPipelines[renderPipelineName];
  122277. pipeline._rebuild();
  122278. }
  122279. }
  122280. };
  122281. /**
  122282. * Disposes of the manager and pipelines
  122283. */
  122284. PostProcessRenderPipelineManager.prototype.dispose = function () {
  122285. for (var renderPipelineName in this._renderPipelines) {
  122286. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  122287. var pipeline = this._renderPipelines[renderPipelineName];
  122288. pipeline.dispose();
  122289. }
  122290. }
  122291. };
  122292. return PostProcessRenderPipelineManager;
  122293. }());
  122294. /***/ }),
  122295. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  122296. /*!****************************************************************************************!*\
  122297. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  122298. \****************************************************************************************/
  122299. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  122300. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122301. "use strict";
  122302. __webpack_require__.r(__webpack_exports__);
  122303. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  122304. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  122305. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  122306. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  122307. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  122308. get: function () {
  122309. if (!this._postProcessRenderPipelineManager) {
  122310. // Register the G Buffer component to the scene.
  122311. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  122312. if (!component) {
  122313. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  122314. this._addComponent(component);
  122315. }
  122316. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  122317. }
  122318. return this._postProcessRenderPipelineManager;
  122319. },
  122320. enumerable: true,
  122321. configurable: true
  122322. });
  122323. /**
  122324. * Defines the Render Pipeline scene component responsible to rendering pipelines
  122325. */
  122326. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  122327. /**
  122328. * Creates a new instance of the component for the given scene
  122329. * @param scene Defines the scene to register the component in
  122330. */
  122331. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  122332. /**
  122333. * The component name helpfull to identify the component in the list of scene components.
  122334. */
  122335. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  122336. this.scene = scene;
  122337. }
  122338. /**
  122339. * Registers the component in a given scene
  122340. */
  122341. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  122342. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  122343. };
  122344. /**
  122345. * Rebuilds the elements related to this component in case of
  122346. * context lost for instance.
  122347. */
  122348. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  122349. if (this.scene._postProcessRenderPipelineManager) {
  122350. this.scene._postProcessRenderPipelineManager._rebuild();
  122351. }
  122352. };
  122353. /**
  122354. * Disposes the component and the associated ressources
  122355. */
  122356. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  122357. if (this.scene._postProcessRenderPipelineManager) {
  122358. this.scene._postProcessRenderPipelineManager.dispose();
  122359. }
  122360. };
  122361. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  122362. if (this.scene._postProcessRenderPipelineManager) {
  122363. this.scene._postProcessRenderPipelineManager.update();
  122364. }
  122365. };
  122366. return PostProcessRenderPipelineManagerSceneComponent;
  122367. }());
  122368. /***/ }),
  122369. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  122370. /*!**********************************************!*\
  122371. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  122372. \**********************************************/
  122373. /*! exports provided: AnaglyphPostProcess */
  122374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122375. "use strict";
  122376. __webpack_require__.r(__webpack_exports__);
  122377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  122378. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122379. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122380. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  122381. /**
  122382. * Postprocess used to generate anaglyphic rendering
  122383. */
  122384. var AnaglyphPostProcess = /** @class */ (function (_super) {
  122385. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  122386. /**
  122387. * Creates a new AnaglyphPostProcess
  122388. * @param name defines postprocess name
  122389. * @param options defines creation options or target ratio scale
  122390. * @param rigCameras defines cameras using this postprocess
  122391. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  122392. * @param engine defines hosting engine
  122393. * @param reusable defines if the postprocess will be reused multiple times per frame
  122394. */
  122395. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  122396. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  122397. _this._passedProcess = rigCameras[0]._rigPostProcess;
  122398. _this.onApplyObservable.add(function (effect) {
  122399. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  122400. });
  122401. return _this;
  122402. }
  122403. return AnaglyphPostProcess;
  122404. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122405. /***/ }),
  122406. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  122407. /*!***************************************************!*\
  122408. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  122409. \***************************************************/
  122410. /*! exports provided: BlackAndWhitePostProcess */
  122411. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122412. "use strict";
  122413. __webpack_require__.r(__webpack_exports__);
  122414. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  122415. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122416. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122417. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  122418. /**
  122419. * Post process used to render in black and white
  122420. */
  122421. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  122422. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  122423. /**
  122424. * Creates a black and white post process
  122425. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  122426. * @param name The name of the effect.
  122427. * @param options The required width/height ratio to downsize to before computing the render pass.
  122428. * @param camera The camera to apply the render pass to.
  122429. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122430. * @param engine The engine which the post process will be applied. (default: current engine)
  122431. * @param reusable If the post process can be reused on the same frame. (default: false)
  122432. */
  122433. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  122434. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  122435. /**
  122436. * Linear about to convert he result to black and white (default: 1)
  122437. */
  122438. _this.degree = 1;
  122439. _this.onApplyObservable.add(function (effect) {
  122440. effect.setFloat("degree", _this.degree);
  122441. });
  122442. return _this;
  122443. }
  122444. return BlackAndWhitePostProcess;
  122445. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122446. /***/ }),
  122447. /***/ "./PostProcesses/bloomEffect.ts":
  122448. /*!**************************************!*\
  122449. !*** ./PostProcesses/bloomEffect.ts ***!
  122450. \**************************************/
  122451. /*! exports provided: BloomEffect */
  122452. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122453. "use strict";
  122454. __webpack_require__.r(__webpack_exports__);
  122455. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  122456. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122457. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  122458. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  122459. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  122460. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  122461. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122462. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122463. /**
  122464. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  122465. */
  122466. var BloomEffect = /** @class */ (function (_super) {
  122467. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  122468. /**
  122469. * Creates a new instance of @see BloomEffect
  122470. * @param scene The scene the effect belongs to.
  122471. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  122472. * @param bloomKernel The size of the kernel to be used when applying the blur.
  122473. * @param bloomWeight The the strength of bloom.
  122474. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  122475. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  122476. */
  122477. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  122478. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  122479. if (blockCompilation === void 0) { blockCompilation = false; }
  122480. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  122481. return _this._effects;
  122482. }, true) || this;
  122483. _this.bloomScale = bloomScale;
  122484. /**
  122485. * @hidden Internal
  122486. */
  122487. _this._effects = [];
  122488. _this._downscale = new _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__["ExtractHighlightsPostProcess"]("highlights", 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType, blockCompilation);
  122489. _this._blurX = new _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__["BlurPostProcess"]("horizontal blur", new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1.0, 0), 10.0, bloomScale, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType, undefined, blockCompilation);
  122490. _this._blurX.alwaysForcePOT = true;
  122491. _this._blurX.autoClear = false;
  122492. _this._blurY = new _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__["BlurPostProcess"]("vertical blur", new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](0, 1.0), 10.0, bloomScale, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType, undefined, blockCompilation);
  122493. _this._blurY.alwaysForcePOT = true;
  122494. _this._blurY.autoClear = false;
  122495. _this.kernel = bloomKernel;
  122496. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  122497. _this._merge = new _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__["BloomMergePostProcess"]("bloomMerge", _this._downscale, _this._blurY, bloomWeight, bloomScale, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType, blockCompilation);
  122498. _this._merge.autoClear = false;
  122499. _this._effects.push(_this._merge);
  122500. return _this;
  122501. }
  122502. Object.defineProperty(BloomEffect.prototype, "threshold", {
  122503. /**
  122504. * The luminance threshold to find bright areas of the image to bloom.
  122505. */
  122506. get: function () {
  122507. return this._downscale.threshold;
  122508. },
  122509. set: function (value) {
  122510. this._downscale.threshold = value;
  122511. },
  122512. enumerable: true,
  122513. configurable: true
  122514. });
  122515. Object.defineProperty(BloomEffect.prototype, "weight", {
  122516. /**
  122517. * The strength of the bloom.
  122518. */
  122519. get: function () {
  122520. return this._merge.weight;
  122521. },
  122522. set: function (value) {
  122523. this._merge.weight = value;
  122524. },
  122525. enumerable: true,
  122526. configurable: true
  122527. });
  122528. Object.defineProperty(BloomEffect.prototype, "kernel", {
  122529. /**
  122530. * Specifies the size of the bloom blur kernel, relative to the final output size
  122531. */
  122532. get: function () {
  122533. return this._blurX.kernel / this.bloomScale;
  122534. },
  122535. set: function (value) {
  122536. this._blurX.kernel = value * this.bloomScale;
  122537. this._blurY.kernel = value * this.bloomScale;
  122538. },
  122539. enumerable: true,
  122540. configurable: true
  122541. });
  122542. /**
  122543. * Disposes each of the internal effects for a given camera.
  122544. * @param camera The camera to dispose the effect on.
  122545. */
  122546. BloomEffect.prototype.disposeEffects = function (camera) {
  122547. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  122548. this._effects[effectIndex].dispose(camera);
  122549. }
  122550. };
  122551. /**
  122552. * @hidden Internal
  122553. */
  122554. BloomEffect.prototype._updateEffects = function () {
  122555. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  122556. this._effects[effectIndex].updateEffect();
  122557. }
  122558. };
  122559. /**
  122560. * Internal
  122561. * @returns if all the contained post processes are ready.
  122562. * @hidden
  122563. */
  122564. BloomEffect.prototype._isReady = function () {
  122565. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  122566. if (!this._effects[effectIndex].isReady()) {
  122567. return false;
  122568. }
  122569. }
  122570. return true;
  122571. };
  122572. return BloomEffect;
  122573. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  122574. /***/ }),
  122575. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  122576. /*!************************************************!*\
  122577. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  122578. \************************************************/
  122579. /*! exports provided: BloomMergePostProcess */
  122580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122581. "use strict";
  122582. __webpack_require__.r(__webpack_exports__);
  122583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  122584. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122585. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122586. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122587. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  122588. /**
  122589. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  122590. */
  122591. var BloomMergePostProcess = /** @class */ (function (_super) {
  122592. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  122593. /**
  122594. * Creates a new instance of @see BloomMergePostProcess
  122595. * @param name The name of the effect.
  122596. * @param originalFromInput Post process which's input will be used for the merge.
  122597. * @param blurred Blurred highlights post process which's output will be used.
  122598. * @param weight Weight of the bloom to be added to the original input.
  122599. * @param options The required width/height ratio to downsize to before computing the render pass.
  122600. * @param camera The camera to apply the render pass to.
  122601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122602. * @param engine The engine which the post process will be applied. (default: current engine)
  122603. * @param reusable If the post process can be reused on the same frame. (default: false)
  122604. * @param textureType Type of textures used when performing the post process. (default: 0)
  122605. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  122606. */
  122607. function BloomMergePostProcess(name, originalFromInput, blurred,
  122608. /** Weight of the bloom to be added to the original input. */
  122609. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122610. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122611. if (blockCompilation === void 0) { blockCompilation = false; }
  122612. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  122613. _this.weight = weight;
  122614. _this.onApplyObservable.add(function (effect) {
  122615. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  122616. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  122617. effect.setFloat("bloomWeight", _this.weight);
  122618. });
  122619. if (!blockCompilation) {
  122620. _this.updateEffect();
  122621. }
  122622. return _this;
  122623. }
  122624. return BloomMergePostProcess;
  122625. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122626. /***/ }),
  122627. /***/ "./PostProcesses/blurPostProcess.ts":
  122628. /*!******************************************!*\
  122629. !*** ./PostProcesses/blurPostProcess.ts ***!
  122630. \******************************************/
  122631. /*! exports provided: BlurPostProcess */
  122632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122633. "use strict";
  122634. __webpack_require__.r(__webpack_exports__);
  122635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  122636. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122637. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122638. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122639. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122640. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  122641. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  122642. /**
  122643. * The Blur Post Process which blurs an image based on a kernel and direction.
  122644. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  122645. */
  122646. var BlurPostProcess = /** @class */ (function (_super) {
  122647. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  122648. /**
  122649. * Creates a new instance BlurPostProcess
  122650. * @param name The name of the effect.
  122651. * @param direction The direction in which to blur the image.
  122652. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  122653. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  122654. * @param camera The camera to apply the render pass to.
  122655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122656. * @param engine The engine which the post process will be applied. (default: current engine)
  122657. * @param reusable If the post process can be reused on the same frame. (default: false)
  122658. * @param textureType Type of textures used when performing the post process. (default: 0)
  122659. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  122660. */
  122661. function BlurPostProcess(name,
  122662. /** The direction in which to blur the image. */
  122663. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  122664. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  122665. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122666. if (defines === void 0) { defines = ""; }
  122667. if (blockCompilation === void 0) { blockCompilation = false; }
  122668. var _this = _super.call(this, name, "kernelBlur", ["delta", "direction", "cameraMinMaxZ"], ["circleOfConfusionSampler"], options, camera, samplingMode, engine, reusable, null, textureType, "kernelBlur", { varyingCount: 0, depCount: 0 }, true) || this;
  122669. _this.direction = direction;
  122670. _this.blockCompilation = blockCompilation;
  122671. _this._packedFloat = false;
  122672. _this._staticDefines = "";
  122673. _this._staticDefines = defines;
  122674. _this.onApplyObservable.add(function (effect) {
  122675. if (_this._outputTexture) {
  122676. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  122677. }
  122678. else {
  122679. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  122680. }
  122681. });
  122682. _this.kernel = kernel;
  122683. return _this;
  122684. }
  122685. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  122686. /**
  122687. * Gets the length in pixels of the blur sample region
  122688. */
  122689. get: function () {
  122690. return this._idealKernel;
  122691. },
  122692. /**
  122693. * Sets the length in pixels of the blur sample region
  122694. */
  122695. set: function (v) {
  122696. if (this._idealKernel === v) {
  122697. return;
  122698. }
  122699. v = Math.max(v, 1);
  122700. this._idealKernel = v;
  122701. this._kernel = this._nearestBestKernel(v);
  122702. if (!this.blockCompilation) {
  122703. this._updateParameters();
  122704. }
  122705. },
  122706. enumerable: true,
  122707. configurable: true
  122708. });
  122709. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  122710. /**
  122711. * Gets wether or not the blur is unpacking/repacking floats
  122712. */
  122713. get: function () {
  122714. return this._packedFloat;
  122715. },
  122716. /**
  122717. * Sets wether or not the blur needs to unpack/repack floats
  122718. */
  122719. set: function (v) {
  122720. if (this._packedFloat === v) {
  122721. return;
  122722. }
  122723. this._packedFloat = v;
  122724. if (!this.blockCompilation) {
  122725. this._updateParameters();
  122726. }
  122727. },
  122728. enumerable: true,
  122729. configurable: true
  122730. });
  122731. /**
  122732. * Updates the effect with the current post process compile time values and recompiles the shader.
  122733. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  122734. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  122735. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  122736. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  122737. * @param onCompiled Called when the shader has been compiled.
  122738. * @param onError Called if there is an error when compiling a shader.
  122739. */
  122740. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  122741. if (defines === void 0) { defines = null; }
  122742. if (uniforms === void 0) { uniforms = null; }
  122743. if (samplers === void 0) { samplers = null; }
  122744. this._updateParameters(onCompiled, onError);
  122745. };
  122746. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  122747. // Generate sampling offsets and weights
  122748. var N = this._kernel;
  122749. var centerIndex = (N - 1) / 2;
  122750. // Generate Gaussian sampling weights over kernel
  122751. var offsets = [];
  122752. var weights = [];
  122753. var totalWeight = 0;
  122754. for (var i = 0; i < N; i++) {
  122755. var u = i / (N - 1);
  122756. var w = this._gaussianWeight(u * 2.0 - 1);
  122757. offsets[i] = (i - centerIndex);
  122758. weights[i] = w;
  122759. totalWeight += w;
  122760. }
  122761. // Normalize weights
  122762. for (var i = 0; i < weights.length; i++) {
  122763. weights[i] /= totalWeight;
  122764. }
  122765. // Optimize: combine samples to take advantage of hardware linear sampling
  122766. // Walk from left to center, combining pairs (symmetrically)
  122767. var linearSamplingWeights = [];
  122768. var linearSamplingOffsets = [];
  122769. var linearSamplingMap = [];
  122770. for (var i = 0; i <= centerIndex; i += 2) {
  122771. var j = Math.min(i + 1, Math.floor(centerIndex));
  122772. var singleCenterSample = i === j;
  122773. if (singleCenterSample) {
  122774. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  122775. }
  122776. else {
  122777. var sharedCell = j === centerIndex;
  122778. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  122779. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  122780. if (offsetLinear === 0) {
  122781. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  122782. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  122783. }
  122784. else {
  122785. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  122786. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  122787. }
  122788. }
  122789. }
  122790. for (var i = 0; i < linearSamplingMap.length; i++) {
  122791. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  122792. linearSamplingWeights[i] = linearSamplingMap[i].w;
  122793. }
  122794. // Replace with optimized
  122795. offsets = linearSamplingOffsets;
  122796. weights = linearSamplingWeights;
  122797. // Generate shaders
  122798. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  122799. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  122800. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  122801. var defines = "";
  122802. defines += this._staticDefines;
  122803. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  122804. if (this._staticDefines.indexOf("DOF") != -1) {
  122805. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  122806. varyingCount--;
  122807. }
  122808. for (var i = 0; i < varyingCount; i++) {
  122809. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  122810. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  122811. }
  122812. var depCount = 0;
  122813. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  122814. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  122815. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  122816. depCount++;
  122817. }
  122818. if (this.packedFloat) {
  122819. defines += "#define PACKEDFLOAT 1";
  122820. }
  122821. this.blockCompilation = false;
  122822. _super.prototype.updateEffect.call(this, defines, null, null, {
  122823. varyingCount: varyingCount,
  122824. depCount: depCount
  122825. }, onCompiled, onError);
  122826. };
  122827. /**
  122828. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  122829. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  122830. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  122831. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  122832. * The gaps between physical kernels are compensated for in the weighting of the samples
  122833. * @param idealKernel Ideal blur kernel.
  122834. * @return Nearest best kernel.
  122835. */
  122836. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  122837. var v = Math.round(idealKernel);
  122838. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  122839. var k = _a[_i];
  122840. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  122841. return Math.max(k, 3);
  122842. }
  122843. }
  122844. return Math.max(v, 3);
  122845. };
  122846. /**
  122847. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  122848. * @param x The point on the Gaussian distribution to sample.
  122849. * @return the value of the Gaussian function at x.
  122850. */
  122851. BlurPostProcess.prototype._gaussianWeight = function (x) {
  122852. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  122853. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  122854. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  122855. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  122856. // truncated at around 1.3% of peak strength.
  122857. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  122858. var sigma = (1 / 3);
  122859. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  122860. var exponent = -((x * x) / (2.0 * sigma * sigma));
  122861. var weight = (1.0 / denominator) * Math.exp(exponent);
  122862. return weight;
  122863. };
  122864. /**
  122865. * Generates a string that can be used as a floating point number in GLSL.
  122866. * @param x Value to print.
  122867. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  122868. * @return GLSL float string.
  122869. */
  122870. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  122871. if (decimalFigures === void 0) { decimalFigures = 8; }
  122872. return x.toFixed(decimalFigures).replace(/0+$/, '');
  122873. };
  122874. return BlurPostProcess;
  122875. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122876. /***/ }),
  122877. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  122878. /*!*********************************************************!*\
  122879. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  122880. \*********************************************************/
  122881. /*! exports provided: ChromaticAberrationPostProcess */
  122882. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122883. "use strict";
  122884. __webpack_require__.r(__webpack_exports__);
  122885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  122886. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122887. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122888. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122889. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122890. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  122891. /**
  122892. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  122893. */
  122894. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  122895. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  122896. /**
  122897. * Creates a new instance ChromaticAberrationPostProcess
  122898. * @param name The name of the effect.
  122899. * @param screenWidth The width of the screen to apply the effect on.
  122900. * @param screenHeight The height of the screen to apply the effect on.
  122901. * @param options The required width/height ratio to downsize to before computing the render pass.
  122902. * @param camera The camera to apply the render pass to.
  122903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122904. * @param engine The engine which the post process will be applied. (default: current engine)
  122905. * @param reusable If the post process can be reused on the same frame. (default: false)
  122906. * @param textureType Type of textures used when performing the post process. (default: 0)
  122907. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  122908. */
  122909. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122910. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122911. if (blockCompilation === void 0) { blockCompilation = false; }
  122912. var _this = _super.call(this, name, "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  122913. /**
  122914. * The amount of seperation of rgb channels (default: 30)
  122915. */
  122916. _this.aberrationAmount = 30;
  122917. /**
  122918. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  122919. */
  122920. _this.radialIntensity = 0;
  122921. /**
  122922. * The normilized direction in which the rgb channels should be seperated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  122923. */
  122924. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  122925. /**
  122926. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corder] (default: Vector2(0.5 ,0.5))
  122927. */
  122928. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  122929. _this.onApplyObservable.add(function (effect) {
  122930. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  122931. effect.setFloat('screen_width', screenWidth);
  122932. effect.setFloat('screen_height', screenHeight);
  122933. effect.setFloat('radialIntensity', _this.radialIntensity);
  122934. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  122935. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  122936. });
  122937. return _this;
  122938. }
  122939. return ChromaticAberrationPostProcess;
  122940. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  122941. /***/ }),
  122942. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  122943. /*!*******************************************************!*\
  122944. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  122945. \*******************************************************/
  122946. /*! exports provided: CircleOfConfusionPostProcess */
  122947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122948. "use strict";
  122949. __webpack_require__.r(__webpack_exports__);
  122950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  122951. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122952. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122953. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  122954. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122955. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  122956. /**
  122957. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  122958. */
  122959. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  122960. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  122961. /**
  122962. * Creates a new instance CircleOfConfusionPostProcess
  122963. * @param name The name of the effect.
  122964. * @param depthTexture The depth texture of the scene to compute the circle of confusion. This must be set in order for this to function but may be set after initialization if needed.
  122965. * @param options The required width/height ratio to downsize to before computing the render pass.
  122966. * @param camera The camera to apply the render pass to.
  122967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122968. * @param engine The engine which the post process will be applied. (default: current engine)
  122969. * @param reusable If the post process can be reused on the same frame. (default: false)
  122970. * @param textureType Type of textures used when performing the post process. (default: 0)
  122971. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  122972. */
  122973. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122974. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122975. if (blockCompilation === void 0) { blockCompilation = false; }
  122976. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  122977. /**
  122978. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  122979. */
  122980. _this.lensSize = 50;
  122981. /**
  122982. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  122983. */
  122984. _this.fStop = 1.4;
  122985. /**
  122986. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  122987. */
  122988. _this.focusDistance = 2000;
  122989. /**
  122990. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  122991. */
  122992. _this.focalLength = 50;
  122993. _this._depthTexture = null;
  122994. _this._depthTexture = depthTexture;
  122995. _this.onApplyObservable.add(function (effect) {
  122996. if (!_this._depthTexture) {
  122997. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  122998. return;
  122999. }
  123000. effect.setTexture("depthSampler", _this._depthTexture);
  123001. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  123002. var aperture = _this.lensSize / _this.fStop;
  123003. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  123004. effect.setFloat('focusDistance', _this.focusDistance);
  123005. effect.setFloat('cocPrecalculation', cocPrecalculation);
  123006. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  123007. });
  123008. return _this;
  123009. }
  123010. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  123011. /**
  123012. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  123013. */
  123014. set: function (value) {
  123015. this._depthTexture = value;
  123016. },
  123017. enumerable: true,
  123018. configurable: true
  123019. });
  123020. return CircleOfConfusionPostProcess;
  123021. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123022. /***/ }),
  123023. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  123024. /*!*****************************************************!*\
  123025. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  123026. \*****************************************************/
  123027. /*! exports provided: ColorCorrectionPostProcess */
  123028. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123029. "use strict";
  123030. __webpack_require__.r(__webpack_exports__);
  123031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  123032. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123033. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123034. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123035. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  123036. /**
  123037. *
  123038. * This post-process allows the modification of rendered colors by using
  123039. * a 'look-up table' (LUT). This effect is also called Color Grading.
  123040. *
  123041. * The object needs to be provided an url to a texture containing the color
  123042. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  123043. * Use an image editing software to tweak the LUT to match your needs.
  123044. *
  123045. * For an example of a color LUT, see here:
  123046. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  123047. * For explanations on color grading, see here:
  123048. * @see http://udn.epicgames.com/Three/ColorGrading.html
  123049. *
  123050. */
  123051. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  123052. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  123053. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  123054. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  123055. _this._colorTableTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"](colorTableUrl, camera.getScene(), true, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].TRILINEAR_SAMPLINGMODE);
  123056. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  123057. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  123058. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  123059. _this.onApply = function (effect) {
  123060. effect.setTexture("colorTable", _this._colorTableTexture);
  123061. };
  123062. return _this;
  123063. }
  123064. return ColorCorrectionPostProcess;
  123065. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123066. /***/ }),
  123067. /***/ "./PostProcesses/convolutionPostProcess.ts":
  123068. /*!*************************************************!*\
  123069. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  123070. \*************************************************/
  123071. /*! exports provided: ConvolutionPostProcess */
  123072. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123073. "use strict";
  123074. __webpack_require__.r(__webpack_exports__);
  123075. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  123076. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123077. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123078. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123079. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  123080. /**
  123081. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  123082. * input texture to perform effects such as edge detection or sharpening
  123083. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  123084. */
  123085. var ConvolutionPostProcess = /** @class */ (function (_super) {
  123086. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  123087. /**
  123088. * Creates a new instance ConvolutionPostProcess
  123089. * @param name The name of the effect.
  123090. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  123091. * @param options The required width/height ratio to downsize to before computing the render pass.
  123092. * @param camera The camera to apply the render pass to.
  123093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123094. * @param engine The engine which the post process will be applied. (default: current engine)
  123095. * @param reusable If the post process can be reused on the same frame. (default: false)
  123096. * @param textureType Type of textures used when performing the post process. (default: 0)
  123097. */
  123098. function ConvolutionPostProcess(name,
  123099. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  123100. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  123101. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123102. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  123103. _this.kernel = kernel;
  123104. _this.onApply = function (effect) {
  123105. effect.setFloat2("screenSize", _this.width, _this.height);
  123106. effect.setArray("kernel", _this.kernel);
  123107. };
  123108. return _this;
  123109. }
  123110. // Statics
  123111. /**
  123112. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123113. */
  123114. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  123115. /**
  123116. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123117. */
  123118. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  123119. /**
  123120. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123121. */
  123122. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  123123. /**
  123124. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123125. */
  123126. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  123127. /**
  123128. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123129. */
  123130. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  123131. /**
  123132. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123133. */
  123134. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  123135. return ConvolutionPostProcess;
  123136. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123137. /***/ }),
  123138. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  123139. /*!******************************************************!*\
  123140. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  123141. \******************************************************/
  123142. /*! exports provided: DepthOfFieldBlurPostProcess */
  123143. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123144. "use strict";
  123145. __webpack_require__.r(__webpack_exports__);
  123146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  123147. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123148. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123149. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  123150. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123151. /**
  123152. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  123153. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  123154. * based on samples that have a large difference in distance than the center pixel.
  123155. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  123156. */
  123157. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  123158. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  123159. /**
  123160. * Creates a new instance CircleOfConfusionPostProcess
  123161. * @param name The name of the effect.
  123162. * @param scene The scene the effect belongs to.
  123163. * @param direction The direction the blur should be applied.
  123164. * @param kernel The size of the kernel used to blur.
  123165. * @param options The required width/height ratio to downsize to before computing the render pass.
  123166. * @param camera The camera to apply the render pass to.
  123167. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  123168. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  123169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123170. * @param engine The engine which the post process will be applied. (default: current engine)
  123171. * @param reusable If the post process can be reused on the same frame. (default: false)
  123172. * @param textureType Type of textures used when performing the post process. (default: 0)
  123173. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  123174. */
  123175. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  123176. if (imageToBlur === void 0) { imageToBlur = null; }
  123177. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  123178. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123179. if (blockCompilation === void 0) { blockCompilation = false; }
  123180. var _this = _super.call(this, name, direction, kernel, options, camera, samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE, engine, reusable, textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT, "#define DOF 1\r\n", blockCompilation) || this;
  123181. _this.direction = direction;
  123182. _this.onApplyObservable.add(function (effect) {
  123183. if (imageToBlur != null) {
  123184. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  123185. }
  123186. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  123187. if (scene.activeCamera) {
  123188. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  123189. }
  123190. });
  123191. return _this;
  123192. }
  123193. return DepthOfFieldBlurPostProcess;
  123194. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  123195. /***/ }),
  123196. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  123197. /*!*********************************************!*\
  123198. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  123199. \*********************************************/
  123200. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  123201. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123202. "use strict";
  123203. __webpack_require__.r(__webpack_exports__);
  123204. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  123205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  123206. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123207. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123208. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123209. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  123210. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  123211. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  123212. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  123213. /**
  123214. * Specifies the level of max blur that should be applied when using the depth of field effect
  123215. */
  123216. var DepthOfFieldEffectBlurLevel;
  123217. (function (DepthOfFieldEffectBlurLevel) {
  123218. /**
  123219. * Subtle blur
  123220. */
  123221. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  123222. /**
  123223. * Medium blur
  123224. */
  123225. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  123226. /**
  123227. * Large blur
  123228. */
  123229. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  123230. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  123231. /**
  123232. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  123233. */
  123234. var DepthOfFieldEffect = /** @class */ (function (_super) {
  123235. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  123236. /**
  123237. * Creates a new instance DepthOfFieldEffect
  123238. * @param scene The scene the effect belongs to.
  123239. * @param depthTexture The depth texture of the scene to compute the circle of confusion.This must be set in order for this to function but may be set after initialization if needed.
  123240. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  123241. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  123242. */
  123243. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  123244. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  123245. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  123246. if (blockCompilation === void 0) { blockCompilation = false; }
  123247. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  123248. return _this._effects;
  123249. }, true) || this;
  123250. /**
  123251. * @hidden Internal post processes in depth of field effect
  123252. */
  123253. _this._effects = [];
  123254. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  123255. _this._circleOfConfusion = new _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__["CircleOfConfusionPostProcess"]("circleOfConfusion", depthTexture, 1, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType, blockCompilation);
  123256. // Create a pyramid of blurred images (eg. fullSize 1/4 blur, half size 1/2 blur, quarter size 3/4 blur, eith size 4/4 blur)
  123257. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  123258. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  123259. _this._depthOfFieldBlurY = [];
  123260. _this._depthOfFieldBlurX = [];
  123261. var blurCount = 1;
  123262. var kernelSize = 15;
  123263. switch (blurLevel) {
  123264. case DepthOfFieldEffectBlurLevel.High: {
  123265. blurCount = 3;
  123266. kernelSize = 51;
  123267. break;
  123268. }
  123269. case DepthOfFieldEffectBlurLevel.Medium: {
  123270. blurCount = 2;
  123271. kernelSize = 31;
  123272. break;
  123273. }
  123274. default: {
  123275. kernelSize = 15;
  123276. blurCount = 1;
  123277. break;
  123278. }
  123279. }
  123280. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  123281. var ratio = 1.0;
  123282. for (var i = 0; i < blurCount; i++) {
  123283. var blurY = new _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__["DepthOfFieldBlurPostProcess"]("verticle blur", scene, new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 1.0), adjustedKernelSize, ratio, null, _this._circleOfConfusion, i == 0 ? _this._circleOfConfusion : null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType, blockCompilation);
  123284. blurY.autoClear = false;
  123285. ratio = 0.75 / Math.pow(2, i);
  123286. var blurX = new _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__["DepthOfFieldBlurPostProcess"]("horizontal blur", scene, new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1.0, 0), adjustedKernelSize, ratio, null, _this._circleOfConfusion, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType, blockCompilation);
  123287. blurX.autoClear = false;
  123288. _this._depthOfFieldBlurY.push(blurY);
  123289. _this._depthOfFieldBlurX.push(blurX);
  123290. }
  123291. // Set all post processes on the effect.
  123292. _this._effects = [_this._circleOfConfusion];
  123293. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  123294. _this._effects.push(_this._depthOfFieldBlurY[i]);
  123295. _this._effects.push(_this._depthOfFieldBlurX[i]);
  123296. }
  123297. // Merge blurred images with original image based on circleOfConfusion
  123298. _this._dofMerge = new _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__["DepthOfFieldMergePostProcess"]("dofMerge", _this._circleOfConfusion, _this._circleOfConfusion, _this._depthOfFieldBlurX, ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType, blockCompilation);
  123299. _this._dofMerge.autoClear = false;
  123300. _this._effects.push(_this._dofMerge);
  123301. return _this;
  123302. }
  123303. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  123304. get: function () {
  123305. return this._circleOfConfusion.focalLength;
  123306. },
  123307. /**
  123308. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  123309. */
  123310. set: function (value) {
  123311. this._circleOfConfusion.focalLength = value;
  123312. },
  123313. enumerable: true,
  123314. configurable: true
  123315. });
  123316. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  123317. get: function () {
  123318. return this._circleOfConfusion.fStop;
  123319. },
  123320. /**
  123321. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  123322. */
  123323. set: function (value) {
  123324. this._circleOfConfusion.fStop = value;
  123325. },
  123326. enumerable: true,
  123327. configurable: true
  123328. });
  123329. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  123330. get: function () {
  123331. return this._circleOfConfusion.focusDistance;
  123332. },
  123333. /**
  123334. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  123335. */
  123336. set: function (value) {
  123337. this._circleOfConfusion.focusDistance = value;
  123338. },
  123339. enumerable: true,
  123340. configurable: true
  123341. });
  123342. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  123343. get: function () {
  123344. return this._circleOfConfusion.lensSize;
  123345. },
  123346. /**
  123347. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  123348. */
  123349. set: function (value) {
  123350. this._circleOfConfusion.lensSize = value;
  123351. },
  123352. enumerable: true,
  123353. configurable: true
  123354. });
  123355. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  123356. /**
  123357. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  123358. */
  123359. set: function (value) {
  123360. this._circleOfConfusion.depthTexture = value;
  123361. },
  123362. enumerable: true,
  123363. configurable: true
  123364. });
  123365. /**
  123366. * Disposes each of the internal effects for a given camera.
  123367. * @param camera The camera to dispose the effect on.
  123368. */
  123369. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  123370. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  123371. this._effects[effectIndex].dispose(camera);
  123372. }
  123373. };
  123374. /**
  123375. * @hidden Internal
  123376. */
  123377. DepthOfFieldEffect.prototype._updateEffects = function () {
  123378. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  123379. this._effects[effectIndex].updateEffect();
  123380. }
  123381. };
  123382. /**
  123383. * Internal
  123384. * @returns if all the contained post processes are ready.
  123385. * @hidden
  123386. */
  123387. DepthOfFieldEffect.prototype._isReady = function () {
  123388. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  123389. if (!this._effects[effectIndex].isReady()) {
  123390. return false;
  123391. }
  123392. }
  123393. return true;
  123394. };
  123395. return DepthOfFieldEffect;
  123396. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  123397. /***/ }),
  123398. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  123399. /*!*******************************************************!*\
  123400. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  123401. \*******************************************************/
  123402. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  123403. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123404. "use strict";
  123405. __webpack_require__.r(__webpack_exports__);
  123406. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  123407. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  123408. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123409. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123410. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123411. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  123412. /**
  123413. * Options to be set when merging outputs from the default pipeline.
  123414. */
  123415. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  123416. function DepthOfFieldMergePostProcessOptions() {
  123417. }
  123418. return DepthOfFieldMergePostProcessOptions;
  123419. }());
  123420. /**
  123421. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123422. */
  123423. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  123424. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  123425. /**
  123426. * Creates a new instance of DepthOfFieldMergePostProcess
  123427. * @param name The name of the effect.
  123428. * @param originalFromInput Post process which's input will be used for the merge.
  123429. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  123430. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  123431. * @param options The required width/height ratio to downsize to before computing the render pass.
  123432. * @param camera The camera to apply the render pass to.
  123433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123434. * @param engine The engine which the post process will be applied. (default: current engine)
  123435. * @param reusable If the post process can be reused on the same frame. (default: false)
  123436. * @param textureType Type of textures used when performing the post process. (default: 0)
  123437. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  123438. */
  123439. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  123440. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123441. if (blockCompilation === void 0) { blockCompilation = false; }
  123442. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  123443. _this.blurSteps = blurSteps;
  123444. _this.onApplyObservable.add(function (effect) {
  123445. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  123446. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  123447. blurSteps.forEach(function (step, index) {
  123448. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  123449. });
  123450. });
  123451. if (!blockCompilation) {
  123452. _this.updateEffect();
  123453. }
  123454. return _this;
  123455. }
  123456. /**
  123457. * Updates the effect with the current post process compile time values and recompiles the shader.
  123458. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  123459. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  123460. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  123461. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  123462. * @param onCompiled Called when the shader has been compiled.
  123463. * @param onError Called if there is an error when compiling a shader.
  123464. */
  123465. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  123466. if (defines === void 0) { defines = null; }
  123467. if (uniforms === void 0) { uniforms = null; }
  123468. if (samplers === void 0) { samplers = null; }
  123469. if (!defines) {
  123470. defines = "";
  123471. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  123472. }
  123473. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  123474. };
  123475. return DepthOfFieldMergePostProcess;
  123476. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123477. /***/ }),
  123478. /***/ "./PostProcesses/displayPassPostProcess.ts":
  123479. /*!*************************************************!*\
  123480. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  123481. \*************************************************/
  123482. /*! exports provided: DisplayPassPostProcess */
  123483. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123484. "use strict";
  123485. __webpack_require__.r(__webpack_exports__);
  123486. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  123487. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123488. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123489. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  123490. /**
  123491. * DisplayPassPostProcess which produces an output the same as it's input
  123492. */
  123493. var DisplayPassPostProcess = /** @class */ (function (_super) {
  123494. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  123495. /**
  123496. * Creates the DisplayPassPostProcess
  123497. * @param name The name of the effect.
  123498. * @param options The required width/height ratio to downsize to before computing the render pass.
  123499. * @param camera The camera to apply the render pass to.
  123500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123501. * @param engine The engine which the post process will be applied. (default: current engine)
  123502. * @param reusable If the post process can be reused on the same frame. (default: false)
  123503. */
  123504. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  123505. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  123506. }
  123507. return DisplayPassPostProcess;
  123508. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123509. /***/ }),
  123510. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  123511. /*!*******************************************************!*\
  123512. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  123513. \*******************************************************/
  123514. /*! exports provided: ExtractHighlightsPostProcess */
  123515. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123516. "use strict";
  123517. __webpack_require__.r(__webpack_exports__);
  123518. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  123519. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123520. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123521. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123522. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123523. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  123524. /**
  123525. * The extract highlights post process sets all pixels to black except pixels above the specified luminance threshold. Used as the first step for a bloom effect.
  123526. */
  123527. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  123528. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  123529. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  123530. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123531. if (blockCompilation === void 0) { blockCompilation = false; }
  123532. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  123533. /**
  123534. * The luminance threshold, pixels below this value will be set to black.
  123535. */
  123536. _this.threshold = 0.9;
  123537. /** @hidden */
  123538. _this._exposure = 1;
  123539. /**
  123540. * Post process which has the input texture to be used when performing highlight extraction
  123541. * @hidden
  123542. */
  123543. _this._inputPostProcess = null;
  123544. _this.onApplyObservable.add(function (effect) {
  123545. if (_this._inputPostProcess) {
  123546. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  123547. }
  123548. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  123549. effect.setFloat('exposure', _this._exposure);
  123550. });
  123551. return _this;
  123552. }
  123553. return ExtractHighlightsPostProcess;
  123554. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123555. /***/ }),
  123556. /***/ "./PostProcesses/filterPostProcess.ts":
  123557. /*!********************************************!*\
  123558. !*** ./PostProcesses/filterPostProcess.ts ***!
  123559. \********************************************/
  123560. /*! exports provided: FilterPostProcess */
  123561. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123562. "use strict";
  123563. __webpack_require__.r(__webpack_exports__);
  123564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  123565. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123566. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123567. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  123568. /**
  123569. * Applies a kernel filter to the image
  123570. */
  123571. var FilterPostProcess = /** @class */ (function (_super) {
  123572. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  123573. /**
  123574. *
  123575. * @param name The name of the effect.
  123576. * @param kernelMatrix The matrix to be applied to the image
  123577. * @param options The required width/height ratio to downsize to before computing the render pass.
  123578. * @param camera The camera to apply the render pass to.
  123579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123580. * @param engine The engine which the post process will be applied. (default: current engine)
  123581. * @param reusable If the post process can be reused on the same frame. (default: false)
  123582. */
  123583. function FilterPostProcess(name,
  123584. /** The matrix to be applied to the image */
  123585. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  123586. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  123587. _this.kernelMatrix = kernelMatrix;
  123588. _this.onApply = function (effect) {
  123589. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  123590. };
  123591. return _this;
  123592. }
  123593. return FilterPostProcess;
  123594. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123595. /***/ }),
  123596. /***/ "./PostProcesses/fxaaPostProcess.ts":
  123597. /*!******************************************!*\
  123598. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  123599. \******************************************/
  123600. /*! exports provided: FxaaPostProcess */
  123601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123602. "use strict";
  123603. __webpack_require__.r(__webpack_exports__);
  123604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  123605. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123606. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123607. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123608. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123609. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  123610. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  123611. /**
  123612. * Fxaa post process
  123613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  123614. */
  123615. var FxaaPostProcess = /** @class */ (function (_super) {
  123616. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  123617. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  123618. if (camera === void 0) { camera = null; }
  123619. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123620. var _this = _super.call(this, name, "fxaa", ["texelSize"], null, options, camera, samplingMode || _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE, engine, reusable, null, textureType, "fxaa", undefined, true) || this;
  123621. var defines = _this._getDefines();
  123622. _this.updateEffect(defines);
  123623. _this.onApplyObservable.add(function (effect) {
  123624. var texelSize = _this.texelSize;
  123625. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  123626. });
  123627. return _this;
  123628. }
  123629. FxaaPostProcess.prototype._getDefines = function () {
  123630. var engine = this.getEngine();
  123631. if (!engine) {
  123632. return null;
  123633. }
  123634. var glInfo = engine.getGlInfo();
  123635. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  123636. return "#define MALI 1\n";
  123637. }
  123638. return null;
  123639. };
  123640. return FxaaPostProcess;
  123641. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  123642. /***/ }),
  123643. /***/ "./PostProcesses/grainPostProcess.ts":
  123644. /*!*******************************************!*\
  123645. !*** ./PostProcesses/grainPostProcess.ts ***!
  123646. \*******************************************/
  123647. /*! exports provided: GrainPostProcess */
  123648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123649. "use strict";
  123650. __webpack_require__.r(__webpack_exports__);
  123651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  123652. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123653. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123654. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123655. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  123656. /**
  123657. * The GrainPostProcess adds noise to the image at mid luminance levels
  123658. */
  123659. var GrainPostProcess = /** @class */ (function (_super) {
  123660. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  123661. /**
  123662. * Creates a new instance of @see GrainPostProcess
  123663. * @param name The name of the effect.
  123664. * @param options The required width/height ratio to downsize to before computing the render pass.
  123665. * @param camera The camera to apply the render pass to.
  123666. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123667. * @param engine The engine which the post process will be applied. (default: current engine)
  123668. * @param reusable If the post process can be reused on the same frame. (default: false)
  123669. * @param textureType Type of textures used when performing the post process. (default: 0)
  123670. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  123671. */
  123672. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  123673. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123674. if (blockCompilation === void 0) { blockCompilation = false; }
  123675. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  123676. /**
  123677. * The intensity of the grain added (default: 30)
  123678. */
  123679. _this.intensity = 30;
  123680. /**
  123681. * If the grain should be randomized on every frame
  123682. */
  123683. _this.animated = false;
  123684. _this.onApplyObservable.add(function (effect) {
  123685. effect.setFloat('intensity', _this.intensity);
  123686. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  123687. });
  123688. return _this;
  123689. }
  123690. return GrainPostProcess;
  123691. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123692. /***/ }),
  123693. /***/ "./PostProcesses/highlightsPostProcess.ts":
  123694. /*!************************************************!*\
  123695. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  123696. \************************************************/
  123697. /*! exports provided: HighlightsPostProcess */
  123698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123699. "use strict";
  123700. __webpack_require__.r(__webpack_exports__);
  123701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  123702. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123703. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123704. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123705. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  123706. /**
  123707. * Extracts highlights from the image
  123708. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  123709. */
  123710. var HighlightsPostProcess = /** @class */ (function (_super) {
  123711. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  123712. /**
  123713. * Extracts highlights from the image
  123714. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  123715. * @param name The name of the effect.
  123716. * @param options The required width/height ratio to downsize to before computing the render pass.
  123717. * @param camera The camera to apply the render pass to.
  123718. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123719. * @param engine The engine which the post process will be applied. (default: current engine)
  123720. * @param reusable If the post process can be reused on the same frame. (default: false)
  123721. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  123722. */
  123723. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  123724. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123725. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  123726. }
  123727. return HighlightsPostProcess;
  123728. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123729. /***/ }),
  123730. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  123731. /*!*****************************************************!*\
  123732. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  123733. \*****************************************************/
  123734. /*! exports provided: ImageProcessingPostProcess */
  123735. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123736. "use strict";
  123737. __webpack_require__.r(__webpack_exports__);
  123738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  123739. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123740. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  123741. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  123742. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123743. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  123744. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123745. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  123746. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  123747. /**
  123748. * ImageProcessingPostProcess
  123749. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  123750. */
  123751. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  123752. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  123753. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  123754. if (camera === void 0) { camera = null; }
  123755. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123756. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  123757. _this._fromLinearSpace = true;
  123758. /**
  123759. * Defines cache preventing GC.
  123760. */
  123761. _this._defines = {
  123762. IMAGEPROCESSING: false,
  123763. VIGNETTE: false,
  123764. VIGNETTEBLENDMODEMULTIPLY: false,
  123765. VIGNETTEBLENDMODEOPAQUE: false,
  123766. TONEMAPPING: false,
  123767. TONEMAPPING_ACES: false,
  123768. CONTRAST: false,
  123769. COLORCURVES: false,
  123770. COLORGRADING: false,
  123771. COLORGRADING3D: false,
  123772. FROMLINEARSPACE: false,
  123773. SAMPLER3DGREENDEPTH: false,
  123774. SAMPLER3DBGRMAP: false,
  123775. IMAGEPROCESSINGPOSTPROCESS: false,
  123776. EXPOSURE: false,
  123777. };
  123778. // Setup the configuration as forced by the constructor. This would then not force the
  123779. // scene materials output in linear space and let untouched the default forward pass.
  123780. if (imageProcessingConfiguration) {
  123781. imageProcessingConfiguration.applyByPostProcess = true;
  123782. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  123783. // This will cause the shader to be compiled
  123784. _this.fromLinearSpace = false;
  123785. }
  123786. // Setup the default processing configuration to the scene.
  123787. else {
  123788. _this._attachImageProcessingConfiguration(null, true);
  123789. _this.imageProcessingConfiguration.applyByPostProcess = true;
  123790. }
  123791. _this.onApply = function (effect) {
  123792. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  123793. };
  123794. return _this;
  123795. }
  123796. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  123797. /**
  123798. * Gets the image processing configuration used either in this material.
  123799. */
  123800. get: function () {
  123801. return this._imageProcessingConfiguration;
  123802. },
  123803. /**
  123804. * Sets the Default image processing configuration used either in the this material.
  123805. *
  123806. * If sets to null, the scene one is in use.
  123807. */
  123808. set: function (value) {
  123809. this._attachImageProcessingConfiguration(value);
  123810. },
  123811. enumerable: true,
  123812. configurable: true
  123813. });
  123814. /**
  123815. * Attaches a new image processing configuration to the PBR Material.
  123816. * @param configuration
  123817. */
  123818. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  123819. var _this = this;
  123820. if (doNotBuild === void 0) { doNotBuild = false; }
  123821. if (configuration === this._imageProcessingConfiguration) {
  123822. return;
  123823. }
  123824. // Detaches observer.
  123825. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  123826. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  123827. }
  123828. // Pick the scene configuration if needed.
  123829. if (!configuration) {
  123830. var scene = null;
  123831. var engine = this.getEngine();
  123832. var camera = this.getCamera();
  123833. if (camera) {
  123834. scene = camera.getScene();
  123835. }
  123836. else if (engine && engine.scenes) {
  123837. var scenes = engine.scenes;
  123838. scene = scenes[scenes.length - 1];
  123839. }
  123840. else {
  123841. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  123842. }
  123843. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  123844. }
  123845. else {
  123846. this._imageProcessingConfiguration = configuration;
  123847. }
  123848. // Attaches observer.
  123849. if (this._imageProcessingConfiguration) {
  123850. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  123851. _this._updateParameters();
  123852. });
  123853. }
  123854. // Ensure the effect will be rebuilt.
  123855. if (!doNotBuild) {
  123856. this._updateParameters();
  123857. }
  123858. };
  123859. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  123860. /**
  123861. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123862. */
  123863. get: function () {
  123864. return this.imageProcessingConfiguration.colorCurves;
  123865. },
  123866. /**
  123867. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123868. */
  123869. set: function (value) {
  123870. this.imageProcessingConfiguration.colorCurves = value;
  123871. },
  123872. enumerable: true,
  123873. configurable: true
  123874. });
  123875. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  123876. /**
  123877. * Gets wether the color curves effect is enabled.
  123878. */
  123879. get: function () {
  123880. return this.imageProcessingConfiguration.colorCurvesEnabled;
  123881. },
  123882. /**
  123883. * Sets wether the color curves effect is enabled.
  123884. */
  123885. set: function (value) {
  123886. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  123887. },
  123888. enumerable: true,
  123889. configurable: true
  123890. });
  123891. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  123892. /**
  123893. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123894. */
  123895. get: function () {
  123896. return this.imageProcessingConfiguration.colorGradingTexture;
  123897. },
  123898. /**
  123899. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123900. */
  123901. set: function (value) {
  123902. this.imageProcessingConfiguration.colorGradingTexture = value;
  123903. },
  123904. enumerable: true,
  123905. configurable: true
  123906. });
  123907. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  123908. /**
  123909. * Gets wether the color grading effect is enabled.
  123910. */
  123911. get: function () {
  123912. return this.imageProcessingConfiguration.colorGradingEnabled;
  123913. },
  123914. /**
  123915. * Gets wether the color grading effect is enabled.
  123916. */
  123917. set: function (value) {
  123918. this.imageProcessingConfiguration.colorGradingEnabled = value;
  123919. },
  123920. enumerable: true,
  123921. configurable: true
  123922. });
  123923. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  123924. /**
  123925. * Gets exposure used in the effect.
  123926. */
  123927. get: function () {
  123928. return this.imageProcessingConfiguration.exposure;
  123929. },
  123930. /**
  123931. * Sets exposure used in the effect.
  123932. */
  123933. set: function (value) {
  123934. this.imageProcessingConfiguration.exposure = value;
  123935. },
  123936. enumerable: true,
  123937. configurable: true
  123938. });
  123939. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  123940. /**
  123941. * Gets wether tonemapping is enabled or not.
  123942. */
  123943. get: function () {
  123944. return this._imageProcessingConfiguration.toneMappingEnabled;
  123945. },
  123946. /**
  123947. * Sets wether tonemapping is enabled or not
  123948. */
  123949. set: function (value) {
  123950. this._imageProcessingConfiguration.toneMappingEnabled = value;
  123951. },
  123952. enumerable: true,
  123953. configurable: true
  123954. });
  123955. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingType", {
  123956. /**
  123957. * Gets the type of tone mapping effect.
  123958. */
  123959. get: function () {
  123960. return this._imageProcessingConfiguration.toneMappingType;
  123961. },
  123962. /**
  123963. * Sets the type of tone mapping effect.
  123964. */
  123965. set: function (value) {
  123966. this._imageProcessingConfiguration.toneMappingType = value;
  123967. },
  123968. enumerable: true,
  123969. configurable: true
  123970. });
  123971. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  123972. /**
  123973. * Gets contrast used in the effect.
  123974. */
  123975. get: function () {
  123976. return this.imageProcessingConfiguration.contrast;
  123977. },
  123978. /**
  123979. * Sets contrast used in the effect.
  123980. */
  123981. set: function (value) {
  123982. this.imageProcessingConfiguration.contrast = value;
  123983. },
  123984. enumerable: true,
  123985. configurable: true
  123986. });
  123987. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  123988. /**
  123989. * Gets Vignette stretch size.
  123990. */
  123991. get: function () {
  123992. return this.imageProcessingConfiguration.vignetteStretch;
  123993. },
  123994. /**
  123995. * Sets Vignette stretch size.
  123996. */
  123997. set: function (value) {
  123998. this.imageProcessingConfiguration.vignetteStretch = value;
  123999. },
  124000. enumerable: true,
  124001. configurable: true
  124002. });
  124003. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  124004. /**
  124005. * Gets Vignette centre X Offset.
  124006. */
  124007. get: function () {
  124008. return this.imageProcessingConfiguration.vignetteCentreX;
  124009. },
  124010. /**
  124011. * Sets Vignette centre X Offset.
  124012. */
  124013. set: function (value) {
  124014. this.imageProcessingConfiguration.vignetteCentreX = value;
  124015. },
  124016. enumerable: true,
  124017. configurable: true
  124018. });
  124019. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  124020. /**
  124021. * Gets Vignette centre Y Offset.
  124022. */
  124023. get: function () {
  124024. return this.imageProcessingConfiguration.vignetteCentreY;
  124025. },
  124026. /**
  124027. * Sets Vignette centre Y Offset.
  124028. */
  124029. set: function (value) {
  124030. this.imageProcessingConfiguration.vignetteCentreY = value;
  124031. },
  124032. enumerable: true,
  124033. configurable: true
  124034. });
  124035. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  124036. /**
  124037. * Gets Vignette weight or intensity of the vignette effect.
  124038. */
  124039. get: function () {
  124040. return this.imageProcessingConfiguration.vignetteWeight;
  124041. },
  124042. /**
  124043. * Sets Vignette weight or intensity of the vignette effect.
  124044. */
  124045. set: function (value) {
  124046. this.imageProcessingConfiguration.vignetteWeight = value;
  124047. },
  124048. enumerable: true,
  124049. configurable: true
  124050. });
  124051. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  124052. /**
  124053. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  124054. * if vignetteEnabled is set to true.
  124055. */
  124056. get: function () {
  124057. return this.imageProcessingConfiguration.vignetteColor;
  124058. },
  124059. /**
  124060. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  124061. * if vignetteEnabled is set to true.
  124062. */
  124063. set: function (value) {
  124064. this.imageProcessingConfiguration.vignetteColor = value;
  124065. },
  124066. enumerable: true,
  124067. configurable: true
  124068. });
  124069. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  124070. /**
  124071. * Gets Camera field of view used by the Vignette effect.
  124072. */
  124073. get: function () {
  124074. return this.imageProcessingConfiguration.vignetteCameraFov;
  124075. },
  124076. /**
  124077. * Sets Camera field of view used by the Vignette effect.
  124078. */
  124079. set: function (value) {
  124080. this.imageProcessingConfiguration.vignetteCameraFov = value;
  124081. },
  124082. enumerable: true,
  124083. configurable: true
  124084. });
  124085. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  124086. /**
  124087. * Gets the vignette blend mode allowing different kind of effect.
  124088. */
  124089. get: function () {
  124090. return this.imageProcessingConfiguration.vignetteBlendMode;
  124091. },
  124092. /**
  124093. * Sets the vignette blend mode allowing different kind of effect.
  124094. */
  124095. set: function (value) {
  124096. this.imageProcessingConfiguration.vignetteBlendMode = value;
  124097. },
  124098. enumerable: true,
  124099. configurable: true
  124100. });
  124101. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  124102. /**
  124103. * Gets wether the vignette effect is enabled.
  124104. */
  124105. get: function () {
  124106. return this.imageProcessingConfiguration.vignetteEnabled;
  124107. },
  124108. /**
  124109. * Sets wether the vignette effect is enabled.
  124110. */
  124111. set: function (value) {
  124112. this.imageProcessingConfiguration.vignetteEnabled = value;
  124113. },
  124114. enumerable: true,
  124115. configurable: true
  124116. });
  124117. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  124118. /**
  124119. * Gets wether the input of the processing is in Gamma or Linear Space.
  124120. */
  124121. get: function () {
  124122. return this._fromLinearSpace;
  124123. },
  124124. /**
  124125. * Sets wether the input of the processing is in Gamma or Linear Space.
  124126. */
  124127. set: function (value) {
  124128. if (this._fromLinearSpace === value) {
  124129. return;
  124130. }
  124131. this._fromLinearSpace = value;
  124132. this._updateParameters();
  124133. },
  124134. enumerable: true,
  124135. configurable: true
  124136. });
  124137. /**
  124138. * "ImageProcessingPostProcess"
  124139. * @returns "ImageProcessingPostProcess"
  124140. */
  124141. ImageProcessingPostProcess.prototype.getClassName = function () {
  124142. return "ImageProcessingPostProcess";
  124143. };
  124144. ImageProcessingPostProcess.prototype._updateParameters = function () {
  124145. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  124146. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  124147. var defines = "";
  124148. for (var define in this._defines) {
  124149. if (this._defines[define]) {
  124150. defines += "#define " + define + ";\r\n";
  124151. }
  124152. }
  124153. var samplers = ["textureSampler"];
  124154. var uniforms = ["scale"];
  124155. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  124156. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  124157. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  124158. }
  124159. this.updateEffect(defines, uniforms, samplers);
  124160. };
  124161. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  124162. _super.prototype.dispose.call(this, camera);
  124163. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  124164. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  124165. }
  124166. if (this._imageProcessingConfiguration) {
  124167. this.imageProcessingConfiguration.applyByPostProcess = false;
  124168. }
  124169. };
  124170. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124171. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124172. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  124173. return ImageProcessingPostProcess;
  124174. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  124175. /***/ }),
  124176. /***/ "./PostProcesses/index.ts":
  124177. /*!********************************!*\
  124178. !*** ./PostProcesses/index.ts ***!
  124179. \********************************/
  124180. /*! exports provided: AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, VRMultiviewToSingleviewPostProcess, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  124181. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124182. "use strict";
  124183. __webpack_require__.r(__webpack_exports__);
  124184. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  124185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  124186. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  124187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  124188. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  124189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  124190. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  124191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  124192. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  124193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  124194. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  124195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  124196. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  124197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  124198. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  124199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  124200. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  124201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  124202. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  124203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  124204. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  124205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  124206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  124207. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  124208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  124209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  124210. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  124211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  124212. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  124213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  124214. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  124215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  124216. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  124217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  124218. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  124219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  124220. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  124221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  124222. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  124223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  124224. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  124225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  124226. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  124227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  124228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  124229. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  124231. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  124232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  124233. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  124234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  124235. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  124236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  124237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  124238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  124239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  124240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  124241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  124242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  124243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  124244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  124245. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  124246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  124247. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  124248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  124249. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  124250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  124251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  124252. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  124253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  124254. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  124255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  124256. /* harmony import */ var _vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  124257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_30__["VRMultiviewToSingleviewPostProcess"]; });
  124258. /***/ }),
  124259. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  124260. /*!************************************************!*\
  124261. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  124262. \************************************************/
  124263. /*! exports provided: MotionBlurPostProcess */
  124264. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124265. "use strict";
  124266. __webpack_require__.r(__webpack_exports__);
  124267. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  124268. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124269. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  124270. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124271. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124272. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124273. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  124274. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Animations/animatable */ "./Animations/animatable.ts");
  124275. /* harmony import */ var _Rendering_geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  124276. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  124277. /**
  124278. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  124279. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  124280. * As an example, all you have to do is to create the post-process:
  124281. * var mb = new BABYLON.MotionBlurPostProcess(
  124282. * 'mb', // The name of the effect.
  124283. * scene, // The scene containing the objects to blur according to their velocity.
  124284. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  124285. * camera // The camera to apply the render pass to.
  124286. * );
  124287. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  124288. */
  124289. var MotionBlurPostProcess = /** @class */ (function (_super) {
  124290. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  124291. /**
  124292. * Creates a new instance MotionBlurPostProcess
  124293. * @param name The name of the effect.
  124294. * @param scene The scene containing the objects to blur according to their velocity.
  124295. * @param options The required width/height ratio to downsize to before computing the render pass.
  124296. * @param camera The camera to apply the render pass to.
  124297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124298. * @param engine The engine which the post process will be applied. (default: current engine)
  124299. * @param reusable If the post process can be reused on the same frame. (default: false)
  124300. * @param textureType Type of textures used when performing the post process. (default: 0)
  124301. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  124302. */
  124303. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  124304. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124305. if (blockCompilation === void 0) { blockCompilation = false; }
  124306. var _this = _super.call(this, name, "motionBlur", ["motionStrength", "motionScale", "screenSize"], ["velocitySampler"], options, camera, samplingMode, engine, reusable, "#define GEOMETRY_SUPPORTED\n#define SAMPLES 64.0", textureType, undefined, null, blockCompilation) || this;
  124307. /**
  124308. * Defines how much the image is blurred by the movement. Default value is equal to 1
  124309. */
  124310. _this.motionStrength = 1;
  124311. _this._motionBlurSamples = 32;
  124312. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  124313. if (!_this._geometryBufferRenderer) {
  124314. // Geometry buffer renderer is not supported. So, work as a passthrough.
  124315. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  124316. _this.updateEffect();
  124317. }
  124318. else {
  124319. // Geometry buffer renderer is supported.
  124320. _this._geometryBufferRenderer.enableVelocity = true;
  124321. _this.onApply = function (effect) {
  124322. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  124323. effect.setFloat("motionScale", scene.getAnimationRatio());
  124324. effect.setFloat("motionStrength", _this.motionStrength);
  124325. if (_this._geometryBufferRenderer) {
  124326. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  124327. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  124328. }
  124329. };
  124330. }
  124331. return _this;
  124332. }
  124333. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  124334. /**
  124335. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  124336. */
  124337. get: function () {
  124338. return this._motionBlurSamples;
  124339. },
  124340. /**
  124341. * Sets the number of iterations to be used for motion blur quality
  124342. */
  124343. set: function (samples) {
  124344. this._motionBlurSamples = samples;
  124345. if (this._geometryBufferRenderer) {
  124346. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  124347. }
  124348. },
  124349. enumerable: true,
  124350. configurable: true
  124351. });
  124352. /**
  124353. * Disposes the post process.
  124354. * @param camera The camera to dispose the post process on.
  124355. */
  124356. MotionBlurPostProcess.prototype.dispose = function (camera) {
  124357. if (this._geometryBufferRenderer) {
  124358. // Clear previous transformation matrices dictionary used to compute objects velocities
  124359. this._geometryBufferRenderer._previousTransformationMatrices = {};
  124360. }
  124361. _super.prototype.dispose.call(this, camera);
  124362. };
  124363. return MotionBlurPostProcess;
  124364. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  124365. /***/ }),
  124366. /***/ "./PostProcesses/passPostProcess.ts":
  124367. /*!******************************************!*\
  124368. !*** ./PostProcesses/passPostProcess.ts ***!
  124369. \******************************************/
  124370. /*! exports provided: PassPostProcess, PassCubePostProcess */
  124371. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124372. "use strict";
  124373. __webpack_require__.r(__webpack_exports__);
  124374. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  124375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  124376. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124377. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124378. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124379. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  124380. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  124381. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  124382. /**
  124383. * PassPostProcess which produces an output the same as it's input
  124384. */
  124385. var PassPostProcess = /** @class */ (function (_super) {
  124386. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  124387. /**
  124388. * Creates the PassPostProcess
  124389. * @param name The name of the effect.
  124390. * @param options The required width/height ratio to downsize to before computing the render pass.
  124391. * @param camera The camera to apply the render pass to.
  124392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124393. * @param engine The engine which the post process will be applied. (default: current engine)
  124394. * @param reusable If the post process can be reused on the same frame. (default: false)
  124395. * @param textureType The type of texture to be used when performing the post processing.
  124396. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  124397. */
  124398. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  124399. if (camera === void 0) { camera = null; }
  124400. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124401. if (blockCompilation === void 0) { blockCompilation = false; }
  124402. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  124403. }
  124404. return PassPostProcess;
  124405. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  124406. /**
  124407. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  124408. */
  124409. var PassCubePostProcess = /** @class */ (function (_super) {
  124410. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  124411. /**
  124412. * Creates the PassCubePostProcess
  124413. * @param name The name of the effect.
  124414. * @param options The required width/height ratio to downsize to before computing the render pass.
  124415. * @param camera The camera to apply the render pass to.
  124416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124417. * @param engine The engine which the post process will be applied. (default: current engine)
  124418. * @param reusable If the post process can be reused on the same frame. (default: false)
  124419. * @param textureType The type of texture to be used when performing the post processing.
  124420. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  124421. */
  124422. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  124423. if (camera === void 0) { camera = null; }
  124424. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124425. if (blockCompilation === void 0) { blockCompilation = false; }
  124426. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  124427. _this._face = 0;
  124428. return _this;
  124429. }
  124430. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  124431. /**
  124432. * Gets or sets the cube face to display.
  124433. * * 0 is +X
  124434. * * 1 is -X
  124435. * * 2 is +Y
  124436. * * 3 is -Y
  124437. * * 4 is +Z
  124438. * * 5 is -Z
  124439. */
  124440. get: function () {
  124441. return this._face;
  124442. },
  124443. set: function (value) {
  124444. if (value < 0 || value > 5) {
  124445. return;
  124446. }
  124447. this._face = value;
  124448. switch (this._face) {
  124449. case 0:
  124450. this.updateEffect("#define POSITIVEX");
  124451. break;
  124452. case 1:
  124453. this.updateEffect("#define NEGATIVEX");
  124454. break;
  124455. case 2:
  124456. this.updateEffect("#define POSITIVEY");
  124457. break;
  124458. case 3:
  124459. this.updateEffect("#define NEGATIVEY");
  124460. break;
  124461. case 4:
  124462. this.updateEffect("#define POSITIVEZ");
  124463. break;
  124464. case 5:
  124465. this.updateEffect("#define NEGATIVEZ");
  124466. break;
  124467. }
  124468. },
  124469. enumerable: true,
  124470. configurable: true
  124471. });
  124472. return PassCubePostProcess;
  124473. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  124474. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  124475. return new PassPostProcess("rescale", 1, null, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].TEXTURE_BILINEAR_SAMPLINGMODE, engine, false, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].TEXTURETYPE_UNSIGNED_INT);
  124476. };
  124477. /***/ }),
  124478. /***/ "./PostProcesses/postProcess.ts":
  124479. /*!**************************************!*\
  124480. !*** ./PostProcesses/postProcess.ts ***!
  124481. \**************************************/
  124482. /*! exports provided: PostProcess */
  124483. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124484. "use strict";
  124485. __webpack_require__.r(__webpack_exports__);
  124486. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  124487. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  124488. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  124489. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  124490. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124491. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124492. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  124493. /**
  124494. * PostProcess can be used to apply a shader to a texture after it has been rendered
  124495. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124496. */
  124497. var PostProcess = /** @class */ (function () {
  124498. /**
  124499. * Creates a new instance PostProcess
  124500. * @param name The name of the PostProcess.
  124501. * @param fragmentUrl The url of the fragment shader to be used.
  124502. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  124503. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  124504. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  124505. * @param camera The camera to apply the render pass to.
  124506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124507. * @param engine The engine which the post process will be applied. (default: current engine)
  124508. * @param reusable If the post process can be reused on the same frame. (default: false)
  124509. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  124510. * @param textureType Type of textures used when performing the post process. (default: 0)
  124511. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  124512. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  124513. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  124514. */
  124515. function PostProcess(
  124516. /** Name of the PostProcess. */
  124517. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  124518. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  124519. if (defines === void 0) { defines = null; }
  124520. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124521. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  124522. if (blockCompilation === void 0) { blockCompilation = false; }
  124523. this.name = name;
  124524. /**
  124525. * Width of the texture to apply the post process on
  124526. */
  124527. this.width = -1;
  124528. /**
  124529. * Height of the texture to apply the post process on
  124530. */
  124531. this.height = -1;
  124532. /**
  124533. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  124534. * @hidden
  124535. */
  124536. this._outputTexture = null;
  124537. /**
  124538. * If the buffer needs to be cleared before applying the post process. (default: true)
  124539. * Should be set to false if shader will overwrite all previous pixels.
  124540. */
  124541. this.autoClear = true;
  124542. /**
  124543. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  124544. */
  124545. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  124546. /**
  124547. * Animations to be used for the post processing
  124548. */
  124549. this.animations = new Array();
  124550. /**
  124551. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  124552. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  124553. */
  124554. this.enablePixelPerfectMode = false;
  124555. /**
  124556. * Force the postprocess to be applied without taking in account viewport
  124557. */
  124558. this.forceFullscreenViewport = true;
  124559. /**
  124560. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  124561. *
  124562. * | Value | Type | Description |
  124563. * | ----- | ----------------------------------- | ----------- |
  124564. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  124565. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  124566. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  124567. *
  124568. */
  124569. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  124570. /**
  124571. * Force textures to be a power of two (default: false)
  124572. */
  124573. this.alwaysForcePOT = false;
  124574. this._samples = 1;
  124575. /**
  124576. * Modify the scale of the post process to be the same as the viewport (default: false)
  124577. */
  124578. this.adaptScaleToCurrentViewport = false;
  124579. this._reusable = false;
  124580. /**
  124581. * Smart array of input and output textures for the post process.
  124582. * @hidden
  124583. */
  124584. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  124585. /**
  124586. * The index in _textures that corresponds to the output texture.
  124587. * @hidden
  124588. */
  124589. this._currentRenderTextureInd = 0;
  124590. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  124591. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  124592. // Events
  124593. /**
  124594. * An event triggered when the postprocess is activated.
  124595. */
  124596. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  124597. /**
  124598. * An event triggered when the postprocess changes its size.
  124599. */
  124600. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  124601. /**
  124602. * An event triggered when the postprocess applies its effect.
  124603. */
  124604. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  124605. /**
  124606. * An event triggered before rendering the postprocess
  124607. */
  124608. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  124609. /**
  124610. * An event triggered after rendering the postprocess
  124611. */
  124612. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  124613. if (camera != null) {
  124614. this._camera = camera;
  124615. this._scene = camera.getScene();
  124616. camera.attachPostProcess(this);
  124617. this._engine = this._scene.getEngine();
  124618. this._scene.postProcesses.push(this);
  124619. this.uniqueId = this._scene.getUniqueId();
  124620. }
  124621. else if (engine) {
  124622. this._engine = engine;
  124623. this._engine.postProcesses.push(this);
  124624. }
  124625. this._options = options;
  124626. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  124627. this._reusable = reusable || false;
  124628. this._textureType = textureType;
  124629. this._samplers = samplers || [];
  124630. this._samplers.push("textureSampler");
  124631. this._fragmentUrl = fragmentUrl;
  124632. this._vertexUrl = vertexUrl;
  124633. this._parameters = parameters || [];
  124634. this._parameters.push("scale");
  124635. this._indexParameters = indexParameters;
  124636. if (!blockCompilation) {
  124637. this.updateEffect(defines);
  124638. }
  124639. }
  124640. Object.defineProperty(PostProcess.prototype, "samples", {
  124641. /**
  124642. * Number of sample textures (default: 1)
  124643. */
  124644. get: function () {
  124645. return this._samples;
  124646. },
  124647. set: function (n) {
  124648. var _this = this;
  124649. this._samples = n;
  124650. this._textures.forEach(function (texture) {
  124651. if (texture.samples !== _this._samples) {
  124652. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  124653. }
  124654. });
  124655. },
  124656. enumerable: true,
  124657. configurable: true
  124658. });
  124659. /**
  124660. * Returns the fragment url or shader name used in the post process.
  124661. * @returns the fragment url or name in the shader store.
  124662. */
  124663. PostProcess.prototype.getEffectName = function () {
  124664. return this._fragmentUrl;
  124665. };
  124666. Object.defineProperty(PostProcess.prototype, "onActivate", {
  124667. /**
  124668. * A function that is added to the onActivateObservable
  124669. */
  124670. set: function (callback) {
  124671. if (this._onActivateObserver) {
  124672. this.onActivateObservable.remove(this._onActivateObserver);
  124673. }
  124674. if (callback) {
  124675. this._onActivateObserver = this.onActivateObservable.add(callback);
  124676. }
  124677. },
  124678. enumerable: true,
  124679. configurable: true
  124680. });
  124681. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  124682. /**
  124683. * A function that is added to the onSizeChangedObservable
  124684. */
  124685. set: function (callback) {
  124686. if (this._onSizeChangedObserver) {
  124687. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  124688. }
  124689. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  124690. },
  124691. enumerable: true,
  124692. configurable: true
  124693. });
  124694. Object.defineProperty(PostProcess.prototype, "onApply", {
  124695. /**
  124696. * A function that is added to the onApplyObservable
  124697. */
  124698. set: function (callback) {
  124699. if (this._onApplyObserver) {
  124700. this.onApplyObservable.remove(this._onApplyObserver);
  124701. }
  124702. this._onApplyObserver = this.onApplyObservable.add(callback);
  124703. },
  124704. enumerable: true,
  124705. configurable: true
  124706. });
  124707. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  124708. /**
  124709. * A function that is added to the onBeforeRenderObservable
  124710. */
  124711. set: function (callback) {
  124712. if (this._onBeforeRenderObserver) {
  124713. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  124714. }
  124715. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  124716. },
  124717. enumerable: true,
  124718. configurable: true
  124719. });
  124720. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  124721. /**
  124722. * A function that is added to the onAfterRenderObservable
  124723. */
  124724. set: function (callback) {
  124725. if (this._onAfterRenderObserver) {
  124726. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  124727. }
  124728. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  124729. },
  124730. enumerable: true,
  124731. configurable: true
  124732. });
  124733. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  124734. /**
  124735. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  124736. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  124737. */
  124738. get: function () {
  124739. return this._textures.data[this._currentRenderTextureInd];
  124740. },
  124741. set: function (value) {
  124742. this._forcedOutputTexture = value;
  124743. },
  124744. enumerable: true,
  124745. configurable: true
  124746. });
  124747. /**
  124748. * Gets the camera which post process is applied to.
  124749. * @returns The camera the post process is applied to.
  124750. */
  124751. PostProcess.prototype.getCamera = function () {
  124752. return this._camera;
  124753. };
  124754. Object.defineProperty(PostProcess.prototype, "texelSize", {
  124755. /**
  124756. * Gets the texel size of the postprocess.
  124757. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  124758. */
  124759. get: function () {
  124760. if (this._shareOutputWithPostProcess) {
  124761. return this._shareOutputWithPostProcess.texelSize;
  124762. }
  124763. if (this._forcedOutputTexture) {
  124764. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  124765. }
  124766. return this._texelSize;
  124767. },
  124768. enumerable: true,
  124769. configurable: true
  124770. });
  124771. /**
  124772. * Gets a string idenfifying the name of the class
  124773. * @returns "PostProcess" string
  124774. */
  124775. PostProcess.prototype.getClassName = function () {
  124776. return "PostProcess";
  124777. };
  124778. /**
  124779. * Gets the engine which this post process belongs to.
  124780. * @returns The engine the post process was enabled with.
  124781. */
  124782. PostProcess.prototype.getEngine = function () {
  124783. return this._engine;
  124784. };
  124785. /**
  124786. * The effect that is created when initializing the post process.
  124787. * @returns The created effect corrisponding the the postprocess.
  124788. */
  124789. PostProcess.prototype.getEffect = function () {
  124790. return this._effect;
  124791. };
  124792. /**
  124793. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  124794. * @param postProcess The post process to share the output with.
  124795. * @returns This post process.
  124796. */
  124797. PostProcess.prototype.shareOutputWith = function (postProcess) {
  124798. this._disposeTextures();
  124799. this._shareOutputWithPostProcess = postProcess;
  124800. return this;
  124801. };
  124802. /**
  124803. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  124804. * This should be called if the post process that shares output with this post process is disabled/disposed.
  124805. */
  124806. PostProcess.prototype.useOwnOutput = function () {
  124807. if (this._textures.length == 0) {
  124808. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  124809. }
  124810. this._shareOutputWithPostProcess = null;
  124811. };
  124812. /**
  124813. * Updates the effect with the current post process compile time values and recompiles the shader.
  124814. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  124815. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  124816. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  124817. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  124818. * @param onCompiled Called when the shader has been compiled.
  124819. * @param onError Called if there is an error when compiling a shader.
  124820. */
  124821. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  124822. if (defines === void 0) { defines = null; }
  124823. if (uniforms === void 0) { uniforms = null; }
  124824. if (samplers === void 0) { samplers = null; }
  124825. this._effect = this._engine.createEffect({ vertex: this._vertexUrl, fragment: this._fragmentUrl }, ["position"], uniforms || this._parameters, samplers || this._samplers, defines !== null ? defines : "", undefined, onCompiled, onError, indexParameters || this._indexParameters);
  124826. };
  124827. /**
  124828. * The post process is reusable if it can be used multiple times within one frame.
  124829. * @returns If the post process is reusable
  124830. */
  124831. PostProcess.prototype.isReusable = function () {
  124832. return this._reusable;
  124833. };
  124834. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  124835. PostProcess.prototype.markTextureDirty = function () {
  124836. this.width = -1;
  124837. };
  124838. /**
  124839. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  124840. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  124841. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  124842. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  124843. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  124844. * @returns The target texture that was bound to be written to.
  124845. */
  124846. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  124847. var _this = this;
  124848. if (sourceTexture === void 0) { sourceTexture = null; }
  124849. camera = camera || this._camera;
  124850. var scene = camera.getScene();
  124851. var engine = scene.getEngine();
  124852. var maxSize = engine.getCaps().maxTextureSize;
  124853. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  124854. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  124855. // If rendering to a webvr camera's left or right eye only half the width should be used to avoid resize when rendered to screen
  124856. var webVRCamera = camera.parent;
  124857. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  124858. requiredWidth /= 2;
  124859. }
  124860. var desiredWidth = (this._options.width || requiredWidth);
  124861. var desiredHeight = this._options.height || requiredHeight;
  124862. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  124863. if (this.adaptScaleToCurrentViewport) {
  124864. var currentViewport = engine.currentViewport;
  124865. if (currentViewport) {
  124866. desiredWidth *= currentViewport.width;
  124867. desiredHeight *= currentViewport.height;
  124868. }
  124869. }
  124870. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  124871. if (!this._options.width) {
  124872. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  124873. }
  124874. if (!this._options.height) {
  124875. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  124876. }
  124877. }
  124878. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  124879. if (this._textures.length > 0) {
  124880. for (var i = 0; i < this._textures.length; i++) {
  124881. this._engine._releaseTexture(this._textures.data[i]);
  124882. }
  124883. this._textures.reset();
  124884. }
  124885. this.width = desiredWidth;
  124886. this.height = desiredHeight;
  124887. var textureSize = { width: this.width, height: this.height };
  124888. var textureOptions = {
  124889. generateMipMaps: false,
  124890. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  124891. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  124892. samplingMode: this.renderTargetSamplingMode,
  124893. type: this._textureType
  124894. };
  124895. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  124896. if (this._reusable) {
  124897. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  124898. }
  124899. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  124900. this.onSizeChangedObservable.notifyObservers(this);
  124901. }
  124902. this._textures.forEach(function (texture) {
  124903. if (texture.samples !== _this.samples) {
  124904. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  124905. }
  124906. });
  124907. }
  124908. var target;
  124909. if (this._shareOutputWithPostProcess) {
  124910. target = this._shareOutputWithPostProcess.inputTexture;
  124911. }
  124912. else if (this._forcedOutputTexture) {
  124913. target = this._forcedOutputTexture;
  124914. this.width = this._forcedOutputTexture.width;
  124915. this.height = this._forcedOutputTexture.height;
  124916. }
  124917. else {
  124918. target = this.inputTexture;
  124919. }
  124920. // Bind the input of this post process to be used as the output of the previous post process.
  124921. if (this.enablePixelPerfectMode) {
  124922. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  124923. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  124924. }
  124925. else {
  124926. this._scaleRatio.copyFromFloats(1, 1);
  124927. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  124928. }
  124929. this.onActivateObservable.notifyObservers(camera);
  124930. // Clear
  124931. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  124932. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  124933. }
  124934. if (this._reusable) {
  124935. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  124936. }
  124937. return target;
  124938. };
  124939. Object.defineProperty(PostProcess.prototype, "isSupported", {
  124940. /**
  124941. * If the post process is supported.
  124942. */
  124943. get: function () {
  124944. return this._effect.isSupported;
  124945. },
  124946. enumerable: true,
  124947. configurable: true
  124948. });
  124949. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  124950. /**
  124951. * The aspect ratio of the output texture.
  124952. */
  124953. get: function () {
  124954. if (this._shareOutputWithPostProcess) {
  124955. return this._shareOutputWithPostProcess.aspectRatio;
  124956. }
  124957. if (this._forcedOutputTexture) {
  124958. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  124959. }
  124960. return this.width / this.height;
  124961. },
  124962. enumerable: true,
  124963. configurable: true
  124964. });
  124965. /**
  124966. * Get a value indicating if the post-process is ready to be used
  124967. * @returns true if the post-process is ready (shader is compiled)
  124968. */
  124969. PostProcess.prototype.isReady = function () {
  124970. return this._effect && this._effect.isReady();
  124971. };
  124972. /**
  124973. * Binds all textures and uniforms to the shader, this will be run on every pass.
  124974. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  124975. */
  124976. PostProcess.prototype.apply = function () {
  124977. // Check
  124978. if (!this._effect || !this._effect.isReady()) {
  124979. return null;
  124980. }
  124981. // States
  124982. this._engine.enableEffect(this._effect);
  124983. this._engine.setState(false);
  124984. this._engine.setDepthBuffer(false);
  124985. this._engine.setDepthWrite(false);
  124986. // Alpha
  124987. this._engine.setAlphaMode(this.alphaMode);
  124988. if (this.alphaConstants) {
  124989. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  124990. }
  124991. // Bind the output texture of the preivous post process as the input to this post process.
  124992. var source;
  124993. if (this._shareOutputWithPostProcess) {
  124994. source = this._shareOutputWithPostProcess.inputTexture;
  124995. }
  124996. else if (this._forcedOutputTexture) {
  124997. source = this._forcedOutputTexture;
  124998. }
  124999. else {
  125000. source = this.inputTexture;
  125001. }
  125002. this._effect._bindTexture("textureSampler", source);
  125003. // Parameters
  125004. this._effect.setVector2("scale", this._scaleRatio);
  125005. this.onApplyObservable.notifyObservers(this._effect);
  125006. return this._effect;
  125007. };
  125008. PostProcess.prototype._disposeTextures = function () {
  125009. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  125010. return;
  125011. }
  125012. if (this._textures.length > 0) {
  125013. for (var i = 0; i < this._textures.length; i++) {
  125014. this._engine._releaseTexture(this._textures.data[i]);
  125015. }
  125016. }
  125017. this._textures.dispose();
  125018. };
  125019. /**
  125020. * Disposes the post process.
  125021. * @param camera The camera to dispose the post process on.
  125022. */
  125023. PostProcess.prototype.dispose = function (camera) {
  125024. camera = camera || this._camera;
  125025. this._disposeTextures();
  125026. if (this._scene) {
  125027. var index_1 = this._scene.postProcesses.indexOf(this);
  125028. if (index_1 !== -1) {
  125029. this._scene.postProcesses.splice(index_1, 1);
  125030. }
  125031. }
  125032. else {
  125033. var index_2 = this._engine.postProcesses.indexOf(this);
  125034. if (index_2 !== -1) {
  125035. this._engine.postProcesses.splice(index_2, 1);
  125036. }
  125037. }
  125038. if (!camera) {
  125039. return;
  125040. }
  125041. camera.detachPostProcess(this);
  125042. var index = camera._postProcesses.indexOf(this);
  125043. if (index === 0 && camera._postProcesses.length > 0) {
  125044. var firstPostProcess = this._camera._getFirstPostProcess();
  125045. if (firstPostProcess) {
  125046. firstPostProcess.markTextureDirty();
  125047. }
  125048. }
  125049. this.onActivateObservable.clear();
  125050. this.onAfterRenderObservable.clear();
  125051. this.onApplyObservable.clear();
  125052. this.onBeforeRenderObservable.clear();
  125053. this.onSizeChangedObservable.clear();
  125054. };
  125055. return PostProcess;
  125056. }());
  125057. /***/ }),
  125058. /***/ "./PostProcesses/postProcessManager.ts":
  125059. /*!*********************************************!*\
  125060. !*** ./PostProcesses/postProcessManager.ts ***!
  125061. \*********************************************/
  125062. /*! exports provided: PostProcessManager */
  125063. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125064. "use strict";
  125065. __webpack_require__.r(__webpack_exports__);
  125066. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  125067. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125068. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125069. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125070. /**
  125071. * PostProcessManager is used to manage one or more post processes or post process pipelines
  125072. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  125073. */
  125074. var PostProcessManager = /** @class */ (function () {
  125075. /**
  125076. * Creates a new instance PostProcess
  125077. * @param scene The scene that the post process is associated with.
  125078. */
  125079. function PostProcessManager(scene) {
  125080. this._vertexBuffers = {};
  125081. this._scene = scene;
  125082. }
  125083. PostProcessManager.prototype._prepareBuffers = function () {
  125084. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  125085. return;
  125086. }
  125087. // VBO
  125088. var vertices = [];
  125089. vertices.push(1, 1);
  125090. vertices.push(-1, 1);
  125091. vertices.push(-1, -1);
  125092. vertices.push(1, -1);
  125093. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"](this._scene.getEngine(), vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, false, false, 2);
  125094. this._buildIndexBuffer();
  125095. };
  125096. PostProcessManager.prototype._buildIndexBuffer = function () {
  125097. // Indices
  125098. var indices = [];
  125099. indices.push(0);
  125100. indices.push(1);
  125101. indices.push(2);
  125102. indices.push(0);
  125103. indices.push(2);
  125104. indices.push(3);
  125105. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  125106. };
  125107. /**
  125108. * Rebuilds the vertex buffers of the manager.
  125109. * @hidden
  125110. */
  125111. PostProcessManager.prototype._rebuild = function () {
  125112. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  125113. if (!vb) {
  125114. return;
  125115. }
  125116. vb._rebuild();
  125117. this._buildIndexBuffer();
  125118. };
  125119. // Methods
  125120. /**
  125121. * Prepares a frame to be run through a post process.
  125122. * @param sourceTexture The input texture to the post procesess. (default: null)
  125123. * @param postProcesses An array of post processes to be run. (default: null)
  125124. * @returns True if the post processes were able to be run.
  125125. * @hidden
  125126. */
  125127. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  125128. if (sourceTexture === void 0) { sourceTexture = null; }
  125129. if (postProcesses === void 0) { postProcesses = null; }
  125130. var camera = this._scene.activeCamera;
  125131. if (!camera) {
  125132. return false;
  125133. }
  125134. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  125135. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  125136. return false;
  125137. }
  125138. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  125139. return true;
  125140. };
  125141. /**
  125142. * Manually render a set of post processes to a texture.
  125143. * @param postProcesses An array of post processes to be run.
  125144. * @param targetTexture The target texture to render to.
  125145. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  125146. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  125147. * @param lodLevel defines which lod of the texture to render to
  125148. */
  125149. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  125150. if (targetTexture === void 0) { targetTexture = null; }
  125151. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  125152. if (faceIndex === void 0) { faceIndex = 0; }
  125153. if (lodLevel === void 0) { lodLevel = 0; }
  125154. var engine = this._scene.getEngine();
  125155. for (var index = 0; index < postProcesses.length; index++) {
  125156. if (index < postProcesses.length - 1) {
  125157. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  125158. }
  125159. else {
  125160. if (targetTexture) {
  125161. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  125162. }
  125163. else {
  125164. engine.restoreDefaultFramebuffer();
  125165. }
  125166. }
  125167. var pp = postProcesses[index];
  125168. var effect = pp.apply();
  125169. if (effect) {
  125170. pp.onBeforeRenderObservable.notifyObservers(effect);
  125171. // VBOs
  125172. this._prepareBuffers();
  125173. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  125174. // Draw order
  125175. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  125176. pp.onAfterRenderObservable.notifyObservers(effect);
  125177. }
  125178. }
  125179. // Restore depth buffer
  125180. engine.setDepthBuffer(true);
  125181. engine.setDepthWrite(true);
  125182. };
  125183. /**
  125184. * Finalize the result of the output of the postprocesses.
  125185. * @param doNotPresent If true the result will not be displayed to the screen.
  125186. * @param targetTexture The target texture to render to.
  125187. * @param faceIndex The index of the face to bind the target texture to.
  125188. * @param postProcesses The array of post processes to render.
  125189. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  125190. * @hidden
  125191. */
  125192. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  125193. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  125194. var camera = this._scene.activeCamera;
  125195. if (!camera) {
  125196. return;
  125197. }
  125198. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  125199. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  125200. return;
  125201. }
  125202. var engine = this._scene.getEngine();
  125203. for (var index = 0, len = postProcesses.length; index < len; index++) {
  125204. var pp = postProcesses[index];
  125205. if (index < len - 1) {
  125206. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  125207. }
  125208. else {
  125209. if (targetTexture) {
  125210. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  125211. pp._outputTexture = targetTexture;
  125212. }
  125213. else {
  125214. engine.restoreDefaultFramebuffer();
  125215. pp._outputTexture = null;
  125216. }
  125217. }
  125218. if (doNotPresent) {
  125219. break;
  125220. }
  125221. var effect = pp.apply();
  125222. if (effect) {
  125223. pp.onBeforeRenderObservable.notifyObservers(effect);
  125224. // VBOs
  125225. this._prepareBuffers();
  125226. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  125227. // Draw order
  125228. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  125229. pp.onAfterRenderObservable.notifyObservers(effect);
  125230. }
  125231. }
  125232. // Restore states
  125233. engine.setDepthBuffer(true);
  125234. engine.setDepthWrite(true);
  125235. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  125236. };
  125237. /**
  125238. * Disposes of the post process manager.
  125239. */
  125240. PostProcessManager.prototype.dispose = function () {
  125241. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  125242. if (buffer) {
  125243. buffer.dispose();
  125244. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  125245. }
  125246. if (this._indexBuffer) {
  125247. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  125248. this._indexBuffer = null;
  125249. }
  125250. };
  125251. return PostProcessManager;
  125252. }());
  125253. /***/ }),
  125254. /***/ "./PostProcesses/refractionPostProcess.ts":
  125255. /*!************************************************!*\
  125256. !*** ./PostProcesses/refractionPostProcess.ts ***!
  125257. \************************************************/
  125258. /*! exports provided: RefractionPostProcess */
  125259. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125260. "use strict";
  125261. __webpack_require__.r(__webpack_exports__);
  125262. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  125263. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125264. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125265. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125266. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  125267. /**
  125268. * Post process which applies a refractin texture
  125269. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  125270. */
  125271. var RefractionPostProcess = /** @class */ (function (_super) {
  125272. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  125273. /**
  125274. * Initializes the RefractionPostProcess
  125275. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  125276. * @param name The name of the effect.
  125277. * @param refractionTextureUrl Url of the refraction texture to use
  125278. * @param color the base color of the refraction (used to taint the rendering)
  125279. * @param depth simulated refraction depth
  125280. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  125281. * @param camera The camera to apply the render pass to.
  125282. * @param options The required width/height ratio to downsize to before computing the render pass.
  125283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125284. * @param engine The engine which the post process will be applied. (default: current engine)
  125285. * @param reusable If the post process can be reused on the same frame. (default: false)
  125286. */
  125287. function RefractionPostProcess(name, refractionTextureUrl,
  125288. /** the base color of the refraction (used to taint the rendering) */
  125289. color,
  125290. /** simulated refraction depth */
  125291. depth,
  125292. /** the coefficient of the base color (0 to remove base color tainting) */
  125293. colorLevel, options, camera, samplingMode, engine, reusable) {
  125294. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  125295. _this.color = color;
  125296. _this.depth = depth;
  125297. _this.colorLevel = colorLevel;
  125298. _this._ownRefractionTexture = true;
  125299. _this.onActivateObservable.add(function (cam) {
  125300. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  125301. });
  125302. _this.onApplyObservable.add(function (effect) {
  125303. effect.setColor3("baseColor", _this.color);
  125304. effect.setFloat("depth", _this.depth);
  125305. effect.setFloat("colorLevel", _this.colorLevel);
  125306. effect.setTexture("refractionSampler", _this._refTexture);
  125307. });
  125308. return _this;
  125309. }
  125310. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  125311. /**
  125312. * Gets or sets the refraction texture
  125313. * Please note that you are responsible for disposing the texture if you set it manually
  125314. */
  125315. get: function () {
  125316. return this._refTexture;
  125317. },
  125318. set: function (value) {
  125319. if (this._refTexture && this._ownRefractionTexture) {
  125320. this._refTexture.dispose();
  125321. }
  125322. this._refTexture = value;
  125323. this._ownRefractionTexture = false;
  125324. },
  125325. enumerable: true,
  125326. configurable: true
  125327. });
  125328. // Methods
  125329. /**
  125330. * Disposes of the post process
  125331. * @param camera Camera to dispose post process on
  125332. */
  125333. RefractionPostProcess.prototype.dispose = function (camera) {
  125334. if (this._refTexture && this._ownRefractionTexture) {
  125335. this._refTexture.dispose();
  125336. this._refTexture = null;
  125337. }
  125338. _super.prototype.dispose.call(this, camera);
  125339. };
  125340. return RefractionPostProcess;
  125341. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  125342. /***/ }),
  125343. /***/ "./PostProcesses/sharpenPostProcess.ts":
  125344. /*!*********************************************!*\
  125345. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  125346. \*********************************************/
  125347. /*! exports provided: SharpenPostProcess */
  125348. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125349. "use strict";
  125350. __webpack_require__.r(__webpack_exports__);
  125351. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  125352. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125353. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125354. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125355. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  125356. /**
  125357. * The SharpenPostProcess applies a sharpen kernel to every pixel
  125358. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125359. */
  125360. var SharpenPostProcess = /** @class */ (function (_super) {
  125361. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  125362. /**
  125363. * Creates a new instance ConvolutionPostProcess
  125364. * @param name The name of the effect.
  125365. * @param options The required width/height ratio to downsize to before computing the render pass.
  125366. * @param camera The camera to apply the render pass to.
  125367. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125368. * @param engine The engine which the post process will be applied. (default: current engine)
  125369. * @param reusable If the post process can be reused on the same frame. (default: false)
  125370. * @param textureType Type of textures used when performing the post process. (default: 0)
  125371. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  125372. */
  125373. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  125374. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  125375. if (blockCompilation === void 0) { blockCompilation = false; }
  125376. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  125377. /**
  125378. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  125379. */
  125380. _this.colorAmount = 1.0;
  125381. /**
  125382. * How much sharpness should be applied (default: 0.3)
  125383. */
  125384. _this.edgeAmount = 0.3;
  125385. _this.onApply = function (effect) {
  125386. effect.setFloat2("screenSize", _this.width, _this.height);
  125387. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  125388. };
  125389. return _this;
  125390. }
  125391. return SharpenPostProcess;
  125392. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  125393. /***/ }),
  125394. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  125395. /*!***********************************************************!*\
  125396. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  125397. \***********************************************************/
  125398. /*! exports provided: StereoscopicInterlacePostProcess */
  125399. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125400. "use strict";
  125401. __webpack_require__.r(__webpack_exports__);
  125402. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  125403. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125404. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125405. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125406. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  125407. /**
  125408. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  125409. */
  125410. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  125411. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  125412. /**
  125413. * Initializes a StereoscopicInterlacePostProcess
  125414. * @param name The name of the effect.
  125415. * @param rigCameras The rig cameras to be appled to the post process
  125416. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  125417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125418. * @param engine The engine which the post process will be applied. (default: current engine)
  125419. * @param reusable If the post process can be reused on the same frame. (default: false)
  125420. */
  125421. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  125422. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  125423. _this._passedProcess = rigCameras[0]._rigPostProcess;
  125424. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  125425. _this.onSizeChangedObservable.add(function () {
  125426. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  125427. });
  125428. _this.onApplyObservable.add(function (effect) {
  125429. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  125430. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  125431. });
  125432. return _this;
  125433. }
  125434. return StereoscopicInterlacePostProcess;
  125435. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  125436. /***/ }),
  125437. /***/ "./PostProcesses/tonemapPostProcess.ts":
  125438. /*!*********************************************!*\
  125439. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  125440. \*********************************************/
  125441. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  125442. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125443. "use strict";
  125444. __webpack_require__.r(__webpack_exports__);
  125445. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  125446. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  125447. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125448. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125449. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125450. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  125451. /** Defines operator used for tonemapping */
  125452. var TonemappingOperator;
  125453. (function (TonemappingOperator) {
  125454. /** Hable */
  125455. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  125456. /** Reinhard */
  125457. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  125458. /** HejiDawson */
  125459. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  125460. /** Photographic */
  125461. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  125462. })(TonemappingOperator || (TonemappingOperator = {}));
  125463. /**
  125464. * Defines a post process to apply tone mapping
  125465. */
  125466. var TonemapPostProcess = /** @class */ (function (_super) {
  125467. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  125468. /**
  125469. * Creates a new TonemapPostProcess
  125470. * @param name defines the name of the postprocess
  125471. * @param _operator defines the operator to use
  125472. * @param exposureAdjustment defines the required exposure adjustement
  125473. * @param camera defines the camera to use (can be null)
  125474. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  125475. * @param engine defines the hosting engine (can be ignore if camera is set)
  125476. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125477. */
  125478. function TonemapPostProcess(name, _operator,
  125479. /** Defines the required exposure adjustement */
  125480. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  125481. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  125482. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  125483. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  125484. _this._operator = _operator;
  125485. _this.exposureAdjustment = exposureAdjustment;
  125486. var defines = "#define ";
  125487. if (_this._operator === TonemappingOperator.Hable) {
  125488. defines += "HABLE_TONEMAPPING";
  125489. }
  125490. else if (_this._operator === TonemappingOperator.Reinhard) {
  125491. defines += "REINHARD_TONEMAPPING";
  125492. }
  125493. else if (_this._operator === TonemappingOperator.HejiDawson) {
  125494. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  125495. }
  125496. else if (_this._operator === TonemappingOperator.Photographic) {
  125497. defines += "PHOTOGRAPHIC_TONEMAPPING";
  125498. }
  125499. //sadly a second call to create the effect.
  125500. _this.updateEffect(defines);
  125501. _this.onApply = function (effect) {
  125502. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  125503. };
  125504. return _this;
  125505. }
  125506. return TonemapPostProcess;
  125507. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  125508. /***/ }),
  125509. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  125510. /*!***************************************************************!*\
  125511. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  125512. \***************************************************************/
  125513. /*! exports provided: VolumetricLightScatteringPostProcess */
  125514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125515. "use strict";
  125516. __webpack_require__.r(__webpack_exports__);
  125517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  125518. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125519. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  125520. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  125521. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125522. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125523. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  125524. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  125525. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125526. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  125527. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125528. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  125529. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125530. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125531. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  125532. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  125533. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  125534. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  125535. /**
  125536. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  125537. */
  125538. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  125539. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  125540. /**
  125541. * @constructor
  125542. * @param name The post-process name
  125543. * @param ratio The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  125544. * @param camera The camera that the post-process will be attached to
  125545. * @param mesh The mesh used to create the light scattering
  125546. * @param samples The post-process quality, default 100
  125547. * @param samplingModeThe post-process filtering mode
  125548. * @param engine The babylon engine
  125549. * @param reusable If the post-process is reusable
  125550. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  125551. */
  125552. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  125553. if (samples === void 0) { samples = 100; }
  125554. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  125555. var _this = _super.call(this, name, "volumetricLightScattering", ["decay", "exposure", "weight", "meshPositionOnScreen", "density"], ["lightScatteringSampler"], ratio.postProcessRatio || ratio, camera, samplingMode, engine, reusable, "#define NUM_SAMPLES " + samples) || this;
  125556. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  125557. /**
  125558. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  125559. */
  125560. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125561. /**
  125562. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  125563. */
  125564. _this.useCustomMeshPosition = false;
  125565. /**
  125566. * If the post-process should inverse the light scattering direction
  125567. */
  125568. _this.invert = true;
  125569. /**
  125570. * Array containing the excluded meshes not rendered in the internal pass
  125571. */
  125572. _this.excludedMeshes = new Array();
  125573. /**
  125574. * Controls the overall intensity of the post-process
  125575. */
  125576. _this.exposure = 0.3;
  125577. /**
  125578. * Dissipates each sample's contribution in range [0, 1]
  125579. */
  125580. _this.decay = 0.96815;
  125581. /**
  125582. * Controls the overall intensity of each sample
  125583. */
  125584. _this.weight = 0.58767;
  125585. /**
  125586. * Controls the density of each sample
  125587. */
  125588. _this.density = 0.926;
  125589. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  125590. engine = scene.getEngine();
  125591. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  125592. // Configure mesh
  125593. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  125594. // Configure
  125595. _this._createPass(scene, ratio.passRatio || ratio);
  125596. _this.onActivate = function (camera) {
  125597. if (!_this.isSupported) {
  125598. _this.dispose(camera);
  125599. }
  125600. _this.onActivate = null;
  125601. };
  125602. _this.onApplyObservable.add(function (effect) {
  125603. _this._updateMeshScreenCoordinates(scene);
  125604. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  125605. effect.setFloat("exposure", _this.exposure);
  125606. effect.setFloat("decay", _this.decay);
  125607. effect.setFloat("weight", _this.weight);
  125608. effect.setFloat("density", _this.density);
  125609. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  125610. });
  125611. return _this;
  125612. }
  125613. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  125614. /**
  125615. * @hidden
  125616. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  125617. */
  125618. get: function () {
  125619. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  125620. return false;
  125621. },
  125622. set: function (useDiffuseColor) {
  125623. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  125624. },
  125625. enumerable: true,
  125626. configurable: true
  125627. });
  125628. /**
  125629. * Returns the string "VolumetricLightScatteringPostProcess"
  125630. * @returns "VolumetricLightScatteringPostProcess"
  125631. */
  125632. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  125633. return "VolumetricLightScatteringPostProcess";
  125634. };
  125635. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  125636. var mesh = subMesh.getMesh();
  125637. // Render this.mesh as default
  125638. if (mesh === this.mesh && mesh.material) {
  125639. return mesh.material.isReady(mesh);
  125640. }
  125641. var defines = [];
  125642. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  125643. var material = subMesh.getMaterial();
  125644. // Alpha test
  125645. if (material) {
  125646. if (material.needAlphaTesting()) {
  125647. defines.push("#define ALPHATEST");
  125648. }
  125649. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  125650. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  125651. defines.push("#define UV1");
  125652. }
  125653. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  125654. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  125655. defines.push("#define UV2");
  125656. }
  125657. }
  125658. // Bones
  125659. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  125660. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  125661. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  125662. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  125663. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  125664. }
  125665. else {
  125666. defines.push("#define NUM_BONE_INFLUENCERS 0");
  125667. }
  125668. // Instances
  125669. if (useInstances) {
  125670. defines.push("#define INSTANCES");
  125671. attribs.push("world0");
  125672. attribs.push("world1");
  125673. attribs.push("world2");
  125674. attribs.push("world3");
  125675. }
  125676. // Get correct effect
  125677. var join = defines.join("\n");
  125678. if (this._cachedDefines !== join) {
  125679. this._cachedDefines = join;
  125680. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  125681. }
  125682. return this._volumetricLightScatteringPass.isReady();
  125683. };
  125684. /**
  125685. * Sets the new light position for light scattering effect
  125686. * @param position The new custom light position
  125687. */
  125688. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  125689. this.customMeshPosition = position;
  125690. };
  125691. /**
  125692. * Returns the light position for light scattering effect
  125693. * @return Vector3 The custom light position
  125694. */
  125695. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  125696. return this.customMeshPosition;
  125697. };
  125698. /**
  125699. * Disposes the internal assets and detaches the post-process from the camera
  125700. */
  125701. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  125702. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  125703. if (rttIndex !== -1) {
  125704. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  125705. }
  125706. this._volumetricLightScatteringRTT.dispose();
  125707. _super.prototype.dispose.call(this, camera);
  125708. };
  125709. /**
  125710. * Returns the render target texture used by the post-process
  125711. * @return the render target texture used by the post-process
  125712. */
  125713. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  125714. return this._volumetricLightScatteringRTT;
  125715. };
  125716. // Private methods
  125717. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  125718. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  125719. return true;
  125720. }
  125721. return false;
  125722. };
  125723. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  125724. var _this = this;
  125725. var engine = scene.getEngine();
  125726. this._volumetricLightScatteringRTT = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__["RenderTargetTexture"]("volumetricLightScatteringMap", { width: engine.getRenderWidth() * ratio, height: engine.getRenderHeight() * ratio }, scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  125727. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  125728. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  125729. this._volumetricLightScatteringRTT.renderList = null;
  125730. this._volumetricLightScatteringRTT.renderParticles = false;
  125731. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  125732. var camera = this.getCamera();
  125733. if (camera) {
  125734. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  125735. }
  125736. else {
  125737. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  125738. }
  125739. // Custom render function for submeshes
  125740. var renderSubMesh = function (subMesh) {
  125741. var mesh = subMesh.getRenderingMesh();
  125742. if (_this._meshExcluded(mesh)) {
  125743. return;
  125744. }
  125745. var material = subMesh.getMaterial();
  125746. if (!material) {
  125747. return;
  125748. }
  125749. var scene = mesh.getScene();
  125750. var engine = scene.getEngine();
  125751. // Culling
  125752. engine.setState(material.backFaceCulling);
  125753. // Managing instances
  125754. var batch = mesh._getInstancesRenderList(subMesh._id);
  125755. if (batch.mustReturn) {
  125756. return;
  125757. }
  125758. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  125759. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  125760. var effect = _this._volumetricLightScatteringPass;
  125761. if (mesh === _this.mesh) {
  125762. if (subMesh.effect) {
  125763. effect = subMesh.effect;
  125764. }
  125765. else {
  125766. effect = material.getEffect();
  125767. }
  125768. }
  125769. engine.enableEffect(effect);
  125770. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  125771. if (mesh === _this.mesh) {
  125772. material.bind(mesh.getWorldMatrix(), mesh);
  125773. }
  125774. else {
  125775. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  125776. // Alpha test
  125777. if (material && material.needAlphaTesting()) {
  125778. var alphaTexture = material.getAlphaTestTexture();
  125779. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  125780. if (alphaTexture) {
  125781. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  125782. }
  125783. }
  125784. // Bones
  125785. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  125786. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  125787. }
  125788. }
  125789. // Draw
  125790. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  125791. }
  125792. };
  125793. // Render target texture callbacks
  125794. var savedSceneClearColor;
  125795. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  125796. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  125797. savedSceneClearColor = scene.clearColor;
  125798. scene.clearColor = sceneClearColor;
  125799. });
  125800. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  125801. scene.clearColor = savedSceneClearColor;
  125802. });
  125803. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  125804. var engine = scene.getEngine();
  125805. var index;
  125806. if (depthOnlySubMeshes.length) {
  125807. engine.setColorWrite(false);
  125808. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  125809. renderSubMesh(depthOnlySubMeshes.data[index]);
  125810. }
  125811. engine.setColorWrite(true);
  125812. }
  125813. for (index = 0; index < opaqueSubMeshes.length; index++) {
  125814. renderSubMesh(opaqueSubMeshes.data[index]);
  125815. }
  125816. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  125817. renderSubMesh(alphaTestSubMeshes.data[index]);
  125818. }
  125819. if (transparentSubMeshes.length) {
  125820. // Sort sub meshes
  125821. for (index = 0; index < transparentSubMeshes.length; index++) {
  125822. var submesh = transparentSubMeshes.data[index];
  125823. var boundingInfo = submesh.getBoundingInfo();
  125824. if (boundingInfo && scene.activeCamera) {
  125825. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  125826. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  125827. }
  125828. }
  125829. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  125830. sortedArray.sort(function (a, b) {
  125831. // Alpha index first
  125832. if (a._alphaIndex > b._alphaIndex) {
  125833. return 1;
  125834. }
  125835. if (a._alphaIndex < b._alphaIndex) {
  125836. return -1;
  125837. }
  125838. // Then distance to camera
  125839. if (a._distanceToCamera < b._distanceToCamera) {
  125840. return 1;
  125841. }
  125842. if (a._distanceToCamera > b._distanceToCamera) {
  125843. return -1;
  125844. }
  125845. return 0;
  125846. });
  125847. // Render sub meshes
  125848. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  125849. for (index = 0; index < sortedArray.length; index++) {
  125850. renderSubMesh(sortedArray[index]);
  125851. }
  125852. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  125853. }
  125854. };
  125855. };
  125856. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  125857. var transform = scene.getTransformMatrix();
  125858. var meshPosition;
  125859. if (this.useCustomMeshPosition) {
  125860. meshPosition = this.customMeshPosition;
  125861. }
  125862. else if (this.attachedNode) {
  125863. meshPosition = this.attachedNode.position;
  125864. }
  125865. else {
  125866. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  125867. }
  125868. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  125869. this._screenCoordinates.x = pos.x / this._viewPort.width;
  125870. this._screenCoordinates.y = pos.y / this._viewPort.height;
  125871. if (this.invert) {
  125872. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  125873. }
  125874. };
  125875. // Static methods
  125876. /**
  125877. * Creates a default mesh for the Volumeric Light Scattering post-process
  125878. * @param name The mesh name
  125879. * @param scene The scene where to create the mesh
  125880. * @return the default mesh
  125881. */
  125882. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  125883. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  125884. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  125885. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  125886. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  125887. mesh.material = material;
  125888. return mesh;
  125889. };
  125890. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125891. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  125892. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  125893. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125894. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125895. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  125896. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125897. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125898. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  125899. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125900. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  125901. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  125902. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125903. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125904. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  125905. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125906. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125907. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  125908. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125909. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125910. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  125911. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125912. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125913. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  125914. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125915. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125916. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  125917. return VolumetricLightScatteringPostProcess;
  125918. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  125919. /***/ }),
  125920. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  125921. /*!************************************************************!*\
  125922. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  125923. \************************************************************/
  125924. /*! exports provided: VRDistortionCorrectionPostProcess */
  125925. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125926. "use strict";
  125927. __webpack_require__.r(__webpack_exports__);
  125928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  125929. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125930. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125931. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125932. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125933. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  125934. /**
  125935. * VRDistortionCorrectionPostProcess used for mobile VR
  125936. */
  125937. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  125938. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  125939. /**
  125940. * Initializes the VRDistortionCorrectionPostProcess
  125941. * @param name The name of the effect.
  125942. * @param camera The camera to apply the render pass to.
  125943. * @param isRightEye If this is for the right eye distortion
  125944. * @param vrMetrics All the required metrics for the VR camera
  125945. */
  125946. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  125947. var _this = _super.call(this, name, "vrDistortionCorrection", [
  125948. 'LensCenter',
  125949. 'Scale',
  125950. 'ScaleIn',
  125951. 'HmdWarpParam'
  125952. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  125953. _this._isRightEye = isRightEye;
  125954. _this._distortionFactors = vrMetrics.distortionK;
  125955. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  125956. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  125957. _this.adaptScaleToCurrentViewport = true;
  125958. _this.onSizeChangedObservable.add(function () {
  125959. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  125960. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  125961. _this._lensCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](_this._isRightEye ? 0.5 - _this._lensCenterOffset * 0.5 : 0.5 + _this._lensCenterOffset * 0.5, 0.5);
  125962. });
  125963. _this.onApplyObservable.add(function (effect) {
  125964. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  125965. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  125966. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  125967. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  125968. });
  125969. return _this;
  125970. }
  125971. return VRDistortionCorrectionPostProcess;
  125972. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  125973. /***/ }),
  125974. /***/ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts":
  125975. /*!*************************************************************!*\
  125976. !*** ./PostProcesses/vrMultiviewToSingleviewPostProcess.ts ***!
  125977. \*************************************************************/
  125978. /*! exports provided: VRMultiviewToSingleviewPostProcess */
  125979. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125980. "use strict";
  125981. __webpack_require__.r(__webpack_exports__);
  125982. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return VRMultiviewToSingleviewPostProcess; });
  125983. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125984. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125985. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125986. /* harmony import */ var _Shaders_vrMultiviewToSingleview_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/vrMultiviewToSingleview.fragment */ "./Shaders/vrMultiviewToSingleview.fragment.ts");
  125987. /* harmony import */ var _Engines_Extensions_engine_multiview__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/Extensions/engine.multiview */ "./Engines/Extensions/engine.multiview.ts");
  125988. /**
  125989. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  125990. * This will not be used for webXR as it supports displaying texture arrays directly
  125991. */
  125992. var VRMultiviewToSingleviewPostProcess = /** @class */ (function (_super) {
  125993. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRMultiviewToSingleviewPostProcess, _super);
  125994. /**
  125995. * Initializes a VRMultiviewToSingleview
  125996. * @param name name of the post process
  125997. * @param camera camera to be applied to
  125998. * @param scaleFactor scaling factor to the size of the output texture
  125999. */
  126000. function VRMultiviewToSingleviewPostProcess(name, camera, scaleFactor) {
  126001. var _this = _super.call(this, name, "vrMultiviewToSingleview", ["imageIndex"], ["multiviewSampler"], scaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  126002. _this.onSizeChangedObservable.add(function () {
  126003. });
  126004. _this.onApplyObservable.add(function (effect) {
  126005. if (camera._scene.activeCamera && camera._scene.activeCamera.isLeftCamera) {
  126006. effect.setInt("imageIndex", 0);
  126007. }
  126008. else {
  126009. effect.setInt("imageIndex", 1);
  126010. }
  126011. effect.setTexture("multiviewSampler", camera._multiviewTexture);
  126012. });
  126013. return _this;
  126014. }
  126015. return VRMultiviewToSingleviewPostProcess;
  126016. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  126017. /***/ }),
  126018. /***/ "./Probes/index.ts":
  126019. /*!*************************!*\
  126020. !*** ./Probes/index.ts ***!
  126021. \*************************/
  126022. /*! exports provided: ReflectionProbe */
  126023. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126024. "use strict";
  126025. __webpack_require__.r(__webpack_exports__);
  126026. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  126027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  126028. /***/ }),
  126029. /***/ "./Probes/reflectionProbe.ts":
  126030. /*!***********************************!*\
  126031. !*** ./Probes/reflectionProbe.ts ***!
  126032. \***********************************/
  126033. /*! exports provided: ReflectionProbe */
  126034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126035. "use strict";
  126036. __webpack_require__.r(__webpack_exports__);
  126037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  126038. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126039. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  126040. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  126041. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126042. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  126043. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126044. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  126045. if (!this.reflectionProbes) {
  126046. return -1;
  126047. }
  126048. var index = this.reflectionProbes.indexOf(toRemove);
  126049. if (index !== -1) {
  126050. this.reflectionProbes.splice(index, 1);
  126051. }
  126052. return index;
  126053. };
  126054. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  126055. if (!this.reflectionProbes) {
  126056. this.reflectionProbes = [];
  126057. }
  126058. this.reflectionProbes.push(newReflectionProbe);
  126059. };
  126060. /**
  126061. * Class used to generate realtime reflection / refraction cube textures
  126062. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  126063. */
  126064. var ReflectionProbe = /** @class */ (function () {
  126065. /**
  126066. * Creates a new reflection probe
  126067. * @param name defines the name of the probe
  126068. * @param size defines the texture resolution (for each face)
  126069. * @param scene defines the hosting scene
  126070. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  126071. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  126072. */
  126073. function ReflectionProbe(
  126074. /** defines the name of the probe */
  126075. name, size, scene, generateMipMaps, useFloat) {
  126076. if (generateMipMaps === void 0) { generateMipMaps = true; }
  126077. if (useFloat === void 0) { useFloat = false; }
  126078. var _this = this;
  126079. this.name = name;
  126080. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  126081. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  126082. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  126083. this._invertYAxis = false;
  126084. /** Gets or sets probe position (center of the cube map) */
  126085. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  126086. this._scene = scene;
  126087. // Create the scene field if not exist.
  126088. if (!this._scene.reflectionProbes) {
  126089. this._scene.reflectionProbes = new Array();
  126090. }
  126091. this._scene.reflectionProbes.push(this);
  126092. this._renderTargetTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"](name, size, scene, generateMipMaps, true, useFloat ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT, true);
  126093. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  126094. switch (faceIndex) {
  126095. case 0:
  126096. _this._add.copyFromFloats(1, 0, 0);
  126097. break;
  126098. case 1:
  126099. _this._add.copyFromFloats(-1, 0, 0);
  126100. break;
  126101. case 2:
  126102. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  126103. break;
  126104. case 3:
  126105. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  126106. break;
  126107. case 4:
  126108. _this._add.copyFromFloats(0, 0, 1);
  126109. break;
  126110. case 5:
  126111. _this._add.copyFromFloats(0, 0, -1);
  126112. break;
  126113. }
  126114. if (_this._attachedMesh) {
  126115. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  126116. }
  126117. _this.position.addToRef(_this._add, _this._target);
  126118. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  126119. if (scene.activeCamera) {
  126120. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  126121. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  126122. }
  126123. scene._forcedViewPosition = _this.position;
  126124. });
  126125. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  126126. scene._forcedViewPosition = null;
  126127. scene.updateTransformMatrix(true);
  126128. });
  126129. }
  126130. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  126131. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  126132. get: function () {
  126133. return this._renderTargetTexture.samples;
  126134. },
  126135. set: function (value) {
  126136. this._renderTargetTexture.samples = value;
  126137. },
  126138. enumerable: true,
  126139. configurable: true
  126140. });
  126141. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  126142. /** Gets or sets the refresh rate to use (on every frame by default) */
  126143. get: function () {
  126144. return this._renderTargetTexture.refreshRate;
  126145. },
  126146. set: function (value) {
  126147. this._renderTargetTexture.refreshRate = value;
  126148. },
  126149. enumerable: true,
  126150. configurable: true
  126151. });
  126152. /**
  126153. * Gets the hosting scene
  126154. * @returns a Scene
  126155. */
  126156. ReflectionProbe.prototype.getScene = function () {
  126157. return this._scene;
  126158. };
  126159. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  126160. /** Gets the internal CubeTexture used to render to */
  126161. get: function () {
  126162. return this._renderTargetTexture;
  126163. },
  126164. enumerable: true,
  126165. configurable: true
  126166. });
  126167. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  126168. /** Gets the list of meshes to render */
  126169. get: function () {
  126170. return this._renderTargetTexture.renderList;
  126171. },
  126172. enumerable: true,
  126173. configurable: true
  126174. });
  126175. /**
  126176. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  126177. * @param mesh defines the mesh to attach to
  126178. */
  126179. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  126180. this._attachedMesh = mesh;
  126181. };
  126182. /**
  126183. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  126184. * @param renderingGroupId The rendering group id corresponding to its index
  126185. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  126186. */
  126187. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  126188. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  126189. };
  126190. /**
  126191. * Clean all associated resources
  126192. */
  126193. ReflectionProbe.prototype.dispose = function () {
  126194. var index = this._scene.reflectionProbes.indexOf(this);
  126195. if (index !== -1) {
  126196. // Remove from the scene if found
  126197. this._scene.reflectionProbes.splice(index, 1);
  126198. }
  126199. if (this._renderTargetTexture) {
  126200. this._renderTargetTexture.dispose();
  126201. this._renderTargetTexture = null;
  126202. }
  126203. };
  126204. /**
  126205. * Converts the reflection probe information to a readable string for debug purpose.
  126206. * @param fullDetails Supports for multiple levels of logging within scene loading
  126207. * @returns the human readable reflection probe info
  126208. */
  126209. ReflectionProbe.prototype.toString = function (fullDetails) {
  126210. var ret = "Name: " + this.name;
  126211. if (fullDetails) {
  126212. ret += ", position: " + this.position.toString();
  126213. if (this._attachedMesh) {
  126214. ret += ", attached mesh: " + this._attachedMesh.name;
  126215. }
  126216. }
  126217. return ret;
  126218. };
  126219. /**
  126220. * Get the class name of the relfection probe.
  126221. * @returns "ReflectionProbe"
  126222. */
  126223. ReflectionProbe.prototype.getClassName = function () {
  126224. return "ReflectionProbe";
  126225. };
  126226. /**
  126227. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  126228. * @returns The JSON representation of the texture
  126229. */
  126230. ReflectionProbe.prototype.serialize = function () {
  126231. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  126232. serializationObject.isReflectionProbe = true;
  126233. return serializationObject;
  126234. };
  126235. /**
  126236. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  126237. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  126238. * @param scene Define the scene the parsed reflection probe should be instantiated in
  126239. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  126240. * @returns The parsed reflection probe if successful
  126241. */
  126242. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  126243. var reflectionProbe = null;
  126244. if (scene.reflectionProbes) {
  126245. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  126246. var rp = scene.reflectionProbes[index];
  126247. if (rp.name === parsedReflectionProbe.name) {
  126248. reflectionProbe = rp;
  126249. break;
  126250. }
  126251. }
  126252. }
  126253. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  126254. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  126255. if (parsedReflectionProbe._attachedMesh) {
  126256. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  126257. }
  126258. return reflectionProbe;
  126259. };
  126260. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  126262. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  126263. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126264. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  126265. ], ReflectionProbe.prototype, "position", void 0);
  126266. return ReflectionProbe;
  126267. }());
  126268. /***/ }),
  126269. /***/ "./Rendering/boundingBoxRenderer.ts":
  126270. /*!******************************************!*\
  126271. !*** ./Rendering/boundingBoxRenderer.ts ***!
  126272. \******************************************/
  126273. /*! exports provided: BoundingBoxRenderer */
  126274. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126275. "use strict";
  126276. __webpack_require__.r(__webpack_exports__);
  126277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  126278. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  126279. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  126280. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  126281. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  126282. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126283. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  126284. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  126285. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  126286. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  126287. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  126288. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  126289. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  126290. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  126291. get: function () {
  126292. return this._forceShowBoundingBoxes || false;
  126293. },
  126294. set: function (value) {
  126295. this._forceShowBoundingBoxes = value;
  126296. // Lazyly creates a BB renderer if needed.
  126297. if (value) {
  126298. this.getBoundingBoxRenderer();
  126299. }
  126300. },
  126301. enumerable: true,
  126302. configurable: true
  126303. });
  126304. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  126305. if (!this._boundingBoxRenderer) {
  126306. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  126307. }
  126308. return this._boundingBoxRenderer;
  126309. };
  126310. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  126311. get: function () {
  126312. return this._showBoundingBox || false;
  126313. },
  126314. set: function (value) {
  126315. this._showBoundingBox = value;
  126316. // Lazyly creates a BB renderer if needed.
  126317. if (value) {
  126318. this.getScene().getBoundingBoxRenderer();
  126319. }
  126320. },
  126321. enumerable: true,
  126322. configurable: true
  126323. });
  126324. /**
  126325. * Component responsible of rendering the bounding box of the meshes in a scene.
  126326. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  126327. */
  126328. var BoundingBoxRenderer = /** @class */ (function () {
  126329. /**
  126330. * Instantiates a new bounding box renderer in a scene.
  126331. * @param scene the scene the renderer renders in
  126332. */
  126333. function BoundingBoxRenderer(scene) {
  126334. /**
  126335. * The component name helpfull to identify the component in the list of scene components.
  126336. */
  126337. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  126338. /**
  126339. * Color of the bounding box lines placed in front of an object
  126340. */
  126341. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  126342. /**
  126343. * Color of the bounding box lines placed behind an object
  126344. */
  126345. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  126346. /**
  126347. * Defines if the renderer should show the back lines or not
  126348. */
  126349. this.showBackLines = true;
  126350. /**
  126351. * @hidden
  126352. */
  126353. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  126354. this._vertexBuffers = {};
  126355. this.scene = scene;
  126356. scene._addComponent(this);
  126357. }
  126358. /**
  126359. * Registers the component in a given scene
  126360. */
  126361. BoundingBoxRenderer.prototype.register = function () {
  126362. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  126363. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  126364. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  126365. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  126366. };
  126367. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  126368. if (mesh.showSubMeshesBoundingBox) {
  126369. var boundingInfo = subMesh.getBoundingInfo();
  126370. if (boundingInfo !== null && boundingInfo !== undefined) {
  126371. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  126372. this.renderList.push(boundingInfo.boundingBox);
  126373. }
  126374. }
  126375. };
  126376. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  126377. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  126378. var boundingInfo = sourceMesh.getBoundingInfo();
  126379. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  126380. this.renderList.push(boundingInfo.boundingBox);
  126381. }
  126382. };
  126383. BoundingBoxRenderer.prototype._prepareRessources = function () {
  126384. if (this._colorShader) {
  126385. return;
  126386. }
  126387. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  126388. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  126389. uniforms: ["world", "viewProjection", "color"]
  126390. });
  126391. var engine = this.scene.getEngine();
  126392. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  126393. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"](engine, boxdata.positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, false);
  126394. this._createIndexBuffer();
  126395. };
  126396. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  126397. var engine = this.scene.getEngine();
  126398. this._indexBuffer = engine.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]);
  126399. };
  126400. /**
  126401. * Rebuilds the elements related to this component in case of
  126402. * context lost for instance.
  126403. */
  126404. BoundingBoxRenderer.prototype.rebuild = function () {
  126405. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  126406. if (vb) {
  126407. vb._rebuild();
  126408. }
  126409. this._createIndexBuffer();
  126410. };
  126411. /**
  126412. * @hidden
  126413. */
  126414. BoundingBoxRenderer.prototype.reset = function () {
  126415. this.renderList.reset();
  126416. };
  126417. /**
  126418. * Render the bounding boxes of a specific rendering group
  126419. * @param renderingGroupId defines the rendering group to render
  126420. */
  126421. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  126422. if (this.renderList.length === 0) {
  126423. return;
  126424. }
  126425. this._prepareRessources();
  126426. if (!this._colorShader.isReady()) {
  126427. return;
  126428. }
  126429. var engine = this.scene.getEngine();
  126430. engine.setDepthWrite(false);
  126431. this._colorShader._preBind();
  126432. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  126433. var boundingBox = this.renderList.data[boundingBoxIndex];
  126434. if (boundingBox._tag !== renderingGroupId) {
  126435. continue;
  126436. }
  126437. var min = boundingBox.minimum;
  126438. var max = boundingBox.maximum;
  126439. var diff = max.subtract(min);
  126440. var median = min.add(diff.scale(0.5));
  126441. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  126442. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  126443. .multiply(boundingBox.getWorldMatrix());
  126444. // VBOs
  126445. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  126446. if (this.showBackLines) {
  126447. // Back
  126448. engine.setDepthFunctionToGreaterOrEqual();
  126449. this.scene.resetCachedMaterial();
  126450. this._colorShader.setColor4("color", this.backColor.toColor4());
  126451. this._colorShader.bind(worldMatrix);
  126452. // Draw order
  126453. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  126454. }
  126455. // Front
  126456. engine.setDepthFunctionToLess();
  126457. this.scene.resetCachedMaterial();
  126458. this._colorShader.setColor4("color", this.frontColor.toColor4());
  126459. this._colorShader.bind(worldMatrix);
  126460. // Draw order
  126461. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  126462. }
  126463. this._colorShader.unbind();
  126464. engine.setDepthFunctionToLessOrEqual();
  126465. engine.setDepthWrite(true);
  126466. };
  126467. /**
  126468. * In case of occlusion queries, we can render the occlusion bounding box through this method
  126469. * @param mesh Define the mesh to render the occlusion bounding box for
  126470. */
  126471. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  126472. this._prepareRessources();
  126473. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  126474. return;
  126475. }
  126476. var engine = this.scene.getEngine();
  126477. engine.setDepthWrite(false);
  126478. engine.setColorWrite(false);
  126479. this._colorShader._preBind();
  126480. var boundingBox = mesh._boundingInfo.boundingBox;
  126481. var min = boundingBox.minimum;
  126482. var max = boundingBox.maximum;
  126483. var diff = max.subtract(min);
  126484. var median = min.add(diff.scale(0.5));
  126485. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  126486. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  126487. .multiply(boundingBox.getWorldMatrix());
  126488. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  126489. engine.setDepthFunctionToLess();
  126490. this.scene.resetCachedMaterial();
  126491. this._colorShader.bind(worldMatrix);
  126492. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  126493. this._colorShader.unbind();
  126494. engine.setDepthFunctionToLessOrEqual();
  126495. engine.setDepthWrite(true);
  126496. engine.setColorWrite(true);
  126497. };
  126498. /**
  126499. * Dispose and release the resources attached to this renderer.
  126500. */
  126501. BoundingBoxRenderer.prototype.dispose = function () {
  126502. if (!this._colorShader) {
  126503. return;
  126504. }
  126505. this.renderList.dispose();
  126506. this._colorShader.dispose();
  126507. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  126508. if (buffer) {
  126509. buffer.dispose();
  126510. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  126511. }
  126512. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  126513. };
  126514. return BoundingBoxRenderer;
  126515. }());
  126516. /***/ }),
  126517. /***/ "./Rendering/depthRenderer.ts":
  126518. /*!************************************!*\
  126519. !*** ./Rendering/depthRenderer.ts ***!
  126520. \************************************/
  126521. /*! exports provided: DepthRenderer */
  126522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126523. "use strict";
  126524. __webpack_require__.r(__webpack_exports__);
  126525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  126526. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126527. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  126528. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  126529. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  126530. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  126531. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126532. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  126533. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  126534. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  126535. /**
  126536. * This represents a depth renderer in Babylon.
  126537. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126538. */
  126539. var DepthRenderer = /** @class */ (function () {
  126540. /**
  126541. * Instantiates a depth renderer
  126542. * @param scene The scene the renderer belongs to
  126543. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126544. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126545. */
  126546. function DepthRenderer(scene, type, camera) {
  126547. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  126548. if (camera === void 0) { camera = null; }
  126549. var _this = this;
  126550. /**
  126551. * Specifiess that the depth renderer will only be used within
  126552. * the camera it is created for.
  126553. * This can help forcing its rendering during the camera processing.
  126554. */
  126555. this.useOnlyInActiveCamera = false;
  126556. this._scene = scene;
  126557. DepthRenderer._SceneComponentInitialization(this._scene);
  126558. this._camera = camera;
  126559. var engine = scene.getEngine();
  126560. // Render target
  126561. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  126562. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  126563. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  126564. this._depthMap.refreshRate = 1;
  126565. this._depthMap.renderParticles = false;
  126566. this._depthMap.renderList = null;
  126567. // Camera to get depth map from to support multiple concurrent cameras
  126568. this._depthMap.activeCamera = this._camera;
  126569. this._depthMap.ignoreCameraViewport = true;
  126570. this._depthMap.useCameraPostProcesses = false;
  126571. // set default depth value to 1.0 (far away)
  126572. this._depthMap.onClearObservable.add(function (engine) {
  126573. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  126574. });
  126575. // Custom render function
  126576. var renderSubMesh = function (subMesh) {
  126577. var mesh = subMesh.getRenderingMesh();
  126578. var scene = _this._scene;
  126579. var engine = scene.getEngine();
  126580. var material = subMesh.getMaterial();
  126581. if (!material) {
  126582. return;
  126583. }
  126584. // Culling and reverse (right handed system)
  126585. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  126586. // Managing instances
  126587. var batch = mesh._getInstancesRenderList(subMesh._id);
  126588. if (batch.mustReturn) {
  126589. return;
  126590. }
  126591. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  126592. var camera = _this._camera || scene.activeCamera;
  126593. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  126594. engine.enableEffect(_this._effect);
  126595. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  126596. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  126597. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  126598. // Alpha test
  126599. if (material && material.needAlphaTesting()) {
  126600. var alphaTexture = material.getAlphaTestTexture();
  126601. if (alphaTexture) {
  126602. _this._effect.setTexture("diffuseSampler", alphaTexture);
  126603. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  126604. }
  126605. }
  126606. // Bones
  126607. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  126608. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  126609. }
  126610. // Draw
  126611. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  126612. }
  126613. };
  126614. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  126615. var index;
  126616. if (depthOnlySubMeshes.length) {
  126617. engine.setColorWrite(false);
  126618. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  126619. renderSubMesh(depthOnlySubMeshes.data[index]);
  126620. }
  126621. engine.setColorWrite(true);
  126622. }
  126623. for (index = 0; index < opaqueSubMeshes.length; index++) {
  126624. renderSubMesh(opaqueSubMeshes.data[index]);
  126625. }
  126626. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  126627. renderSubMesh(alphaTestSubMeshes.data[index]);
  126628. }
  126629. };
  126630. }
  126631. /**
  126632. * Creates the depth rendering effect and checks if the effect is ready.
  126633. * @param subMesh The submesh to be used to render the depth map of
  126634. * @param useInstances If multiple world instances should be used
  126635. * @returns if the depth renderer is ready to render the depth map
  126636. */
  126637. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  126638. var material = subMesh.getMaterial();
  126639. if (material.disableDepthWrite) {
  126640. return false;
  126641. }
  126642. var defines = [];
  126643. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  126644. var mesh = subMesh.getMesh();
  126645. // Alpha test
  126646. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  126647. defines.push("#define ALPHATEST");
  126648. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  126649. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  126650. defines.push("#define UV1");
  126651. }
  126652. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  126653. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  126654. defines.push("#define UV2");
  126655. }
  126656. }
  126657. // Bones
  126658. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  126659. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  126660. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  126661. if (mesh.numBoneInfluencers > 4) {
  126662. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  126663. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  126664. }
  126665. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  126666. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  126667. }
  126668. else {
  126669. defines.push("#define NUM_BONE_INFLUENCERS 0");
  126670. }
  126671. // Instances
  126672. if (useInstances) {
  126673. defines.push("#define INSTANCES");
  126674. attribs.push("world0");
  126675. attribs.push("world1");
  126676. attribs.push("world2");
  126677. attribs.push("world3");
  126678. }
  126679. // Get correct effect
  126680. var join = defines.join("\n");
  126681. if (this._cachedDefines !== join) {
  126682. this._cachedDefines = join;
  126683. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  126684. }
  126685. return this._effect.isReady();
  126686. };
  126687. /**
  126688. * Gets the texture which the depth map will be written to.
  126689. * @returns The depth map texture
  126690. */
  126691. DepthRenderer.prototype.getDepthMap = function () {
  126692. return this._depthMap;
  126693. };
  126694. /**
  126695. * Disposes of the depth renderer.
  126696. */
  126697. DepthRenderer.prototype.dispose = function () {
  126698. this._depthMap.dispose();
  126699. };
  126700. /** @hidden */
  126701. DepthRenderer._SceneComponentInitialization = function (_) {
  126702. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("DepthRendererSceneComponent");
  126703. };
  126704. return DepthRenderer;
  126705. }());
  126706. /***/ }),
  126707. /***/ "./Rendering/depthRendererSceneComponent.ts":
  126708. /*!**************************************************!*\
  126709. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  126710. \**************************************************/
  126711. /*! exports provided: DepthRendererSceneComponent */
  126712. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126713. "use strict";
  126714. __webpack_require__.r(__webpack_exports__);
  126715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  126716. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  126717. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  126718. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126719. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  126720. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  126721. camera = camera || this.activeCamera;
  126722. if (!camera) {
  126723. throw "No camera available to enable depth renderer";
  126724. }
  126725. if (!this._depthRenderer) {
  126726. this._depthRenderer = {};
  126727. }
  126728. if (!this._depthRenderer[camera.id]) {
  126729. var textureType = 0;
  126730. if (this.getEngine().getCaps().textureHalfFloatRender) {
  126731. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  126732. }
  126733. else if (this.getEngine().getCaps().textureFloatRender) {
  126734. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  126735. }
  126736. else {
  126737. throw "Depth renderer does not support int texture type";
  126738. }
  126739. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  126740. }
  126741. return this._depthRenderer[camera.id];
  126742. };
  126743. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  126744. camera = camera || this.activeCamera;
  126745. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  126746. return;
  126747. }
  126748. this._depthRenderer[camera.id].dispose();
  126749. delete this._depthRenderer[camera.id];
  126750. };
  126751. /**
  126752. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  126753. * in several rendering techniques.
  126754. */
  126755. var DepthRendererSceneComponent = /** @class */ (function () {
  126756. /**
  126757. * Creates a new instance of the component for the given scene
  126758. * @param scene Defines the scene to register the component in
  126759. */
  126760. function DepthRendererSceneComponent(scene) {
  126761. /**
  126762. * The component name helpfull to identify the component in the list of scene components.
  126763. */
  126764. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  126765. this.scene = scene;
  126766. }
  126767. /**
  126768. * Registers the component in a given scene
  126769. */
  126770. DepthRendererSceneComponent.prototype.register = function () {
  126771. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  126772. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  126773. };
  126774. /**
  126775. * Rebuilds the elements related to this component in case of
  126776. * context lost for instance.
  126777. */
  126778. DepthRendererSceneComponent.prototype.rebuild = function () {
  126779. // Nothing to do for this component
  126780. };
  126781. /**
  126782. * Disposes the component and the associated ressources
  126783. */
  126784. DepthRendererSceneComponent.prototype.dispose = function () {
  126785. for (var key in this.scene._depthRenderer) {
  126786. this.scene._depthRenderer[key].dispose();
  126787. }
  126788. };
  126789. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  126790. if (this.scene._depthRenderer) {
  126791. for (var key in this.scene._depthRenderer) {
  126792. var depthRenderer = this.scene._depthRenderer[key];
  126793. if (!depthRenderer.useOnlyInActiveCamera) {
  126794. renderTargets.push(depthRenderer.getDepthMap());
  126795. }
  126796. }
  126797. }
  126798. };
  126799. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  126800. if (this.scene._depthRenderer) {
  126801. for (var key in this.scene._depthRenderer) {
  126802. var depthRenderer = this.scene._depthRenderer[key];
  126803. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  126804. renderTargets.push(depthRenderer.getDepthMap());
  126805. }
  126806. }
  126807. }
  126808. };
  126809. return DepthRendererSceneComponent;
  126810. }());
  126811. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  126812. // Register the G Buffer component to the scene.
  126813. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  126814. if (!component) {
  126815. component = new DepthRendererSceneComponent(scene);
  126816. scene._addComponent(component);
  126817. }
  126818. };
  126819. /***/ }),
  126820. /***/ "./Rendering/edgesRenderer.ts":
  126821. /*!************************************!*\
  126822. !*** ./Rendering/edgesRenderer.ts ***!
  126823. \************************************/
  126824. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  126825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126826. "use strict";
  126827. __webpack_require__.r(__webpack_exports__);
  126828. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  126829. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  126830. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126831. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  126832. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  126833. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  126834. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126835. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  126836. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  126837. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  126838. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126839. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  126840. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  126841. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  126842. if (this._edgesRenderer) {
  126843. this._edgesRenderer.dispose();
  126844. this._edgesRenderer = null;
  126845. }
  126846. return this;
  126847. };
  126848. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  126849. if (epsilon === void 0) { epsilon = 0.95; }
  126850. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  126851. this.disableEdgesRendering();
  126852. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  126853. return this;
  126854. };
  126855. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  126856. get: function () {
  126857. return this._edgesRenderer;
  126858. },
  126859. enumerable: true,
  126860. configurable: true
  126861. });
  126862. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  126863. if (epsilon === void 0) { epsilon = 0.95; }
  126864. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  126865. this.disableEdgesRendering();
  126866. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  126867. return this;
  126868. };
  126869. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  126870. if (epsilon === void 0) { epsilon = 0.95; }
  126871. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  126872. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  126873. return this;
  126874. };
  126875. /**
  126876. * FaceAdjacencies Helper class to generate edges
  126877. */
  126878. var FaceAdjacencies = /** @class */ (function () {
  126879. function FaceAdjacencies() {
  126880. this.edges = new Array();
  126881. this.edgesConnectedCount = 0;
  126882. }
  126883. return FaceAdjacencies;
  126884. }());
  126885. /**
  126886. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  126887. */
  126888. var EdgesRenderer = /** @class */ (function () {
  126889. /**
  126890. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  126891. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  126892. * @param source Mesh used to create edges
  126893. * @param epsilon sum of angles in adjacency to check for edge
  126894. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  126895. * @param generateEdgesLines - should generate Lines or only prepare resources.
  126896. */
  126897. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  126898. if (epsilon === void 0) { epsilon = 0.95; }
  126899. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  126900. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  126901. var _this = this;
  126902. /**
  126903. * Define the size of the edges with an orthographic camera
  126904. */
  126905. this.edgesWidthScalerForOrthographic = 1000.0;
  126906. /**
  126907. * Define the size of the edges with a perspective camera
  126908. */
  126909. this.edgesWidthScalerForPerspective = 50.0;
  126910. this._linesPositions = new Array();
  126911. this._linesNormals = new Array();
  126912. this._linesIndices = new Array();
  126913. this._buffers = {};
  126914. this._checkVerticesInsteadOfIndices = false;
  126915. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  126916. this.isEnabled = true;
  126917. this._source = source;
  126918. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  126919. this._epsilon = epsilon;
  126920. this._prepareRessources();
  126921. if (generateEdgesLines) {
  126922. this._generateEdgesLines();
  126923. }
  126924. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  126925. _this._rebuild();
  126926. });
  126927. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  126928. _this.dispose();
  126929. });
  126930. }
  126931. EdgesRenderer.prototype._prepareRessources = function () {
  126932. if (this._lineShader) {
  126933. return;
  126934. }
  126935. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  126936. attributes: ["position", "normal"],
  126937. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  126938. });
  126939. this._lineShader.disableDepthWrite = true;
  126940. this._lineShader.backFaceCulling = false;
  126941. };
  126942. /** @hidden */
  126943. EdgesRenderer.prototype._rebuild = function () {
  126944. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  126945. if (buffer) {
  126946. buffer._rebuild();
  126947. }
  126948. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  126949. if (buffer) {
  126950. buffer._rebuild();
  126951. }
  126952. var scene = this._source.getScene();
  126953. var engine = scene.getEngine();
  126954. this._ib = engine.createIndexBuffer(this._linesIndices);
  126955. };
  126956. /**
  126957. * Releases the required resources for the edges renderer
  126958. */
  126959. EdgesRenderer.prototype.dispose = function () {
  126960. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  126961. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  126962. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  126963. if (buffer) {
  126964. buffer.dispose();
  126965. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  126966. }
  126967. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  126968. if (buffer) {
  126969. buffer.dispose();
  126970. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  126971. }
  126972. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  126973. this._lineShader.dispose();
  126974. };
  126975. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  126976. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  126977. return 0;
  126978. }
  126979. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  126980. return 1;
  126981. }
  126982. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  126983. return 2;
  126984. }
  126985. return -1;
  126986. };
  126987. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  126988. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  126989. return 0;
  126990. }
  126991. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  126992. return 1;
  126993. }
  126994. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  126995. return 2;
  126996. }
  126997. return -1;
  126998. };
  126999. /**
  127000. * Checks if the pair of p0 and p1 is en edge
  127001. * @param faceIndex
  127002. * @param edge
  127003. * @param faceNormals
  127004. * @param p0
  127005. * @param p1
  127006. * @private
  127007. */
  127008. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  127009. var needToCreateLine;
  127010. if (edge === undefined) {
  127011. needToCreateLine = true;
  127012. }
  127013. else {
  127014. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  127015. needToCreateLine = dotProduct < this._epsilon;
  127016. }
  127017. if (needToCreateLine) {
  127018. this.createLine(p0, p1, this._linesPositions.length / 3);
  127019. }
  127020. };
  127021. /**
  127022. * push line into the position, normal and index buffer
  127023. * @protected
  127024. */
  127025. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  127026. // Positions
  127027. this._linesPositions.push(p0.x, p0.y, p0.z, p0.x, p0.y, p0.z, p1.x, p1.y, p1.z, p1.x, p1.y, p1.z);
  127028. // Normals
  127029. this._linesNormals.push(p1.x, p1.y, p1.z, -1, p1.x, p1.y, p1.z, 1, p0.x, p0.y, p0.z, -1, p0.x, p0.y, p0.z, 1);
  127030. // Indices
  127031. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  127032. };
  127033. /**
  127034. * Generates lines edges from adjacencjes
  127035. * @private
  127036. */
  127037. EdgesRenderer.prototype._generateEdgesLines = function () {
  127038. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  127039. var indices = this._source.getIndices();
  127040. if (!indices || !positions) {
  127041. return;
  127042. }
  127043. // First let's find adjacencies
  127044. var adjacencies = new Array();
  127045. var faceNormals = new Array();
  127046. var index;
  127047. var faceAdjacencies;
  127048. // Prepare faces
  127049. for (index = 0; index < indices.length; index += 3) {
  127050. faceAdjacencies = new FaceAdjacencies();
  127051. var p0Index = indices[index];
  127052. var p1Index = indices[index + 1];
  127053. var p2Index = indices[index + 2];
  127054. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  127055. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  127056. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  127057. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  127058. faceNormal.normalize();
  127059. faceNormals.push(faceNormal);
  127060. adjacencies.push(faceAdjacencies);
  127061. }
  127062. // Scan
  127063. for (index = 0; index < adjacencies.length; index++) {
  127064. faceAdjacencies = adjacencies[index];
  127065. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  127066. var otherFaceAdjacencies = adjacencies[otherIndex];
  127067. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  127068. break;
  127069. }
  127070. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  127071. continue;
  127072. }
  127073. var otherP0 = indices[otherIndex * 3];
  127074. var otherP1 = indices[otherIndex * 3 + 1];
  127075. var otherP2 = indices[otherIndex * 3 + 2];
  127076. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  127077. var otherEdgeIndex = 0;
  127078. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  127079. continue;
  127080. }
  127081. switch (edgeIndex) {
  127082. case 0:
  127083. if (this._checkVerticesInsteadOfIndices) {
  127084. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  127085. }
  127086. else {
  127087. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  127088. }
  127089. break;
  127090. case 1:
  127091. if (this._checkVerticesInsteadOfIndices) {
  127092. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  127093. }
  127094. else {
  127095. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  127096. }
  127097. break;
  127098. case 2:
  127099. if (this._checkVerticesInsteadOfIndices) {
  127100. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  127101. }
  127102. else {
  127103. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  127104. }
  127105. break;
  127106. }
  127107. if (otherEdgeIndex === -1) {
  127108. continue;
  127109. }
  127110. faceAdjacencies.edges[edgeIndex] = otherIndex;
  127111. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  127112. faceAdjacencies.edgesConnectedCount++;
  127113. otherFaceAdjacencies.edgesConnectedCount++;
  127114. if (faceAdjacencies.edgesConnectedCount === 3) {
  127115. break;
  127116. }
  127117. }
  127118. }
  127119. }
  127120. // Create lines
  127121. for (index = 0; index < adjacencies.length; index++) {
  127122. // We need a line when a face has no adjacency on a specific edge or if all the adjacencies has an angle greater than epsilon
  127123. var current = adjacencies[index];
  127124. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  127125. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  127126. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  127127. }
  127128. // Merge into a single mesh
  127129. var engine = this._source.getScene().getEngine();
  127130. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"](engine, this._linesPositions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, false);
  127131. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"](engine, this._linesNormals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, false, false, 4);
  127132. this._ib = engine.createIndexBuffer(this._linesIndices);
  127133. this._indicesCount = this._linesIndices.length;
  127134. };
  127135. /**
  127136. * Checks wether or not the edges renderer is ready to render.
  127137. * @return true if ready, otherwise false.
  127138. */
  127139. EdgesRenderer.prototype.isReady = function () {
  127140. return this._lineShader.isReady();
  127141. };
  127142. /**
  127143. * Renders the edges of the attached mesh,
  127144. */
  127145. EdgesRenderer.prototype.render = function () {
  127146. var scene = this._source.getScene();
  127147. if (!this.isReady() || !scene.activeCamera) {
  127148. return;
  127149. }
  127150. var engine = scene.getEngine();
  127151. this._lineShader._preBind();
  127152. if (this._source.edgesColor.a !== 1) {
  127153. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  127154. }
  127155. else {
  127156. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  127157. }
  127158. // VBOs
  127159. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  127160. scene.resetCachedMaterial();
  127161. this._lineShader.setColor4("color", this._source.edgesColor);
  127162. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  127163. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  127164. }
  127165. else {
  127166. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  127167. }
  127168. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  127169. this._lineShader.bind(this._source.getWorldMatrix());
  127170. // Draw order
  127171. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  127172. this._lineShader.unbind();
  127173. };
  127174. return EdgesRenderer;
  127175. }());
  127176. /**
  127177. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  127178. */
  127179. var LineEdgesRenderer = /** @class */ (function (_super) {
  127180. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  127181. /**
  127182. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  127183. * @param source LineMesh used to generate edges
  127184. * @param epsilon not important (specified angle for edge detection)
  127185. * @param checkVerticesInsteadOfIndices not important for LineMesh
  127186. */
  127187. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  127188. if (epsilon === void 0) { epsilon = 0.95; }
  127189. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  127190. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  127191. _this._generateEdgesLines();
  127192. return _this;
  127193. }
  127194. /**
  127195. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  127196. */
  127197. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  127198. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  127199. var indices = this._source.getIndices();
  127200. if (!indices || !positions) {
  127201. return;
  127202. }
  127203. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  127204. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  127205. var len = indices.length - 1;
  127206. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  127207. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  127208. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  127209. this.createLine(p0, p1, offset);
  127210. }
  127211. // Merge into a single mesh
  127212. var engine = this._source.getScene().getEngine();
  127213. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"](engine, this._linesPositions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, false);
  127214. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"](engine, this._linesNormals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, false, false, 4);
  127215. this._ib = engine.createIndexBuffer(this._linesIndices);
  127216. this._indicesCount = this._linesIndices.length;
  127217. };
  127218. return LineEdgesRenderer;
  127219. }(EdgesRenderer));
  127220. /***/ }),
  127221. /***/ "./Rendering/geometryBufferRenderer.ts":
  127222. /*!*********************************************!*\
  127223. !*** ./Rendering/geometryBufferRenderer.ts ***!
  127224. \*********************************************/
  127225. /*! exports provided: GeometryBufferRenderer */
  127226. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127227. "use strict";
  127228. __webpack_require__.r(__webpack_exports__);
  127229. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  127230. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  127231. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  127232. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127233. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  127234. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  127235. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  127236. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  127237. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  127238. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  127239. /**
  127240. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  127241. */
  127242. var GeometryBufferRenderer = /** @class */ (function () {
  127243. /**
  127244. * Creates a new G Buffer for the scene
  127245. * @param scene The scene the buffer belongs to
  127246. * @param ratio How big is the buffer related to the main canvas.
  127247. */
  127248. function GeometryBufferRenderer(scene, ratio) {
  127249. if (ratio === void 0) { ratio = 1; }
  127250. /**
  127251. * Dictionary used to store the previous transformation matrices of each rendered mesh
  127252. * in order to compute objects velocities when enableVelocity is set to "true"
  127253. * @hidden
  127254. */
  127255. this._previousTransformationMatrices = {};
  127256. this._enablePosition = false;
  127257. this._enableVelocity = false;
  127258. this._positionIndex = -1;
  127259. this._velocityIndex = -1;
  127260. this._scene = scene;
  127261. this._ratio = ratio;
  127262. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  127263. // Render target
  127264. this._createRenderTargets();
  127265. }
  127266. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  127267. /**
  127268. * Set the render list (meshes to be rendered) used in the G buffer.
  127269. */
  127270. set: function (meshes) {
  127271. this._multiRenderTarget.renderList = meshes;
  127272. },
  127273. enumerable: true,
  127274. configurable: true
  127275. });
  127276. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  127277. /**
  127278. * Gets wether or not G buffer are supported by the running hardware.
  127279. * This requires draw buffer supports
  127280. */
  127281. get: function () {
  127282. return this._multiRenderTarget.isSupported;
  127283. },
  127284. enumerable: true,
  127285. configurable: true
  127286. });
  127287. /**
  127288. * Returns the index of the given texture type in the G-Buffer textures array
  127289. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  127290. * @returns the index of the given texture type in the G-Buffer textures array
  127291. */
  127292. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  127293. switch (textureType) {
  127294. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  127295. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  127296. default: return -1;
  127297. }
  127298. };
  127299. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  127300. /**
  127301. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  127302. */
  127303. get: function () {
  127304. return this._enablePosition;
  127305. },
  127306. /**
  127307. * Sets whether or not objects positions are enabled for the G buffer.
  127308. */
  127309. set: function (enable) {
  127310. this._enablePosition = enable;
  127311. this.dispose();
  127312. this._createRenderTargets();
  127313. },
  127314. enumerable: true,
  127315. configurable: true
  127316. });
  127317. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  127318. /**
  127319. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  127320. */
  127321. get: function () {
  127322. return this._enableVelocity;
  127323. },
  127324. /**
  127325. * Sets wether or not objects velocities are enabled for the G buffer.
  127326. */
  127327. set: function (enable) {
  127328. this._enableVelocity = enable;
  127329. this.dispose();
  127330. this._createRenderTargets();
  127331. },
  127332. enumerable: true,
  127333. configurable: true
  127334. });
  127335. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  127336. /**
  127337. * Gets the scene associated with the buffer.
  127338. */
  127339. get: function () {
  127340. return this._scene;
  127341. },
  127342. enumerable: true,
  127343. configurable: true
  127344. });
  127345. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  127346. /**
  127347. * Gets the ratio used by the buffer during its creation.
  127348. * How big is the buffer related to the main canvas.
  127349. */
  127350. get: function () {
  127351. return this._ratio;
  127352. },
  127353. enumerable: true,
  127354. configurable: true
  127355. });
  127356. /**
  127357. * Checks wether everything is ready to render a submesh to the G buffer.
  127358. * @param subMesh the submesh to check readiness for
  127359. * @param useInstances is the mesh drawn using instance or not
  127360. * @returns true if ready otherwise false
  127361. */
  127362. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  127363. var material = subMesh.getMaterial();
  127364. if (material && material.disableDepthWrite) {
  127365. return false;
  127366. }
  127367. var defines = [];
  127368. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  127369. var mesh = subMesh.getMesh();
  127370. // Alpha test
  127371. if (material && material.needAlphaTesting()) {
  127372. defines.push("#define ALPHATEST");
  127373. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  127374. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  127375. defines.push("#define UV1");
  127376. }
  127377. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  127378. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  127379. defines.push("#define UV2");
  127380. }
  127381. }
  127382. // Buffers
  127383. if (this._enablePosition) {
  127384. defines.push("#define POSITION");
  127385. defines.push("#define POSITION_INDEX " + this._positionIndex);
  127386. }
  127387. if (this._enableVelocity) {
  127388. defines.push("#define VELOCITY");
  127389. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  127390. }
  127391. // Bones
  127392. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  127393. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  127394. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  127395. if (mesh.numBoneInfluencers > 4) {
  127396. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  127397. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  127398. }
  127399. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  127400. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  127401. }
  127402. else {
  127403. defines.push("#define NUM_BONE_INFLUENCERS 0");
  127404. }
  127405. // Instances
  127406. if (useInstances) {
  127407. defines.push("#define INSTANCES");
  127408. attribs.push("world0");
  127409. attribs.push("world1");
  127410. attribs.push("world2");
  127411. attribs.push("world3");
  127412. }
  127413. // Setup textures count
  127414. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  127415. // Get correct effect
  127416. var join = defines.join("\n");
  127417. if (this._cachedDefines !== join) {
  127418. this._cachedDefines = join;
  127419. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  127420. }
  127421. return this._effect.isReady();
  127422. };
  127423. /**
  127424. * Gets the current underlying G Buffer.
  127425. * @returns the buffer
  127426. */
  127427. GeometryBufferRenderer.prototype.getGBuffer = function () {
  127428. return this._multiRenderTarget;
  127429. };
  127430. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  127431. /**
  127432. * Gets the number of samples used to render the buffer (anti aliasing).
  127433. */
  127434. get: function () {
  127435. return this._multiRenderTarget.samples;
  127436. },
  127437. /**
  127438. * Sets the number of samples used to render the buffer (anti aliasing).
  127439. */
  127440. set: function (value) {
  127441. this._multiRenderTarget.samples = value;
  127442. },
  127443. enumerable: true,
  127444. configurable: true
  127445. });
  127446. /**
  127447. * Disposes the renderer and frees up associated resources.
  127448. */
  127449. GeometryBufferRenderer.prototype.dispose = function () {
  127450. this.getGBuffer().dispose();
  127451. };
  127452. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  127453. var _this = this;
  127454. var engine = this._scene.getEngine();
  127455. var count = 2;
  127456. if (this._enablePosition) {
  127457. this._positionIndex = count;
  127458. count++;
  127459. }
  127460. if (this._enableVelocity) {
  127461. this._velocityIndex = count;
  127462. count++;
  127463. }
  127464. this._multiRenderTarget = new _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__["MultiRenderTarget"]("gBuffer", { width: engine.getRenderWidth() * this._ratio, height: engine.getRenderHeight() * this._ratio }, count, this._scene, { generateMipMaps: false, generateDepthTexture: true, defaultType: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT });
  127465. if (!this.isSupported) {
  127466. return;
  127467. }
  127468. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  127469. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  127470. this._multiRenderTarget.refreshRate = 1;
  127471. this._multiRenderTarget.renderParticles = false;
  127472. this._multiRenderTarget.renderList = null;
  127473. // set default depth value to 1.0 (far away)
  127474. this._multiRenderTarget.onClearObservable.add(function (engine) {
  127475. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  127476. });
  127477. // Custom render function
  127478. var renderSubMesh = function (subMesh) {
  127479. var mesh = subMesh.getRenderingMesh();
  127480. var scene = _this._scene;
  127481. var engine = scene.getEngine();
  127482. var material = subMesh.getMaterial();
  127483. if (!material) {
  127484. return;
  127485. }
  127486. // Velocity
  127487. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  127488. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  127489. }
  127490. // Culling
  127491. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  127492. // Managing instances
  127493. var batch = mesh._getInstancesRenderList(subMesh._id);
  127494. if (batch.mustReturn) {
  127495. return;
  127496. }
  127497. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  127498. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  127499. engine.enableEffect(_this._effect);
  127500. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  127501. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  127502. _this._effect.setMatrix("view", scene.getViewMatrix());
  127503. // Alpha test
  127504. if (material && material.needAlphaTesting()) {
  127505. var alphaTexture = material.getAlphaTestTexture();
  127506. if (alphaTexture) {
  127507. _this._effect.setTexture("diffuseSampler", alphaTexture);
  127508. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  127509. }
  127510. }
  127511. // Bones
  127512. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  127513. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  127514. }
  127515. // Velocity
  127516. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  127517. // Draw
  127518. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  127519. }
  127520. // Velocity
  127521. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  127522. };
  127523. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  127524. var index;
  127525. if (depthOnlySubMeshes.length) {
  127526. engine.setColorWrite(false);
  127527. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  127528. renderSubMesh(depthOnlySubMeshes.data[index]);
  127529. }
  127530. engine.setColorWrite(true);
  127531. }
  127532. for (index = 0; index < opaqueSubMeshes.length; index++) {
  127533. renderSubMesh(opaqueSubMeshes.data[index]);
  127534. }
  127535. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  127536. renderSubMesh(alphaTestSubMeshes.data[index]);
  127537. }
  127538. };
  127539. };
  127540. /**
  127541. * Constant used to retrieve the position texture index in the G-Buffer textures array
  127542. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  127543. */
  127544. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  127545. /**
  127546. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  127547. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  127548. */
  127549. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  127550. /** @hidden */
  127551. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  127552. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("GeometryBufferRendererSceneComponent");
  127553. };
  127554. return GeometryBufferRenderer;
  127555. }());
  127556. /***/ }),
  127557. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  127558. /*!***********************************************************!*\
  127559. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  127560. \***********************************************************/
  127561. /*! exports provided: GeometryBufferRendererSceneComponent */
  127562. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127563. "use strict";
  127564. __webpack_require__.r(__webpack_exports__);
  127565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  127566. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  127567. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  127568. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  127569. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  127570. get: function () {
  127571. this._geometryBufferRenderer;
  127572. },
  127573. set: function (value) {
  127574. if (value && value.isSupported) {
  127575. this._geometryBufferRenderer = value;
  127576. }
  127577. },
  127578. enumerable: true,
  127579. configurable: true
  127580. });
  127581. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  127582. if (ratio === void 0) { ratio = 1; }
  127583. if (this._geometryBufferRenderer) {
  127584. return this._geometryBufferRenderer;
  127585. }
  127586. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  127587. if (!this._geometryBufferRenderer.isSupported) {
  127588. this._geometryBufferRenderer = null;
  127589. }
  127590. return this._geometryBufferRenderer;
  127591. };
  127592. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  127593. if (!this._geometryBufferRenderer) {
  127594. return;
  127595. }
  127596. this._geometryBufferRenderer.dispose();
  127597. this._geometryBufferRenderer = null;
  127598. };
  127599. /**
  127600. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  127601. * in several rendering techniques.
  127602. */
  127603. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  127604. /**
  127605. * Creates a new instance of the component for the given scene
  127606. * @param scene Defines the scene to register the component in
  127607. */
  127608. function GeometryBufferRendererSceneComponent(scene) {
  127609. /**
  127610. * The component name helpful to identify the component in the list of scene components.
  127611. */
  127612. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  127613. this.scene = scene;
  127614. }
  127615. /**
  127616. * Registers the component in a given scene
  127617. */
  127618. GeometryBufferRendererSceneComponent.prototype.register = function () {
  127619. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  127620. };
  127621. /**
  127622. * Rebuilds the elements related to this component in case of
  127623. * context lost for instance.
  127624. */
  127625. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  127626. // Nothing to do for this component
  127627. };
  127628. /**
  127629. * Disposes the component and the associated ressources
  127630. */
  127631. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  127632. // Nothing to do for this component
  127633. };
  127634. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  127635. if (this.scene._geometryBufferRenderer) {
  127636. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  127637. }
  127638. };
  127639. return GeometryBufferRendererSceneComponent;
  127640. }());
  127641. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  127642. // Register the G Buffer component to the scene.
  127643. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  127644. if (!component) {
  127645. component = new GeometryBufferRendererSceneComponent(scene);
  127646. scene._addComponent(component);
  127647. }
  127648. };
  127649. /***/ }),
  127650. /***/ "./Rendering/index.ts":
  127651. /*!****************************!*\
  127652. !*** ./Rendering/index.ts ***!
  127653. \****************************/
  127654. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  127655. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127656. "use strict";
  127657. __webpack_require__.r(__webpack_exports__);
  127658. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  127659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  127660. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  127661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  127662. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  127663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  127664. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  127665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  127666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  127667. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  127668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  127669. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  127670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  127671. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  127672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  127673. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  127674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  127675. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  127676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  127677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  127678. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  127679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  127680. /***/ }),
  127681. /***/ "./Rendering/outlineRenderer.ts":
  127682. /*!**************************************!*\
  127683. !*** ./Rendering/outlineRenderer.ts ***!
  127684. \**************************************/
  127685. /*! exports provided: OutlineRenderer */
  127686. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127687. "use strict";
  127688. __webpack_require__.r(__webpack_exports__);
  127689. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  127690. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  127691. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  127692. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  127693. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127694. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  127695. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  127696. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  127697. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  127698. /**
  127699. * Gets the outline renderer associated with the scene
  127700. * @returns a OutlineRenderer
  127701. */
  127702. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  127703. if (!this._outlineRenderer) {
  127704. this._outlineRenderer = new OutlineRenderer(this);
  127705. }
  127706. return this._outlineRenderer;
  127707. };
  127708. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  127709. get: function () {
  127710. return this._renderOutline;
  127711. },
  127712. set: function (value) {
  127713. if (value) {
  127714. // Lazy Load the component.
  127715. this.getScene().getOutlineRenderer();
  127716. }
  127717. this._renderOutline = value;
  127718. },
  127719. enumerable: true,
  127720. configurable: true
  127721. });
  127722. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  127723. get: function () {
  127724. return this._renderOverlay;
  127725. },
  127726. set: function (value) {
  127727. if (value) {
  127728. // Lazy Load the component.
  127729. this.getScene().getOutlineRenderer();
  127730. }
  127731. this._renderOverlay = value;
  127732. },
  127733. enumerable: true,
  127734. configurable: true
  127735. });
  127736. /**
  127737. * This class is responsible to draw bothe outline/overlay of meshes.
  127738. * It should not be used directly but through the available method on mesh.
  127739. */
  127740. var OutlineRenderer = /** @class */ (function () {
  127741. /**
  127742. * Instantiates a new outline renderer. (There could be only one per scene).
  127743. * @param scene Defines the scene it belongs to
  127744. */
  127745. function OutlineRenderer(scene) {
  127746. /**
  127747. * The name of the component. Each component must have a unique name.
  127748. */
  127749. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  127750. /**
  127751. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  127752. */
  127753. this.zOffset = 1;
  127754. this.scene = scene;
  127755. this._engine = scene.getEngine();
  127756. this.scene._addComponent(this);
  127757. }
  127758. /**
  127759. * Register the component to one instance of a scene.
  127760. */
  127761. OutlineRenderer.prototype.register = function () {
  127762. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  127763. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  127764. };
  127765. /**
  127766. * Rebuilds the elements related to this component in case of
  127767. * context lost for instance.
  127768. */
  127769. OutlineRenderer.prototype.rebuild = function () {
  127770. // Nothing to do here.
  127771. };
  127772. /**
  127773. * Disposes the component and the associated ressources.
  127774. */
  127775. OutlineRenderer.prototype.dispose = function () {
  127776. // Nothing to do here.
  127777. };
  127778. /**
  127779. * Renders the outline in the canvas.
  127780. * @param subMesh Defines the sumesh to render
  127781. * @param batch Defines the batch of meshes in case of instances
  127782. * @param useOverlay Defines if the rendering is for the overlay or the outline
  127783. */
  127784. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  127785. var _this = this;
  127786. if (useOverlay === void 0) { useOverlay = false; }
  127787. var scene = this.scene;
  127788. var engine = scene.getEngine();
  127789. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  127790. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  127791. return;
  127792. }
  127793. var mesh = subMesh.getRenderingMesh();
  127794. var material = subMesh.getMaterial();
  127795. if (!material || !scene.activeCamera) {
  127796. return;
  127797. }
  127798. engine.enableEffect(this._effect);
  127799. // Logarithmic depth
  127800. if (material.useLogarithmicDepth) {
  127801. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  127802. }
  127803. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  127804. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  127805. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  127806. // Bones
  127807. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  127808. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  127809. }
  127810. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  127811. // Alpha test
  127812. if (material && material.needAlphaTesting()) {
  127813. var alphaTexture = material.getAlphaTestTexture();
  127814. if (alphaTexture) {
  127815. this._effect.setTexture("diffuseSampler", alphaTexture);
  127816. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  127817. }
  127818. }
  127819. engine.setZOffset(-this.zOffset);
  127820. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  127821. engine.setZOffset(0);
  127822. };
  127823. /**
  127824. * Returns whether or not the outline renderer is ready for a given submesh.
  127825. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  127826. * @param subMesh Defines the submesh to check readyness for
  127827. * @param useInstances Defines wheter wee are trying to render instances or not
  127828. * @returns true if ready otherwise false
  127829. */
  127830. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  127831. var defines = [];
  127832. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  127833. var mesh = subMesh.getMesh();
  127834. var material = subMesh.getMaterial();
  127835. if (material) {
  127836. // Alpha test
  127837. if (material.needAlphaTesting()) {
  127838. defines.push("#define ALPHATEST");
  127839. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  127840. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  127841. defines.push("#define UV1");
  127842. }
  127843. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  127844. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  127845. defines.push("#define UV2");
  127846. }
  127847. }
  127848. //Logarithmic depth
  127849. if (material.useLogarithmicDepth) {
  127850. defines.push("#define LOGARITHMICDEPTH");
  127851. }
  127852. }
  127853. // Bones
  127854. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  127855. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  127856. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  127857. if (mesh.numBoneInfluencers > 4) {
  127858. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  127859. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  127860. }
  127861. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  127862. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  127863. }
  127864. else {
  127865. defines.push("#define NUM_BONE_INFLUENCERS 0");
  127866. }
  127867. // Instances
  127868. if (useInstances) {
  127869. defines.push("#define INSTANCES");
  127870. attribs.push("world0");
  127871. attribs.push("world1");
  127872. attribs.push("world2");
  127873. attribs.push("world3");
  127874. }
  127875. // Get correct effect
  127876. var join = defines.join("\n");
  127877. if (this._cachedDefines !== join) {
  127878. this._cachedDefines = join;
  127879. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  127880. }
  127881. return this._effect.isReady();
  127882. };
  127883. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  127884. // Outline - step 1
  127885. this._savedDepthWrite = this._engine.getDepthWrite();
  127886. if (mesh.renderOutline) {
  127887. var material = subMesh.getMaterial();
  127888. if (material && material.needAlphaBlending) {
  127889. this._engine.cacheStencilState();
  127890. // Draw only to stencil buffer for the original mesh
  127891. // The resulting stencil buffer will be used so the outline is not visible inside the mesh when the mesh is transparent
  127892. this._engine.setDepthWrite(false);
  127893. this._engine.setColorWrite(false);
  127894. this._engine.setStencilBuffer(true);
  127895. this._engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].REPLACE);
  127896. this._engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALWAYS);
  127897. this._engine.setStencilMask(OutlineRenderer._StencilReference);
  127898. this._engine.setStencilFunctionReference(OutlineRenderer._StencilReference);
  127899. this.render(subMesh, batch, /* This sets offset to 0 */ true);
  127900. this._engine.setColorWrite(true);
  127901. this._engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].NOTEQUAL);
  127902. }
  127903. // Draw the outline using the above stencil if needed to avoid drawing within the mesh
  127904. this._engine.setDepthWrite(false);
  127905. this.render(subMesh, batch);
  127906. this._engine.setDepthWrite(this._savedDepthWrite);
  127907. if (material && material.needAlphaBlending) {
  127908. this._engine.restoreStencilState();
  127909. }
  127910. }
  127911. };
  127912. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  127913. // Outline - step 2
  127914. if (mesh.renderOutline && this._savedDepthWrite) {
  127915. this._engine.setDepthWrite(true);
  127916. this._engine.setColorWrite(false);
  127917. this.render(subMesh, batch);
  127918. this._engine.setColorWrite(true);
  127919. }
  127920. // Overlay
  127921. if (mesh.renderOverlay) {
  127922. var currentMode = this._engine.getAlphaMode();
  127923. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  127924. this.render(subMesh, batch, true);
  127925. this._engine.setAlphaMode(currentMode);
  127926. }
  127927. };
  127928. /**
  127929. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  127930. */
  127931. OutlineRenderer._StencilReference = 0x04;
  127932. return OutlineRenderer;
  127933. }());
  127934. /***/ }),
  127935. /***/ "./Rendering/renderingGroup.ts":
  127936. /*!*************************************!*\
  127937. !*** ./Rendering/renderingGroup.ts ***!
  127938. \*************************************/
  127939. /*! exports provided: RenderingGroup */
  127940. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127941. "use strict";
  127942. __webpack_require__.r(__webpack_exports__);
  127943. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  127944. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  127945. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  127946. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127947. /**
  127948. * This represents the object necessary to create a rendering group.
  127949. * This is exclusively used and created by the rendering manager.
  127950. * To modify the behavior, you use the available helpers in your scene or meshes.
  127951. * @hidden
  127952. */
  127953. var RenderingGroup = /** @class */ (function () {
  127954. /**
  127955. * Creates a new rendering group.
  127956. * @param index The rendering group index
  127957. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  127958. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  127959. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  127960. */
  127961. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  127962. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  127963. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  127964. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  127965. this.index = index;
  127966. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127967. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127968. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127969. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127970. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127971. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127972. /** @hidden */
  127973. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  127974. this._scene = scene;
  127975. this.opaqueSortCompareFn = opaqueSortCompareFn;
  127976. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  127977. this.transparentSortCompareFn = transparentSortCompareFn;
  127978. }
  127979. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  127980. /**
  127981. * Set the opaque sort comparison function.
  127982. * If null the sub meshes will be render in the order they were created
  127983. */
  127984. set: function (value) {
  127985. this._opaqueSortCompareFn = value;
  127986. if (value) {
  127987. this._renderOpaque = this.renderOpaqueSorted;
  127988. }
  127989. else {
  127990. this._renderOpaque = RenderingGroup.renderUnsorted;
  127991. }
  127992. },
  127993. enumerable: true,
  127994. configurable: true
  127995. });
  127996. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  127997. /**
  127998. * Set the alpha test sort comparison function.
  127999. * If null the sub meshes will be render in the order they were created
  128000. */
  128001. set: function (value) {
  128002. this._alphaTestSortCompareFn = value;
  128003. if (value) {
  128004. this._renderAlphaTest = this.renderAlphaTestSorted;
  128005. }
  128006. else {
  128007. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  128008. }
  128009. },
  128010. enumerable: true,
  128011. configurable: true
  128012. });
  128013. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  128014. /**
  128015. * Set the transparent sort comparison function.
  128016. * If null the sub meshes will be render in the order they were created
  128017. */
  128018. set: function (value) {
  128019. if (value) {
  128020. this._transparentSortCompareFn = value;
  128021. }
  128022. else {
  128023. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  128024. }
  128025. this._renderTransparent = this.renderTransparentSorted;
  128026. },
  128027. enumerable: true,
  128028. configurable: true
  128029. });
  128030. /**
  128031. * Render all the sub meshes contained in the group.
  128032. * @param customRenderFunction Used to override the default render behaviour of the group.
  128033. * @returns true if rendered some submeshes.
  128034. */
  128035. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  128036. if (customRenderFunction) {
  128037. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  128038. return;
  128039. }
  128040. var engine = this._scene.getEngine();
  128041. // Depth only
  128042. if (this._depthOnlySubMeshes.length !== 0) {
  128043. engine.setColorWrite(false);
  128044. this._renderAlphaTest(this._depthOnlySubMeshes);
  128045. engine.setColorWrite(true);
  128046. }
  128047. // Opaque
  128048. if (this._opaqueSubMeshes.length !== 0) {
  128049. this._renderOpaque(this._opaqueSubMeshes);
  128050. }
  128051. // Alpha test
  128052. if (this._alphaTestSubMeshes.length !== 0) {
  128053. this._renderAlphaTest(this._alphaTestSubMeshes);
  128054. }
  128055. var stencilState = engine.getStencilBuffer();
  128056. engine.setStencilBuffer(false);
  128057. // Sprites
  128058. if (renderSprites) {
  128059. this._renderSprites();
  128060. }
  128061. // Particles
  128062. if (renderParticles) {
  128063. this._renderParticles(activeMeshes);
  128064. }
  128065. if (this.onBeforeTransparentRendering) {
  128066. this.onBeforeTransparentRendering();
  128067. }
  128068. // Transparent
  128069. if (this._transparentSubMeshes.length !== 0) {
  128070. this._renderTransparent(this._transparentSubMeshes);
  128071. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  128072. }
  128073. // Set back stencil to false in case it changes before the edge renderer.
  128074. engine.setStencilBuffer(false);
  128075. // Edges
  128076. if (this._edgesRenderers.length) {
  128077. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  128078. this._edgesRenderers.data[edgesRendererIndex].render();
  128079. }
  128080. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  128081. }
  128082. // Restore Stencil state.
  128083. engine.setStencilBuffer(stencilState);
  128084. };
  128085. /**
  128086. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  128087. * @param subMeshes The submeshes to render
  128088. */
  128089. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  128090. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  128091. };
  128092. /**
  128093. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  128094. * @param subMeshes The submeshes to render
  128095. */
  128096. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  128097. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  128098. };
  128099. /**
  128100. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  128101. * @param subMeshes The submeshes to render
  128102. */
  128103. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  128104. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  128105. };
  128106. /**
  128107. * Renders the submeshes in a specified order.
  128108. * @param subMeshes The submeshes to sort before render
  128109. * @param sortCompareFn The comparison function use to sort
  128110. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  128111. * @param transparent Specifies to activate blending if true
  128112. */
  128113. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  128114. var subIndex = 0;
  128115. var subMesh;
  128116. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  128117. for (; subIndex < subMeshes.length; subIndex++) {
  128118. subMesh = subMeshes.data[subIndex];
  128119. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  128120. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  128121. }
  128122. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  128123. if (sortCompareFn) {
  128124. sortedArray.sort(sortCompareFn);
  128125. }
  128126. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  128127. subMesh = sortedArray[subIndex];
  128128. if (transparent) {
  128129. var material = subMesh.getMaterial();
  128130. if (material && material.needDepthPrePass) {
  128131. var engine = material.getScene().getEngine();
  128132. engine.setColorWrite(false);
  128133. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  128134. subMesh.render(false);
  128135. engine.setColorWrite(true);
  128136. }
  128137. }
  128138. subMesh.render(transparent);
  128139. }
  128140. };
  128141. /**
  128142. * Renders the submeshes in the order they were dispatched (no sort applied).
  128143. * @param subMeshes The submeshes to render
  128144. */
  128145. RenderingGroup.renderUnsorted = function (subMeshes) {
  128146. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  128147. var submesh = subMeshes.data[subIndex];
  128148. submesh.render(false);
  128149. }
  128150. };
  128151. /**
  128152. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  128153. * are rendered back to front if in the same alpha index.
  128154. *
  128155. * @param a The first submesh
  128156. * @param b The second submesh
  128157. * @returns The result of the comparison
  128158. */
  128159. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  128160. // Alpha index first
  128161. if (a._alphaIndex > b._alphaIndex) {
  128162. return 1;
  128163. }
  128164. if (a._alphaIndex < b._alphaIndex) {
  128165. return -1;
  128166. }
  128167. // Then distance to camera
  128168. return RenderingGroup.backToFrontSortCompare(a, b);
  128169. };
  128170. /**
  128171. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  128172. * are rendered back to front.
  128173. *
  128174. * @param a The first submesh
  128175. * @param b The second submesh
  128176. * @returns The result of the comparison
  128177. */
  128178. RenderingGroup.backToFrontSortCompare = function (a, b) {
  128179. // Then distance to camera
  128180. if (a._distanceToCamera < b._distanceToCamera) {
  128181. return 1;
  128182. }
  128183. if (a._distanceToCamera > b._distanceToCamera) {
  128184. return -1;
  128185. }
  128186. return 0;
  128187. };
  128188. /**
  128189. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  128190. * are rendered front to back (prevent overdraw).
  128191. *
  128192. * @param a The first submesh
  128193. * @param b The second submesh
  128194. * @returns The result of the comparison
  128195. */
  128196. RenderingGroup.frontToBackSortCompare = function (a, b) {
  128197. // Then distance to camera
  128198. if (a._distanceToCamera < b._distanceToCamera) {
  128199. return -1;
  128200. }
  128201. if (a._distanceToCamera > b._distanceToCamera) {
  128202. return 1;
  128203. }
  128204. return 0;
  128205. };
  128206. /**
  128207. * Resets the different lists of submeshes to prepare a new frame.
  128208. */
  128209. RenderingGroup.prototype.prepare = function () {
  128210. this._opaqueSubMeshes.reset();
  128211. this._transparentSubMeshes.reset();
  128212. this._alphaTestSubMeshes.reset();
  128213. this._depthOnlySubMeshes.reset();
  128214. this._particleSystems.reset();
  128215. this._spriteManagers.reset();
  128216. this._edgesRenderers.reset();
  128217. };
  128218. RenderingGroup.prototype.dispose = function () {
  128219. this._opaqueSubMeshes.dispose();
  128220. this._transparentSubMeshes.dispose();
  128221. this._alphaTestSubMeshes.dispose();
  128222. this._depthOnlySubMeshes.dispose();
  128223. this._particleSystems.dispose();
  128224. this._spriteManagers.dispose();
  128225. this._edgesRenderers.dispose();
  128226. };
  128227. /**
  128228. * Inserts the submesh in its correct queue depending on its material.
  128229. * @param subMesh The submesh to dispatch
  128230. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  128231. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  128232. */
  128233. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  128234. // Get mesh and materials if not provided
  128235. if (mesh === undefined) {
  128236. mesh = subMesh.getMesh();
  128237. }
  128238. if (material === undefined) {
  128239. material = subMesh.getMaterial();
  128240. }
  128241. if (material === null || material === undefined) {
  128242. return;
  128243. }
  128244. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  128245. this._transparentSubMeshes.push(subMesh);
  128246. }
  128247. else if (material.needAlphaTesting()) { // Alpha test
  128248. if (material.needDepthPrePass) {
  128249. this._depthOnlySubMeshes.push(subMesh);
  128250. }
  128251. this._alphaTestSubMeshes.push(subMesh);
  128252. }
  128253. else {
  128254. if (material.needDepthPrePass) {
  128255. this._depthOnlySubMeshes.push(subMesh);
  128256. }
  128257. this._opaqueSubMeshes.push(subMesh); // Opaque
  128258. }
  128259. mesh._renderingGroup = this;
  128260. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  128261. this._edgesRenderers.push(mesh._edgesRenderer);
  128262. }
  128263. };
  128264. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  128265. this._spriteManagers.push(spriteManager);
  128266. };
  128267. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  128268. this._particleSystems.push(particleSystem);
  128269. };
  128270. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  128271. if (this._particleSystems.length === 0) {
  128272. return;
  128273. }
  128274. // Particles
  128275. var activeCamera = this._scene.activeCamera;
  128276. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  128277. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  128278. var particleSystem = this._particleSystems.data[particleIndex];
  128279. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  128280. continue;
  128281. }
  128282. var emitter = particleSystem.emitter;
  128283. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  128284. this._scene._activeParticles.addCount(particleSystem.render(), false);
  128285. }
  128286. }
  128287. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  128288. };
  128289. RenderingGroup.prototype._renderSprites = function () {
  128290. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  128291. return;
  128292. }
  128293. // Sprites
  128294. var activeCamera = this._scene.activeCamera;
  128295. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  128296. for (var id = 0; id < this._spriteManagers.length; id++) {
  128297. var spriteManager = this._spriteManagers.data[id];
  128298. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  128299. spriteManager.render();
  128300. }
  128301. }
  128302. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  128303. };
  128304. return RenderingGroup;
  128305. }());
  128306. /***/ }),
  128307. /***/ "./Rendering/renderingManager.ts":
  128308. /*!***************************************!*\
  128309. !*** ./Rendering/renderingManager.ts ***!
  128310. \***************************************/
  128311. /*! exports provided: RenderingGroupInfo, RenderingManager */
  128312. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128313. "use strict";
  128314. __webpack_require__.r(__webpack_exports__);
  128315. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  128316. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  128317. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  128318. /**
  128319. * This class is used by the onRenderingGroupObservable
  128320. */
  128321. var RenderingGroupInfo = /** @class */ (function () {
  128322. function RenderingGroupInfo() {
  128323. }
  128324. return RenderingGroupInfo;
  128325. }());
  128326. /**
  128327. * This is the manager responsible of all the rendering for meshes sprites and particles.
  128328. * It is enable to manage the different groups as well as the different necessary sort functions.
  128329. * This should not be used directly aside of the few static configurations
  128330. */
  128331. var RenderingManager = /** @class */ (function () {
  128332. /**
  128333. * Instantiates a new rendering group for a particular scene
  128334. * @param scene Defines the scene the groups belongs to
  128335. */
  128336. function RenderingManager(scene) {
  128337. /**
  128338. * @hidden
  128339. */
  128340. this._useSceneAutoClearSetup = false;
  128341. this._renderingGroups = new Array();
  128342. this._autoClearDepthStencil = {};
  128343. this._customOpaqueSortCompareFn = {};
  128344. this._customAlphaTestSortCompareFn = {};
  128345. this._customTransparentSortCompareFn = {};
  128346. this._renderingGroupInfo = new RenderingGroupInfo();
  128347. this._scene = scene;
  128348. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  128349. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  128350. }
  128351. }
  128352. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  128353. if (depth === void 0) { depth = true; }
  128354. if (stencil === void 0) { stencil = true; }
  128355. if (this._depthStencilBufferAlreadyCleaned) {
  128356. return;
  128357. }
  128358. this._scene.getEngine().clear(null, false, depth, stencil);
  128359. this._depthStencilBufferAlreadyCleaned = true;
  128360. };
  128361. /**
  128362. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  128363. * @hidden
  128364. */
  128365. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  128366. // Update the observable context (not null as it only goes away on dispose)
  128367. var info = this._renderingGroupInfo;
  128368. info.scene = this._scene;
  128369. info.camera = this._scene.activeCamera;
  128370. // Dispatch sprites
  128371. if (this._scene.spriteManagers && renderSprites) {
  128372. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  128373. var manager = this._scene.spriteManagers[index];
  128374. this.dispatchSprites(manager);
  128375. }
  128376. }
  128377. // Render
  128378. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  128379. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  128380. var renderingGroup = this._renderingGroups[index];
  128381. if (!renderingGroup) {
  128382. continue;
  128383. }
  128384. var renderingGroupMask = Math.pow(2, index);
  128385. info.renderingGroupId = index;
  128386. // Before Observable
  128387. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  128388. // Clear depth/stencil if needed
  128389. if (RenderingManager.AUTOCLEAR) {
  128390. var autoClear = this._useSceneAutoClearSetup ?
  128391. this._scene.getAutoClearDepthStencilSetup(index) :
  128392. this._autoClearDepthStencil[index];
  128393. if (autoClear && autoClear.autoClear) {
  128394. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  128395. }
  128396. }
  128397. // Render
  128398. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  128399. var step = _a[_i];
  128400. step.action(index);
  128401. }
  128402. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  128403. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  128404. var step = _c[_b];
  128405. step.action(index);
  128406. }
  128407. // After Observable
  128408. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  128409. }
  128410. };
  128411. /**
  128412. * Resets the different information of the group to prepare a new frame
  128413. * @hidden
  128414. */
  128415. RenderingManager.prototype.reset = function () {
  128416. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  128417. var renderingGroup = this._renderingGroups[index];
  128418. if (renderingGroup) {
  128419. renderingGroup.prepare();
  128420. }
  128421. }
  128422. };
  128423. /**
  128424. * Dispose and release the group and its associated resources.
  128425. * @hidden
  128426. */
  128427. RenderingManager.prototype.dispose = function () {
  128428. this.freeRenderingGroups();
  128429. this._renderingGroups.length = 0;
  128430. this._renderingGroupInfo = null;
  128431. };
  128432. /**
  128433. * Clear the info related to rendering groups preventing retention points during dispose.
  128434. */
  128435. RenderingManager.prototype.freeRenderingGroups = function () {
  128436. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  128437. var renderingGroup = this._renderingGroups[index];
  128438. if (renderingGroup) {
  128439. renderingGroup.dispose();
  128440. }
  128441. }
  128442. };
  128443. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  128444. if (this._renderingGroups[renderingGroupId] === undefined) {
  128445. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  128446. }
  128447. };
  128448. /**
  128449. * Add a sprite manager to the rendering manager in order to render it this frame.
  128450. * @param spriteManager Define the sprite manager to render
  128451. */
  128452. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  128453. var renderingGroupId = spriteManager.renderingGroupId || 0;
  128454. this._prepareRenderingGroup(renderingGroupId);
  128455. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  128456. };
  128457. /**
  128458. * Add a particle system to the rendering manager in order to render it this frame.
  128459. * @param particleSystem Define the particle system to render
  128460. */
  128461. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  128462. var renderingGroupId = particleSystem.renderingGroupId || 0;
  128463. this._prepareRenderingGroup(renderingGroupId);
  128464. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  128465. };
  128466. /**
  128467. * Add a submesh to the manager in order to render it this frame
  128468. * @param subMesh The submesh to dispatch
  128469. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  128470. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  128471. */
  128472. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  128473. if (mesh === undefined) {
  128474. mesh = subMesh.getMesh();
  128475. }
  128476. var renderingGroupId = mesh.renderingGroupId || 0;
  128477. this._prepareRenderingGroup(renderingGroupId);
  128478. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  128479. };
  128480. /**
  128481. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  128482. * This allowed control for front to back rendering or reversly depending of the special needs.
  128483. *
  128484. * @param renderingGroupId The rendering group id corresponding to its index
  128485. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  128486. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  128487. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  128488. */
  128489. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  128490. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  128491. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  128492. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  128493. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  128494. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  128495. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  128496. if (this._renderingGroups[renderingGroupId]) {
  128497. var group = this._renderingGroups[renderingGroupId];
  128498. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  128499. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  128500. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  128501. }
  128502. };
  128503. /**
  128504. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  128505. *
  128506. * @param renderingGroupId The rendering group id corresponding to its index
  128507. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128508. * @param depth Automatically clears depth between groups if true and autoClear is true.
  128509. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  128510. */
  128511. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  128512. if (depth === void 0) { depth = true; }
  128513. if (stencil === void 0) { stencil = true; }
  128514. this._autoClearDepthStencil[renderingGroupId] = {
  128515. autoClear: autoClearDepthStencil,
  128516. depth: depth,
  128517. stencil: stencil
  128518. };
  128519. };
  128520. /**
  128521. * Gets the current auto clear configuration for one rendering group of the rendering
  128522. * manager.
  128523. * @param index the rendering group index to get the information for
  128524. * @returns The auto clear setup for the requested rendering group
  128525. */
  128526. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  128527. return this._autoClearDepthStencil[index];
  128528. };
  128529. /**
  128530. * The max id used for rendering groups (not included)
  128531. */
  128532. RenderingManager.MAX_RENDERINGGROUPS = 4;
  128533. /**
  128534. * The min id used for rendering groups (included)
  128535. */
  128536. RenderingManager.MIN_RENDERINGGROUPS = 0;
  128537. /**
  128538. * Used to globally prevent autoclearing scenes.
  128539. */
  128540. RenderingManager.AUTOCLEAR = true;
  128541. return RenderingManager;
  128542. }());
  128543. /***/ }),
  128544. /***/ "./Rendering/utilityLayerRenderer.ts":
  128545. /*!*******************************************!*\
  128546. !*** ./Rendering/utilityLayerRenderer.ts ***!
  128547. \*******************************************/
  128548. /*! exports provided: UtilityLayerRenderer */
  128549. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128550. "use strict";
  128551. __webpack_require__.r(__webpack_exports__);
  128552. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  128553. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  128554. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  128555. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  128556. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  128557. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  128558. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  128559. /**
  128560. * Renders a layer on top of an existing scene
  128561. */
  128562. var UtilityLayerRenderer = /** @class */ (function () {
  128563. /**
  128564. * Instantiates a UtilityLayerRenderer
  128565. * @param originalScene the original scene that will be rendered on top of
  128566. * @param handleEvents boolean indicating if the utility layer should handle events
  128567. */
  128568. function UtilityLayerRenderer(
  128569. /** the original scene that will be rendered on top of */
  128570. originalScene, handleEvents) {
  128571. if (handleEvents === void 0) { handleEvents = true; }
  128572. var _this = this;
  128573. this.originalScene = originalScene;
  128574. this._pointerCaptures = {};
  128575. this._lastPointerEvents = {};
  128576. this._sharedGizmoLight = null;
  128577. /**
  128578. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  128579. */
  128580. this.pickUtilitySceneFirst = true;
  128581. /**
  128582. * If the utility layer should automatically be rendered on top of existing scene
  128583. */
  128584. this.shouldRender = true;
  128585. /**
  128586. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  128587. */
  128588. this.onlyCheckPointerDownEvents = true;
  128589. /**
  128590. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  128591. */
  128592. this.processAllEvents = false;
  128593. /**
  128594. * Observable raised when the pointer move from the utility layer scene to the main scene
  128595. */
  128596. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  128597. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  128598. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  128599. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  128600. this.utilityLayerScene._allowPostProcessClearColor = false;
  128601. originalScene.getEngine().scenes.pop();
  128602. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  128603. this.utilityLayerScene.detachControl();
  128604. if (handleEvents) {
  128605. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  128606. if (!_this.utilityLayerScene.activeCamera) {
  128607. return;
  128608. }
  128609. if (!_this.processAllEvents) {
  128610. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  128611. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  128612. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  128613. return;
  128614. }
  128615. }
  128616. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  128617. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  128618. var pointerEvent = (prePointerInfo.event);
  128619. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  128620. _this._pointerCaptures[pointerEvent.pointerId] = false;
  128621. return;
  128622. }
  128623. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  128624. if (!prePointerInfo.ray && utilityScenePick) {
  128625. prePointerInfo.ray = utilityScenePick.ray;
  128626. }
  128627. // always fire the prepointer oversvable
  128628. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  128629. // allow every non pointer down event to flow to the utility layer
  128630. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  128631. if (!prePointerInfo.skipOnPointerObservable) {
  128632. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  128633. }
  128634. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  128635. _this._pointerCaptures[pointerEvent.pointerId] = false;
  128636. }
  128637. return;
  128638. }
  128639. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  128640. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  128641. if (utilityScenePick && utilityScenePick.hit) {
  128642. if (!prePointerInfo.skipOnPointerObservable) {
  128643. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  128644. }
  128645. prePointerInfo.skipOnPointerObservable = true;
  128646. }
  128647. }
  128648. else {
  128649. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  128650. var pointerEvent_1 = (prePointerInfo.event);
  128651. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  128652. if (originalScenePick && utilityScenePick) {
  128653. // No pick in utility scene
  128654. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  128655. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  128656. // We touched an utility mesh present in the main scene
  128657. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  128658. prePointerInfo.skipOnPointerObservable = true;
  128659. }
  128660. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  128661. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  128662. }
  128663. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  128664. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  128665. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  128666. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  128667. }
  128668. }
  128669. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  128670. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  128671. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  128672. // If a previous utility layer set this, do not unset this
  128673. if (!prePointerInfo.skipOnPointerObservable) {
  128674. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  128675. }
  128676. }
  128677. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  128678. // We have a pick in both scenes but main is closer than utility
  128679. // We touched an utility mesh present in the main scene
  128680. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  128681. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  128682. prePointerInfo.skipOnPointerObservable = true;
  128683. }
  128684. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  128685. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  128686. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  128687. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  128688. }
  128689. }
  128690. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  128691. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  128692. }
  128693. }
  128694. }
  128695. });
  128696. // As a newly added utility layer will be rendered over the screen last, it's pointer events should be processed first
  128697. if (this._originalPointerObserver) {
  128698. originalScene.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver);
  128699. }
  128700. }
  128701. // Render directly on top of existing scene without clearing
  128702. this.utilityLayerScene.autoClear = false;
  128703. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  128704. if (_this.shouldRender) {
  128705. _this.render();
  128706. }
  128707. });
  128708. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  128709. _this.dispose();
  128710. });
  128711. this._updateCamera();
  128712. }
  128713. /**
  128714. * @hidden
  128715. * Light which used by gizmos to get light shading
  128716. */
  128717. UtilityLayerRenderer.prototype._getSharedGizmoLight = function () {
  128718. if (!this._sharedGizmoLight) {
  128719. this._sharedGizmoLight = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]("shared gizmo light", new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 1, 0), this.utilityLayerScene);
  128720. this._sharedGizmoLight.intensity = 2;
  128721. this._sharedGizmoLight.groundColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].Gray();
  128722. }
  128723. return this._sharedGizmoLight;
  128724. };
  128725. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  128726. /**
  128727. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  128728. */
  128729. get: function () {
  128730. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  128731. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  128732. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  128733. UtilityLayerRenderer._DefaultUtilityLayer = null;
  128734. });
  128735. }
  128736. return UtilityLayerRenderer._DefaultUtilityLayer;
  128737. },
  128738. enumerable: true,
  128739. configurable: true
  128740. });
  128741. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  128742. /**
  128743. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  128744. */
  128745. get: function () {
  128746. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  128747. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  128748. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  128749. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  128750. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  128751. });
  128752. }
  128753. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  128754. },
  128755. enumerable: true,
  128756. configurable: true
  128757. });
  128758. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  128759. if (!prePointerInfo.skipOnPointerObservable) {
  128760. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  128761. this._lastPointerEvents[pointerEvent.pointerId] = true;
  128762. }
  128763. };
  128764. /**
  128765. * Renders the utility layers scene on top of the original scene
  128766. */
  128767. UtilityLayerRenderer.prototype.render = function () {
  128768. this._updateCamera();
  128769. if (this.utilityLayerScene.activeCamera) {
  128770. // Set the camera's scene to utility layers scene
  128771. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  128772. var camera = this.utilityLayerScene.activeCamera;
  128773. camera._scene = this.utilityLayerScene;
  128774. if (camera.leftCamera) {
  128775. camera.leftCamera._scene = this.utilityLayerScene;
  128776. }
  128777. if (camera.rightCamera) {
  128778. camera.rightCamera._scene = this.utilityLayerScene;
  128779. }
  128780. this.utilityLayerScene.render(false);
  128781. // Reset camera's scene back to original
  128782. camera._scene = oldScene;
  128783. if (camera.leftCamera) {
  128784. camera.leftCamera._scene = oldScene;
  128785. }
  128786. if (camera.rightCamera) {
  128787. camera.rightCamera._scene = oldScene;
  128788. }
  128789. }
  128790. };
  128791. /**
  128792. * Disposes of the renderer
  128793. */
  128794. UtilityLayerRenderer.prototype.dispose = function () {
  128795. this.onPointerOutObservable.clear();
  128796. if (this._afterRenderObserver) {
  128797. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  128798. }
  128799. if (this._sceneDisposeObserver) {
  128800. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  128801. }
  128802. if (this._originalPointerObserver) {
  128803. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  128804. }
  128805. this.utilityLayerScene.dispose();
  128806. };
  128807. UtilityLayerRenderer.prototype._updateCamera = function () {
  128808. if (this.originalScene.activeCameras.length > 1) {
  128809. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  128810. }
  128811. else {
  128812. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  128813. }
  128814. };
  128815. UtilityLayerRenderer._DefaultUtilityLayer = null;
  128816. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  128817. return UtilityLayerRenderer;
  128818. }());
  128819. /***/ }),
  128820. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  128821. /*!*****************************************************************!*\
  128822. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  128823. \*****************************************************************/
  128824. /*! exports provided: backgroundFragmentDeclaration */
  128825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128826. "use strict";
  128827. __webpack_require__.r(__webpack_exports__);
  128828. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  128829. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128830. var name = 'backgroundFragmentDeclaration';
  128831. var shader = " uniform 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";
  128832. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128833. /** @hidden */
  128834. var backgroundFragmentDeclaration = { name: name, shader: shader };
  128835. /***/ }),
  128836. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  128837. /*!************************************************************!*\
  128838. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  128839. \************************************************************/
  128840. /*! exports provided: backgroundUboDeclaration */
  128841. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128842. "use strict";
  128843. __webpack_require__.r(__webpack_exports__);
  128844. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  128845. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128846. var name = 'backgroundUboDeclaration';
  128847. var shader = "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};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};";
  128848. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128849. /** @hidden */
  128850. var backgroundUboDeclaration = { name: name, shader: shader };
  128851. /***/ }),
  128852. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  128853. /*!***************************************************************!*\
  128854. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  128855. \***************************************************************/
  128856. /*! exports provided: backgroundVertexDeclaration */
  128857. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128858. "use strict";
  128859. __webpack_require__.r(__webpack_exports__);
  128860. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  128861. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128862. var name = 'backgroundVertexDeclaration';
  128863. var shader = "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";
  128864. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128865. /** @hidden */
  128866. var backgroundVertexDeclaration = { name: name, shader: shader };
  128867. /***/ }),
  128868. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  128869. /*!****************************************************!*\
  128870. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  128871. \****************************************************/
  128872. /*! exports provided: bonesDeclaration */
  128873. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128874. "use strict";
  128875. __webpack_require__.r(__webpack_exports__);
  128876. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  128877. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128878. var name = 'bonesDeclaration';
  128879. var shader = "#if NUM_BONE_INFLUENCERS>0\n#ifdef BONETEXTURE\nuniform sampler2D boneSampler;\nuniform float boneTextureWidth;\n#else\nuniform mat4 mBones[BonesPerMesh];\n#endif\nattribute vec4 matricesIndices;\nattribute vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nattribute vec4 matricesIndicesExtra;\nattribute vec4 matricesWeightsExtra;\n#endif\n#ifdef BONETEXTURE\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";
  128880. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128881. /** @hidden */
  128882. var bonesDeclaration = { name: name, shader: shader };
  128883. /***/ }),
  128884. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  128885. /*!***********************************************!*\
  128886. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  128887. \***********************************************/
  128888. /*! exports provided: bonesVertex */
  128889. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128890. "use strict";
  128891. __webpack_require__.r(__webpack_exports__);
  128892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  128893. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128894. var name = 'bonesVertex';
  128895. var shader = "#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";
  128896. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128897. /** @hidden */
  128898. var bonesVertex = { name: name, shader: shader };
  128899. /***/ }),
  128900. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  128901. /*!************************************************!*\
  128902. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  128903. \************************************************/
  128904. /*! exports provided: bumpFragment */
  128905. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128906. "use strict";
  128907. __webpack_require__.r(__webpack_exports__);
  128908. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  128909. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128910. var name = 'bumpFragment';
  128911. var shader = "vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#else\nfloat normalScale=vBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\n#endif\n#elif defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW,vPositionW,vMainUV1,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 BUMP\n#ifdef OBJECTSPACE_NORMALMAP\nnormalW=normalize(texture2D(bumpSampler,vBumpUV).xyz*2.0-1.0);\nnormalW=normalize(mat3(normalMatrix)*normalW);\n#else\nnormalW=perturbNormal(TBN,vBumpUV+uvOffset);\n#endif\n#endif";
  128912. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128913. /** @hidden */
  128914. var bumpFragment = { name: name, shader: shader };
  128915. /***/ }),
  128916. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  128917. /*!*********************************************************!*\
  128918. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  128919. \*********************************************************/
  128920. /*! exports provided: bumpFragmentFunctions */
  128921. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128922. "use strict";
  128923. __webpack_require__.r(__webpack_exports__);
  128924. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  128925. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128926. var name = 'bumpFragmentFunctions';
  128927. var shader = "#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\n#endif\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv,sampler2D textureSampler,float scale)\n{\nvec3 map=texture2D(textureSampler,uv).xyz;\nmap=map*2.0-1.0;\n#ifdef NORMALXYSCALE\nmap=normalize(map*vec3(scale,scale,1.0));\n#endif\nreturn normalize(cotangentFrame*map);\n}\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)\n{\n\nuv=gl_FrontFacing ? uv : -uv;\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\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;\n\ntangent*=tangentSpaceParams.x;\nbitangent*=tangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\n#endif\n#ifdef BUMP\n#if BUMPDIRECTUV == 1\n#define vBumpUV vMainUV1\n#elif BUMPDIRECTUV == 2\n#define vBumpUV vMainUV2\n#else\nvarying vec2 vBumpUV;\n#endif\nuniform sampler2D bumpSampler;\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nreturn perturbNormal(cotangentFrame,uv,bumpSampler,vBumpInfos.y);\n}\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\nreturn cotangent_frame(normal,p,uv,vTangentSpaceParams);\n}\n#endif\n#if defined(BUMP) && defined(PARALLAX)\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\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;\n\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,vBumpUV+vCurrOffset).w;\n\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;\n\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{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif";
  128928. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128929. /** @hidden */
  128930. var bumpFragmentFunctions = { name: name, shader: shader };
  128931. /***/ }),
  128932. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  128933. /*!**********************************************!*\
  128934. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  128935. \**********************************************/
  128936. /*! exports provided: bumpVertex */
  128937. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128938. "use strict";
  128939. __webpack_require__.r(__webpack_exports__);
  128940. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  128941. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128942. var name = 'bumpVertex';
  128943. var shader = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP)\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";
  128944. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128945. /** @hidden */
  128946. var bumpVertex = { name: name, shader: shader };
  128947. /***/ }),
  128948. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  128949. /*!*********************************************************!*\
  128950. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  128951. \*********************************************************/
  128952. /*! exports provided: bumpVertexDeclaration */
  128953. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128954. "use strict";
  128955. __webpack_require__.r(__webpack_exports__);
  128956. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  128957. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128958. var name = 'bumpVertexDeclaration';
  128959. var shader = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  128960. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128961. /** @hidden */
  128962. var bumpVertexDeclaration = { name: name, shader: shader };
  128963. /***/ }),
  128964. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  128965. /*!*****************************************************!*\
  128966. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  128967. \*****************************************************/
  128968. /*! exports provided: clipPlaneFragment */
  128969. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128970. "use strict";
  128971. __webpack_require__.r(__webpack_exports__);
  128972. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  128973. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128974. var name = 'clipPlaneFragment';
  128975. var shader = "#ifdef CLIPPLANE\nif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE2\nif (fClipDistance2>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE3\nif (fClipDistance3>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE4\nif (fClipDistance4>0.0)\n{\ndiscard;\n}\n#endif";
  128976. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128977. /** @hidden */
  128978. var clipPlaneFragment = { name: name, shader: shader };
  128979. /***/ }),
  128980. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  128981. /*!****************************************************************!*\
  128982. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  128983. \****************************************************************/
  128984. /*! exports provided: clipPlaneFragmentDeclaration */
  128985. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128986. "use strict";
  128987. __webpack_require__.r(__webpack_exports__);
  128988. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  128989. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128990. var name = 'clipPlaneFragmentDeclaration';
  128991. var shader = "#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";
  128992. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128993. /** @hidden */
  128994. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  128995. /***/ }),
  128996. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  128997. /*!*****************************************************************!*\
  128998. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  128999. \*****************************************************************/
  129000. /*! exports provided: clipPlaneFragmentDeclaration2 */
  129001. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129002. "use strict";
  129003. __webpack_require__.r(__webpack_exports__);
  129004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  129005. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129006. var name = 'clipPlaneFragmentDeclaration2';
  129007. var shader = "#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";
  129008. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129009. /** @hidden */
  129010. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  129011. /***/ }),
  129012. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  129013. /*!***************************************************!*\
  129014. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  129015. \***************************************************/
  129016. /*! exports provided: clipPlaneVertex */
  129017. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129018. "use strict";
  129019. __webpack_require__.r(__webpack_exports__);
  129020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  129021. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129022. var name = 'clipPlaneVertex';
  129023. var shader = "#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";
  129024. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129025. /** @hidden */
  129026. var clipPlaneVertex = { name: name, shader: shader };
  129027. /***/ }),
  129028. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  129029. /*!**************************************************************!*\
  129030. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  129031. \**************************************************************/
  129032. /*! exports provided: clipPlaneVertexDeclaration */
  129033. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129034. "use strict";
  129035. __webpack_require__.r(__webpack_exports__);
  129036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  129037. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129038. var name = 'clipPlaneVertexDeclaration';
  129039. var shader = "#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";
  129040. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129041. /** @hidden */
  129042. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  129043. /***/ }),
  129044. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  129045. /*!***************************************************************!*\
  129046. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  129047. \***************************************************************/
  129048. /*! exports provided: clipPlaneVertexDeclaration2 */
  129049. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129050. "use strict";
  129051. __webpack_require__.r(__webpack_exports__);
  129052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  129053. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129054. var name = 'clipPlaneVertexDeclaration2';
  129055. var shader = "#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";
  129056. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129057. /** @hidden */
  129058. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  129059. /***/ }),
  129060. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  129061. /*!**************************************************************!*\
  129062. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  129063. \**************************************************************/
  129064. /*! exports provided: defaultFragmentDeclaration */
  129065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129066. "use strict";
  129067. __webpack_require__.r(__webpack_exports__);
  129068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  129069. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129070. var name = 'defaultFragmentDeclaration';
  129071. var shader = "uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\nuniform float visibility;\n\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#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#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\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REFLECTIONMAP_SKYBOX\n#else\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION)\nuniform mat4 reflectionMatrix;\n#endif\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";
  129072. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129073. /** @hidden */
  129074. var defaultFragmentDeclaration = { name: name, shader: shader };
  129075. /***/ }),
  129076. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  129077. /*!*********************************************************!*\
  129078. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  129079. \*********************************************************/
  129080. /*! exports provided: defaultUboDeclaration */
  129081. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129082. "use strict";
  129083. __webpack_require__.r(__webpack_exports__);
  129084. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  129085. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129086. var name = 'defaultUboDeclaration';
  129087. var shader = "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;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nfloat visibility;\nvec4 vDiffuseColor;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};\n";
  129088. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129089. /** @hidden */
  129090. var defaultUboDeclaration = { name: name, shader: shader };
  129091. /***/ }),
  129092. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  129093. /*!************************************************************!*\
  129094. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  129095. \************************************************************/
  129096. /*! exports provided: defaultVertexDeclaration */
  129097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129098. "use strict";
  129099. __webpack_require__.r(__webpack_exports__);
  129100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  129101. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129102. var name = 'defaultVertexDeclaration';
  129103. var shader = "\nuniform 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";
  129104. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129105. /** @hidden */
  129106. var defaultVertexDeclaration = { name: name, shader: shader };
  129107. /***/ }),
  129108. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  129109. /*!************************************************!*\
  129110. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  129111. \************************************************/
  129112. /*! exports provided: depthPrePass */
  129113. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129114. "use strict";
  129115. __webpack_require__.r(__webpack_exports__);
  129116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  129117. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129118. var name = 'depthPrePass';
  129119. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  129120. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129121. /** @hidden */
  129122. var depthPrePass = { name: name, shader: shader };
  129123. /***/ }),
  129124. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  129125. /*!***********************************************!*\
  129126. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  129127. \***********************************************/
  129128. /*! exports provided: fogFragment */
  129129. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129130. "use strict";
  129131. __webpack_require__.r(__webpack_exports__);
  129132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  129133. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129134. var name = 'fogFragment';
  129135. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  129136. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129137. /** @hidden */
  129138. var fogFragment = { name: name, shader: shader };
  129139. /***/ }),
  129140. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  129141. /*!**********************************************************!*\
  129142. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  129143. \**********************************************************/
  129144. /*! exports provided: fogFragmentDeclaration */
  129145. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129146. "use strict";
  129147. __webpack_require__.r(__webpack_exports__);
  129148. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  129149. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129150. var name = 'fogFragmentDeclaration';
  129151. var shader = "#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";
  129152. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129153. /** @hidden */
  129154. var fogFragmentDeclaration = { name: name, shader: shader };
  129155. /***/ }),
  129156. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  129157. /*!*********************************************!*\
  129158. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  129159. \*********************************************/
  129160. /*! exports provided: fogVertex */
  129161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129162. "use strict";
  129163. __webpack_require__.r(__webpack_exports__);
  129164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  129165. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129166. var name = 'fogVertex';
  129167. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  129168. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129169. /** @hidden */
  129170. var fogVertex = { name: name, shader: shader };
  129171. /***/ }),
  129172. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  129173. /*!********************************************************!*\
  129174. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  129175. \********************************************************/
  129176. /*! exports provided: fogVertexDeclaration */
  129177. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129178. "use strict";
  129179. __webpack_require__.r(__webpack_exports__);
  129180. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  129181. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129182. var name = 'fogVertexDeclaration';
  129183. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  129184. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129185. /** @hidden */
  129186. var fogVertexDeclaration = { name: name, shader: shader };
  129187. /***/ }),
  129188. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  129189. /*!***************************************************!*\
  129190. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  129191. \***************************************************/
  129192. /*! exports provided: fresnelFunction */
  129193. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129194. "use strict";
  129195. __webpack_require__.r(__webpack_exports__);
  129196. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  129197. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129198. var name = 'fresnelFunction';
  129199. var shader = "#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";
  129200. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129201. /** @hidden */
  129202. var fresnelFunction = { name: name, shader: shader };
  129203. /***/ }),
  129204. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  129205. /*!******************************************************!*\
  129206. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  129207. \******************************************************/
  129208. /*! exports provided: harmonicsFunctions */
  129209. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129210. "use strict";
  129211. __webpack_require__.r(__webpack_exports__);
  129212. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  129213. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129214. var name = 'harmonicsFunctions';
  129215. var shader = "#ifdef USESPHERICALFROMREFLECTIONMAP\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;\nvec3 quaternionVectorRotation_ScaledSqrtTwo(vec4 Q,vec3 V){\nvec3 T=cross(Q.xyz,V);\nT+=Q.www*V;\nreturn cross(Q.xyz,T)+V;\n}\nvec3 environmentIrradianceJones(vec3 normal)\n{\n\n\n\n\n\n\n\n\n\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";
  129216. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129217. /** @hidden */
  129218. var harmonicsFunctions = { name: name, shader: shader };
  129219. /***/ }),
  129220. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  129221. /*!***************************************************!*\
  129222. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  129223. \***************************************************/
  129224. /*! exports provided: helperFunctions */
  129225. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129226. "use strict";
  129227. __webpack_require__.r(__webpack_exports__);
  129228. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  129229. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129230. var name = 'helperFunctions';
  129231. var shader = "const float PI=3.1415926535897932384626433832795;\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}\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}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(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}\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}\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.);\n\nvec3 rgb=color.rgb*D;\n\nrgb=toGammaSpace(rgb);\nreturn vec4(rgb,D);\n}\nvec3 fromRGBD(vec4 rgbd) {\n\nrgbd.rgb=toLinearSpace(rgbd.rgb);\n\nreturn rgbd.rgb/rgbd.a;\n}";
  129232. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129233. /** @hidden */
  129234. var helperFunctions = { name: name, shader: shader };
  129235. /***/ }),
  129236. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  129237. /*!**************************************************************!*\
  129238. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  129239. \**************************************************************/
  129240. /*! exports provided: imageProcessingDeclaration */
  129241. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129242. "use strict";
  129243. __webpack_require__.r(__webpack_exports__);
  129244. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  129245. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129246. var name = 'imageProcessingDeclaration';
  129247. var shader = "#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";
  129248. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129249. /** @hidden */
  129250. var imageProcessingDeclaration = { name: name, shader: shader };
  129251. /***/ }),
  129252. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  129253. /*!************************************************************!*\
  129254. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  129255. \************************************************************/
  129256. /*! exports provided: imageProcessingFunctions */
  129257. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129258. "use strict";
  129259. __webpack_require__.r(__webpack_exports__);
  129260. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  129261. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129262. var name = 'imageProcessingFunctions';
  129263. var shader = "#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\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);\n\n\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\n\n\n\n\n\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);\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;\n\ncolor=RRTAndODTFit(color);\ncolor=ACESOutputMat*color;\n\ncolor=saturate(color);\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\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);\n\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\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=saturate(result.rgb);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\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\n\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}";
  129264. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129265. /** @hidden */
  129266. var imageProcessingFunctions = { name: name, shader: shader };
  129267. /***/ }),
  129268. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  129269. /*!********************************************************!*\
  129270. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  129271. \********************************************************/
  129272. /*! exports provided: instancesDeclaration */
  129273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129274. "use strict";
  129275. __webpack_require__.r(__webpack_exports__);
  129276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  129277. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129278. var name = 'instancesDeclaration';
  129279. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  129280. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129281. /** @hidden */
  129282. var instancesDeclaration = { name: name, shader: shader };
  129283. /***/ }),
  129284. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  129285. /*!***************************************************!*\
  129286. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  129287. \***************************************************/
  129288. /*! exports provided: instancesVertex */
  129289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129290. "use strict";
  129291. __webpack_require__.r(__webpack_exports__);
  129292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  129293. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129294. var name = 'instancesVertex';
  129295. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  129296. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129297. /** @hidden */
  129298. var instancesVertex = { name: name, shader: shader };
  129299. /***/ }),
  129300. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  129301. /*!******************************************************!*\
  129302. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  129303. \******************************************************/
  129304. /*! exports provided: kernelBlurFragment */
  129305. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129306. "use strict";
  129307. __webpack_require__.r(__webpack_exports__);
  129308. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  129309. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129310. var name = 'kernelBlurFragment';
  129311. var shader = "#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";
  129312. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129313. /** @hidden */
  129314. var kernelBlurFragment = { name: name, shader: shader };
  129315. /***/ }),
  129316. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  129317. /*!*******************************************************!*\
  129318. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  129319. \*******************************************************/
  129320. /*! exports provided: kernelBlurFragment2 */
  129321. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129322. "use strict";
  129323. __webpack_require__.r(__webpack_exports__);
  129324. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  129325. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129326. var name = 'kernelBlurFragment2';
  129327. var shader = "#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";
  129328. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129329. /** @hidden */
  129330. var kernelBlurFragment2 = { name: name, shader: shader };
  129331. /***/ }),
  129332. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  129333. /*!****************************************************************!*\
  129334. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  129335. \****************************************************************/
  129336. /*! exports provided: kernelBlurVaryingDeclaration */
  129337. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129338. "use strict";
  129339. __webpack_require__.r(__webpack_exports__);
  129340. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  129341. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129342. var name = 'kernelBlurVaryingDeclaration';
  129343. var shader = "varying vec2 sampleCoord{X};";
  129344. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129345. /** @hidden */
  129346. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  129347. /***/ }),
  129348. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  129349. /*!****************************************************!*\
  129350. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  129351. \****************************************************/
  129352. /*! exports provided: kernelBlurVertex */
  129353. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129354. "use strict";
  129355. __webpack_require__.r(__webpack_exports__);
  129356. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  129357. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129358. var name = 'kernelBlurVertex';
  129359. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  129360. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129361. /** @hidden */
  129362. var kernelBlurVertex = { name: name, shader: shader };
  129363. /***/ }),
  129364. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  129365. /*!*************************************************!*\
  129366. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  129367. \*************************************************/
  129368. /*! exports provided: lightFragment */
  129369. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129370. "use strict";
  129371. __webpack_require__.r(__webpack_exports__);
  129372. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  129373. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129374. var name = 'lightFragment';
  129375. var shader = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n\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\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\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=roughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightDiffuse.a,preInfo.lightDistance);\n#endif\n\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,transmittance);\n#else\ninfo.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef SPECULARTERM\n#ifdef ANISOTROPIC\ninfo.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicTangent,anisotropicBitangent,anisotropy,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#else\ninfo.specular=computeSpecularLighting(preInfo,normalW,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n#endif\n\n#ifdef SHEEN\n#ifdef SHEEN_LINKWITHALBEDO\n\npreInfo.roughness=sheenIntensity;\n#endif\ninfo.sheen=computeSheenLighting(preInfo,normalW,sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef CLEARCOAT\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=clearCoatRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(clearCoatRoughness,light{X}.vLightDiffuse.a,preInfo.lightDistance);\n#endif\ninfo.clearCoat=computeClearCoatLighting(preInfo,clearCoatNormalW,clearCoatAARoughnessFactors.x,clearCoatIntensity,light{X}.vLightDiffuse.rgb);\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatLightingAbsorption(clearCoatNdotVRefract,preInfo.L,clearCoatNormalW,clearCoatColor,clearCoatThickness,clearCoatIntensity);\ninfo.diffuse*=absorption;\n#ifdef SPECULARTERM\ninfo.specular*=absorption;\n#endif\n#endif\n\ninfo.diffuse*=info.clearCoat.w;\n#ifdef SPECULARTERM\ninfo.specular*=info.clearCoat.w*info.clearCoat.w;\n#endif\n#ifdef SHEEN\ninfo.sheen*=info.clearCoat.w*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,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,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,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 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*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#ifdef CLEARCOAT\n#ifndef LIGHTMAPNOSPECULAR{X}\nclearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor;\n#endif\n#endif\n#ifdef SHEEN\n#ifndef LIGHTMAPNOSPECULAR{X}\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\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";
  129376. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129377. /** @hidden */
  129378. var lightFragment = { name: name, shader: shader };
  129379. /***/ }),
  129380. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  129381. /*!************************************************************!*\
  129382. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  129383. \************************************************************/
  129384. /*! exports provided: lightFragmentDeclaration */
  129385. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129386. "use strict";
  129387. __webpack_require__.r(__webpack_exports__);
  129388. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  129389. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129390. var name = 'lightFragmentDeclaration';
  129391. var shader = "#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec3 vLightSpecular{X};\n#else\nvec3 vLightSpecular{X}=vec3(0.);\n#endif\n#ifdef SHADOW{X}\n#if 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";
  129392. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129393. /** @hidden */
  129394. var lightFragmentDeclaration = { name: name, shader: shader };
  129395. /***/ }),
  129396. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  129397. /*!*******************************************************!*\
  129398. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  129399. \*******************************************************/
  129400. /*! exports provided: lightUboDeclaration */
  129401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129402. "use strict";
  129403. __webpack_require__.r(__webpack_exports__);
  129404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  129405. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129406. var name = 'lightUboDeclaration';
  129407. var shader = "#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec3 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#if 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";
  129408. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129409. /** @hidden */
  129410. var lightUboDeclaration = { name: name, shader: shader };
  129411. /***/ }),
  129412. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  129413. /*!***********************************************************!*\
  129414. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  129415. \***********************************************************/
  129416. /*! exports provided: lightsFragmentFunctions */
  129417. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129418. "use strict";
  129419. __webpack_require__.r(__webpack_exports__);
  129420. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  129421. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129422. var name = 'lightsFragmentFunctions';
  129423. var shader = "\nstruct 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}\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\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);\n\nfloat cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));\nif (cosAngle>=lightDirection.w)\n{\ncosAngle=max(0.,pow(cosAngle,lightData.w));\nattenuation*=cosAngle;\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\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;\n\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\n\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}\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}";
  129424. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129425. /** @hidden */
  129426. var lightsFragmentFunctions = { name: name, shader: shader };
  129427. /***/ }),
  129428. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  129429. /*!*******************************************************!*\
  129430. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  129431. \*******************************************************/
  129432. /*! exports provided: logDepthDeclaration */
  129433. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129434. "use strict";
  129435. __webpack_require__.r(__webpack_exports__);
  129436. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  129437. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129438. var name = 'logDepthDeclaration';
  129439. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  129440. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129441. /** @hidden */
  129442. var logDepthDeclaration = { name: name, shader: shader };
  129443. /***/ }),
  129444. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  129445. /*!****************************************************!*\
  129446. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  129447. \****************************************************/
  129448. /*! exports provided: logDepthFragment */
  129449. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129450. "use strict";
  129451. __webpack_require__.r(__webpack_exports__);
  129452. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  129453. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129454. var name = 'logDepthFragment';
  129455. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  129456. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129457. /** @hidden */
  129458. var logDepthFragment = { name: name, shader: shader };
  129459. /***/ }),
  129460. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  129461. /*!**************************************************!*\
  129462. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  129463. \**************************************************/
  129464. /*! exports provided: logDepthVertex */
  129465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129466. "use strict";
  129467. __webpack_require__.r(__webpack_exports__);
  129468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  129469. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129470. var name = 'logDepthVertex';
  129471. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  129472. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129473. /** @hidden */
  129474. var logDepthVertex = { name: name, shader: shader };
  129475. /***/ }),
  129476. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  129477. /*!******************************************************!*\
  129478. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  129479. \******************************************************/
  129480. /*! exports provided: morphTargetsVertex */
  129481. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129482. "use strict";
  129483. __webpack_require__.r(__webpack_exports__);
  129484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  129485. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129486. var name = 'morphTargetsVertex';
  129487. var shader = "#ifdef MORPHTARGETS\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#endif";
  129488. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129489. /** @hidden */
  129490. var morphTargetsVertex = { name: name, shader: shader };
  129491. /***/ }),
  129492. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  129493. /*!*****************************************************************!*\
  129494. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  129495. \*****************************************************************/
  129496. /*! exports provided: morphTargetsVertexDeclaration */
  129497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129498. "use strict";
  129499. __webpack_require__.r(__webpack_exports__);
  129500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  129501. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129502. var name = 'morphTargetsVertexDeclaration';
  129503. var shader = "#ifdef MORPHTARGETS\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#endif";
  129504. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129505. /** @hidden */
  129506. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  129507. /***/ }),
  129508. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  129509. /*!***********************************************************************!*\
  129510. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  129511. \***********************************************************************/
  129512. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  129513. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129514. "use strict";
  129515. __webpack_require__.r(__webpack_exports__);
  129516. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  129517. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129518. var name = 'morphTargetsVertexGlobalDeclaration';
  129519. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  129520. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129521. /** @hidden */
  129522. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  129523. /***/ }),
  129524. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  129525. /*!**********************************************************!*\
  129526. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  129527. \**********************************************************/
  129528. /*! exports provided: mrtFragmentDeclaration */
  129529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129530. "use strict";
  129531. __webpack_require__.r(__webpack_exports__);
  129532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  129533. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129534. var name = 'mrtFragmentDeclaration';
  129535. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  129536. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129537. /** @hidden */
  129538. var mrtFragmentDeclaration = { name: name, shader: shader };
  129539. /***/ }),
  129540. /***/ "./Shaders/ShadersInclude/pbrBRDFFunctions.ts":
  129541. /*!****************************************************!*\
  129542. !*** ./Shaders/ShadersInclude/pbrBRDFFunctions.ts ***!
  129543. \****************************************************/
  129544. /*! exports provided: pbrBRDFFunctions */
  129545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129546. "use strict";
  129547. __webpack_require__.r(__webpack_exports__);
  129548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrBRDFFunctions", function() { return pbrBRDFFunctions; });
  129549. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129550. var name = 'pbrBRDFFunctions';
  129551. var shader = "\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\n\n\n\n#ifdef MS_BRDF_ENERGY_CONSERVATION\n\n\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,sampler2D brdfSampler) {\n\nvec2 UV=vec2(NdotV,perceptualRoughness);\n\nvec4 brdfLookup=texture2D(brdfSampler,UV);\n#ifdef ENVIRONMENTBRDF_RGBD\nbrdfLookup.rgb=fromRGBD(brdfLookup.rgba);\n#endif\nreturn brdfLookup.rgb;\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#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)\nvec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\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(REFLECTION)\n\nvec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {\nvec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;\nreturn sheenEnvironmentReflectance;\n}\n#endif\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\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\n\n\n\n\n\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\n\n\n\n\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\n#ifdef SHEEN\n\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\n\n\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\n\n\n\n#ifdef BRDF_V_HEIGHT_CORRELATED\n\n\n\nfloat smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {\n#ifdef MOBILE\n\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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfloat smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)\n{\n#ifdef MOBILE\n\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);\n\nreturn visibility;\n}\n#endif\n#ifdef ANISOTROPIC\n\n\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) {\n\n\n\nreturn 0.25/(VdotH*VdotH);\n}\n#endif\n#ifdef SHEEN\n\n\n\nfloat visibility_Ashikhmin(float NdotL,float NdotV)\n{\nreturn 1./(4.*(NdotL+NdotV-NdotL*NdotV));\n}\n#endif\n\n\n\n\n\n\n\nfloat diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {\n\n\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\n\n\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}\n\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";
  129552. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129553. /** @hidden */
  129554. var pbrBRDFFunctions = { name: name, shader: shader };
  129555. /***/ }),
  129556. /***/ "./Shaders/ShadersInclude/pbrDebug.ts":
  129557. /*!********************************************!*\
  129558. !*** ./Shaders/ShadersInclude/pbrDebug.ts ***!
  129559. \********************************************/
  129560. /*! exports provided: pbrDebug */
  129561. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129562. "use strict";
  129563. __webpack_require__.r(__webpack_exports__);
  129564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDebug", function() { return pbrDebug; });
  129565. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129566. var name = 'pbrDebug';
  129567. var shader = "#if DEBUGMODE>0\nif (vClipSpacePosition.x/vClipSpacePosition.w<vDebugMode.x) {\nreturn;\n}\n\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) || defined(PARALLAX) || defined(ANISOTROPIC))\n\ngl_FragColor.rgb=TBN[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 4 && (defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC))\n\ngl_FragColor.rgb=TBN[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 5\n\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)\n\ngl_FragColor.rgb=TBNClearCoat[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\n\ngl_FragColor.rgb=TBNClearCoat[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 10 && defined(CLEARCOAT)\n\ngl_FragColor.rgb=clearCoatNormalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 11 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicNormal;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 12 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicTangent;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 13 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicBitangent;\n#define DEBUGMODE_NORMALIZE\n\n#elif DEBUGMODE == 20 && defined(ALBEDO)\ngl_FragColor.rgb=albedoTexture.rgb;\n#elif DEBUGMODE == 21 && defined(AMBIENT)\ngl_FragColor.rgb=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=surfaceMetallicColorMap.rgb;\n#elif DEBUGMODE == 26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)\ngl_FragColor.rgb=surfaceReflectivityColorMap.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)\ngl_FragColor.rgb=clearCoatMapData.rgb;\n#elif DEBUGMODE == 28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)\ngl_FragColor.rgb=clearCoatTintMapData.rgb;\n#elif DEBUGMODE == 29 && defined(SHEEN) && defined(SHEEN_TEXTURE)\ngl_FragColor.rgb=sheenMapData.rgb;\n#elif DEBUGMODE == 30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)\ngl_FragColor.rgb=anisotropyMapData.rgb;\n#elif DEBUGMODE == 31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)\ngl_FragColor.rgb=thicknessMap.rgb;\n\n#elif DEBUGMODE == 40 && defined(SS_REFRACTION)\n\ngl_FragColor.rgb=environmentRefraction.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 41 && defined(REFLECTION)\ngl_FragColor.rgb=environmentRadiance.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION)\ngl_FragColor.rgb=environmentClearCoatRadiance;\n#define DEBUGMODE_GAMMA\n\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=environmentIrradiance.rgb;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 60\ngl_FragColor.rgb=surfaceAlbedo.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 61\ngl_FragColor.rgb=specularEnvironmentR0;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 62\ngl_FragColor.rgb=vec3(roughness);\n#elif DEBUGMODE == 63\ngl_FragColor.rgb=vec3(alphaG);\n#elif DEBUGMODE == 64\ngl_FragColor.rgb=vec3(NdotV);\n#elif DEBUGMODE == 65 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\ngl_FragColor.rgb=clearCoatColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 66 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatRoughness);\n#elif DEBUGMODE == 67 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatNdotV);\n#elif DEBUGMODE == 68 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)\ngl_FragColor.rgb=transmittance;\n#elif DEBUGMODE == 69 && defined(SUBSURFACE) && defined(SS_REFRACTION)\ngl_FragColor.rgb=refractionTransmittance;\n\n#elif DEBUGMODE == 70 && defined(RADIANCEOCCLUSION)\ngl_FragColor.rgb=vec3(seo);\n#elif DEBUGMODE == 71 && defined(HORIZONOCCLUSION)\ngl_FragColor.rgb=vec3(eho);\n#elif DEBUGMODE == 72 && defined(MS_BRDF_ENERGY_CONSERVATION)\ngl_FragColor.rgb=vec3(energyConservationFactor);\n#elif DEBUGMODE == 73 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=specularEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 74 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=clearCoatEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 75 && defined(SHEEN) && defined(REFLECTION)\ngl_FragColor.rgb=sheenEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 76 && defined(ALPHABLEND)\ngl_FragColor.rgb=vec3(luminanceOverAlpha);\n#elif DEBUGMODE == 77\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#endif";
  129568. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129569. /** @hidden */
  129570. var pbrDebug = { name: name, shader: shader };
  129571. /***/ }),
  129572. /***/ "./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts":
  129573. /*!*********************************************************************!*\
  129574. !*** ./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts ***!
  129575. \*********************************************************************/
  129576. /*! exports provided: pbrDirectLightingFalloffFunctions */
  129577. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129578. "use strict";
  129579. __webpack_require__.r(__webpack_exports__);
  129580. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingFalloffFunctions", function() { return pbrDirectLightingFalloffFunctions; });
  129581. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129582. var name = 'pbrDirectLightingFalloffFunctions';
  129583. var shader = "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;\n\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;\n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\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{\n\n\n\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=saturate(cd*lightAngleScale+lightAngleOffset);\n\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}";
  129584. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129585. /** @hidden */
  129586. var pbrDirectLightingFalloffFunctions = { name: name, shader: shader };
  129587. /***/ }),
  129588. /***/ "./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts":
  129589. /*!**************************************************************!*\
  129590. !*** ./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts ***!
  129591. \**************************************************************/
  129592. /*! exports provided: pbrDirectLightingFunctions */
  129593. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129594. "use strict";
  129595. __webpack_require__.r(__webpack_exports__);
  129596. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingFunctions", function() { return pbrDirectLightingFunctions; });
  129597. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129598. var name = 'pbrDirectLightingFunctions';
  129599. var shader = "#define CLEARCOATREFLECTANCE90 1.0\n\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef CLEARCOAT\n\n\nvec4 clearCoat;\n#endif\n#ifdef SHEEN\nvec3 sheen;\n#endif\n};\n\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\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}\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);\n\nfloat wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);\n\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 visibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);\n#else\nfloat visibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);\n#endif\nvec3 specTerm=fresnel*distribution*visibility;\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 visibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);\nvec3 specTerm=fresnel*distribution*visibility;\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 visibility=visibility_Kelemen(info.VdotH);\nfloat clearCoatTerm=fresnel*distribution*visibility;\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);\n\n\nvec3 fresnel=reflectance0;\nfloat distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);\nfloat visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);\nvec3 sheenTerm=fresnel*distribution*visibility;\nreturn sheenTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n";
  129600. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129601. /** @hidden */
  129602. var pbrDirectLightingFunctions = { name: name, shader: shader };
  129603. /***/ }),
  129604. /***/ "./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts":
  129605. /*!*******************************************************************!*\
  129606. !*** ./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts ***!
  129607. \*******************************************************************/
  129608. /*! exports provided: pbrDirectLightingSetupFunctions */
  129609. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129610. "use strict";
  129611. __webpack_require__.r(__webpack_exports__);
  129612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingSetupFunctions", function() { return pbrDirectLightingSetupFunctions; });
  129613. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129614. var name = 'pbrDirectLightingSetupFunctions';
  129615. var shader = "\nstruct preLightingInfo\n{\n\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat lightDistance;\n\nfloat attenuation;\n\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;\n\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\n\nresult.lightDistance=sqrt(result.lightDistanceSquared);\n\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;\n\nresult.lightDistance=length(-lightData.xyz);\n\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;\n\n\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}";
  129616. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129617. /** @hidden */
  129618. var pbrDirectLightingSetupFunctions = { name: name, shader: shader };
  129619. /***/ }),
  129620. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  129621. /*!**********************************************************!*\
  129622. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  129623. \**********************************************************/
  129624. /*! exports provided: pbrFragmentDeclaration */
  129625. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129626. "use strict";
  129627. __webpack_require__.r(__webpack_exports__);
  129628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  129629. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129630. var name = 'pbrFragmentDeclaration';
  129631. var shader = "uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\n\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\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\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\n#ifdef CLEARCOAT\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\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\n#ifdef ANISOTROPIC\nuniform vec3 vAnisotropy;\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\nuniform vec4 vSheenColor;\n#ifdef SHEEN_TEXTURE\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n#endif\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;;\n#endif\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\n#endif";
  129632. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129633. /** @hidden */
  129634. var pbrFragmentDeclaration = { name: name, shader: shader };
  129635. /***/ }),
  129636. /***/ "./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts":
  129637. /*!***************************************************************!*\
  129638. !*** ./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts ***!
  129639. \***************************************************************/
  129640. /*! exports provided: pbrFragmentExtraDeclaration */
  129641. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129642. "use strict";
  129643. __webpack_require__.r(__webpack_exports__);
  129644. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentExtraDeclaration", function() { return pbrFragmentExtraDeclaration; });
  129645. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129646. var name = 'pbrFragmentExtraDeclaration';
  129647. var shader = "uniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nuniform vec2 vDebugMode;\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif";
  129648. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129649. /** @hidden */
  129650. var pbrFragmentExtraDeclaration = { name: name, shader: shader };
  129651. /***/ }),
  129652. /***/ "./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts":
  129653. /*!******************************************************************!*\
  129654. !*** ./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts ***!
  129655. \******************************************************************/
  129656. /*! exports provided: pbrFragmentSamplersDeclaration */
  129657. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129658. "use strict";
  129659. __webpack_require__.r(__webpack_exports__);
  129660. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentSamplersDeclaration", function() { return pbrFragmentSamplersDeclaration; });
  129661. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129662. var name = 'pbrFragmentSamplersDeclaration';
  129663. var shader = "#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\n#if CLEARCOAT_TEXTUREDIRECTUV == 1\n#define vClearCoatUV vMainUV1\n#elif CLEARCOAT_TEXTUREDIRECTUV == 2\n#define vClearCoatUV vMainUV2\n#else\nvarying vec2 vClearCoatUV;\n#endif\nuniform sampler2D clearCoatSampler;\n#endif\n#ifdef CLEARCOAT_BUMP\n#if CLEARCOAT_BUMPDIRECTUV == 1\n#define vClearCoatBumpUV vMainUV1\n#elif CLEARCOAT_BUMPDIRECTUV == 2\n#define vClearCoatBumpUV vMainUV2\n#else\nvarying vec2 vClearCoatBumpUV;\n#endif\nuniform sampler2D clearCoatBumpSampler;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\n#if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1\n#define vClearCoatTintUV vMainUV1\n#elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2\n#define vClearCoatTintUV vMainUV2\n#else\nvarying vec2 vClearCoatTintUV;\n#endif\nuniform sampler2D clearCoatTintSampler;\n#endif\n#endif\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\n#if SHEEN_TEXTUREDIRECTUV == 1\n#define vSheenUV vMainUV1\n#elif SHEEN_TEXTUREDIRECTUV == 2\n#define vSheenUV vMainUV2\n#else\nvarying vec2 vSheenUV;\n#endif\nuniform sampler2D sheenSampler;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\n#if ANISOTROPIC_TEXTUREDIRECTUV == 1\n#define vAnisotropyUV vMainUV1\n#elif ANISOTROPIC_TEXTUREDIRECTUV == 2\n#define vAnisotropyUV vMainUV2\n#else\nvarying vec2 vAnisotropyUV;\n#endif\nuniform sampler2D anisotropySampler;\n#endif\n#endif\n\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#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 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#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\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 samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\n#if SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 1\n#define vThicknessUV vMainUV1\n#elif SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 2\n#define vThicknessUV vMainUV2\n#else\nvarying vec2 vThicknessUV;\n#endif\nuniform sampler2D thicknessSampler;\n#endif\n#endif";
  129664. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129665. /** @hidden */
  129666. var pbrFragmentSamplersDeclaration = { name: name, shader: shader };
  129667. /***/ }),
  129668. /***/ "./Shaders/ShadersInclude/pbrHelperFunctions.ts":
  129669. /*!******************************************************!*\
  129670. !*** ./Shaders/ShadersInclude/pbrHelperFunctions.ts ***!
  129671. \******************************************************/
  129672. /*! exports provided: pbrHelperFunctions */
  129673. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129674. "use strict";
  129675. __webpack_require__.r(__webpack_exports__);
  129676. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrHelperFunctions", function() { return pbrHelperFunctions; });
  129677. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129678. var name = 'pbrHelperFunctions';
  129679. var shader = "\n#define RECIPROCAL_PI2 0.15915494\n#define RECIPROCAL_PI 0.31830988618\n\n#define MINIMUMVARIANCE 0.0005\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nreturn square(roughness)+MINIMUMVARIANCE;\n}\nfloat fresnelGrazingReflectance(float reflectance0) {\n\n\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));\n\nfloat geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n\ngeometricAlphaGFactor*=0.75;\nreturn vec2(geometricRoughnessFactor,geometricAlphaGFactor);\n#else\nreturn vec2(0.);\n#endif\n}\n#ifdef ANISOTROPIC\n\n\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}\n\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}\n#endif\n#if defined(CLEARCOAT) || defined(SS_REFRACTION)\n\n\n\nvec3 cocaLambert(vec3 alpha,float distance) {\nreturn exp(-alpha*distance);\n}\n\nvec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {\nreturn cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));\n}\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\n\n\n\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";
  129680. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129681. /** @hidden */
  129682. var pbrHelperFunctions = { name: name, shader: shader };
  129683. /***/ }),
  129684. /***/ "./Shaders/ShadersInclude/pbrIBLFunctions.ts":
  129685. /*!***************************************************!*\
  129686. !*** ./Shaders/ShadersInclude/pbrIBLFunctions.ts ***!
  129687. \***************************************************/
  129688. /*! exports provided: pbrIBLFunctions */
  129689. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129690. "use strict";
  129691. __webpack_require__.r(__webpack_exports__);
  129692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrIBLFunctions", function() { return pbrIBLFunctions; });
  129693. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129694. var name = 'pbrIBLFunctions';
  129695. var shader = "#if defined(REFLECTION) || defined(SS_REFRACTION)\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\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) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=saturate(1.0+1.1*dot(reflection,normal));\nreturn square(temp);\n}\n#endif\n\n\n\n\n#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nreturn getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);\n}\n#endif";
  129696. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129697. /** @hidden */
  129698. var pbrIBLFunctions = { name: name, shader: shader };
  129699. /***/ }),
  129700. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  129701. /*!*****************************************************!*\
  129702. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  129703. \*****************************************************/
  129704. /*! exports provided: pbrUboDeclaration */
  129705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129706. "use strict";
  129707. __webpack_require__.r(__webpack_exports__);
  129708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  129709. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129710. var name = 'pbrUboDeclaration';
  129711. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec4 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float pointSize;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\nuniform vec3 vAnisotropy;\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\nuniform vec4 vSheenColor;\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};";
  129712. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129713. /** @hidden */
  129714. var pbrUboDeclaration = { name: name, shader: shader };
  129715. /***/ }),
  129716. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  129717. /*!********************************************************!*\
  129718. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  129719. \********************************************************/
  129720. /*! exports provided: pbrVertexDeclaration */
  129721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129722. "use strict";
  129723. __webpack_require__.r(__webpack_exports__);
  129724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  129725. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129726. var name = 'pbrVertexDeclaration';
  129727. var shader = "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 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\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\n#endif\n\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\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\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n#endif\n#endif\n\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#endif\n";
  129728. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129729. /** @hidden */
  129730. var pbrVertexDeclaration = { name: name, shader: shader };
  129731. /***/ }),
  129732. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  129733. /*!****************************************************!*\
  129734. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  129735. \****************************************************/
  129736. /*! exports provided: pointCloudVertex */
  129737. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129738. "use strict";
  129739. __webpack_require__.r(__webpack_exports__);
  129740. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  129741. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129742. var name = 'pointCloudVertex';
  129743. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  129744. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129745. /** @hidden */
  129746. var pointCloudVertex = { name: name, shader: shader };
  129747. /***/ }),
  129748. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  129749. /*!******************************************************!*\
  129750. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  129751. \******************************************************/
  129752. /*! exports provided: reflectionFunction */
  129753. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129754. "use strict";
  129755. __webpack_require__.r(__webpack_exports__);
  129756. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  129757. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129758. var name = 'reflectionFunction';
  129759. var shader = "#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\nvec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {\n\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;\n\nvec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);\n\nfloat distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);\n\nvec3 intersectPositionWS=vertexPos+origVec*distance;\n\nreturn intersectPositionWS-cubePos;\n}\n#endif\nvec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvec3 direction=normalize(vDirectionW);\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;\n#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\nreturn vec3(1.0-s,t,0);\n#else\nreturn vec3(s,t,0);\n#endif\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR\nvec3 cameraToVertex=normalize(worldPos.xyz-vEyePosition.xyz);\nvec3 r=normalize(reflect(cameraToVertex,worldNormal));\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#endif\n#ifdef REFLECTIONMAP_SPHERICAL\nvec3 viewDir=normalize(vec3(view*worldPos));\nvec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));\nvec3 r=reflect(viewDir,viewNormal);\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#endif\n#ifdef REFLECTIONMAP_PLANAR\nvec3 viewDir=worldPos.xyz-vEyePosition.xyz;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n#endif\n#ifdef REFLECTIONMAP_CUBIC\nvec3 viewDir=normalize(worldPos.xyz-vEyePosition.xyz);\n\nvec3 coords=reflect(viewDir,worldNormal);\n#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\ncoords=parallaxCorrectNormal(worldPos.xyz,coords,vReflectionSize,vReflectionPosition);\n#endif\ncoords=vec3(reflectionMatrix*vec4(coords,0));\n#ifdef INVERTCUBICMAP\ncoords.y*=-1.0;\n#endif\nreturn coords;\n#endif\n#ifdef REFLECTIONMAP_PROJECTION\nreturn vec3(reflectionMatrix*(view*worldPos));\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nreturn vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}";
  129760. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129761. /** @hidden */
  129762. var reflectionFunction = { name: name, shader: shader };
  129763. /***/ }),
  129764. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  129765. /*!************************************************************!*\
  129766. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  129767. \************************************************************/
  129768. /*! exports provided: shadowsFragmentFunctions */
  129769. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129770. "use strict";
  129771. __webpack_require__.r(__webpack_exports__);
  129772. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  129773. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129774. var name = 'shadowsFragmentFunctions';
  129775. var shader = "#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.0,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\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\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\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\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}\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}\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}\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}\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\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\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}\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\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}\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}\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}\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}\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#ifdef WEBGL2\n\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat shadow=texture2D(shadowSampler,uvDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\n\n\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\n\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\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}\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\n\n\n\n\nfloat computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,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}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture(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}\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\n\nfloat AAOffset=shadowMapSizeInverse*10.;\n\n\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];\n\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);\n\nshadow=mix(shadow,1.,depthMetric-avgBlockerDepth);\n\nshadow=mix(darkness,1.,shadow);\n\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,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}\nfloat computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,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}\nfloat computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,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#endif\n#endif\n";
  129776. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129777. /** @hidden */
  129778. var shadowsFragmentFunctions = { name: name, shader: shader };
  129779. /***/ }),
  129780. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  129781. /*!*************************************************!*\
  129782. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  129783. \*************************************************/
  129784. /*! exports provided: shadowsVertex */
  129785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129786. "use strict";
  129787. __webpack_require__.r(__webpack_exports__);
  129788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  129789. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129790. var name = 'shadowsVertex';
  129791. var shader = "#ifdef SHADOWS\n#if defined(SHADOW{X}) && !defined(SHADOWCUBE{X})\nvPositionFromLight{X}=lightMatrix{X}*worldPos;\nvDepthMetric{X}=((vPositionFromLight{X}.z+light{X}.depthValues.x)/(light{X}.depthValues.y));\n#endif\n#endif";
  129792. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129793. /** @hidden */
  129794. var shadowsVertex = { name: name, shader: shader };
  129795. /***/ }),
  129796. /***/ "./Shaders/anaglyph.fragment.ts":
  129797. /*!**************************************!*\
  129798. !*** ./Shaders/anaglyph.fragment.ts ***!
  129799. \**************************************/
  129800. /*! exports provided: anaglyphPixelShader */
  129801. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129802. "use strict";
  129803. __webpack_require__.r(__webpack_exports__);
  129804. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  129805. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129806. var name = 'anaglyphPixelShader';
  129807. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D leftSampler;\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}";
  129808. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129809. /** @hidden */
  129810. var anaglyphPixelShader = { name: name, shader: shader };
  129811. /***/ }),
  129812. /***/ "./Shaders/background.fragment.ts":
  129813. /*!****************************************!*\
  129814. !*** ./Shaders/background.fragment.ts ***!
  129815. \****************************************/
  129816. /*! exports provided: backgroundPixelShader */
  129817. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129818. "use strict";
  129819. __webpack_require__.r(__webpack_exports__);
  129820. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  129821. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129822. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  129823. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  129824. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  129825. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  129826. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  129827. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  129828. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129829. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  129830. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  129831. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  129832. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  129833. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  129834. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  129835. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  129836. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  129837. var name = 'backgroundPixelShader';
  129838. var shader = "#ifdef TEXTURELODSUPPORT\n#extension GL_EXT_shader_texture_lod : enable\n#endif\nprecision highp float;\n#include<__decl__backgroundFragment>\n#define RECIPROCAL_PI2 0.15915494\n\nuniform vec3 vEyePosition;\n\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\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\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#ifndef SHADOWONLY\n#define SHADOWONLY;\n#endif\n#include<imageProcessingDeclaration>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<helperFunctions>\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<imageProcessingFunctions>\n#include<clipPlaneFragmentDeclaration>\n\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{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\n#endif\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(0.0,1.0,0.0);\n#endif\n\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\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\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\n\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\n\nreflectionColor.rgb*=vReflectionInfos.x;\n#endif\n\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\n\ndiffuseMap.rgb*=vDiffuseInfos.y;\n#ifdef DIFFUSEHASALPHA\nfinalAlpha*=diffuseMap.a;\n#endif\ndiffuseColor=diffuseMap.rgb;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 colorBase=diffuseColor;\n#else\nvec3 colorBase=reflectionColor.rgb*diffuseColor;\n#endif\ncolorBase=max(colorBase,0.0);\n\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\n#ifdef REFLECTIONFRESNEL\nvec3 reflectionAmount=vReflectionControl.xxx;\nvec3 reflectionReflectance0=vReflectionControl.yyy;\nvec3 reflectionReflectance90=vReflectionControl.zzz;\nfloat VdotN=dot(normalize(vEyePosition),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-vBackgroundCenter));\n\nconst float startAngle=0.1;\nfloat fadeFactor=saturate(viewAngleToFloor/startAngle);\nfinalAlpha*=fadeFactor*fadeFactor;\n#endif\n\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\n\nvec4 color=vec4(finalColor,finalAlpha);\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\ncolor.rgb=clamp(color.rgb,0.,30.0);\n#else\n\ncolor=applyImageProcessing(color);\n#endif\n#ifdef PREMULTIPLYALPHA\n\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}\n";
  129839. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129840. /** @hidden */
  129841. var backgroundPixelShader = { name: name, shader: shader };
  129842. /***/ }),
  129843. /***/ "./Shaders/background.vertex.ts":
  129844. /*!**************************************!*\
  129845. !*** ./Shaders/background.vertex.ts ***!
  129846. \**************************************/
  129847. /*! exports provided: backgroundVertexShader */
  129848. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129849. "use strict";
  129850. __webpack_require__.r(__webpack_exports__);
  129851. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  129852. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129853. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  129854. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  129855. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129856. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  129857. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129858. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  129859. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  129860. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  129861. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  129862. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  129863. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  129864. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  129865. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  129866. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  129867. var name = 'backgroundVertexShader';
  129868. var shader = "precision highp float;\n#include<__decl__backgroundVertex>\n#include<helperFunctions>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n\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__lightFragment>[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\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\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\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  129869. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129870. /** @hidden */
  129871. var backgroundVertexShader = { name: name, shader: shader };
  129872. /***/ }),
  129873. /***/ "./Shaders/blackAndWhite.fragment.ts":
  129874. /*!*******************************************!*\
  129875. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  129876. \*******************************************/
  129877. /*! exports provided: blackAndWhitePixelShader */
  129878. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129879. "use strict";
  129880. __webpack_require__.r(__webpack_exports__);
  129881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  129882. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129883. var name = 'blackAndWhitePixelShader';
  129884. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float degree;\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}";
  129885. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129886. /** @hidden */
  129887. var blackAndWhitePixelShader = { name: name, shader: shader };
  129888. /***/ }),
  129889. /***/ "./Shaders/bloomMerge.fragment.ts":
  129890. /*!****************************************!*\
  129891. !*** ./Shaders/bloomMerge.fragment.ts ***!
  129892. \****************************************/
  129893. /*! exports provided: bloomMergePixelShader */
  129894. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129895. "use strict";
  129896. __webpack_require__.r(__webpack_exports__);
  129897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  129898. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129899. var name = 'bloomMergePixelShader';
  129900. var shader = "uniform sampler2D textureSampler;\nuniform sampler2D bloomBlur;\nvarying vec2 vUV;\nuniform float bloomWeight;\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";
  129901. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129902. /** @hidden */
  129903. var bloomMergePixelShader = { name: name, shader: shader };
  129904. /***/ }),
  129905. /***/ "./Shaders/chromaticAberration.fragment.ts":
  129906. /*!*************************************************!*\
  129907. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  129908. \*************************************************/
  129909. /*! exports provided: chromaticAberrationPixelShader */
  129910. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129911. "use strict";
  129912. __webpack_require__.r(__webpack_exports__);
  129913. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  129914. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129915. var name = 'chromaticAberrationPixelShader';
  129916. var shader = "\nuniform sampler2D textureSampler;\n\nuniform float chromatic_aberration;\nuniform float radialIntensity;\nuniform vec2 direction;\nuniform vec2 centerPosition;\nuniform float screen_width;\nuniform float screen_height;\n\nvarying vec2 vUV;\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);\n\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;\n\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}";
  129917. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129918. /** @hidden */
  129919. var chromaticAberrationPixelShader = { name: name, shader: shader };
  129920. /***/ }),
  129921. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  129922. /*!***********************************************!*\
  129923. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  129924. \***********************************************/
  129925. /*! exports provided: circleOfConfusionPixelShader */
  129926. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129927. "use strict";
  129928. __webpack_require__.r(__webpack_exports__);
  129929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  129930. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129931. var name = 'circleOfConfusionPixelShader';
  129932. var shader = "\nuniform sampler2D depthSampler;\n\nvarying vec2 vUV;\n\nuniform vec2 cameraMinMaxZ;\n\nuniform float focusDistance;\nuniform float cocPrecalculation;\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";
  129933. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129934. /** @hidden */
  129935. var circleOfConfusionPixelShader = { name: name, shader: shader };
  129936. /***/ }),
  129937. /***/ "./Shaders/color.fragment.ts":
  129938. /*!***********************************!*\
  129939. !*** ./Shaders/color.fragment.ts ***!
  129940. \***********************************/
  129941. /*! exports provided: colorPixelShader */
  129942. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129943. "use strict";
  129944. __webpack_require__.r(__webpack_exports__);
  129945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  129946. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129947. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  129948. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  129949. var name = 'colorPixelShader';
  129950. var shader = "#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\n#include<clipPlaneFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}";
  129951. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129952. /** @hidden */
  129953. var colorPixelShader = { name: name, shader: shader };
  129954. /***/ }),
  129955. /***/ "./Shaders/color.vertex.ts":
  129956. /*!*********************************!*\
  129957. !*** ./Shaders/color.vertex.ts ***!
  129958. \*********************************/
  129959. /*! exports provided: colorVertexShader */
  129960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129961. "use strict";
  129962. __webpack_require__.r(__webpack_exports__);
  129963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  129964. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129965. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  129966. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  129967. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129968. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  129969. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  129970. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  129971. var name = 'colorVertexShader';
  129972. var shader = "\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n#include<clipPlaneVertexDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\n#include<clipPlaneVertex>\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}";
  129973. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129974. /** @hidden */
  129975. var colorVertexShader = { name: name, shader: shader };
  129976. /***/ }),
  129977. /***/ "./Shaders/colorCorrection.fragment.ts":
  129978. /*!*********************************************!*\
  129979. !*** ./Shaders/colorCorrection.fragment.ts ***!
  129980. \*********************************************/
  129981. /*! exports provided: colorCorrectionPixelShader */
  129982. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129983. "use strict";
  129984. __webpack_require__.r(__webpack_exports__);
  129985. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  129986. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129987. var name = 'colorCorrectionPixelShader';
  129988. var shader = "\nuniform sampler2D textureSampler;\nuniform sampler2D colorTable;\n\nvarying vec2 vUV;\n\nconst float SLICE_COUNT=16.0;\n\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}\nvoid main(void)\n{\nvec4 screen_color=texture2D(textureSampler,vUV);\ngl_FragColor=sampleAs3DTexture(colorTable,screen_color.rgb,SLICE_COUNT);\n}";
  129989. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129990. /** @hidden */
  129991. var colorCorrectionPixelShader = { name: name, shader: shader };
  129992. /***/ }),
  129993. /***/ "./Shaders/convolution.fragment.ts":
  129994. /*!*****************************************!*\
  129995. !*** ./Shaders/convolution.fragment.ts ***!
  129996. \*****************************************/
  129997. /*! exports provided: convolutionPixelShader */
  129998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129999. "use strict";
  130000. __webpack_require__.r(__webpack_exports__);
  130001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  130002. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130003. var name = 'convolutionPixelShader';
  130004. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform float kernel[9];\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}";
  130005. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130006. /** @hidden */
  130007. var convolutionPixelShader = { name: name, shader: shader };
  130008. /***/ }),
  130009. /***/ "./Shaders/default.fragment.ts":
  130010. /*!*************************************!*\
  130011. !*** ./Shaders/default.fragment.ts ***!
  130012. \*************************************/
  130013. /*! exports provided: defaultPixelShader */
  130014. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130015. "use strict";
  130016. __webpack_require__.r(__webpack_exports__);
  130017. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  130018. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130019. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  130020. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  130021. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130022. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  130023. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  130024. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  130025. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  130026. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  130027. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  130028. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  130029. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  130030. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  130031. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  130032. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  130033. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  130034. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  130035. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  130036. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  130037. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  130038. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  130039. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  130040. var name = 'defaultPixelShader';
  130041. var shader = "#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\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 AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n\n#include<fresnelFunction>\n\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<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<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\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#ifdef ALPHATEST\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#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\n\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\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\n\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\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0) {\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb;\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).rgb;\n#endif\n#ifdef IS_REFRACTION_LINEAR\nrefractionColor=toGammaSpace(refractionColor);\n#endif\nrefractionColor*=vRefractionInfos.x;\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\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).rgb;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb;\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).rgb;\n#endif\n#ifdef IS_REFLECTION_LINEAR\nreflectionColor=toGammaSpace(reflectionColor);\n#endif\nreflectionColor*=vReflectionInfos.x;\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=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*=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\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\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\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,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\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\n\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\n\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\ngl_FragColor=color;\n}\n";
  130042. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130043. /** @hidden */
  130044. var defaultPixelShader = { name: name, shader: shader };
  130045. /***/ }),
  130046. /***/ "./Shaders/default.vertex.ts":
  130047. /*!***********************************!*\
  130048. !*** ./Shaders/default.vertex.ts ***!
  130049. \***********************************/
  130050. /*! exports provided: defaultVertexShader */
  130051. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130052. "use strict";
  130053. __webpack_require__.r(__webpack_exports__);
  130054. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  130055. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130056. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  130057. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  130058. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130059. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130060. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130061. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  130062. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  130063. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  130064. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  130065. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  130066. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  130067. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  130068. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  130069. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  130070. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130071. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130072. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  130073. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  130074. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  130075. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  130076. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  130077. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  130078. var name = 'defaultVertexShader';
  130079. var shader = "#include<__decl__defaultVertex>\n\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#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\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#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[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#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(positionUpdated,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#endif\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\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#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n";
  130080. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130081. /** @hidden */
  130082. var defaultVertexShader = { name: name, shader: shader };
  130083. /***/ }),
  130084. /***/ "./Shaders/depth.fragment.ts":
  130085. /*!***********************************!*\
  130086. !*** ./Shaders/depth.fragment.ts ***!
  130087. \***********************************/
  130088. /*! exports provided: depthPixelShader */
  130089. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130090. "use strict";
  130091. __webpack_require__.r(__webpack_exports__);
  130092. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  130093. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130094. var name = 'depthPixelShader';
  130095. var shader = "#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nvarying float vDepthMetric;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragColor=vec4(vDepthMetric,vDepthMetric*vDepthMetric,0.0,1.0);\n}";
  130096. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130097. /** @hidden */
  130098. var depthPixelShader = { name: name, shader: shader };
  130099. /***/ }),
  130100. /***/ "./Shaders/depth.vertex.ts":
  130101. /*!*********************************!*\
  130102. !*** ./Shaders/depth.vertex.ts ***!
  130103. \*********************************/
  130104. /*! exports provided: depthVertexShader */
  130105. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130106. "use strict";
  130107. __webpack_require__.r(__webpack_exports__);
  130108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  130109. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130110. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130111. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130112. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130113. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130114. var name = 'depthVertexShader';
  130115. var shader = "\nattribute vec3 position;\n#include<bonesDeclaration>\n\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;\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}";
  130116. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130117. /** @hidden */
  130118. var depthVertexShader = { name: name, shader: shader };
  130119. /***/ }),
  130120. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  130121. /*!******************************************!*\
  130122. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  130123. \******************************************/
  130124. /*! exports provided: depthBoxBlurPixelShader */
  130125. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130126. "use strict";
  130127. __webpack_require__.r(__webpack_exports__);
  130128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  130129. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130130. var name = 'depthBoxBlurPixelShader';
  130131. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\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}";
  130132. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130133. /** @hidden */
  130134. var depthBoxBlurPixelShader = { name: name, shader: shader };
  130135. /***/ }),
  130136. /***/ "./Shaders/depthOfField.fragment.ts":
  130137. /*!******************************************!*\
  130138. !*** ./Shaders/depthOfField.fragment.ts ***!
  130139. \******************************************/
  130140. /*! exports provided: depthOfFieldPixelShader */
  130141. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130142. "use strict";
  130143. __webpack_require__.r(__webpack_exports__);
  130144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  130145. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130146. var name = 'depthOfFieldPixelShader';
  130147. var shader = "\n\n\n\n\nuniform sampler2D textureSampler;\nuniform sampler2D highlightsSampler;\nuniform sampler2D depthSampler;\nuniform sampler2D grainSampler;\n\nuniform float grain_amount;\nuniform bool blur_noise;\nuniform float screen_width;\nuniform float screen_height;\nuniform float distortion;\nuniform bool dof_enabled;\n\nuniform float screen_distance;\nuniform float aperture;\nuniform float darken;\nuniform float edge_blur;\nuniform bool highlights;\n\nuniform float near;\nuniform float far;\n\nvarying vec2 vUV;\n\n#define PI 3.14159265\n#define TWOPI 6.28318530\n#define inverse_focal_length 0.1\n\nvec2 centered_screen_pos;\nvec2 distorted_coords;\nfloat radius2;\nfloat radius;\n\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}\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}\n\nfloat sampleScreen(inout vec4 color,const in vec2 offset,const in float weight) {\n\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}\n\nfloat getBlurLevel(float size) {\nreturn min(3.0,ceil(size/1.0));\n}\n\nvec4 getBlurColor(float size) {\nvec4 col=texture2D(textureSampler,distorted_coords);\nif (size == 0.0) { return col; }\n\n\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;\n\nif (darken>0.0) {\ncol.rgb*=clamp(0.3,1.0,1.05-size*0.5*darken);\n}\n\n\n\n\nreturn col;\n}\nvoid main(void)\n{\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);\n\n\nfloat coc=abs(aperture*(screen_distance*(inverse_focal_length-1.0/distance)-1.0));\n\nif (dof_enabled == false || coc<0.07) { coc=0.0; }\n\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}\n\nfloat blur_amount=max(edge_blur_amount,coc);\n\nif (blur_amount == 0.0) {\ngl_FragColor=texture2D(textureSampler,distorted_coords);\n}\nelse {\n\ngl_FragColor=getBlurColor(blur_amount*1.7);\n\nif (highlights) {\ngl_FragColor.rgb+=clamp(coc,0.0,1.0)*texture2D(highlightsSampler,distorted_coords).rgb;\n}\nif (blur_noise) {\n\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}\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";
  130148. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130149. /** @hidden */
  130150. var depthOfFieldPixelShader = { name: name, shader: shader };
  130151. /***/ }),
  130152. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  130153. /*!***********************************************!*\
  130154. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  130155. \***********************************************/
  130156. /*! exports provided: depthOfFieldMergePixelShader */
  130157. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130158. "use strict";
  130159. __webpack_require__.r(__webpack_exports__);
  130160. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  130161. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130162. var name = 'depthOfFieldMergePixelShader';
  130163. var shader = "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\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";
  130164. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130165. /** @hidden */
  130166. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  130167. /***/ }),
  130168. /***/ "./Shaders/displayPass.fragment.ts":
  130169. /*!*****************************************!*\
  130170. !*** ./Shaders/displayPass.fragment.ts ***!
  130171. \*****************************************/
  130172. /*! exports provided: displayPassPixelShader */
  130173. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130174. "use strict";
  130175. __webpack_require__.r(__webpack_exports__);
  130176. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  130177. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130178. var name = 'displayPassPixelShader';
  130179. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  130180. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130181. /** @hidden */
  130182. var displayPassPixelShader = { name: name, shader: shader };
  130183. /***/ }),
  130184. /***/ "./Shaders/extractHighlights.fragment.ts":
  130185. /*!***********************************************!*\
  130186. !*** ./Shaders/extractHighlights.fragment.ts ***!
  130187. \***********************************************/
  130188. /*! exports provided: extractHighlightsPixelShader */
  130189. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130190. "use strict";
  130191. __webpack_require__.r(__webpack_exports__);
  130192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  130193. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130194. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130195. var name = 'extractHighlightsPixelShader';
  130196. var shader = "#include<helperFunctions>\n\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float threshold;\nuniform float exposure;\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}";
  130197. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130198. /** @hidden */
  130199. var extractHighlightsPixelShader = { name: name, shader: shader };
  130200. /***/ }),
  130201. /***/ "./Shaders/filter.fragment.ts":
  130202. /*!************************************!*\
  130203. !*** ./Shaders/filter.fragment.ts ***!
  130204. \************************************/
  130205. /*! exports provided: filterPixelShader */
  130206. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130207. "use strict";
  130208. __webpack_require__.r(__webpack_exports__);
  130209. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterPixelShader", function() { return filterPixelShader; });
  130210. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130211. var name = 'filterPixelShader';
  130212. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform mat4 kernelMatrix;\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}";
  130213. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130214. /** @hidden */
  130215. var filterPixelShader = { name: name, shader: shader };
  130216. /***/ }),
  130217. /***/ "./Shaders/fxaa.fragment.ts":
  130218. /*!**********************************!*\
  130219. !*** ./Shaders/fxaa.fragment.ts ***!
  130220. \**********************************/
  130221. /*! exports provided: fxaaPixelShader */
  130222. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130223. "use strict";
  130224. __webpack_require__.r(__webpack_exports__);
  130225. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  130226. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130227. var name = 'fxaaPixelShader';
  130228. var shader = "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}";
  130229. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130230. /** @hidden */
  130231. var fxaaPixelShader = { name: name, shader: shader };
  130232. /***/ }),
  130233. /***/ "./Shaders/fxaa.vertex.ts":
  130234. /*!********************************!*\
  130235. !*** ./Shaders/fxaa.vertex.ts ***!
  130236. \********************************/
  130237. /*! exports provided: fxaaVertexShader */
  130238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130239. "use strict";
  130240. __webpack_require__.r(__webpack_exports__);
  130241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  130242. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130243. var name = 'fxaaVertexShader';
  130244. var shader = "\nattribute vec2 position;\nuniform vec2 texelSize;\n\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);\nvoid main(void) {\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}";
  130245. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130246. /** @hidden */
  130247. var fxaaVertexShader = { name: name, shader: shader };
  130248. /***/ }),
  130249. /***/ "./Shaders/geometry.fragment.ts":
  130250. /*!**************************************!*\
  130251. !*** ./Shaders/geometry.fragment.ts ***!
  130252. \**************************************/
  130253. /*! exports provided: geometryPixelShader */
  130254. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130255. "use strict";
  130256. __webpack_require__.r(__webpack_exports__);
  130257. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  130258. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130259. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  130260. var name = 'geometryPixelShader';
  130261. var shader = "#extension GL_EXT_draw_buffers : require\nprecision highp float;\nprecision highp int;\nvarying vec3 vNormalV;\nvarying vec4 vViewPos;\n#ifdef POSITION\nvarying vec3 vPosition;\n#endif\n#ifdef VELOCITY\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include<mrtFragmentDeclaration>[RENDER_TARGET_COUNT]\nvoid main() {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\n\ngl_FragData[1]=vec4(normalize(vNormalV),1.0);\n\n#ifdef POSITION\ngl_FragData[POSITION_INDEX]=vec4(vPosition,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=(a-b)*0.5+0.5;\nvelocity*=0.5+0.5;\nvelocity=vec2(pow(velocity.x,3.0),pow(velocity.y,3.0));\ngl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n}";
  130262. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130263. /** @hidden */
  130264. var geometryPixelShader = { name: name, shader: shader };
  130265. /***/ }),
  130266. /***/ "./Shaders/geometry.vertex.ts":
  130267. /*!************************************!*\
  130268. !*** ./Shaders/geometry.vertex.ts ***!
  130269. \************************************/
  130270. /*! exports provided: geometryVertexShader */
  130271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130272. "use strict";
  130273. __webpack_require__.r(__webpack_exports__);
  130274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  130275. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130276. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130277. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130278. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130279. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130280. var name = 'geometryVertexShader';
  130281. var shader = "precision highp float;\nprecision highp int;\n#include<bonesDeclaration>\n#include<instancesDeclaration>\nattribute vec3 position;\nattribute vec3 normal;\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\nuniform mat4 viewProjection;\nuniform mat4 view;\nvarying vec3 vNormalV;\nvarying vec4 vViewPos;\n#ifdef POSITION\nvarying vec3 vPosition;\n#endif\n#ifdef VELOCITY\nuniform mat4 previousWorldViewProjection;\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 pos=vec4(finalWorld*vec4(position,1.0));\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normal,0.0)));\nvViewPos=view*pos;\n#ifdef POSITION\nvPosition=pos.xyz/pos.w;\n#endif\n#ifdef VELOCITY\nvCurrentPosition=viewProjection*finalWorld*vec4(position,1.0);\nvPreviousPosition=previousWorldViewProjection*vec4(position,1.0);\n#endif\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}";
  130282. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130283. /** @hidden */
  130284. var geometryVertexShader = { name: name, shader: shader };
  130285. /***/ }),
  130286. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  130287. /*!*************************************************!*\
  130288. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  130289. \*************************************************/
  130290. /*! exports provided: glowBlurPostProcessPixelShader */
  130291. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130292. "use strict";
  130293. __webpack_require__.r(__webpack_exports__);
  130294. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  130295. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130296. var name = 'glowBlurPostProcessPixelShader';
  130297. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nuniform vec2 direction;\nuniform float blurWidth;\n\nfloat getLuminance(vec3 color)\n{\nreturn dot(color,vec3(0.2126,0.7152,0.0722));\n}\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{\n\nvec4 texel=texture2D(textureSampler,start+texelOffset);\nbaseColor.a+=texel.a*weights[i];\n\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}";
  130298. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130299. /** @hidden */
  130300. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  130301. /***/ }),
  130302. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  130303. /*!***********************************************!*\
  130304. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  130305. \***********************************************/
  130306. /*! exports provided: glowMapGenerationPixelShader */
  130307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130308. "use strict";
  130309. __webpack_require__.r(__webpack_exports__);
  130310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  130311. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130312. var name = 'glowMapGenerationPixelShader';
  130313. var shader = "#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\nuniform vec4 color;\nvoid main(void)\n{\nvec4 finalColor=color;\n\n#ifdef DIFFUSE\nvec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);\nfinalColor.a*=albedoTexture.a;\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\ngl_FragColor=texture2D(emissiveSampler,vUVEmissive)*finalColor;\n#else\ngl_FragColor=finalColor;\n#endif\n#ifdef GLOW\ngl_FragColor.rgb*=gl_FragColor.a;\ngl_FragColor.a=1.0;\n#endif\n}";
  130314. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130315. /** @hidden */
  130316. var glowMapGenerationPixelShader = { name: name, shader: shader };
  130317. /***/ }),
  130318. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  130319. /*!*********************************************!*\
  130320. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  130321. \*********************************************/
  130322. /*! exports provided: glowMapGenerationVertexShader */
  130323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130324. "use strict";
  130325. __webpack_require__.r(__webpack_exports__);
  130326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  130327. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130328. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130329. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  130330. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  130331. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130332. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  130333. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130334. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130335. var name = 'glowMapGenerationVertexShader';
  130336. var shader = "\nattribute vec3 position;\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n\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\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\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(uv,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(uv,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(uv,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}";
  130337. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130338. /** @hidden */
  130339. var glowMapGenerationVertexShader = { name: name, shader: shader };
  130340. /***/ }),
  130341. /***/ "./Shaders/glowMapMerge.fragment.ts":
  130342. /*!******************************************!*\
  130343. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  130344. \******************************************/
  130345. /*! exports provided: glowMapMergePixelShader */
  130346. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130347. "use strict";
  130348. __webpack_require__.r(__webpack_exports__);
  130349. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  130350. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130351. var name = 'glowMapMergePixelShader';
  130352. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#ifdef EMISSIVE\nuniform sampler2D textureSampler2;\n#endif\n\nuniform float offset;\nvoid main(void) {\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\ngl_FragColor=baseColor;\n}";
  130353. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130354. /** @hidden */
  130355. var glowMapMergePixelShader = { name: name, shader: shader };
  130356. /***/ }),
  130357. /***/ "./Shaders/glowMapMerge.vertex.ts":
  130358. /*!****************************************!*\
  130359. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  130360. \****************************************/
  130361. /*! exports provided: glowMapMergeVertexShader */
  130362. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130363. "use strict";
  130364. __webpack_require__.r(__webpack_exports__);
  130365. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  130366. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130367. var name = 'glowMapMergeVertexShader';
  130368. var shader = "\nattribute vec2 position;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n}";
  130369. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130370. /** @hidden */
  130371. var glowMapMergeVertexShader = { name: name, shader: shader };
  130372. /***/ }),
  130373. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  130374. /*!************************************************!*\
  130375. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  130376. \************************************************/
  130377. /*! exports provided: gpuRenderParticlesPixelShader */
  130378. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130379. "use strict";
  130380. __webpack_require__.r(__webpack_exports__);
  130381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  130382. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130383. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  130384. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  130385. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130386. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  130387. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  130388. var name = 'gpuRenderParticlesPixelShader';
  130389. var shader = "#version 300 es\nuniform sampler2D textureSampler;\nin vec2 vUV;\nin vec4 vColor;\nout vec4 outFragColor;\n#include<clipPlaneFragmentDeclaration2>\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\nvoid main() {\n#include<clipPlaneFragment>\nvec4 textureColor=texture(textureSampler,vUV);\noutFragColor=textureColor*vColor;\n#ifdef BLENDMULTIPLYMODE\nfloat alpha=vColor.a*textureColor.a;\noutFragColor.rgb=outFragColor.rgb*alpha+vec3(1.0)*(1.0-alpha);\n#endif\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\noutFragColor.rgb=toLinearSpace(outFragColor.rgb);\n#else\n#ifdef IMAGEPROCESSING\noutFragColor.rgb=toLinearSpace(outFragColor.rgb);\noutFragColor=applyImageProcessing(outFragColor);\n#endif\n#endif\n}\n";
  130390. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130391. /** @hidden */
  130392. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  130393. /***/ }),
  130394. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  130395. /*!**********************************************!*\
  130396. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  130397. \**********************************************/
  130398. /*! exports provided: gpuRenderParticlesVertexShader */
  130399. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130400. "use strict";
  130401. __webpack_require__.r(__webpack_exports__);
  130402. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  130403. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130404. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  130405. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  130406. var name = 'gpuRenderParticlesVertexShader';
  130407. var shader = "#version 300 es\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\nuniform vec3 worldOffset;\n\nin vec3 position;\nin float age;\nin float life;\nin vec3 size;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef BILLBOARDSTRETCHED\nin vec3 direction;\n#endif\nin float angle;\n#ifdef ANIMATESHEET\nin float cellIndex;\n#endif\nin vec2 offset;\nin vec2 uv;\nout vec2 vUV;\nout vec4 vColor;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration2>\n#ifdef COLORGRADIENTS\nuniform sampler2D colorGradientSampler;\n#else\nuniform vec4 colorDead;\nin 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;\nreturn (position+worldOffset)+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+worldOffset)+alignedCorner;\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=texture(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.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,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;\nvec3 worldPos=rotateAlign(toCamera,rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#else\n\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nvec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;\n#endif\n#else\n\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);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\n\nvec4 viewPosition=view*vec4(worldPos,1.0);\n#endif\ngl_Position=projection*viewPosition;\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*viewPosition;\n#endif\n#include<clipPlaneVertex>\n}";
  130408. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130409. /** @hidden */
  130410. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  130411. /***/ }),
  130412. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  130413. /*!************************************************!*\
  130414. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  130415. \************************************************/
  130416. /*! exports provided: gpuUpdateParticlesPixelShader */
  130417. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130418. "use strict";
  130419. __webpack_require__.r(__webpack_exports__);
  130420. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  130421. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130422. var name = 'gpuUpdateParticlesPixelShader';
  130423. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  130424. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130425. /** @hidden */
  130426. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  130427. /***/ }),
  130428. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  130429. /*!**********************************************!*\
  130430. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  130431. \**********************************************/
  130432. /*! exports provided: gpuUpdateParticlesVertexShader */
  130433. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130434. "use strict";
  130435. __webpack_require__.r(__webpack_exports__);
  130436. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  130437. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130438. var name = 'gpuUpdateParticlesVertexShader';
  130439. var shader = "#version 300 es\n#define PI 3.14159\nuniform float currentCount;\nuniform float timeDelta;\nuniform float stopFactor;\nuniform mat4 emitterWM;\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\n\nin vec3 position;\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\n\nout vec3 outPosition;\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 vec3 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;\n\nif (newAge>=life && stopFactor != 0.) {\nvec3 position;\nvec3 direction;\n\nvec4 randoms=getRandomVec4(seed.x);\n\noutLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;\noutAge=mod(newAge,outLife);\n\noutSeed=seed;\n\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\n\noutColor=color1+(color2-color1)*randoms.b;\n#endif\n\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\n#ifdef POINTEMITTER\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nposition=vec3(0,0,0);\ndirection=direction1+(direction2-direction1)*randoms3;\n#elif defined(BOXEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nposition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;\ndirection=direction1+(direction2-direction1)*randoms3;\n#elif defined(HEMISPHERICEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\n\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);\nposition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);\ndirection=position+directionRandomizer*randoms3;\n#elif defined(SPHEREEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\n\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);\nposition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ);\n#ifdef DIRECTEDSPHEREEMITTER\ndirection=direction1+(direction2-direction1)*randoms3;\n#else\n\ndirection=position+directionRandomizer*randoms3;\n#endif\n#elif defined(CYLINDEREMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\n\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);\nposition=vec3(xPos,yPos,zPos);\n#ifdef DIRECTEDCYLINDEREMITTER\ndirection=direction1+(direction2-direction1)*randoms3;\n#else\n\nangle=angle+((randoms3.x-0.5)*PI);\ndirection=vec3(cos(angle),randoms3.y-0.5,sin(angle));\ndirection=normalize(direction);\n#endif\n#elif defined(CONEEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nfloat s=2.0*PI*randoms2.x;\n#ifdef CONEEMITTERSPAWNPOINT\nfloat h=0.00001;\n#else\nfloat h=randoms2.y*height.y;\n\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;\nposition=vec3(randX,randY,randZ);\n\nif (abs(cos(coneAngle)) == 1.0) {\ndirection=vec3(0.,1.0,0.);\n} else {\nvec3 randoms3=getRandomVec3(seed.z);\ndirection=position+directionRandomizer*randoms3;\n}\n#else\n\nposition=vec3(0.,0.,0.);\n\ndirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5));\n#endif\nfloat power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a;\noutPosition=(emitterWM*vec4(position,1.)).xyz;\nvec3 initial=(emitterWM*vec4(direction,0.)).xyz;\noutDirection=initial*power;\n#ifndef BILLBOARD\noutInitialDirection=initial;\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\noutPosition=position+direction*directionScale;\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\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\nvec3 localPosition=outPosition-emitterWM[3].xyz;\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#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#endif\nfloat ratio=clamp(mod(offsetAge*cellInfos.z,life)/life,0.,1.0);\noutCellIndex=float(int(cellInfos.x+ratio*dist));\n#endif\n}\n}";
  130440. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130441. /** @hidden */
  130442. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  130443. /***/ }),
  130444. /***/ "./Shaders/grain.fragment.ts":
  130445. /*!***********************************!*\
  130446. !*** ./Shaders/grain.fragment.ts ***!
  130447. \***********************************/
  130448. /*! exports provided: grainPixelShader */
  130449. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130450. "use strict";
  130451. __webpack_require__.r(__webpack_exports__);
  130452. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  130453. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130454. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130455. var name = 'grainPixelShader';
  130456. var shader = "#include<helperFunctions>\n\nuniform sampler2D textureSampler;\n\nuniform float intensity;\nuniform float animatedSeed;\n\nvarying vec2 vUV;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\nvec2 seed=vUV*(animatedSeed);\nfloat grain=dither(seed,intensity);\n\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}";
  130457. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130458. /** @hidden */
  130459. var grainPixelShader = { name: name, shader: shader };
  130460. /***/ }),
  130461. /***/ "./Shaders/highlights.fragment.ts":
  130462. /*!****************************************!*\
  130463. !*** ./Shaders/highlights.fragment.ts ***!
  130464. \****************************************/
  130465. /*! exports provided: highlightsPixelShader */
  130466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130467. "use strict";
  130468. __webpack_require__.r(__webpack_exports__);
  130469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  130470. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130471. var name = 'highlightsPixelShader';
  130472. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nconst vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);\nvoid main(void)\n{\nvec4 tex=texture2D(textureSampler,vUV);\nvec3 c=tex.rgb;\nfloat luma=dot(c.rgb,RGBLuminanceCoefficients);\n\n\ngl_FragColor=vec4(pow(c,vec3(25.0-luma*15.0)),tex.a);\n}";
  130473. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130474. /** @hidden */
  130475. var highlightsPixelShader = { name: name, shader: shader };
  130476. /***/ }),
  130477. /***/ "./Shaders/imageProcessing.fragment.ts":
  130478. /*!*********************************************!*\
  130479. !*** ./Shaders/imageProcessing.fragment.ts ***!
  130480. \*********************************************/
  130481. /*! exports provided: imageProcessingPixelShader */
  130482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130483. "use strict";
  130484. __webpack_require__.r(__webpack_exports__);
  130485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  130486. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130487. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  130488. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130489. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  130490. var name = 'imageProcessingPixelShader';
  130491. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\nvoid main(void)\n{\nvec4 result=texture2D(textureSampler,vUV);\n#ifdef IMAGEPROCESSING\n#ifndef FROMLINEARSPACE\n\nresult.rgb=toLinearSpace(result.rgb);\n#endif\nresult=applyImageProcessing(result);\n#else\n\n#ifdef FROMLINEARSPACE\nresult=applyImageProcessing(result);\n#endif\n#endif\ngl_FragColor=result;\n}";
  130492. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130493. /** @hidden */
  130494. var imageProcessingPixelShader = { name: name, shader: shader };
  130495. /***/ }),
  130496. /***/ "./Shaders/kernelBlur.fragment.ts":
  130497. /*!****************************************!*\
  130498. !*** ./Shaders/kernelBlur.fragment.ts ***!
  130499. \****************************************/
  130500. /*! exports provided: kernelBlurPixelShader */
  130501. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130502. "use strict";
  130503. __webpack_require__.r(__webpack_exports__);
  130504. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  130505. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130506. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  130507. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  130508. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  130509. var name = 'kernelBlurPixelShader';
  130510. var shader = "\nuniform sampler2D textureSampler;\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#ifdef DOF\nuniform sampler2D circleOfConfusionSampler;\nuniform vec2 cameraMinMaxZ;\nfloat sampleDistance(const in vec2 offset) {\nfloat depth=texture2D(circleOfConfusionSampler,offset).g;\nreturn cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth;\n}\nfloat sampleCoC(const in vec2 offset) {\nfloat coc=texture2D(circleOfConfusionSampler,offset).r;\nreturn coc;\n}\n#endif\n#include<kernelBlurVaryingDeclaration>[0..varyingCount]\n#ifdef PACKEDFLOAT\nvec4 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}\n#endif\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\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}";
  130511. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130512. /** @hidden */
  130513. var kernelBlurPixelShader = { name: name, shader: shader };
  130514. /***/ }),
  130515. /***/ "./Shaders/kernelBlur.vertex.ts":
  130516. /*!**************************************!*\
  130517. !*** ./Shaders/kernelBlur.vertex.ts ***!
  130518. \**************************************/
  130519. /*! exports provided: kernelBlurVertexShader */
  130520. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130521. "use strict";
  130522. __webpack_require__.r(__webpack_exports__);
  130523. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  130524. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130525. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  130526. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  130527. var name = 'kernelBlurVertexShader';
  130528. var shader = "\nattribute vec2 position;\n\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#include<kernelBlurVaryingDeclaration>[0..varyingCount]\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nsampleCenter=(position*madd+madd);\n#include<kernelBlurVertex>[0..varyingCount]\ngl_Position=vec4(position,0.0,1.0);\n}";
  130529. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130530. /** @hidden */
  130531. var kernelBlurVertexShader = { name: name, shader: shader };
  130532. /***/ }),
  130533. /***/ "./Shaders/layer.fragment.ts":
  130534. /*!***********************************!*\
  130535. !*** ./Shaders/layer.fragment.ts ***!
  130536. \***********************************/
  130537. /*! exports provided: layerPixelShader */
  130538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130539. "use strict";
  130540. __webpack_require__.r(__webpack_exports__);
  130541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  130542. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130543. var name = 'layerPixelShader';
  130544. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=baseColor*color;\n}";
  130545. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130546. /** @hidden */
  130547. var layerPixelShader = { name: name, shader: shader };
  130548. /***/ }),
  130549. /***/ "./Shaders/layer.vertex.ts":
  130550. /*!*********************************!*\
  130551. !*** ./Shaders/layer.vertex.ts ***!
  130552. \*********************************/
  130553. /*! exports provided: layerVertexShader */
  130554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130555. "use strict";
  130556. __webpack_require__.r(__webpack_exports__);
  130557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  130558. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130559. var name = 'layerVertexShader';
  130560. var shader = "\nattribute vec2 position;\n\nuniform vec2 scale;\nuniform vec2 offset;\nuniform mat4 textureMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\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}";
  130561. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130562. /** @hidden */
  130563. var layerVertexShader = { name: name, shader: shader };
  130564. /***/ }),
  130565. /***/ "./Shaders/lensFlare.fragment.ts":
  130566. /*!***************************************!*\
  130567. !*** ./Shaders/lensFlare.fragment.ts ***!
  130568. \***************************************/
  130569. /*! exports provided: lensFlarePixelShader */
  130570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130571. "use strict";
  130572. __webpack_require__.r(__webpack_exports__);
  130573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  130574. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130575. var name = 'lensFlarePixelShader';
  130576. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\ngl_FragColor=baseColor*color;\n}";
  130577. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130578. /** @hidden */
  130579. var lensFlarePixelShader = { name: name, shader: shader };
  130580. /***/ }),
  130581. /***/ "./Shaders/lensFlare.vertex.ts":
  130582. /*!*************************************!*\
  130583. !*** ./Shaders/lensFlare.vertex.ts ***!
  130584. \*************************************/
  130585. /*! exports provided: lensFlareVertexShader */
  130586. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130587. "use strict";
  130588. __webpack_require__.r(__webpack_exports__);
  130589. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  130590. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130591. var name = 'lensFlareVertexShader';
  130592. var shader = "\nattribute vec2 position;\n\nuniform mat4 viewportMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=position*madd+madd;\ngl_Position=viewportMatrix*vec4(position,0.0,1.0);\n}";
  130593. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130594. /** @hidden */
  130595. var lensFlareVertexShader = { name: name, shader: shader };
  130596. /***/ }),
  130597. /***/ "./Shaders/lensHighlights.fragment.ts":
  130598. /*!********************************************!*\
  130599. !*** ./Shaders/lensHighlights.fragment.ts ***!
  130600. \********************************************/
  130601. /*! exports provided: lensHighlightsPixelShader */
  130602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130603. "use strict";
  130604. __webpack_require__.r(__webpack_exports__);
  130605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  130606. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130607. var name = 'lensHighlightsPixelShader';
  130608. var shader = "\nuniform sampler2D textureSampler;\n\nuniform float gain;\nuniform float threshold;\nuniform float screen_width;\nuniform float screen_height;\n\nvarying vec2 vUV;\n\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}\nvoid main(void)\n{\nvec4 original=texture2D(textureSampler,vUV);\n\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;\n\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\n}";
  130609. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130610. /** @hidden */
  130611. var lensHighlightsPixelShader = { name: name, shader: shader };
  130612. /***/ }),
  130613. /***/ "./Shaders/line.fragment.ts":
  130614. /*!**********************************!*\
  130615. !*** ./Shaders/line.fragment.ts ***!
  130616. \**********************************/
  130617. /*! exports provided: linePixelShader */
  130618. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130619. "use strict";
  130620. __webpack_require__.r(__webpack_exports__);
  130621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  130622. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130623. var name = 'linePixelShader';
  130624. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  130625. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130626. /** @hidden */
  130627. var linePixelShader = { name: name, shader: shader };
  130628. /***/ }),
  130629. /***/ "./Shaders/line.vertex.ts":
  130630. /*!********************************!*\
  130631. !*** ./Shaders/line.vertex.ts ***!
  130632. \********************************/
  130633. /*! exports provided: lineVertexShader */
  130634. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130635. "use strict";
  130636. __webpack_require__.r(__webpack_exports__);
  130637. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  130638. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130639. var name = 'lineVertexShader';
  130640. var shader = "\nattribute vec3 position;\nattribute vec4 normal;\n\nuniform mat4 worldViewProjection;\nuniform float width;\nuniform float aspectRatio;\nvoid main(void) {\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}";
  130641. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130642. /** @hidden */
  130643. var lineVertexShader = { name: name, shader: shader };
  130644. /***/ }),
  130645. /***/ "./Shaders/motionBlur.fragment.ts":
  130646. /*!****************************************!*\
  130647. !*** ./Shaders/motionBlur.fragment.ts ***!
  130648. \****************************************/
  130649. /*! exports provided: motionBlurPixelShader */
  130650. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130651. "use strict";
  130652. __webpack_require__.r(__webpack_exports__);
  130653. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  130654. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130655. var name = 'motionBlurPixelShader';
  130656. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D velocitySampler;\nuniform float motionStrength;\nuniform float motionScale;\nuniform vec2 screenSize;\nvoid main(void)\n{\n#ifdef GEOMETRY_SUPPORTED\nvec2 texelSize=1.0/screenSize;\nvec2 velocityColor=texture2D(velocitySampler,vUV).rg;\nvec2 velocity=vec2(pow(velocityColor.r,1.0/3.0),pow(velocityColor.g,1.0/3.0))*2.0-1.0;\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);\n#else\ngl_FragColor=texture2D(textureSampler,vUV);\n#endif\n}\n";
  130657. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130658. /** @hidden */
  130659. var motionBlurPixelShader = { name: name, shader: shader };
  130660. /***/ }),
  130661. /***/ "./Shaders/noise.fragment.ts":
  130662. /*!***********************************!*\
  130663. !*** ./Shaders/noise.fragment.ts ***!
  130664. \***********************************/
  130665. /*! exports provided: noisePixelShader */
  130666. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130667. "use strict";
  130668. __webpack_require__.r(__webpack_exports__);
  130669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  130670. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130671. var name = 'noisePixelShader';
  130672. var shader = "\n\nuniform float brightness;\nuniform float persistence;\nuniform float timeScale;\n\nvarying vec2 vUV;\n\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\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";
  130673. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130674. /** @hidden */
  130675. var noisePixelShader = { name: name, shader: shader };
  130676. /***/ }),
  130677. /***/ "./Shaders/outline.fragment.ts":
  130678. /*!*************************************!*\
  130679. !*** ./Shaders/outline.fragment.ts ***!
  130680. \*************************************/
  130681. /*! exports provided: outlinePixelShader */
  130682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130683. "use strict";
  130684. __webpack_require__.r(__webpack_exports__);
  130685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  130686. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130687. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  130688. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  130689. var name = 'outlinePixelShader';
  130690. var shader = "#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<logDepthDeclaration>\nvoid main(void) {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#include<logDepthFragment>\ngl_FragColor=color;\n}";
  130691. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130692. /** @hidden */
  130693. var outlinePixelShader = { name: name, shader: shader };
  130694. /***/ }),
  130695. /***/ "./Shaders/outline.vertex.ts":
  130696. /*!***********************************!*\
  130697. !*** ./Shaders/outline.vertex.ts ***!
  130698. \***********************************/
  130699. /*! exports provided: outlineVertexShader */
  130700. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130701. "use strict";
  130702. __webpack_require__.r(__webpack_exports__);
  130703. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  130704. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130705. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130706. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130707. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  130708. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130709. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130710. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  130711. var name = 'outlineVertexShader';
  130712. var shader = "\nattribute vec3 position;\nattribute vec3 normal;\n#include<bonesDeclaration>\n\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>\nvoid main(void)\n{\nvec3 offsetPosition=position+normal*offset;\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(offsetPosition,1.0);\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include<logDepthVertex>\n}\n";
  130713. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130714. /** @hidden */
  130715. var outlineVertexShader = { name: name, shader: shader };
  130716. /***/ }),
  130717. /***/ "./Shaders/particles.fragment.ts":
  130718. /*!***************************************!*\
  130719. !*** ./Shaders/particles.fragment.ts ***!
  130720. \***************************************/
  130721. /*! exports provided: particlesPixelShader */
  130722. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130723. "use strict";
  130724. __webpack_require__.r(__webpack_exports__);
  130725. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  130726. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130727. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  130728. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  130729. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130730. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  130731. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  130732. var name = 'particlesPixelShader';
  130733. var shader = "\nvarying 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\nvoid main(void) {\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;\n\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\n\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}";
  130734. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130735. /** @hidden */
  130736. var particlesPixelShader = { name: name, shader: shader };
  130737. /***/ }),
  130738. /***/ "./Shaders/particles.vertex.ts":
  130739. /*!*************************************!*\
  130740. !*** ./Shaders/particles.vertex.ts ***!
  130741. \*************************************/
  130742. /*! exports provided: particlesVertexShader */
  130743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130744. "use strict";
  130745. __webpack_require__.r(__webpack_exports__);
  130746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  130747. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130748. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  130749. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  130750. var name = 'particlesVertexShader';
  130751. var shader = "\nattribute 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;\n\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\n#ifdef ANIMATESHEET\nuniform vec3 particlesInfos;\n#endif\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\n#endif\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\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\nvoid main(void) {\nvec2 cornerPos;\ncornerPos=(vec2(offset.x-0.5,offset.y-0.5)-translationPivot)*size+translationPivot;\n#ifdef BILLBOARD\n\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.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner);\nvec3 viewPos=(view*vec4(worldPos,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;\nvec3 worldPos=rotateAlign(toCamera,rotatedCorner);\nvec3 viewPos=(view*vec4(worldPos,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;\n#endif\n#ifdef RAMPGRADIENT\nremapRanges=remapData;\n#endif\n\ngl_Position=projection*vec4(viewPos,1.0);\n#else\n\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);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\ngl_Position=projection*view*vec4(worldPos,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\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*vec4(viewPos,1.0);\n#endif\n#include<clipPlaneVertex>\n}";
  130752. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130753. /** @hidden */
  130754. var particlesVertexShader = { name: name, shader: shader };
  130755. /***/ }),
  130756. /***/ "./Shaders/pass.fragment.ts":
  130757. /*!**********************************!*\
  130758. !*** ./Shaders/pass.fragment.ts ***!
  130759. \**********************************/
  130760. /*! exports provided: passPixelShader */
  130761. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130762. "use strict";
  130763. __webpack_require__.r(__webpack_exports__);
  130764. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  130765. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130766. var name = 'passPixelShader';
  130767. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  130768. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130769. /** @hidden */
  130770. var passPixelShader = { name: name, shader: shader };
  130771. /***/ }),
  130772. /***/ "./Shaders/passCube.fragment.ts":
  130773. /*!**************************************!*\
  130774. !*** ./Shaders/passCube.fragment.ts ***!
  130775. \**************************************/
  130776. /*! exports provided: passCubePixelShader */
  130777. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130778. "use strict";
  130779. __webpack_require__.r(__webpack_exports__);
  130780. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  130781. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130782. var name = 'passCubePixelShader';
  130783. var shader = "\nvarying vec2 vUV;\nuniform samplerCube textureSampler;\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}";
  130784. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130785. /** @hidden */
  130786. var passCubePixelShader = { name: name, shader: shader };
  130787. /***/ }),
  130788. /***/ "./Shaders/pbr.fragment.ts":
  130789. /*!*********************************!*\
  130790. !*** ./Shaders/pbr.fragment.ts ***!
  130791. \*********************************/
  130792. /*! exports provided: pbrPixelShader */
  130793. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130794. "use strict";
  130795. __webpack_require__.r(__webpack_exports__);
  130796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  130797. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130798. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  130799. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  130800. /* harmony import */ var _ShadersInclude_pbrFragmentExtraDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentExtraDeclaration */ "./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts");
  130801. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  130802. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  130803. /* harmony import */ var _ShadersInclude_pbrFragmentSamplersDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentSamplersDeclaration */ "./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts");
  130804. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  130805. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  130806. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  130807. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  130808. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130809. /* harmony import */ var _ShadersInclude_pbrHelperFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrHelperFunctions */ "./Shaders/ShadersInclude/pbrHelperFunctions.ts");
  130810. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  130811. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  130812. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  130813. /* harmony import */ var _ShadersInclude_pbrDirectLightingSetupFunctions__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingSetupFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts");
  130814. /* harmony import */ var _ShadersInclude_pbrDirectLightingFalloffFunctions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingFalloffFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts");
  130815. /* harmony import */ var _ShadersInclude_pbrBRDFFunctions__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/pbrBRDFFunctions */ "./Shaders/ShadersInclude/pbrBRDFFunctions.ts");
  130816. /* harmony import */ var _ShadersInclude_pbrDirectLightingFunctions__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts");
  130817. /* harmony import */ var _ShadersInclude_pbrIBLFunctions__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/pbrIBLFunctions */ "./Shaders/ShadersInclude/pbrIBLFunctions.ts");
  130818. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  130819. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  130820. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  130821. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  130822. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  130823. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  130824. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  130825. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  130826. /* harmony import */ var _ShadersInclude_pbrDebug__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./ShadersInclude/pbrDebug */ "./Shaders/ShadersInclude/pbrDebug.ts");
  130827. var name = 'pbrPixelShader';
  130828. var shader = "#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\nprecision highp float;\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\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\n#include<helperFunctions>\n#include<pbrHelperFunctions>\n#include<imageProcessingFunctions>\n#include<shadowsFragmentFunctions>\n#include<harmonicsFunctions>\n#include<pbrDirectLightingSetupFunctions>\n#include<pbrDirectLightingFalloffFunctions>\n#include<pbrBRDFFunctions>\n#include<pbrDirectLightingFunctions>\n#include<pbrIBLFunctions>\n#include<bumpFragmentFunctions>\n#ifdef REFLECTION\n#include<reflectionFunction>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\n\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\n\nvec3 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\n#ifdef CLEARCOAT\n\nvec3 clearCoatNormalW=normalW;\n#endif\n#include<bumpFragment>\n#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\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALBEDO\n\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\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\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\n#include<depthPrePass>\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n#ifdef REFLECTANCE\n\n\n\n\n\nsurfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);\n#else\n\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#endif\n#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=saturate(microSurface);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\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);\n\nalpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#endif\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\n\nfloat NdotV=absEps(NdotVUnclamped);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);\n#ifdef SPECULARAA\n\nalphaG+=AARoughnessFactors.y;\n#endif\n#ifdef ANISOTROPIC\nfloat anisotropy=vAnisotropy.b;\nvec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);\n#ifdef ANISOTROPIC_TEXTURE\nvec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;\nanisotropy*=anisotropyMapData.b;\nanisotropyDirection.rg*=anisotropyMapData.rg*2.0-1.0;\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));\nvec3 anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy);\n#endif\n\n#ifdef SS_REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 refractionVector=refract(-viewDirectionW,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\n#ifdef SS_REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\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;\n#endif\n#ifdef SS_LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef SS_LODINREFRACTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);\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\n\nenvironmentRefraction.rgb*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicNormal);\n#else\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\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#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD);\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\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\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\n#ifdef ANISOTROPIC\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(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\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance.rgb*=vReflectionInfos.x;\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n\n#ifdef SHEEN\nfloat sheenIntensity=vSheenColor.a;\n#ifdef SHEEN_TEXTURE\nvec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset)*vSheenInfos.y;\nsheenIntensity*=sheenMapData.a;\n#endif\n#ifdef SHEEN_LINKWITHALBEDO\nfloat sheenFactor=pow5(1.0-sheenIntensity);\nvec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);\nfloat sheenRoughness=sheenIntensity;\n\nsurfaceAlbedo.rgb*=sheenFactor;\n#else\nvec3 sheenColor=vSheenColor.rgb;\n#ifdef SHEEN_TEXTURE\nsheenColor.rgb*=toLinearSpace(sheenMapData.rgb);\n#endif\nfloat sheenRoughness=roughness;\n\nsheenIntensity*=(1.-reflectance);\n\nsheenColor*=sheenIntensity;\n#endif\n\n#if defined(REFLECTION)\nfloat sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);\n#ifdef SPECULARAA\n\nsheenAlphaG+=AARoughnessFactors.y;\n#endif\nvec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);\n\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat sheenReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,sheenAlphaG,NdotVUnclamped);\n#else\nfloat sheenReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,sheenAlphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nsheenReflectionLOD=sheenReflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nenvironmentSheenRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,sheenReflectionLOD);\n#else\nfloat lodSheenReflectionNormalized=saturate(sheenReflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodSheenReflectionNormalizedDoubled=lodSheenReflectionNormalized*2.0;\nvec4 environmentSheenMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodSheenReflectionNormalizedDoubled<1.0){\nenvironmentSheenRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSheenMid,\nlodSheenReflectionNormalizedDoubled\n);\n}else{\nenvironmentSheenRadiance=mix(\nenvironmentSheenMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodSheenReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentSheenRadiance.rgb=fromRGBD(environmentSheenRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentSheenRadiance.rgb=toLinearSpace(environmentSheenRadiance.rgb);\n#endif\n\nenvironmentSheenRadiance.rgb*=vReflectionInfos.x;\nenvironmentSheenRadiance.rgb*=vReflectionColor.rgb;\n#endif\n#endif\n\n#ifdef CLEARCOAT\n\nfloat clearCoatIntensity=vClearCoatParams.x;\nfloat clearCoatRoughness=vClearCoatParams.y;\n#ifdef CLEARCOAT_TEXTURE\nvec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;\nclearCoatIntensity*=clearCoatMapData.x;\nclearCoatRoughness*=clearCoatMapData.y;\n#endif\n#ifdef CLEARCOAT_TINT\nvec3 clearCoatColor=vClearCoatTintParams.rgb;\nfloat clearCoatThickness=vClearCoatTintParams.a;\n#ifdef CLEARCOAT_TINT_TEXTURE\nvec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);\nclearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);\nclearCoatThickness*=clearCoatTintMapData.a;\n#endif\nclearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);\n#endif\n\n\n\n\nvec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);\nspecularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);\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\nmat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,vClearCoatBumpUV,vClearCoatTangentSpaceParams);\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nclearCoatNormalW=normalize(texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset).xyz*2.0-1.0);\nclearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);\n#else\nclearCoatNormalW=perturbNormal(TBN,vClearCoatBumpUV+uvOffset,clearCoatBumpSampler,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=gl_FrontFacing ? clearCoatNormalW : -clearCoatNormalW;\n#endif\n\nvec2 clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);\n\nfloat clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);\n\nfloat clearCoatNdotV=absEps(clearCoatNdotVUnclamped);\n\n#if defined(REFLECTION)\nfloat clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\n#ifdef SPECULARAA\n\nclearCoatAlphaG+=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\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\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat clearCoatReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,clearCoatAlphaG,clearCoatNdotVUnclamped);\n#else\nfloat clearCoatReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,clearCoatAlphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nclearCoatReflectionLOD=clearCoatReflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nfloat requestedClearCoatReflectionLOD=clearCoatReflectionLOD;\nenvironmentClearCoatRadiance=sampleReflectionLod(reflectionSampler,clearCoatReflectionCoords,requestedClearCoatReflectionLOD);\n#else\nfloat lodClearCoatReflectionNormalized=saturate(clearCoatReflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodClearCoatReflectionNormalizedDoubled=lodClearCoatReflectionNormalized*2.0;\nvec4 environmentClearCoatMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodClearCoatReflectionNormalizedDoubled<1.0){\nenvironmentClearCoatRadiance=mix(\nsampleReflection(reflectionSamplerHigh,clearCoatReflectionCoords),\nenvironmentClearCoatMid,\nlodClearCoatReflectionNormalizedDoubled\n);\n}else{\nenvironmentClearCoatRadiance=mix(\nenvironmentClearCoatMid,\nsampleReflection(reflectionSamplerLow,clearCoatReflectionCoords),\nlodClearCoatReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentClearCoatRadiance.rgb=fromRGBD(environmentClearCoatRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentClearCoatRadiance.rgb=toLinearSpace(environmentClearCoatRadiance.rgb);\n#endif\n#ifdef CLEARCOAT_TINT\n\nvec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);\n\nfloat clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));\nvec3 absorption=vec3(0.);\n#endif\n\nenvironmentClearCoatRadiance.rgb*=vReflectionInfos.x;\nenvironmentClearCoatRadiance.rgb*=vReflectionColor.rgb;\n#endif\n#endif\n\n#if defined(ENVIRONMENTBRDF)\n\nvec3 environmentBrdf=getBRDFLookup(NdotV,roughness,environmentBrdfSampler);\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nvec3 energyConservationFactor=getEnergyConservationFactor(specularEnvironmentR0,environmentBrdf);\n#endif\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nfloat refractionIntensity=vSubSurfaceIntensity.x;\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nrefractionIntensity*=(1.0-alpha);\n\nalpha=1.0;\n#endif\n#endif\n#ifdef SS_TRANSLUCENCY\nfloat translucencyIntensity=vSubSurfaceIntensity.y;\n#endif\n#ifdef SS_SCATTERING\nfloat scatteringIntensity=vSubSurfaceIntensity.z;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nvec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);\nfloat thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;\n#ifdef SS_MASK_FROM_THICKNESS_TEXTURE\n#ifdef SS_REFRACTION\nrefractionIntensity*=thicknessMap.g;\n#endif\n#ifdef SS_TRANSLUCENCY\ntranslucencyIntensity*=thicknessMap.b;\n#endif\n#ifdef SS_SCATTERING\nscatteringIntensity*=thicknessMap.a;\n#endif\n#endif\n#else\nfloat thickness=vThicknessParam.y;\n#endif\n#ifdef SS_TRANSLUCENCY\nthickness=maxEps(thickness);\nvec3 transmittance=transmittanceBRDF_Burley(vTintColor.rgb,vDiffusionDistance,thickness);\ntransmittance*=translucencyIntensity;\n#endif\n#endif\n\n\nvec3 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\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb;\n#ifdef GAMMALIGHTMAP\nlightmapColor=toLinearSpace(lightmapColor);\n#endif\nlightmapColor*=vLightmapInfos.y;\n#endif\n\npreLightingInfo preInfo;\nlightingInfo info;\nfloat shadow=1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\nvec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(specularEnvironmentR0,environmentBrdf);\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#if defined(SHEEN) && defined(REFLECTION)\nvec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentBrdf);\n#ifdef RADIANCEOCCLUSION\nsheenEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nsheenEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#endif\n\n#ifdef CLEARCOAT\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness,environmentBrdfSampler);\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);\nclearCoatEnvironmentReflectance*=clearCoatEho;\n#endif\n#endif\n#endif\n#else\n\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));\n#endif\nclearCoatEnvironmentReflectance*=clearCoatIntensity;\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatAbsorption(clearCoatNdotVRefract,clearCoatNdotVRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\n#ifdef REFLECTION\nenvironmentIrradiance*=absorption;\n#endif\n#ifdef SHEEN\nsheenEnvironmentReflectance*=absorption;\n#endif\nspecularEnvironmentReflectance*=absorption;\n#endif\n\nfloat fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnelIBLClearCoat*=clearCoatIntensity;\nfloat conservationFactor=(1.-fresnelIBLClearCoat);\n#ifdef REFLECTION\nenvironmentIrradiance*=conservationFactor;\n#endif\n#ifdef SHEEN\nsheenEnvironmentReflectance*=(conservationFactor*conservationFactor);\n#endif\nspecularEnvironmentReflectance*=(conservationFactor*conservationFactor);\n#endif\n\n#ifdef SS_REFRACTION\nvec3 refractionTransmittance=vec3(refractionIntensity);\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nvec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);\n\n\n\n\n\nrefractionTransmittance*=cocaLambert(volumeAlbedo,thickness);\n#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)\n\nfloat maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);\nvec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);\n\nenvironmentRefraction.rgb*=volumeAlbedo;\n#else\n\n#endif\n\nsurfaceAlbedo*=(1.-refractionIntensity);\n\nenvironmentIrradiance*=(1.-refractionIntensity);\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);\n\nrefractionTransmittance*=1.0-specularEnvironmentReflectance;\n#endif\n\n#if defined(REFLECTION) && defined(USESPHERICALFROMREFLECTIONMAP) && defined(SS_TRANSLUCENCY)\n#if defined(USESPHERICALINVERTEX)\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\n#endif\nvec3 refractionIrradiance=environmentIrradianceJones(-irradianceVector);\nrefractionIrradiance*=transmittance;\n#endif\n\n\n\n#ifndef METALLICWORKFLOW\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n#endif\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(SS_TRANSLUCENCY)\nfinalIrradiance+=refractionIrradiance;\n#endif\nfinalIrradiance*=surfaceAlbedo.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\n\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalSpecularScaled*=energyConservationFactor;\n#endif\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance.rgb;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalRadianceScaled*=energyConservationFactor;\n#endif\n#endif\n\n#ifdef SS_REFRACTION\nvec3 finalRefraction=environmentRefraction.rgb;\nfinalRefraction*=refractionTransmittance;\n#endif\n\n#ifdef CLEARCOAT\nvec3 finalClearCoat=clearCoatBase;\nfinalClearCoat=max(finalClearCoat,0.0);\n\nvec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalClearCoatScaled*=energyConservationFactor;\n#endif\n\n#ifdef REFLECTION\nvec3 finalClearCoatRadiance=environmentClearCoatRadiance.rgb;\nfinalClearCoatRadiance*=clearCoatEnvironmentReflectance;\n\nvec3 finalClearCoatRadianceScaled=finalClearCoatRadiance*vLightingIntensity.z;\n#endif\n#ifdef SS_REFRACTION\nfinalRefraction*=(conservationFactor*conservationFactor);\n#ifdef CLEARCOAT_TINT\nfinalRefraction*=absorption;\n#endif\n#endif\n#endif\n\n#ifdef SHEEN\nvec3 finalSheen=sheenBase*sheenColor;\nfinalSheen=max(finalSheen,0.0);\nvec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;\n\n\n\n\n\n#ifdef REFLECTION\nvec3 finalSheenRadiance=environmentSheenRadiance.rgb;\nfinalSheenRadiance*=sheenEnvironmentReflectance;\n\nvec3 finalSheenRadianceScaled=finalSheenRadiance*vLightingIntensity.z;\n#endif\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#if defined(CLEARCOAT)\nluminanceOverAlpha+=getLuminance(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)\nalpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);\n#endif\n#endif\n#endif\n\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\nvec3 finalAmbient=vAmbientColor;\nfinalAmbient*=surfaceAlbedo.rgb;\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\n\n#ifdef AMBIENT\nvec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),ambientOcclusionColor,vAmbientInfos.w);\n#else\nvec3 ambientOcclusionForDirectDiffuse=ambientOcclusionColor;\n#endif\n\n\n\nvec4 finalColor=vec4(\nfinalAmbient*ambientOcclusionColor +\nfinalDiffuse*ambientOcclusionForDirectDiffuse*vLightingIntensity.x +\n#ifndef UNLIT\n#ifdef REFLECTION\nfinalIrradiance*ambientOcclusionColor*vLightingIntensity.z +\n#endif\n#ifdef SPECULARTERM\n\n\nfinalSpecularScaled +\n#endif\n#ifdef CLEARCOAT\n\n\nfinalClearCoatScaled +\n#endif\n#ifdef SHEEN\n\n\nfinalSheenScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#ifdef CLEARCOAT\n\n\nfinalClearCoatRadianceScaled +\n#endif\n#ifdef SHEEN\n\n\nfinalSheenRadianceScaled +\n#endif\n#endif\n#ifdef SS_REFRACTION\nfinalRefraction*vLightingIntensity.z +\n#endif\n#endif\nfinalEmissive*vLightingIntensity.y,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\n\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\nfinalColor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\ngl_FragColor=finalColor;\n#include<pbrDebug>\n}\n";
  130829. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130830. /** @hidden */
  130831. var pbrPixelShader = { name: name, shader: shader };
  130832. /***/ }),
  130833. /***/ "./Shaders/pbr.vertex.ts":
  130834. /*!*******************************!*\
  130835. !*** ./Shaders/pbr.vertex.ts ***!
  130836. \*******************************/
  130837. /*! exports provided: pbrVertexShader */
  130838. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130839. "use strict";
  130840. __webpack_require__.r(__webpack_exports__);
  130841. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  130842. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130843. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  130844. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  130845. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130846. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130847. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130848. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  130849. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  130850. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  130851. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  130852. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  130853. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  130854. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  130855. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  130856. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  130857. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  130858. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130859. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130860. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  130861. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  130862. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  130863. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  130864. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  130865. var name = 'pbrVertexShader';
  130866. var shader = "precision highp float;\n#include<__decl__pbrVertex>\n#define CUSTOM_VERTEX_BEGIN\n\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#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatUV;\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nvarying vec2 vClearCoatBumpUV;\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatTintUV;\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\nvarying vec2 vSheenUV;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\nvarying vec2 vAnisotropyUV;\n#endif\n#endif\n#ifdef SUBSURFACE\n#if defined(SS_THICKNESSANDMASK_TEXTURE) && SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 0\nvarying vec2 vThicknessUV;\n#endif\n#endif\n\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#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[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#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(positionUpdated,1.0)).xyz;\n#else\nvPositionUVW=positionUpdated;\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(positionUpdated,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#endif\n#if DEBUGMODE>0\nvClipSpacePosition=gl_Position;\n#endif\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\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=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\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(ALBEDO) && ALBEDODIRECTUV == 0\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nif (vClearCoatInfos.x == 0.)\n{\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nif (vClearCoatBumpInfos.x == 0.)\n{\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nif (vClearCoatTintInfos.x == 0.)\n{\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\nif (vSheenInfos.x == 0.)\n{\nvSheenUV=vec2(sheenMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSheenUV=vec2(sheenMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef ANISOTROPIC\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\nif (vAnisotropyInfos.x == 0.)\n{\nvAnisotropyUV=vec2(anisotropyMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAnisotropyUV=vec2(anisotropyMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef SUBSURFACE\n#if defined(SS_THICKNESSANDMASK_TEXTURE) && SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 0\nif (vThicknessInfos.x == 0.)\n{\nvThicknessUV=vec2(thicknessMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvThicknessUV=vec2(thicknessMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n\n#include<bumpVertex>\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}";
  130867. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130868. /** @hidden */
  130869. var pbrVertexShader = { name: name, shader: shader };
  130870. /***/ }),
  130871. /***/ "./Shaders/postprocess.vertex.ts":
  130872. /*!***************************************!*\
  130873. !*** ./Shaders/postprocess.vertex.ts ***!
  130874. \***************************************/
  130875. /*! exports provided: postprocessVertexShader */
  130876. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130877. "use strict";
  130878. __webpack_require__.r(__webpack_exports__);
  130879. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  130880. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130881. var name = 'postprocessVertexShader';
  130882. var shader = "\nattribute vec2 position;\nuniform vec2 scale;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=(position*madd+madd)*scale;\ngl_Position=vec4(position,0.0,1.0);\n}";
  130883. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130884. /** @hidden */
  130885. var postprocessVertexShader = { name: name, shader: shader };
  130886. /***/ }),
  130887. /***/ "./Shaders/procedural.vertex.ts":
  130888. /*!**************************************!*\
  130889. !*** ./Shaders/procedural.vertex.ts ***!
  130890. \**************************************/
  130891. /*! exports provided: proceduralVertexShader */
  130892. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130893. "use strict";
  130894. __webpack_require__.r(__webpack_exports__);
  130895. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  130896. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130897. var name = 'proceduralVertexShader';
  130898. var shader = "\nattribute vec2 position;\n\nvarying vec2 vPosition;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvPosition=position;\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n}";
  130899. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130900. /** @hidden */
  130901. var proceduralVertexShader = { name: name, shader: shader };
  130902. /***/ }),
  130903. /***/ "./Shaders/refraction.fragment.ts":
  130904. /*!****************************************!*\
  130905. !*** ./Shaders/refraction.fragment.ts ***!
  130906. \****************************************/
  130907. /*! exports provided: refractionPixelShader */
  130908. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130909. "use strict";
  130910. __webpack_require__.r(__webpack_exports__);
  130911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  130912. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130913. var name = 'refractionPixelShader';
  130914. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D refractionSampler;\n\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}";
  130915. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130916. /** @hidden */
  130917. var refractionPixelShader = { name: name, shader: shader };
  130918. /***/ }),
  130919. /***/ "./Shaders/rgbdDecode.fragment.ts":
  130920. /*!****************************************!*\
  130921. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  130922. \****************************************/
  130923. /*! exports provided: rgbdDecodePixelShader */
  130924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130925. "use strict";
  130926. __webpack_require__.r(__webpack_exports__);
  130927. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  130928. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130929. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130930. var name = 'rgbdDecodePixelShader';
  130931. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);\n}";
  130932. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130933. /** @hidden */
  130934. var rgbdDecodePixelShader = { name: name, shader: shader };
  130935. /***/ }),
  130936. /***/ "./Shaders/rgbdEncode.fragment.ts":
  130937. /*!****************************************!*\
  130938. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  130939. \****************************************/
  130940. /*! exports provided: rgbdEncodePixelShader */
  130941. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130942. "use strict";
  130943. __webpack_require__.r(__webpack_exports__);
  130944. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  130945. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130946. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130947. var name = 'rgbdEncodePixelShader';
  130948. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  130949. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130950. /** @hidden */
  130951. var rgbdEncodePixelShader = { name: name, shader: shader };
  130952. /***/ }),
  130953. /***/ "./Shaders/shadowMap.fragment.ts":
  130954. /*!***************************************!*\
  130955. !*** ./Shaders/shadowMap.fragment.ts ***!
  130956. \***************************************/
  130957. /*! exports provided: shadowMapPixelShader */
  130958. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130959. "use strict";
  130960. __webpack_require__.r(__webpack_exports__);
  130961. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  130962. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130963. var name = 'shadowMapPixelShader';
  130964. var shader = "#ifndef FLOAT\nvec4 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}\n#endif\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nuniform vec3 biasAndScale;\nuniform vec2 depthValues;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nfloat depth=vDepthMetric;\n#ifdef ESM\ndepth=clamp(exp(-min(87.,biasAndScale.z*depth)),0.,1.);\n#endif\n#ifdef FLOAT\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depth);\n#endif\n}";
  130965. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130966. /** @hidden */
  130967. var shadowMapPixelShader = { name: name, shader: shader };
  130968. /***/ }),
  130969. /***/ "./Shaders/shadowMap.vertex.ts":
  130970. /*!*************************************!*\
  130971. !*** ./Shaders/shadowMap.vertex.ts ***!
  130972. \*************************************/
  130973. /*! exports provided: shadowMapVertexShader */
  130974. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130975. "use strict";
  130976. __webpack_require__.r(__webpack_exports__);
  130977. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  130978. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130979. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130980. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  130981. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  130982. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130983. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130984. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  130985. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130986. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130987. var name = 'shadowMapVertexShader';
  130988. var shader = "\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\nuniform vec3 lightData;\n#endif\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n\n#include<instancesDeclaration>\n#include<helperFunctions>\nuniform mat4 viewProjection;\nuniform vec3 biasAndScale;\nuniform vec2 depthValues;\nvarying float vDepthMetric;\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\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvec3 worldNor=normalize(normalWorld*normal);\n#ifdef DIRECTIONINLIGHTDATA\nvec3 worldLightDir=normalize(-lightData.xyz);\n#else\nvec3 directionToLight=lightData.xyz-worldPos.xyz;\nvec3 worldLightDir=normalize(directionToLight);\n#endif\nfloat ndl=dot(worldNor,worldLightDir);\nfloat sinNL=sqrt(1.0-ndl*ndl);\nfloat normalBias=biasAndScale.y*sinNL;\nworldPos.xyz-=worldNor*normalBias;\n#endif\n\ngl_Position=viewProjection*worldPos;\n#ifdef DEPTHTEXTURE\n\ngl_Position.z+=biasAndScale.x*gl_Position.w;\n#endif\n\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y))+biasAndScale.x;\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}";
  130989. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130990. /** @hidden */
  130991. var shadowMapVertexShader = { name: name, shader: shader };
  130992. /***/ }),
  130993. /***/ "./Shaders/sharpen.fragment.ts":
  130994. /*!*************************************!*\
  130995. !*** ./Shaders/sharpen.fragment.ts ***!
  130996. \*************************************/
  130997. /*! exports provided: sharpenPixelShader */
  130998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130999. "use strict";
  131000. __webpack_require__.r(__webpack_exports__);
  131001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  131002. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131003. var name = 'sharpenPixelShader';
  131004. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform vec2 sharpnessAmounts;\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}";
  131005. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131006. /** @hidden */
  131007. var sharpenPixelShader = { name: name, shader: shader };
  131008. /***/ }),
  131009. /***/ "./Shaders/sprites.fragment.ts":
  131010. /*!*************************************!*\
  131011. !*** ./Shaders/sprites.fragment.ts ***!
  131012. \*************************************/
  131013. /*! exports provided: spritesPixelShader */
  131014. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131015. "use strict";
  131016. __webpack_require__.r(__webpack_exports__);
  131017. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  131018. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131019. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  131020. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  131021. var name = 'spritesPixelShader';
  131022. var shader = "uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest)\n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include<fogFragment>\ngl_FragColor=color;\n}";
  131023. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131024. /** @hidden */
  131025. var spritesPixelShader = { name: name, shader: shader };
  131026. /***/ }),
  131027. /***/ "./Shaders/sprites.vertex.ts":
  131028. /*!***********************************!*\
  131029. !*** ./Shaders/sprites.vertex.ts ***!
  131030. \***********************************/
  131031. /*! exports provided: spritesVertexShader */
  131032. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131033. "use strict";
  131034. __webpack_require__.r(__webpack_exports__);
  131035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  131036. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131037. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  131038. var name = 'spritesVertexShader';
  131039. var shader = "\nattribute vec4 position;\nattribute vec4 options;\nattribute vec4 cellInfo;\nattribute vec4 color;\n\nuniform vec2 textureInfos;\nuniform mat4 view;\nuniform mat4 projection;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#include<fogVertexDeclaration>\nvoid main(void) {\nvec3 viewPos=(view*vec4(position.xyz,1.0)).xyz;\nvec2 cornerPos;\nfloat angle=position.w;\nvec2 size=vec2(options.x,options.y);\nvec2 offset=options.zw;\nvec2 uvScale=textureInfos.xy;\ncornerPos=vec2(offset.x-0.5,offset.y-0.5)*size;\n\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.;\n\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0);\n\nvColor=color;\n\nvec2 uvOffset=vec2(abs(offset.x-cellInfo.x),1.0-abs(offset.y-cellInfo.y));\nvUV=(uvOffset+cellInfo.zw)*uvScale;\n\n#ifdef FOG\nvFogDistance=viewPos;\n#endif\n}";
  131040. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131041. /** @hidden */
  131042. var spritesVertexShader = { name: name, shader: shader };
  131043. /***/ }),
  131044. /***/ "./Shaders/ssao.fragment.ts":
  131045. /*!**********************************!*\
  131046. !*** ./Shaders/ssao.fragment.ts ***!
  131047. \**********************************/
  131048. /*! exports provided: ssaoPixelShader */
  131049. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131050. "use strict";
  131051. __webpack_require__.r(__webpack_exports__);
  131052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  131053. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131054. var name = 'ssaoPixelShader';
  131055. var shader = "\nuniform 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";
  131056. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131057. /** @hidden */
  131058. var ssaoPixelShader = { name: name, shader: shader };
  131059. /***/ }),
  131060. /***/ "./Shaders/ssao2.fragment.ts":
  131061. /*!***********************************!*\
  131062. !*** ./Shaders/ssao2.fragment.ts ***!
  131063. \***********************************/
  131064. /*! exports provided: ssao2PixelShader */
  131065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131066. "use strict";
  131067. __webpack_require__.r(__webpack_exports__);
  131068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  131069. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131070. var name = 'ssao2PixelShader';
  131071. var shader = "\nprecision 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( const in float invClipZ,const in float near,const in float far ) {\nreturn ( near*far )/( ( far-near )*invClipZ-far );\n}\nfloat viewZToPerspectiveDepth( const in float viewZ,const in float near,const in float far ) {\nreturn ( near*far/viewZ+far)/( far-near );\n}\nfloat viewZToOrthographicDepth( const in float viewZ,const in float near,const in float far ) {\nreturn ( viewZ+near )/( near-far );\n}\n#ifdef SSAO\nuniform sampler2D randomSampler;\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 float maxZ;\nuniform float minZAspect;\nuniform vec2 texelSize;\nuniform mat4 projection;\nvoid main()\n{\nvec3 random=texture2D(randomSampler,vUV*randTextureTiles).rgb;\nfloat depth=texture2D(textureSampler,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 origin=vViewRay*depth;\nvec3 rvec=random*2.0-1.0;\nrvec.z=0.0;\n\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) {\n\nvec3 samplePosition=scales[(i+int(random.x*16.0)) % 16]*tbn*sampleSphere[(i+int(random.y*16.0)) % 16];\nsamplePosition=samplePosition*correctedRadius+origin;\n\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}\n\nfloat sampleDepth=abs(texture2D(textureSampler,offset.xy).r);\n\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";
  131072. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131073. /** @hidden */
  131074. var ssao2PixelShader = { name: name, shader: shader };
  131075. /***/ }),
  131076. /***/ "./Shaders/ssaoCombine.fragment.ts":
  131077. /*!*****************************************!*\
  131078. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  131079. \*****************************************/
  131080. /*! exports provided: ssaoCombinePixelShader */
  131081. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131082. "use strict";
  131083. __webpack_require__.r(__webpack_exports__);
  131084. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  131085. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131086. var name = 'ssaoCombinePixelShader';
  131087. var shader = "uniform sampler2D textureSampler;\nuniform sampler2D originalColor;\nuniform vec4 viewport;\nvarying vec2 vUV;\nvoid main(void) {\nvec4 ssaoColor=texture2D(textureSampler,viewport.xy+vUV*viewport.zw);\nvec4 sceneColor=texture2D(originalColor,vUV);\ngl_FragColor=sceneColor*ssaoColor;\n}\n";
  131088. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131089. /** @hidden */
  131090. var ssaoCombinePixelShader = { name: name, shader: shader };
  131091. /***/ }),
  131092. /***/ "./Shaders/standard.fragment.ts":
  131093. /*!**************************************!*\
  131094. !*** ./Shaders/standard.fragment.ts ***!
  131095. \**************************************/
  131096. /*! exports provided: standardPixelShader */
  131097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131098. "use strict";
  131099. __webpack_require__.r(__webpack_exports__);
  131100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  131101. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131102. var name = 'standardPixelShader';
  131103. var shader = "uniform sampler2D textureSampler;\nvarying vec2 vUV;\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{\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]);\n\nfloat GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));\n\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\nvec4 pack(float value) {\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(value*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\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);\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";
  131104. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131105. /** @hidden */
  131106. var standardPixelShader = { name: name, shader: shader };
  131107. /***/ }),
  131108. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  131109. /*!***************************************************!*\
  131110. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  131111. \***************************************************/
  131112. /*! exports provided: stereoscopicInterlacePixelShader */
  131113. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131114. "use strict";
  131115. __webpack_require__.r(__webpack_exports__);
  131116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  131117. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131118. var name = 'stereoscopicInterlacePixelShader';
  131119. var shader = "const vec3 TWO=vec3(2.0,2.0,2.0);\nvarying vec2 vUV;\nuniform sampler2D camASampler;\nuniform sampler2D textureSampler;\nuniform vec2 stepSize;\nvoid main(void)\n{\nbool useCamB;\nvec2 texCoord1;\nvec2 texCoord2;\nvec3 frag1;\nvec3 frag2;\n#ifdef IS_STEREOSCOPIC_HORIZ\nuseCamB=vUV.x>0.5;\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\nuseCamB=vUV.y>0.5;\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\nif (useCamB){\nfrag1=texture2D(textureSampler,texCoord1).rgb;\nfrag2=texture2D(textureSampler,texCoord2).rgb;\n}else{\nfrag1=texture2D(camASampler ,texCoord1).rgb;\nfrag2=texture2D(camASampler ,texCoord2).rgb;\n}\ngl_FragColor=vec4((frag1+frag2)/TWO,1.0);\n}";
  131120. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131121. /** @hidden */
  131122. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  131123. /***/ }),
  131124. /***/ "./Shaders/tonemap.fragment.ts":
  131125. /*!*************************************!*\
  131126. !*** ./Shaders/tonemap.fragment.ts ***!
  131127. \*************************************/
  131128. /*! exports provided: tonemapPixelShader */
  131129. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131130. "use strict";
  131131. __webpack_require__.r(__webpack_exports__);
  131132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  131133. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131134. var name = 'tonemapPixelShader';
  131135. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\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}\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}";
  131136. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131137. /** @hidden */
  131138. var tonemapPixelShader = { name: name, shader: shader };
  131139. /***/ }),
  131140. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  131141. /*!*******************************************************!*\
  131142. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  131143. \*******************************************************/
  131144. /*! exports provided: volumetricLightScatteringPixelShader */
  131145. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131146. "use strict";
  131147. __webpack_require__.r(__webpack_exports__);
  131148. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  131149. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131150. var name = 'volumetricLightScatteringPixelShader';
  131151. var shader = "uniform sampler2D textureSampler;\nuniform sampler2D lightScatteringSampler;\nuniform float decay;\nuniform float exposure;\nuniform float weight;\nuniform float density;\nuniform vec2 meshPositionOnScreen;\nvarying vec2 vUV;\nvoid main(void) {\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}\n";
  131152. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131153. /** @hidden */
  131154. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  131155. /***/ }),
  131156. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  131157. /*!***********************************************************!*\
  131158. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  131159. \***********************************************************/
  131160. /*! exports provided: volumetricLightScatteringPassPixelShader */
  131161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131162. "use strict";
  131163. __webpack_require__.r(__webpack_exports__);
  131164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  131165. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131166. var name = 'volumetricLightScatteringPassPixelShader';
  131167. var shader = "#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\n#endif\n#if defined(ALPHATEST)\nuniform sampler2D diffuseSampler;\n#endif\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";
  131168. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131169. /** @hidden */
  131170. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  131171. /***/ }),
  131172. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  131173. /*!****************************************************!*\
  131174. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  131175. \****************************************************/
  131176. /*! exports provided: vrDistortionCorrectionPixelShader */
  131177. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131178. "use strict";
  131179. __webpack_require__.r(__webpack_exports__);
  131180. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  131181. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131182. var name = 'vrDistortionCorrectionPixelShader';
  131183. var shader = "\nvarying 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}\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}";
  131184. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131185. /** @hidden */
  131186. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  131187. /***/ }),
  131188. /***/ "./Shaders/vrMultiviewToSingleview.fragment.ts":
  131189. /*!*****************************************************!*\
  131190. !*** ./Shaders/vrMultiviewToSingleview.fragment.ts ***!
  131191. \*****************************************************/
  131192. /*! exports provided: vrMultiviewToSingleviewPixelShader */
  131193. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131194. "use strict";
  131195. __webpack_require__.r(__webpack_exports__);
  131196. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrMultiviewToSingleviewPixelShader", function() { return vrMultiviewToSingleviewPixelShader; });
  131197. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131198. var name = 'vrMultiviewToSingleviewPixelShader';
  131199. var shader = "#ifdef GL_ES\nprecision mediump sampler2DArray;\n#endif\nvarying vec2 vUV;\nuniform sampler2DArray multiviewSampler;\nuniform int imageIndex;\nvoid main(void)\n{\ngl_FragColor=texture(multiviewSampler,vec3(vUV,imageIndex));\n}";
  131200. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131201. /** @hidden */
  131202. var vrMultiviewToSingleviewPixelShader = { name: name, shader: shader };
  131203. /***/ }),
  131204. /***/ "./Sprites/index.ts":
  131205. /*!**************************!*\
  131206. !*** ./Sprites/index.ts ***!
  131207. \**************************/
  131208. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  131209. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131210. "use strict";
  131211. __webpack_require__.r(__webpack_exports__);
  131212. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  131213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  131214. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  131215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  131216. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  131217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  131218. /***/ }),
  131219. /***/ "./Sprites/sprite.ts":
  131220. /*!***************************!*\
  131221. !*** ./Sprites/sprite.ts ***!
  131222. \***************************/
  131223. /*! exports provided: Sprite */
  131224. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131225. "use strict";
  131226. __webpack_require__.r(__webpack_exports__);
  131227. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  131228. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  131229. /**
  131230. * Class used to represent a sprite
  131231. * @see http://doc.babylonjs.com/babylon101/sprites
  131232. */
  131233. var Sprite = /** @class */ (function () {
  131234. /**
  131235. * Creates a new Sprite
  131236. * @param name defines the name
  131237. * @param manager defines the manager
  131238. */
  131239. function Sprite(
  131240. /** defines the name */
  131241. name, manager) {
  131242. this.name = name;
  131243. /** Gets or sets the main color */
  131244. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  131245. /** Gets or sets the width */
  131246. this.width = 1.0;
  131247. /** Gets or sets the height */
  131248. this.height = 1.0;
  131249. /** Gets or sets rotation angle */
  131250. this.angle = 0;
  131251. /** Gets or sets the cell index in the sprite sheet */
  131252. this.cellIndex = 0;
  131253. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  131254. this.invertU = 0;
  131255. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  131256. this.invertV = 0;
  131257. /** Gets the list of attached animations */
  131258. this.animations = new Array();
  131259. /** Gets or sets a boolean indicating if the sprite can be picked */
  131260. this.isPickable = false;
  131261. this._animationStarted = false;
  131262. this._loopAnimation = false;
  131263. this._fromIndex = 0;
  131264. this._toIndex = 0;
  131265. this._delay = 0;
  131266. this._direction = 1;
  131267. this._time = 0;
  131268. /**
  131269. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  131270. */
  131271. this.isVisible = true;
  131272. this._manager = manager;
  131273. this._manager.sprites.push(this);
  131274. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  131275. }
  131276. Object.defineProperty(Sprite.prototype, "size", {
  131277. /**
  131278. * Gets or sets the sprite size
  131279. */
  131280. get: function () {
  131281. return this.width;
  131282. },
  131283. set: function (value) {
  131284. this.width = value;
  131285. this.height = value;
  131286. },
  131287. enumerable: true,
  131288. configurable: true
  131289. });
  131290. /**
  131291. * Starts an animation
  131292. * @param from defines the initial key
  131293. * @param to defines the end key
  131294. * @param loop defines if the animation must loop
  131295. * @param delay defines the start delay (in ms)
  131296. * @param onAnimationEnd defines a callback to call when animation ends
  131297. */
  131298. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  131299. this._fromIndex = from;
  131300. this._toIndex = to;
  131301. this._loopAnimation = loop;
  131302. this._delay = delay;
  131303. this._animationStarted = true;
  131304. this._direction = from < to ? 1 : -1;
  131305. this.cellIndex = from;
  131306. this._time = 0;
  131307. this._onAnimationEnd = onAnimationEnd;
  131308. };
  131309. /** Stops current animation (if any) */
  131310. Sprite.prototype.stopAnimation = function () {
  131311. this._animationStarted = false;
  131312. };
  131313. /** @hidden */
  131314. Sprite.prototype._animate = function (deltaTime) {
  131315. if (!this._animationStarted) {
  131316. return;
  131317. }
  131318. this._time += deltaTime;
  131319. if (this._time > this._delay) {
  131320. this._time = this._time % this._delay;
  131321. this.cellIndex += this._direction;
  131322. if (this.cellIndex > this._toIndex) {
  131323. if (this._loopAnimation) {
  131324. this.cellIndex = this._fromIndex;
  131325. }
  131326. else {
  131327. this.cellIndex = this._toIndex;
  131328. this._animationStarted = false;
  131329. if (this._onAnimationEnd) {
  131330. this._onAnimationEnd();
  131331. }
  131332. if (this.disposeWhenFinishedAnimating) {
  131333. this.dispose();
  131334. }
  131335. }
  131336. }
  131337. }
  131338. };
  131339. /** Release associated resources */
  131340. Sprite.prototype.dispose = function () {
  131341. for (var i = 0; i < this._manager.sprites.length; i++) {
  131342. if (this._manager.sprites[i] == this) {
  131343. this._manager.sprites.splice(i, 1);
  131344. }
  131345. }
  131346. };
  131347. return Sprite;
  131348. }());
  131349. /***/ }),
  131350. /***/ "./Sprites/spriteManager.ts":
  131351. /*!**********************************!*\
  131352. !*** ./Sprites/spriteManager.ts ***!
  131353. \**********************************/
  131354. /*! exports provided: SpriteManager */
  131355. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131356. "use strict";
  131357. __webpack_require__.r(__webpack_exports__);
  131358. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  131359. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  131360. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  131361. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  131362. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  131363. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  131364. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  131365. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  131366. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  131367. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  131368. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  131369. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  131370. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  131371. /**
  131372. * Class used to manage multiple sprites on the same spritesheet
  131373. * @see http://doc.babylonjs.com/babylon101/sprites
  131374. */
  131375. var SpriteManager = /** @class */ (function () {
  131376. /**
  131377. * Creates a new sprite manager
  131378. * @param name defines the manager's name
  131379. * @param imgUrl defines the sprite sheet url
  131380. * @param capacity defines the maximum allowed number of sprites
  131381. * @param cellSize defines the size of a sprite cell
  131382. * @param scene defines the hosting scene
  131383. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  131384. * @param samplingMode defines the smapling mode to use with spritesheet
  131385. */
  131386. function SpriteManager(
  131387. /** defines the manager's name */
  131388. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  131389. if (epsilon === void 0) { epsilon = 0.01; }
  131390. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  131391. this.name = name;
  131392. /** Gets the list of sprites */
  131393. this.sprites = new Array();
  131394. /** Gets or sets the rendering group id (0 by default) */
  131395. this.renderingGroupId = 0;
  131396. /** Gets or sets camera layer mask */
  131397. this.layerMask = 0x0FFFFFFF;
  131398. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  131399. this.fogEnabled = true;
  131400. /** Gets or sets a boolean indicating if the sprites are pickable */
  131401. this.isPickable = false;
  131402. /**
  131403. * An event triggered when the manager is disposed.
  131404. */
  131405. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  131406. this._vertexBuffers = {};
  131407. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  131408. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  131409. }
  131410. this._capacity = capacity;
  131411. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  131412. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  131413. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  131414. if (cellSize.width && cellSize.height) {
  131415. this.cellWidth = cellSize.width;
  131416. this.cellHeight = cellSize.height;
  131417. }
  131418. else if (cellSize !== undefined) {
  131419. this.cellWidth = cellSize;
  131420. this.cellHeight = cellSize;
  131421. }
  131422. else {
  131423. return;
  131424. }
  131425. this._epsilon = epsilon;
  131426. this._scene = scene;
  131427. this._scene.spriteManagers.push(this);
  131428. var indices = [];
  131429. var index = 0;
  131430. for (var count = 0; count < capacity; count++) {
  131431. indices.push(index);
  131432. indices.push(index + 1);
  131433. indices.push(index + 2);
  131434. indices.push(index);
  131435. indices.push(index + 2);
  131436. indices.push(index + 3);
  131437. index += 4;
  131438. }
  131439. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  131440. // VBO
  131441. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  131442. this._vertexData = new Float32Array(capacity * 16 * 4);
  131443. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  131444. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  131445. var options = this._buffer.createVertexBuffer("options", 4, 4);
  131446. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  131447. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  131448. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  131449. this._vertexBuffers["options"] = options;
  131450. this._vertexBuffers["cellInfo"] = cellInfo;
  131451. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  131452. // Effects
  131453. this._effectBase = this._scene.getEngine().createEffect("sprites", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "options", "cellInfo", _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind], ["view", "projection", "textureInfos", "alphaTest"], ["diffuseSampler"], "");
  131454. this._effectFog = this._scene.getEngine().createEffect("sprites", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "options", "cellInfo", _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind], ["view", "projection", "textureInfos", "alphaTest", "vFogInfos", "vFogColor"], ["diffuseSampler"], "#define FOG");
  131455. }
  131456. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  131457. /**
  131458. * Callback called when the manager is disposed
  131459. */
  131460. set: function (callback) {
  131461. if (this._onDisposeObserver) {
  131462. this.onDisposeObservable.remove(this._onDisposeObserver);
  131463. }
  131464. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  131465. },
  131466. enumerable: true,
  131467. configurable: true
  131468. });
  131469. Object.defineProperty(SpriteManager.prototype, "texture", {
  131470. /**
  131471. * Gets or sets the spritesheet texture
  131472. */
  131473. get: function () {
  131474. return this._spriteTexture;
  131475. },
  131476. set: function (value) {
  131477. this._spriteTexture = value;
  131478. },
  131479. enumerable: true,
  131480. configurable: true
  131481. });
  131482. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  131483. var arrayOffset = index * 16;
  131484. if (offsetX === 0) {
  131485. offsetX = this._epsilon;
  131486. }
  131487. else if (offsetX === 1) {
  131488. offsetX = 1 - this._epsilon;
  131489. }
  131490. if (offsetY === 0) {
  131491. offsetY = this._epsilon;
  131492. }
  131493. else if (offsetY === 1) {
  131494. offsetY = 1 - this._epsilon;
  131495. }
  131496. this._vertexData[arrayOffset] = sprite.position.x;
  131497. this._vertexData[arrayOffset + 1] = sprite.position.y;
  131498. this._vertexData[arrayOffset + 2] = sprite.position.z;
  131499. this._vertexData[arrayOffset + 3] = sprite.angle;
  131500. this._vertexData[arrayOffset + 4] = sprite.width;
  131501. this._vertexData[arrayOffset + 5] = sprite.height;
  131502. this._vertexData[arrayOffset + 6] = offsetX;
  131503. this._vertexData[arrayOffset + 7] = offsetY;
  131504. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  131505. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  131506. var offset = (sprite.cellIndex / rowSize) >> 0;
  131507. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  131508. this._vertexData[arrayOffset + 11] = offset;
  131509. // Color
  131510. this._vertexData[arrayOffset + 12] = sprite.color.r;
  131511. this._vertexData[arrayOffset + 13] = sprite.color.g;
  131512. this._vertexData[arrayOffset + 14] = sprite.color.b;
  131513. this._vertexData[arrayOffset + 15] = sprite.color.a;
  131514. };
  131515. /**
  131516. * Intersects the sprites with a ray
  131517. * @param ray defines the ray to intersect with
  131518. * @param camera defines the current active camera
  131519. * @param predicate defines a predicate used to select candidate sprites
  131520. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  131521. * @returns null if no hit or a PickingInfo
  131522. */
  131523. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  131524. var count = Math.min(this._capacity, this.sprites.length);
  131525. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  131526. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  131527. var distance = Number.MAX_VALUE;
  131528. var currentSprite = null;
  131529. var pickedPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  131530. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  131531. var cameraView = camera.getViewMatrix();
  131532. for (var index = 0; index < count; index++) {
  131533. var sprite = this.sprites[index];
  131534. if (!sprite) {
  131535. continue;
  131536. }
  131537. if (predicate) {
  131538. if (!predicate(sprite)) {
  131539. continue;
  131540. }
  131541. }
  131542. else if (!sprite.isPickable) {
  131543. continue;
  131544. }
  131545. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  131546. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  131547. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  131548. if (ray.intersectsBoxMinMax(min, max)) {
  131549. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  131550. if (distance > currentDistance) {
  131551. distance = currentDistance;
  131552. currentSprite = sprite;
  131553. if (fastCheck) {
  131554. break;
  131555. }
  131556. }
  131557. }
  131558. }
  131559. if (currentSprite) {
  131560. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  131561. cameraView.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  131562. result.hit = true;
  131563. result.pickedSprite = currentSprite;
  131564. result.distance = distance;
  131565. // Get picked point
  131566. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  131567. direction.copyFrom(ray.direction);
  131568. direction.normalize();
  131569. direction.scaleInPlace(distance);
  131570. ray.origin.addToRef(direction, pickedPoint);
  131571. result.pickedPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(pickedPoint, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  131572. return result;
  131573. }
  131574. return null;
  131575. };
  131576. /**
  131577. * Render all child sprites
  131578. */
  131579. SpriteManager.prototype.render = function () {
  131580. // Check
  131581. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  131582. || !this._spriteTexture.isReady() || !this.sprites.length) {
  131583. return;
  131584. }
  131585. var engine = this._scene.getEngine();
  131586. var baseSize = this._spriteTexture.getBaseSize();
  131587. // Sprites
  131588. var deltaTime = engine.getDeltaTime();
  131589. var max = Math.min(this._capacity, this.sprites.length);
  131590. var rowSize = baseSize.width / this.cellWidth;
  131591. var offset = 0;
  131592. var noSprite = true;
  131593. for (var index = 0; index < max; index++) {
  131594. var sprite = this.sprites[index];
  131595. if (!sprite || !sprite.isVisible) {
  131596. continue;
  131597. }
  131598. noSprite = false;
  131599. sprite._animate(deltaTime);
  131600. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  131601. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  131602. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  131603. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  131604. }
  131605. if (noSprite) {
  131606. return;
  131607. }
  131608. this._buffer.update(this._vertexData);
  131609. // Render
  131610. var effect = this._effectBase;
  131611. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  131612. effect = this._effectFog;
  131613. }
  131614. engine.enableEffect(effect);
  131615. var viewMatrix = this._scene.getViewMatrix();
  131616. effect.setTexture("diffuseSampler", this._spriteTexture);
  131617. effect.setMatrix("view", viewMatrix);
  131618. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  131619. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  131620. // Fog
  131621. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  131622. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  131623. effect.setColor3("vFogColor", this._scene.fogColor);
  131624. }
  131625. // VBOs
  131626. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  131627. // Draw order
  131628. engine.setDepthFunctionToLessOrEqual();
  131629. effect.setBool("alphaTest", true);
  131630. engine.setColorWrite(false);
  131631. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  131632. engine.setColorWrite(true);
  131633. effect.setBool("alphaTest", false);
  131634. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  131635. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  131636. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  131637. };
  131638. /**
  131639. * Release associated resources
  131640. */
  131641. SpriteManager.prototype.dispose = function () {
  131642. if (this._buffer) {
  131643. this._buffer.dispose();
  131644. this._buffer = null;
  131645. }
  131646. if (this._indexBuffer) {
  131647. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  131648. this._indexBuffer = null;
  131649. }
  131650. if (this._spriteTexture) {
  131651. this._spriteTexture.dispose();
  131652. this._spriteTexture = null;
  131653. }
  131654. // Remove from scene
  131655. var index = this._scene.spriteManagers.indexOf(this);
  131656. this._scene.spriteManagers.splice(index, 1);
  131657. // Callback
  131658. this.onDisposeObservable.notifyObservers(this);
  131659. this.onDisposeObservable.clear();
  131660. };
  131661. return SpriteManager;
  131662. }());
  131663. /***/ }),
  131664. /***/ "./Sprites/spriteSceneComponent.ts":
  131665. /*!*****************************************!*\
  131666. !*** ./Sprites/spriteSceneComponent.ts ***!
  131667. \*****************************************/
  131668. /*! exports provided: SpriteSceneComponent */
  131669. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131670. "use strict";
  131671. __webpack_require__.r(__webpack_exports__);
  131672. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  131673. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  131674. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  131675. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  131676. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  131677. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  131678. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  131679. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  131680. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  131681. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  131682. return null;
  131683. }
  131684. var pickingInfo = null;
  131685. if (!camera) {
  131686. if (!this.activeCamera) {
  131687. return null;
  131688. }
  131689. camera = this.activeCamera;
  131690. }
  131691. if (this.spriteManagers.length > 0) {
  131692. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  131693. var spriteManager = this.spriteManagers[spriteIndex];
  131694. if (!spriteManager.isPickable) {
  131695. continue;
  131696. }
  131697. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  131698. if (!result || !result.hit) {
  131699. continue;
  131700. }
  131701. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  131702. continue;
  131703. }
  131704. pickingInfo = result;
  131705. if (fastCheck) {
  131706. break;
  131707. }
  131708. }
  131709. }
  131710. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  131711. };
  131712. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  131713. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  131714. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  131715. };
  131716. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  131717. if (!this._tempSpritePickingRay) {
  131718. return null;
  131719. }
  131720. if (!camera) {
  131721. if (!this.activeCamera) {
  131722. return null;
  131723. }
  131724. camera = this.activeCamera;
  131725. }
  131726. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  131727. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  131728. };
  131729. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  131730. if (this._pointerOverSprite === sprite) {
  131731. return;
  131732. }
  131733. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  131734. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  131735. }
  131736. this._pointerOverSprite = sprite;
  131737. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  131738. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  131739. }
  131740. };
  131741. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  131742. return this._pointerOverSprite;
  131743. };
  131744. /**
  131745. * Defines the sprite scene component responsible to manage sprites
  131746. * in a given scene.
  131747. */
  131748. var SpriteSceneComponent = /** @class */ (function () {
  131749. /**
  131750. * Creates a new instance of the component for the given scene
  131751. * @param scene Defines the scene to register the component in
  131752. */
  131753. function SpriteSceneComponent(scene) {
  131754. /**
  131755. * The component name helpfull to identify the component in the list of scene components.
  131756. */
  131757. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  131758. this.scene = scene;
  131759. this.scene.spriteManagers = new Array();
  131760. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  131761. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  131762. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  131763. this._spritePredicate = function (sprite) {
  131764. if (!sprite.actionManager) {
  131765. return false;
  131766. }
  131767. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  131768. };
  131769. }
  131770. /**
  131771. * Registers the component in a given scene
  131772. */
  131773. SpriteSceneComponent.prototype.register = function () {
  131774. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  131775. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  131776. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  131777. };
  131778. /**
  131779. * Rebuilds the elements related to this component in case of
  131780. * context lost for instance.
  131781. */
  131782. SpriteSceneComponent.prototype.rebuild = function () {
  131783. /** Nothing to do for sprites */
  131784. };
  131785. /**
  131786. * Disposes the component and the associated ressources.
  131787. */
  131788. SpriteSceneComponent.prototype.dispose = function () {
  131789. this.scene.onBeforeSpritesRenderingObservable.clear();
  131790. this.scene.onAfterSpritesRenderingObservable.clear();
  131791. var spriteManagers = this.scene.spriteManagers;
  131792. while (spriteManagers.length) {
  131793. spriteManagers[0].dispose();
  131794. }
  131795. };
  131796. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  131797. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  131798. if (result) {
  131799. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  131800. }
  131801. return result;
  131802. };
  131803. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  131804. var scene = this.scene;
  131805. if (isMeshPicked) {
  131806. scene.setPointerOverSprite(null);
  131807. }
  131808. else {
  131809. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  131810. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  131811. scene.setPointerOverSprite(pickResult.pickedSprite);
  131812. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  131813. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  131814. }
  131815. else {
  131816. canvas.style.cursor = scene.hoverCursor;
  131817. }
  131818. }
  131819. else {
  131820. scene.setPointerOverSprite(null);
  131821. }
  131822. }
  131823. return pickResult;
  131824. };
  131825. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  131826. var scene = this.scene;
  131827. scene._pickedDownSprite = null;
  131828. if (scene.spriteManagers.length > 0) {
  131829. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  131830. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  131831. if (pickResult.pickedSprite.actionManager) {
  131832. scene._pickedDownSprite = pickResult.pickedSprite;
  131833. switch (evt.button) {
  131834. case 0:
  131835. pickResult.pickedSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(pickResult.pickedSprite, scene, evt));
  131836. break;
  131837. case 1:
  131838. pickResult.pickedSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(pickResult.pickedSprite, scene, evt));
  131839. break;
  131840. case 2:
  131841. pickResult.pickedSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(pickResult.pickedSprite, scene, evt));
  131842. break;
  131843. }
  131844. if (pickResult.pickedSprite.actionManager) {
  131845. pickResult.pickedSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(pickResult.pickedSprite, scene, evt));
  131846. }
  131847. }
  131848. }
  131849. }
  131850. return pickResult;
  131851. };
  131852. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  131853. var scene = this.scene;
  131854. if (scene.spriteManagers.length > 0) {
  131855. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  131856. if (spritePickResult) {
  131857. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  131858. if (spritePickResult.pickedSprite.actionManager) {
  131859. spritePickResult.pickedSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(spritePickResult.pickedSprite, scene, evt));
  131860. if (spritePickResult.pickedSprite.actionManager) {
  131861. if (!this.scene._isPointerSwiping()) {
  131862. spritePickResult.pickedSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(spritePickResult.pickedSprite, scene, evt));
  131863. }
  131864. }
  131865. }
  131866. }
  131867. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  131868. scene._pickedDownSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(scene._pickedDownSprite, scene, evt));
  131869. }
  131870. }
  131871. }
  131872. return pickResult;
  131873. };
  131874. return SpriteSceneComponent;
  131875. }());
  131876. /***/ }),
  131877. /***/ "./States/alphaCullingState.ts":
  131878. /*!*************************************!*\
  131879. !*** ./States/alphaCullingState.ts ***!
  131880. \*************************************/
  131881. /*! exports provided: _AlphaState */
  131882. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131883. "use strict";
  131884. __webpack_require__.r(__webpack_exports__);
  131885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  131886. /**
  131887. * @hidden
  131888. **/
  131889. var _AlphaState = /** @class */ (function () {
  131890. /**
  131891. * Initializes the state.
  131892. */
  131893. function _AlphaState() {
  131894. this._isAlphaBlendDirty = false;
  131895. this._isBlendFunctionParametersDirty = false;
  131896. this._isBlendEquationParametersDirty = false;
  131897. this._isBlendConstantsDirty = false;
  131898. this._alphaBlend = false;
  131899. this._blendFunctionParameters = new Array(4);
  131900. this._blendEquationParameters = new Array(2);
  131901. this._blendConstants = new Array(4);
  131902. this.reset();
  131903. }
  131904. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  131905. get: function () {
  131906. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  131907. },
  131908. enumerable: true,
  131909. configurable: true
  131910. });
  131911. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  131912. get: function () {
  131913. return this._alphaBlend;
  131914. },
  131915. set: function (value) {
  131916. if (this._alphaBlend === value) {
  131917. return;
  131918. }
  131919. this._alphaBlend = value;
  131920. this._isAlphaBlendDirty = true;
  131921. },
  131922. enumerable: true,
  131923. configurable: true
  131924. });
  131925. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  131926. if (this._blendConstants[0] === r &&
  131927. this._blendConstants[1] === g &&
  131928. this._blendConstants[2] === b &&
  131929. this._blendConstants[3] === a) {
  131930. return;
  131931. }
  131932. this._blendConstants[0] = r;
  131933. this._blendConstants[1] = g;
  131934. this._blendConstants[2] = b;
  131935. this._blendConstants[3] = a;
  131936. this._isBlendConstantsDirty = true;
  131937. };
  131938. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  131939. if (this._blendFunctionParameters[0] === value0 &&
  131940. this._blendFunctionParameters[1] === value1 &&
  131941. this._blendFunctionParameters[2] === value2 &&
  131942. this._blendFunctionParameters[3] === value3) {
  131943. return;
  131944. }
  131945. this._blendFunctionParameters[0] = value0;
  131946. this._blendFunctionParameters[1] = value1;
  131947. this._blendFunctionParameters[2] = value2;
  131948. this._blendFunctionParameters[3] = value3;
  131949. this._isBlendFunctionParametersDirty = true;
  131950. };
  131951. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  131952. if (this._blendEquationParameters[0] === rgb &&
  131953. this._blendEquationParameters[1] === alpha) {
  131954. return;
  131955. }
  131956. this._blendEquationParameters[0] = rgb;
  131957. this._blendEquationParameters[1] = alpha;
  131958. this._isBlendEquationParametersDirty = true;
  131959. };
  131960. _AlphaState.prototype.reset = function () {
  131961. this._alphaBlend = false;
  131962. this._blendFunctionParameters[0] = null;
  131963. this._blendFunctionParameters[1] = null;
  131964. this._blendFunctionParameters[2] = null;
  131965. this._blendFunctionParameters[3] = null;
  131966. this._blendEquationParameters[0] = null;
  131967. this._blendEquationParameters[1] = null;
  131968. this._blendConstants[0] = null;
  131969. this._blendConstants[1] = null;
  131970. this._blendConstants[2] = null;
  131971. this._blendConstants[3] = null;
  131972. this._isAlphaBlendDirty = true;
  131973. this._isBlendFunctionParametersDirty = false;
  131974. this._isBlendEquationParametersDirty = false;
  131975. this._isBlendConstantsDirty = false;
  131976. };
  131977. _AlphaState.prototype.apply = function (gl) {
  131978. if (!this.isDirty) {
  131979. return;
  131980. }
  131981. // Alpha blend
  131982. if (this._isAlphaBlendDirty) {
  131983. if (this._alphaBlend) {
  131984. gl.enable(gl.BLEND);
  131985. }
  131986. else {
  131987. gl.disable(gl.BLEND);
  131988. }
  131989. this._isAlphaBlendDirty = false;
  131990. }
  131991. // Alpha function
  131992. if (this._isBlendFunctionParametersDirty) {
  131993. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  131994. this._isBlendFunctionParametersDirty = false;
  131995. }
  131996. // Alpha equation
  131997. if (this._isBlendEquationParametersDirty) {
  131998. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  131999. this._isBlendEquationParametersDirty = false;
  132000. }
  132001. // Constants
  132002. if (this._isBlendConstantsDirty) {
  132003. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  132004. this._isBlendConstantsDirty = false;
  132005. }
  132006. };
  132007. return _AlphaState;
  132008. }());
  132009. /***/ }),
  132010. /***/ "./States/depthCullingState.ts":
  132011. /*!*************************************!*\
  132012. !*** ./States/depthCullingState.ts ***!
  132013. \*************************************/
  132014. /*! exports provided: _DepthCullingState */
  132015. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132016. "use strict";
  132017. __webpack_require__.r(__webpack_exports__);
  132018. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  132019. /**
  132020. * @hidden
  132021. **/
  132022. var _DepthCullingState = /** @class */ (function () {
  132023. /**
  132024. * Initializes the state.
  132025. */
  132026. function _DepthCullingState() {
  132027. this._isDepthTestDirty = false;
  132028. this._isDepthMaskDirty = false;
  132029. this._isDepthFuncDirty = false;
  132030. this._isCullFaceDirty = false;
  132031. this._isCullDirty = false;
  132032. this._isZOffsetDirty = false;
  132033. this._isFrontFaceDirty = false;
  132034. this.reset();
  132035. }
  132036. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  132037. get: function () {
  132038. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  132039. },
  132040. enumerable: true,
  132041. configurable: true
  132042. });
  132043. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  132044. get: function () {
  132045. return this._zOffset;
  132046. },
  132047. set: function (value) {
  132048. if (this._zOffset === value) {
  132049. return;
  132050. }
  132051. this._zOffset = value;
  132052. this._isZOffsetDirty = true;
  132053. },
  132054. enumerable: true,
  132055. configurable: true
  132056. });
  132057. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  132058. get: function () {
  132059. return this._cullFace;
  132060. },
  132061. set: function (value) {
  132062. if (this._cullFace === value) {
  132063. return;
  132064. }
  132065. this._cullFace = value;
  132066. this._isCullFaceDirty = true;
  132067. },
  132068. enumerable: true,
  132069. configurable: true
  132070. });
  132071. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  132072. get: function () {
  132073. return this._cull;
  132074. },
  132075. set: function (value) {
  132076. if (this._cull === value) {
  132077. return;
  132078. }
  132079. this._cull = value;
  132080. this._isCullDirty = true;
  132081. },
  132082. enumerable: true,
  132083. configurable: true
  132084. });
  132085. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  132086. get: function () {
  132087. return this._depthFunc;
  132088. },
  132089. set: function (value) {
  132090. if (this._depthFunc === value) {
  132091. return;
  132092. }
  132093. this._depthFunc = value;
  132094. this._isDepthFuncDirty = true;
  132095. },
  132096. enumerable: true,
  132097. configurable: true
  132098. });
  132099. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  132100. get: function () {
  132101. return this._depthMask;
  132102. },
  132103. set: function (value) {
  132104. if (this._depthMask === value) {
  132105. return;
  132106. }
  132107. this._depthMask = value;
  132108. this._isDepthMaskDirty = true;
  132109. },
  132110. enumerable: true,
  132111. configurable: true
  132112. });
  132113. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  132114. get: function () {
  132115. return this._depthTest;
  132116. },
  132117. set: function (value) {
  132118. if (this._depthTest === value) {
  132119. return;
  132120. }
  132121. this._depthTest = value;
  132122. this._isDepthTestDirty = true;
  132123. },
  132124. enumerable: true,
  132125. configurable: true
  132126. });
  132127. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  132128. get: function () {
  132129. return this._frontFace;
  132130. },
  132131. set: function (value) {
  132132. if (this._frontFace === value) {
  132133. return;
  132134. }
  132135. this._frontFace = value;
  132136. this._isFrontFaceDirty = true;
  132137. },
  132138. enumerable: true,
  132139. configurable: true
  132140. });
  132141. _DepthCullingState.prototype.reset = function () {
  132142. this._depthMask = true;
  132143. this._depthTest = true;
  132144. this._depthFunc = null;
  132145. this._cullFace = null;
  132146. this._cull = null;
  132147. this._zOffset = 0;
  132148. this._frontFace = null;
  132149. this._isDepthTestDirty = true;
  132150. this._isDepthMaskDirty = true;
  132151. this._isDepthFuncDirty = false;
  132152. this._isCullFaceDirty = false;
  132153. this._isCullDirty = false;
  132154. this._isZOffsetDirty = false;
  132155. this._isFrontFaceDirty = false;
  132156. };
  132157. _DepthCullingState.prototype.apply = function (gl) {
  132158. if (!this.isDirty) {
  132159. return;
  132160. }
  132161. // Cull
  132162. if (this._isCullDirty) {
  132163. if (this.cull) {
  132164. gl.enable(gl.CULL_FACE);
  132165. }
  132166. else {
  132167. gl.disable(gl.CULL_FACE);
  132168. }
  132169. this._isCullDirty = false;
  132170. }
  132171. // Cull face
  132172. if (this._isCullFaceDirty) {
  132173. gl.cullFace(this.cullFace);
  132174. this._isCullFaceDirty = false;
  132175. }
  132176. // Depth mask
  132177. if (this._isDepthMaskDirty) {
  132178. gl.depthMask(this.depthMask);
  132179. this._isDepthMaskDirty = false;
  132180. }
  132181. // Depth test
  132182. if (this._isDepthTestDirty) {
  132183. if (this.depthTest) {
  132184. gl.enable(gl.DEPTH_TEST);
  132185. }
  132186. else {
  132187. gl.disable(gl.DEPTH_TEST);
  132188. }
  132189. this._isDepthTestDirty = false;
  132190. }
  132191. // Depth func
  132192. if (this._isDepthFuncDirty) {
  132193. gl.depthFunc(this.depthFunc);
  132194. this._isDepthFuncDirty = false;
  132195. }
  132196. // zOffset
  132197. if (this._isZOffsetDirty) {
  132198. if (this.zOffset) {
  132199. gl.enable(gl.POLYGON_OFFSET_FILL);
  132200. gl.polygonOffset(this.zOffset, 0);
  132201. }
  132202. else {
  132203. gl.disable(gl.POLYGON_OFFSET_FILL);
  132204. }
  132205. this._isZOffsetDirty = false;
  132206. }
  132207. // Front face
  132208. if (this._isFrontFaceDirty) {
  132209. gl.frontFace(this.frontFace);
  132210. this._isFrontFaceDirty = false;
  132211. }
  132212. };
  132213. return _DepthCullingState;
  132214. }());
  132215. /***/ }),
  132216. /***/ "./States/index.ts":
  132217. /*!*************************!*\
  132218. !*** ./States/index.ts ***!
  132219. \*************************/
  132220. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  132221. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132222. "use strict";
  132223. __webpack_require__.r(__webpack_exports__);
  132224. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  132225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  132226. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  132227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  132228. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  132229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  132230. /***/ }),
  132231. /***/ "./States/stencilState.ts":
  132232. /*!********************************!*\
  132233. !*** ./States/stencilState.ts ***!
  132234. \********************************/
  132235. /*! exports provided: _StencilState */
  132236. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132237. "use strict";
  132238. __webpack_require__.r(__webpack_exports__);
  132239. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  132240. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  132241. /**
  132242. * @hidden
  132243. **/
  132244. var _StencilState = /** @class */ (function () {
  132245. function _StencilState() {
  132246. this._isStencilTestDirty = false;
  132247. this._isStencilMaskDirty = false;
  132248. this._isStencilFuncDirty = false;
  132249. this._isStencilOpDirty = false;
  132250. this.reset();
  132251. }
  132252. Object.defineProperty(_StencilState.prototype, "isDirty", {
  132253. get: function () {
  132254. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  132255. },
  132256. enumerable: true,
  132257. configurable: true
  132258. });
  132259. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  132260. get: function () {
  132261. return this._stencilFunc;
  132262. },
  132263. set: function (value) {
  132264. if (this._stencilFunc === value) {
  132265. return;
  132266. }
  132267. this._stencilFunc = value;
  132268. this._isStencilFuncDirty = true;
  132269. },
  132270. enumerable: true,
  132271. configurable: true
  132272. });
  132273. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  132274. get: function () {
  132275. return this._stencilFuncRef;
  132276. },
  132277. set: function (value) {
  132278. if (this._stencilFuncRef === value) {
  132279. return;
  132280. }
  132281. this._stencilFuncRef = value;
  132282. this._isStencilFuncDirty = true;
  132283. },
  132284. enumerable: true,
  132285. configurable: true
  132286. });
  132287. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  132288. get: function () {
  132289. return this._stencilFuncMask;
  132290. },
  132291. set: function (value) {
  132292. if (this._stencilFuncMask === value) {
  132293. return;
  132294. }
  132295. this._stencilFuncMask = value;
  132296. this._isStencilFuncDirty = true;
  132297. },
  132298. enumerable: true,
  132299. configurable: true
  132300. });
  132301. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  132302. get: function () {
  132303. return this._stencilOpStencilFail;
  132304. },
  132305. set: function (value) {
  132306. if (this._stencilOpStencilFail === value) {
  132307. return;
  132308. }
  132309. this._stencilOpStencilFail = value;
  132310. this._isStencilOpDirty = true;
  132311. },
  132312. enumerable: true,
  132313. configurable: true
  132314. });
  132315. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  132316. get: function () {
  132317. return this._stencilOpDepthFail;
  132318. },
  132319. set: function (value) {
  132320. if (this._stencilOpDepthFail === value) {
  132321. return;
  132322. }
  132323. this._stencilOpDepthFail = value;
  132324. this._isStencilOpDirty = true;
  132325. },
  132326. enumerable: true,
  132327. configurable: true
  132328. });
  132329. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  132330. get: function () {
  132331. return this._stencilOpStencilDepthPass;
  132332. },
  132333. set: function (value) {
  132334. if (this._stencilOpStencilDepthPass === value) {
  132335. return;
  132336. }
  132337. this._stencilOpStencilDepthPass = value;
  132338. this._isStencilOpDirty = true;
  132339. },
  132340. enumerable: true,
  132341. configurable: true
  132342. });
  132343. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  132344. get: function () {
  132345. return this._stencilMask;
  132346. },
  132347. set: function (value) {
  132348. if (this._stencilMask === value) {
  132349. return;
  132350. }
  132351. this._stencilMask = value;
  132352. this._isStencilMaskDirty = true;
  132353. },
  132354. enumerable: true,
  132355. configurable: true
  132356. });
  132357. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  132358. get: function () {
  132359. return this._stencilTest;
  132360. },
  132361. set: function (value) {
  132362. if (this._stencilTest === value) {
  132363. return;
  132364. }
  132365. this._stencilTest = value;
  132366. this._isStencilTestDirty = true;
  132367. },
  132368. enumerable: true,
  132369. configurable: true
  132370. });
  132371. _StencilState.prototype.reset = function () {
  132372. this._stencilTest = false;
  132373. this._stencilMask = 0xFF;
  132374. this._stencilFunc = _StencilState.ALWAYS;
  132375. this._stencilFuncRef = 1;
  132376. this._stencilFuncMask = 0xFF;
  132377. this._stencilOpStencilFail = _StencilState.KEEP;
  132378. this._stencilOpDepthFail = _StencilState.KEEP;
  132379. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  132380. this._isStencilTestDirty = true;
  132381. this._isStencilMaskDirty = true;
  132382. this._isStencilFuncDirty = true;
  132383. this._isStencilOpDirty = true;
  132384. };
  132385. _StencilState.prototype.apply = function (gl) {
  132386. if (!this.isDirty) {
  132387. return;
  132388. }
  132389. // Stencil test
  132390. if (this._isStencilTestDirty) {
  132391. if (this.stencilTest) {
  132392. gl.enable(gl.STENCIL_TEST);
  132393. }
  132394. else {
  132395. gl.disable(gl.STENCIL_TEST);
  132396. }
  132397. this._isStencilTestDirty = false;
  132398. }
  132399. // Stencil mask
  132400. if (this._isStencilMaskDirty) {
  132401. gl.stencilMask(this.stencilMask);
  132402. this._isStencilMaskDirty = false;
  132403. }
  132404. // Stencil func
  132405. if (this._isStencilFuncDirty) {
  132406. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  132407. this._isStencilFuncDirty = false;
  132408. }
  132409. // Stencil op
  132410. if (this._isStencilOpDirty) {
  132411. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  132412. this._isStencilOpDirty = false;
  132413. }
  132414. };
  132415. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  132416. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  132417. /** Passed to stencilOperation to specify that stencil value must be kept */
  132418. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  132419. /** Passed to stencilOperation to specify that stencil value must be replaced */
  132420. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  132421. return _StencilState;
  132422. }());
  132423. /***/ }),
  132424. /***/ "./abstractScene.ts":
  132425. /*!**************************!*\
  132426. !*** ./abstractScene.ts ***!
  132427. \**************************/
  132428. /*! exports provided: AbstractScene */
  132429. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132430. "use strict";
  132431. __webpack_require__.r(__webpack_exports__);
  132432. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  132433. /**
  132434. * Base class of the scene acting as a container for the different elements composing a scene.
  132435. * This class is dynamically extended by the different components of the scene increasing
  132436. * flexibility and reducing coupling
  132437. */
  132438. var AbstractScene = /** @class */ (function () {
  132439. function AbstractScene() {
  132440. /**
  132441. * Gets the list of root nodes (ie. nodes with no parent)
  132442. */
  132443. this.rootNodes = new Array();
  132444. /** All of the cameras added to this scene
  132445. * @see http://doc.babylonjs.com/babylon101/cameras
  132446. */
  132447. this.cameras = new Array();
  132448. /**
  132449. * All of the lights added to this scene
  132450. * @see http://doc.babylonjs.com/babylon101/lights
  132451. */
  132452. this.lights = new Array();
  132453. /**
  132454. * All of the (abstract) meshes added to this scene
  132455. */
  132456. this.meshes = new Array();
  132457. /**
  132458. * The list of skeletons added to the scene
  132459. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  132460. */
  132461. this.skeletons = new Array();
  132462. /**
  132463. * All of the particle systems added to this scene
  132464. * @see http://doc.babylonjs.com/babylon101/particles
  132465. */
  132466. this.particleSystems = new Array();
  132467. /**
  132468. * Gets a list of Animations associated with the scene
  132469. */
  132470. this.animations = [];
  132471. /**
  132472. * All of the animation groups added to this scene
  132473. * @see http://doc.babylonjs.com/how_to/group
  132474. */
  132475. this.animationGroups = new Array();
  132476. /**
  132477. * All of the multi-materials added to this scene
  132478. * @see http://doc.babylonjs.com/how_to/multi_materials
  132479. */
  132480. this.multiMaterials = new Array();
  132481. /**
  132482. * All of the materials added to this scene
  132483. * In the context of a Scene, it is not supposed to be modified manually.
  132484. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  132485. * Note also that the order of the Material wihin the array is not significant and might change.
  132486. * @see http://doc.babylonjs.com/babylon101/materials
  132487. */
  132488. this.materials = new Array();
  132489. /**
  132490. * The list of morph target managers added to the scene
  132491. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  132492. */
  132493. this.morphTargetManagers = new Array();
  132494. /**
  132495. * The list of geometries used in the scene.
  132496. */
  132497. this.geometries = new Array();
  132498. /**
  132499. * All of the tranform nodes added to this scene
  132500. * In the context of a Scene, it is not supposed to be modified manually.
  132501. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  132502. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  132503. * @see http://doc.babylonjs.com/how_to/transformnode
  132504. */
  132505. this.transformNodes = new Array();
  132506. /**
  132507. * ActionManagers available on the scene.
  132508. */
  132509. this.actionManagers = new Array();
  132510. /**
  132511. * Textures to keep.
  132512. */
  132513. this.textures = new Array();
  132514. /**
  132515. * Environment texture for the scene
  132516. */
  132517. this.environmentTexture = null;
  132518. }
  132519. /**
  132520. * Adds a parser in the list of available ones
  132521. * @param name Defines the name of the parser
  132522. * @param parser Defines the parser to add
  132523. */
  132524. AbstractScene.AddParser = function (name, parser) {
  132525. this._BabylonFileParsers[name] = parser;
  132526. };
  132527. /**
  132528. * Gets a general parser from the list of avaialble ones
  132529. * @param name Defines the name of the parser
  132530. * @returns the requested parser or null
  132531. */
  132532. AbstractScene.GetParser = function (name) {
  132533. if (this._BabylonFileParsers[name]) {
  132534. return this._BabylonFileParsers[name];
  132535. }
  132536. return null;
  132537. };
  132538. /**
  132539. * Adds n individual parser in the list of available ones
  132540. * @param name Defines the name of the parser
  132541. * @param parser Defines the parser to add
  132542. */
  132543. AbstractScene.AddIndividualParser = function (name, parser) {
  132544. this._IndividualBabylonFileParsers[name] = parser;
  132545. };
  132546. /**
  132547. * Gets an individual parser from the list of avaialble ones
  132548. * @param name Defines the name of the parser
  132549. * @returns the requested parser or null
  132550. */
  132551. AbstractScene.GetIndividualParser = function (name) {
  132552. if (this._IndividualBabylonFileParsers[name]) {
  132553. return this._IndividualBabylonFileParsers[name];
  132554. }
  132555. return null;
  132556. };
  132557. /**
  132558. * Parser json data and populate both a scene and its associated container object
  132559. * @param jsonData Defines the data to parse
  132560. * @param scene Defines the scene to parse the data for
  132561. * @param container Defines the container attached to the parsing sequence
  132562. * @param rootUrl Defines the root url of the data
  132563. */
  132564. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  132565. for (var parserName in this._BabylonFileParsers) {
  132566. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  132567. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  132568. }
  132569. }
  132570. };
  132571. /**
  132572. * Stores the list of available parsers in the application.
  132573. */
  132574. AbstractScene._BabylonFileParsers = {};
  132575. /**
  132576. * Stores the list of available individual parsers in the application.
  132577. */
  132578. AbstractScene._IndividualBabylonFileParsers = {};
  132579. return AbstractScene;
  132580. }());
  132581. /***/ }),
  132582. /***/ "./assetContainer.ts":
  132583. /*!***************************!*\
  132584. !*** ./assetContainer.ts ***!
  132585. \***************************/
  132586. /*! exports provided: KeepAssets, AssetContainer */
  132587. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132588. "use strict";
  132589. __webpack_require__.r(__webpack_exports__);
  132590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  132591. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  132592. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  132593. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  132594. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  132595. /**
  132596. * Set of assets to keep when moving a scene into an asset container.
  132597. */
  132598. var KeepAssets = /** @class */ (function (_super) {
  132599. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  132600. function KeepAssets() {
  132601. return _super !== null && _super.apply(this, arguments) || this;
  132602. }
  132603. return KeepAssets;
  132604. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  132605. /**
  132606. * Container with a set of assets that can be added or removed from a scene.
  132607. */
  132608. var AssetContainer = /** @class */ (function (_super) {
  132609. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  132610. /**
  132611. * Instantiates an AssetContainer.
  132612. * @param scene The scene the AssetContainer belongs to.
  132613. */
  132614. function AssetContainer(scene) {
  132615. var _this = _super.call(this) || this;
  132616. _this.scene = scene;
  132617. _this["sounds"] = [];
  132618. _this["effectLayers"] = [];
  132619. _this["layers"] = [];
  132620. _this["lensFlareSystems"] = [];
  132621. _this["proceduralTextures"] = [];
  132622. _this["reflectionProbes"] = [];
  132623. return _this;
  132624. }
  132625. /**
  132626. * Adds all the assets from the container to the scene.
  132627. */
  132628. AssetContainer.prototype.addAllToScene = function () {
  132629. var _this = this;
  132630. this.cameras.forEach(function (o) {
  132631. _this.scene.addCamera(o);
  132632. });
  132633. this.lights.forEach(function (o) {
  132634. _this.scene.addLight(o);
  132635. });
  132636. this.meshes.forEach(function (o) {
  132637. _this.scene.addMesh(o);
  132638. });
  132639. this.skeletons.forEach(function (o) {
  132640. _this.scene.addSkeleton(o);
  132641. });
  132642. this.animations.forEach(function (o) {
  132643. _this.scene.addAnimation(o);
  132644. });
  132645. this.animationGroups.forEach(function (o) {
  132646. _this.scene.addAnimationGroup(o);
  132647. });
  132648. this.multiMaterials.forEach(function (o) {
  132649. _this.scene.addMultiMaterial(o);
  132650. });
  132651. this.materials.forEach(function (o) {
  132652. _this.scene.addMaterial(o);
  132653. });
  132654. this.morphTargetManagers.forEach(function (o) {
  132655. _this.scene.addMorphTargetManager(o);
  132656. });
  132657. this.geometries.forEach(function (o) {
  132658. _this.scene.addGeometry(o);
  132659. });
  132660. this.transformNodes.forEach(function (o) {
  132661. _this.scene.addTransformNode(o);
  132662. });
  132663. this.actionManagers.forEach(function (o) {
  132664. _this.scene.addActionManager(o);
  132665. });
  132666. this.textures.forEach(function (o) {
  132667. _this.scene.addTexture(o);
  132668. });
  132669. this.reflectionProbes.forEach(function (o) {
  132670. _this.scene.addReflectionProbe(o);
  132671. });
  132672. if (this.environmentTexture) {
  132673. this.scene.environmentTexture = this.environmentTexture;
  132674. }
  132675. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  132676. var component = _a[_i];
  132677. component.addFromContainer(this);
  132678. }
  132679. };
  132680. /**
  132681. * Removes all the assets in the container from the scene
  132682. */
  132683. AssetContainer.prototype.removeAllFromScene = function () {
  132684. var _this = this;
  132685. this.cameras.forEach(function (o) {
  132686. _this.scene.removeCamera(o);
  132687. });
  132688. this.lights.forEach(function (o) {
  132689. _this.scene.removeLight(o);
  132690. });
  132691. this.meshes.forEach(function (o) {
  132692. _this.scene.removeMesh(o);
  132693. });
  132694. this.skeletons.forEach(function (o) {
  132695. _this.scene.removeSkeleton(o);
  132696. });
  132697. this.animations.forEach(function (o) {
  132698. _this.scene.removeAnimation(o);
  132699. });
  132700. this.animationGroups.forEach(function (o) {
  132701. _this.scene.removeAnimationGroup(o);
  132702. });
  132703. this.multiMaterials.forEach(function (o) {
  132704. _this.scene.removeMultiMaterial(o);
  132705. });
  132706. this.materials.forEach(function (o) {
  132707. _this.scene.removeMaterial(o);
  132708. });
  132709. this.morphTargetManagers.forEach(function (o) {
  132710. _this.scene.removeMorphTargetManager(o);
  132711. });
  132712. this.geometries.forEach(function (o) {
  132713. _this.scene.removeGeometry(o);
  132714. });
  132715. this.transformNodes.forEach(function (o) {
  132716. _this.scene.removeTransformNode(o);
  132717. });
  132718. this.actionManagers.forEach(function (o) {
  132719. _this.scene.removeActionManager(o);
  132720. });
  132721. this.textures.forEach(function (o) {
  132722. _this.scene.removeTexture(o);
  132723. });
  132724. this.reflectionProbes.forEach(function (o) {
  132725. _this.scene.removeReflectionProbe(o);
  132726. });
  132727. if (this.environmentTexture === this.scene.environmentTexture) {
  132728. this.scene.environmentTexture = null;
  132729. }
  132730. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  132731. var component = _a[_i];
  132732. component.removeFromContainer(this);
  132733. }
  132734. };
  132735. /**
  132736. * Disposes all the assets in the container
  132737. */
  132738. AssetContainer.prototype.dispose = function () {
  132739. this.cameras.forEach(function (o) {
  132740. o.dispose();
  132741. });
  132742. this.cameras = [];
  132743. this.lights.forEach(function (o) {
  132744. o.dispose();
  132745. });
  132746. this.lights = [];
  132747. this.meshes.forEach(function (o) {
  132748. o.dispose();
  132749. });
  132750. this.meshes = [];
  132751. this.skeletons.forEach(function (o) {
  132752. o.dispose();
  132753. });
  132754. this.skeletons = [];
  132755. this.animationGroups.forEach(function (o) {
  132756. o.dispose();
  132757. });
  132758. this.animationGroups = [];
  132759. this.multiMaterials.forEach(function (o) {
  132760. o.dispose();
  132761. });
  132762. this.multiMaterials = [];
  132763. this.materials.forEach(function (o) {
  132764. o.dispose();
  132765. });
  132766. this.materials = [];
  132767. this.geometries.forEach(function (o) {
  132768. o.dispose();
  132769. });
  132770. this.geometries = [];
  132771. this.transformNodes.forEach(function (o) {
  132772. o.dispose();
  132773. });
  132774. this.transformNodes = [];
  132775. this.actionManagers.forEach(function (o) {
  132776. o.dispose();
  132777. });
  132778. this.actionManagers = [];
  132779. this.textures.forEach(function (o) {
  132780. o.dispose();
  132781. });
  132782. this.textures = [];
  132783. this.reflectionProbes.forEach(function (o) {
  132784. o.dispose();
  132785. });
  132786. this.reflectionProbes = [];
  132787. if (this.environmentTexture) {
  132788. this.environmentTexture.dispose();
  132789. this.environmentTexture = null;
  132790. }
  132791. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  132792. var component = _a[_i];
  132793. component.removeFromContainer(this, true);
  132794. }
  132795. };
  132796. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  132797. if (!sourceAssets) {
  132798. return;
  132799. }
  132800. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  132801. var asset = sourceAssets_1[_i];
  132802. var move = true;
  132803. if (keepAssets) {
  132804. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  132805. var keepAsset = keepAssets_1[_a];
  132806. if (asset === keepAsset) {
  132807. move = false;
  132808. break;
  132809. }
  132810. }
  132811. }
  132812. if (move) {
  132813. targetAssets.push(asset);
  132814. }
  132815. }
  132816. };
  132817. /**
  132818. * Removes all the assets contained in the scene and adds them to the container.
  132819. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  132820. */
  132821. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  132822. if (keepAssets === undefined) {
  132823. keepAssets = new KeepAssets();
  132824. }
  132825. for (var key in this) {
  132826. if (this.hasOwnProperty(key)) {
  132827. this[key] = this[key] || [];
  132828. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  132829. }
  132830. }
  132831. this.removeAllFromScene();
  132832. };
  132833. /**
  132834. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  132835. * @returns the root mesh
  132836. */
  132837. AssetContainer.prototype.createRootMesh = function () {
  132838. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  132839. this.meshes.forEach(function (m) {
  132840. if (!m.parent) {
  132841. rootMesh.addChild(m);
  132842. }
  132843. });
  132844. this.meshes.unshift(rootMesh);
  132845. return rootMesh;
  132846. };
  132847. return AssetContainer;
  132848. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  132849. /***/ }),
  132850. /***/ "./index.ts":
  132851. /*!******************!*\
  132852. !*** ./index.ts ***!
  132853. \******************/
  132854. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, _IAnimationState, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, VRMultiviewToSingleviewPostProcess, ReflectionProbe, BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer, Sprite, SpriteManager, SpriteSceneComponent, _AlphaState, _DepthCullingState, _StencilState, AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, EquiRectangularCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, MeshExploder, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  132855. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132856. "use strict";
  132857. __webpack_require__.r(__webpack_exports__);
  132858. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  132859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  132860. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  132861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  132862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  132863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  132864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  132865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  132866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  132867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  132868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  132869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  132870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  132871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  132872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  132873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  132874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  132875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  132876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  132877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  132878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  132879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  132880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  132881. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  132882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  132883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IAnimationState", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["_IAnimationState"]; });
  132884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  132885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  132886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  132887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  132888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  132889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  132890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  132891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  132892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  132893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  132894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  132895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  132896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  132897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  132898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  132899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  132900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  132901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  132902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  132903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  132904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  132905. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  132906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  132907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  132908. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  132909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  132910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  132911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  132912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  132913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  132914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  132915. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  132916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  132917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  132918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  132919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  132920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  132921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  132922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  132923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  132924. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  132925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  132926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  132927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  132928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  132929. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  132930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  132931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  132932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  132933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  132934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  132935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  132936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  132937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  132938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  132939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  132940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  132941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  132942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  132943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  132944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  132945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  132946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  132947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  132948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  132949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  132950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  132951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  132952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  132953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  132954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  132955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraMouseWheelInput"]; });
  132956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraPointersInput"]; });
  132957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  132958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  132959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  132960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  132961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  132962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  132963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  132964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  132965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  132966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  132967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  132968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  132969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  132970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  132971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  132972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  132973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  132974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  132975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["OnAfterEnteringVRObservableEvent"]; });
  132976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  132977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  132978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  132979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  132980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  132981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  132982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  132983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  132984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  132985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  132986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  132987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  132988. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  132989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  132990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["DefaultCollisionCoordinator"]; });
  132991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  132992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  132993. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  132994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  132995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  132996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  132997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  132998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  132999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  133000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  133001. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  133002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  133003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  133004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  133005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  133006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  133007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  133008. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  133009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  133010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  133011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  133012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  133013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  133014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  133015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  133016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  133017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  133018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  133019. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  133020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  133021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  133022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  133023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  133024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  133025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  133026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  133027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  133028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  133029. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  133030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  133031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  133032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  133033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  133034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  133035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  133036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  133037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  133038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  133039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  133040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  133041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  133042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  133043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  133044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  133045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  133046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  133047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  133048. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  133049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  133050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  133051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  133052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  133053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  133054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  133055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  133056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  133057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  133058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["LightGizmo"]; });
  133059. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  133060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  133061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  133062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  133063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  133064. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  133065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  133066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  133067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  133068. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  133069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  133070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  133071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  133072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  133073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  133074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  133075. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  133076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  133077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  133078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  133079. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  133080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  133081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  133082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  133083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  133084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  133085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  133086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  133087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  133088. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  133089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  133090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  133091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  133092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  133093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  133094. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  133095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  133096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  133097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  133098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  133099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  133100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  133101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  133102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  133103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  133104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  133105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  133106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  133107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  133108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  133109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  133110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  133111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  133112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EquiRectangularCubeTexture"]; });
  133113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  133114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  133115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  133116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  133117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  133118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  133119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  133120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  133121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  133122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  133123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterialDefines"]; });
  133124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  133125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  133126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  133127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  133128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  133129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  133130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  133131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  133132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  133133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  133134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  133135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  133136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  133137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  133138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  133139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  133140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  133141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  133142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  133143. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  133144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  133145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  133146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  133147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  133148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  133149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  133150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  133151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  133152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  133153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  133154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  133155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  133156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  133157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  133158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  133159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  133160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  133161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  133162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  133163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  133164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  133165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  133166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  133167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  133168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  133169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  133170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  133171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  133172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  133173. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  133174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  133175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  133176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  133177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  133178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  133179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  133180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TrailMesh"]; });
  133181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  133182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  133183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  133184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  133185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  133186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  133187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  133188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  133189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  133190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  133191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  133192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  133193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  133194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  133195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  133196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  133197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  133198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  133199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxBuilder"]; });
  133200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereBuilder"]; });
  133201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderBuilder"]; });
  133202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesBuilder"]; });
  133203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneBuilder"]; });
  133204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  133205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscBuilder"]; });
  133206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonBuilder"]; });
  133207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["HemisphereBuilder"]; });
  133208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusBuilder"]; });
  133209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotBuilder"]; });
  133210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonBuilder"]; });
  133211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["ShapeBuilder"]; });
  133212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LatheBuilder"]; });
  133213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundBuilder"]; });
  133214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TubeBuilder"]; });
  133215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolyhedronBuilder"]; });
  133216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["IcoSphereBuilder"]; });
  133217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DecalBuilder"]; });
  133218. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  133219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  133220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  133221. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  133222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  133223. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  133224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  133225. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  133226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  133227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  133228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  133229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  133230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  133231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  133232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  133233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  133234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  133235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  133236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  133237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  133238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  133239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  133240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  133241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  133242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  133243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  133244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  133245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  133246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  133247. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  133248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  133249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  133250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  133251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEventOptions"]; });
  133252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEventOptions"]; });
  133253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEventOptions"]; });
  133254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  133255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  133256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  133257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  133258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  133259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  133260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  133261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  133262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  133263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  133264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  133265. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  133266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  133267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  133268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  133269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  133270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  133271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  133272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  133273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  133274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  133275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  133276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  133277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  133278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  133279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  133280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  133281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  133282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  133283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  133284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  133285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  133286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  133287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  133288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  133289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  133290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  133291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  133292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  133293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  133294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  133295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  133296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  133297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  133298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  133299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRMultiviewToSingleviewPostProcess"]; });
  133300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  133301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  133302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  133303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  133304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  133305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  133306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  133307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  133308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  133309. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  133310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  133311. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  133312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  133313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  133314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  133315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  133316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  133317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  133318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  133319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  133320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  133321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  133322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  133323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  133324. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  133325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  133326. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  133327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  133328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  133329. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  133330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  133331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  133332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  133333. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  133334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  133335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  133336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  133337. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  133338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  133339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  133340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  133341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  133342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  133343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  133344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  133345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  133346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  133347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  133348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  133349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EquiRectangularCubeTextureAssetTask"]; });
  133350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  133351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  133352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  133353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  133354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  133355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  133356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  133357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  133358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  133359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  133360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  133361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  133362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  133363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  133364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMatrix"]; });
  133365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  133366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  133367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  133368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  133369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshExploder"]; });
  133370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  133371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  133372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  133373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  133374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  133375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  133376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  133377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  133378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  133379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  133380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  133381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  133382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  133383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  133384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  133385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  133386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  133387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  133388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  133389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  133390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  133391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  133392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  133393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  133394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  133395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  133396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  133397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  133398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  133399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  133400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  133401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  133402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  133403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  133404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  133405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  133406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  133407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  133408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  133409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  133410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  133411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  133412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  133413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  133414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  133415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  133416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  133417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  133418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WebRequest"]; });
  133419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["InspectableType"]; });
  133420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  133421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  133422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  133423. /***/ }),
  133424. /***/ "./node.ts":
  133425. /*!*****************!*\
  133426. !*** ./node.ts ***!
  133427. \*****************/
  133428. /*! exports provided: Node */
  133429. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133430. "use strict";
  133431. __webpack_require__.r(__webpack_exports__);
  133432. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  133433. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  133434. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  133435. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  133436. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  133437. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  133438. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  133439. /**
  133440. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  133441. */
  133442. var Node = /** @class */ (function () {
  133443. /**
  133444. * Creates a new Node
  133445. * @param name the name and id to be given to this node
  133446. * @param scene the scene this node will be added to
  133447. * @param addToRootNodes the node will be added to scene.rootNodes
  133448. */
  133449. function Node(name, scene, addToRootNodes) {
  133450. if (scene === void 0) { scene = null; }
  133451. if (addToRootNodes === void 0) { addToRootNodes = true; }
  133452. /**
  133453. * Gets or sets a string used to store user defined state for the node
  133454. */
  133455. this.state = "";
  133456. /**
  133457. * Gets or sets an object used to store user defined information for the node
  133458. */
  133459. this.metadata = null;
  133460. /**
  133461. * For internal use only. Please do not use.
  133462. */
  133463. this.reservedDataStore = null;
  133464. /**
  133465. * Gets or sets a boolean used to define if the node must be serialized
  133466. */
  133467. this.doNotSerialize = false;
  133468. /** @hidden */
  133469. this._isDisposed = false;
  133470. /**
  133471. * Gets a list of Animations associated with the node
  133472. */
  133473. this.animations = new Array();
  133474. this._ranges = {};
  133475. this._isEnabled = true;
  133476. this._isParentEnabled = true;
  133477. this._isReady = true;
  133478. /** @hidden */
  133479. this._currentRenderId = -1;
  133480. this._parentUpdateId = -1;
  133481. /** @hidden */
  133482. this._childUpdateId = -1;
  133483. /** @hidden */
  133484. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  133485. /** @hidden */
  133486. this._worldMatrixDeterminant = 0;
  133487. /** @hidden */
  133488. this._worldMatrixDeterminantIsDirty = true;
  133489. /** @hidden */
  133490. this._sceneRootNodesIndex = -1;
  133491. this._animationPropertiesOverride = null;
  133492. /** @hidden */
  133493. this._isNode = true;
  133494. /**
  133495. * An event triggered when the mesh is disposed
  133496. */
  133497. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133498. // Behaviors
  133499. this._behaviors = new Array();
  133500. this.name = name;
  133501. this.id = name;
  133502. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  133503. this.uniqueId = this._scene.getUniqueId();
  133504. this._initCache();
  133505. if (addToRootNodes) {
  133506. this.addToSceneRootNodes();
  133507. }
  133508. }
  133509. /**
  133510. * Add a new node constructor
  133511. * @param type defines the type name of the node to construct
  133512. * @param constructorFunc defines the constructor function
  133513. */
  133514. Node.AddNodeConstructor = function (type, constructorFunc) {
  133515. this._NodeConstructors[type] = constructorFunc;
  133516. };
  133517. /**
  133518. * Returns a node constructor based on type name
  133519. * @param type defines the type name
  133520. * @param name defines the new node name
  133521. * @param scene defines the hosting scene
  133522. * @param options defines optional options to transmit to constructors
  133523. * @returns the new constructor or null
  133524. */
  133525. Node.Construct = function (type, name, scene, options) {
  133526. var constructorFunc = this._NodeConstructors[type];
  133527. if (!constructorFunc) {
  133528. return null;
  133529. }
  133530. return constructorFunc(name, scene, options);
  133531. };
  133532. /**
  133533. * Gets a boolean indicating if the node has been disposed
  133534. * @returns true if the node was disposed
  133535. */
  133536. Node.prototype.isDisposed = function () {
  133537. return this._isDisposed;
  133538. };
  133539. Object.defineProperty(Node.prototype, "parent", {
  133540. get: function () {
  133541. return this._parentNode;
  133542. },
  133543. /**
  133544. * Gets or sets the parent of the node (without keeping the current position in the scene)
  133545. * @see https://doc.babylonjs.com/how_to/parenting
  133546. */
  133547. set: function (parent) {
  133548. if (this._parentNode === parent) {
  133549. return;
  133550. }
  133551. var previousParentNode = this._parentNode;
  133552. // Remove self from list of children of parent
  133553. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  133554. var index = this._parentNode._children.indexOf(this);
  133555. if (index !== -1) {
  133556. this._parentNode._children.splice(index, 1);
  133557. }
  133558. if (!parent && !this._isDisposed) {
  133559. this.addToSceneRootNodes();
  133560. }
  133561. }
  133562. // Store new parent
  133563. this._parentNode = parent;
  133564. // Add as child to new parent
  133565. if (this._parentNode) {
  133566. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  133567. this._parentNode._children = new Array();
  133568. }
  133569. this._parentNode._children.push(this);
  133570. if (!previousParentNode) {
  133571. this.removeFromSceneRootNodes();
  133572. }
  133573. }
  133574. // Enabled state
  133575. this._syncParentEnabledState();
  133576. },
  133577. enumerable: true,
  133578. configurable: true
  133579. });
  133580. Node.prototype.addToSceneRootNodes = function () {
  133581. if (this._sceneRootNodesIndex === -1) {
  133582. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  133583. this._scene.rootNodes.push(this);
  133584. }
  133585. };
  133586. Node.prototype.removeFromSceneRootNodes = function () {
  133587. if (this._sceneRootNodesIndex !== -1) {
  133588. var rootNodes = this._scene.rootNodes;
  133589. var lastIdx = rootNodes.length - 1;
  133590. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  133591. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  133592. this._scene.rootNodes.pop();
  133593. this._sceneRootNodesIndex = -1;
  133594. }
  133595. };
  133596. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  133597. /**
  133598. * Gets or sets the animation properties override
  133599. */
  133600. get: function () {
  133601. if (!this._animationPropertiesOverride) {
  133602. return this._scene.animationPropertiesOverride;
  133603. }
  133604. return this._animationPropertiesOverride;
  133605. },
  133606. set: function (value) {
  133607. this._animationPropertiesOverride = value;
  133608. },
  133609. enumerable: true,
  133610. configurable: true
  133611. });
  133612. /**
  133613. * Gets a string idenfifying the name of the class
  133614. * @returns "Node" string
  133615. */
  133616. Node.prototype.getClassName = function () {
  133617. return "Node";
  133618. };
  133619. Object.defineProperty(Node.prototype, "onDispose", {
  133620. /**
  133621. * Sets a callback that will be raised when the node will be disposed
  133622. */
  133623. set: function (callback) {
  133624. if (this._onDisposeObserver) {
  133625. this.onDisposeObservable.remove(this._onDisposeObserver);
  133626. }
  133627. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  133628. },
  133629. enumerable: true,
  133630. configurable: true
  133631. });
  133632. /**
  133633. * Gets the scene of the node
  133634. * @returns a scene
  133635. */
  133636. Node.prototype.getScene = function () {
  133637. return this._scene;
  133638. };
  133639. /**
  133640. * Gets the engine of the node
  133641. * @returns a Engine
  133642. */
  133643. Node.prototype.getEngine = function () {
  133644. return this._scene.getEngine();
  133645. };
  133646. /**
  133647. * Attach a behavior to the node
  133648. * @see http://doc.babylonjs.com/features/behaviour
  133649. * @param behavior defines the behavior to attach
  133650. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  133651. * @returns the current Node
  133652. */
  133653. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  133654. var _this = this;
  133655. if (attachImmediately === void 0) { attachImmediately = false; }
  133656. var index = this._behaviors.indexOf(behavior);
  133657. if (index !== -1) {
  133658. return this;
  133659. }
  133660. behavior.init();
  133661. if (this._scene.isLoading && !attachImmediately) {
  133662. // We defer the attach when the scene will be loaded
  133663. this._scene.onDataLoadedObservable.addOnce(function () {
  133664. behavior.attach(_this);
  133665. });
  133666. }
  133667. else {
  133668. behavior.attach(this);
  133669. }
  133670. this._behaviors.push(behavior);
  133671. return this;
  133672. };
  133673. /**
  133674. * Remove an attached behavior
  133675. * @see http://doc.babylonjs.com/features/behaviour
  133676. * @param behavior defines the behavior to attach
  133677. * @returns the current Node
  133678. */
  133679. Node.prototype.removeBehavior = function (behavior) {
  133680. var index = this._behaviors.indexOf(behavior);
  133681. if (index === -1) {
  133682. return this;
  133683. }
  133684. this._behaviors[index].detach();
  133685. this._behaviors.splice(index, 1);
  133686. return this;
  133687. };
  133688. Object.defineProperty(Node.prototype, "behaviors", {
  133689. /**
  133690. * Gets the list of attached behaviors
  133691. * @see http://doc.babylonjs.com/features/behaviour
  133692. */
  133693. get: function () {
  133694. return this._behaviors;
  133695. },
  133696. enumerable: true,
  133697. configurable: true
  133698. });
  133699. /**
  133700. * Gets an attached behavior by name
  133701. * @param name defines the name of the behavior to look for
  133702. * @see http://doc.babylonjs.com/features/behaviour
  133703. * @returns null if behavior was not found else the requested behavior
  133704. */
  133705. Node.prototype.getBehaviorByName = function (name) {
  133706. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  133707. var behavior = _a[_i];
  133708. if (behavior.name === name) {
  133709. return behavior;
  133710. }
  133711. }
  133712. return null;
  133713. };
  133714. /**
  133715. * Returns the latest update of the World matrix
  133716. * @returns a Matrix
  133717. */
  133718. Node.prototype.getWorldMatrix = function () {
  133719. if (this._currentRenderId !== this._scene.getRenderId()) {
  133720. this.computeWorldMatrix();
  133721. }
  133722. return this._worldMatrix;
  133723. };
  133724. /** @hidden */
  133725. Node.prototype._getWorldMatrixDeterminant = function () {
  133726. if (this._worldMatrixDeterminantIsDirty) {
  133727. this._worldMatrixDeterminantIsDirty = false;
  133728. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  133729. }
  133730. return this._worldMatrixDeterminant;
  133731. };
  133732. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  133733. /**
  133734. * Returns directly the latest state of the mesh World matrix.
  133735. * A Matrix is returned.
  133736. */
  133737. get: function () {
  133738. return this._worldMatrix;
  133739. },
  133740. enumerable: true,
  133741. configurable: true
  133742. });
  133743. // override it in derived class if you add new variables to the cache
  133744. // and call the parent class method
  133745. /** @hidden */
  133746. Node.prototype._initCache = function () {
  133747. this._cache = {};
  133748. this._cache.parent = undefined;
  133749. };
  133750. /** @hidden */
  133751. Node.prototype.updateCache = function (force) {
  133752. if (!force && this.isSynchronized()) {
  133753. return;
  133754. }
  133755. this._cache.parent = this.parent;
  133756. this._updateCache();
  133757. };
  133758. /** @hidden */
  133759. Node.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  133760. if (initialCall === void 0) { initialCall = true; }
  133761. if (!this.parent) {
  133762. return null;
  133763. }
  133764. return this.parent._getActionManagerForTrigger(trigger, false);
  133765. };
  133766. // override it in derived class if you add new variables to the cache
  133767. // and call the parent class method if !ignoreParentClass
  133768. /** @hidden */
  133769. Node.prototype._updateCache = function (ignoreParentClass) {
  133770. };
  133771. // override it in derived class if you add new variables to the cache
  133772. /** @hidden */
  133773. Node.prototype._isSynchronized = function () {
  133774. return true;
  133775. };
  133776. /** @hidden */
  133777. Node.prototype._markSyncedWithParent = function () {
  133778. if (this._parentNode) {
  133779. this._parentUpdateId = this._parentNode._childUpdateId;
  133780. }
  133781. };
  133782. /** @hidden */
  133783. Node.prototype.isSynchronizedWithParent = function () {
  133784. if (!this._parentNode) {
  133785. return true;
  133786. }
  133787. if (this._parentUpdateId !== this._parentNode._childUpdateId) {
  133788. return false;
  133789. }
  133790. return this._parentNode.isSynchronized();
  133791. };
  133792. /** @hidden */
  133793. Node.prototype.isSynchronized = function () {
  133794. if (this._cache.parent != this._parentNode) {
  133795. this._cache.parent = this._parentNode;
  133796. return false;
  133797. }
  133798. if (this._parentNode && !this.isSynchronizedWithParent()) {
  133799. return false;
  133800. }
  133801. return this._isSynchronized();
  133802. };
  133803. /**
  133804. * Is this node ready to be used/rendered
  133805. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  133806. * @return true if the node is ready
  133807. */
  133808. Node.prototype.isReady = function (completeCheck) {
  133809. if (completeCheck === void 0) { completeCheck = false; }
  133810. return this._isReady;
  133811. };
  133812. /**
  133813. * Is this node enabled?
  133814. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  133815. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  133816. * @return whether this node (and its parent) is enabled
  133817. */
  133818. Node.prototype.isEnabled = function (checkAncestors) {
  133819. if (checkAncestors === void 0) { checkAncestors = true; }
  133820. if (checkAncestors === false) {
  133821. return this._isEnabled;
  133822. }
  133823. if (!this._isEnabled) {
  133824. return false;
  133825. }
  133826. return this._isParentEnabled;
  133827. };
  133828. /** @hidden */
  133829. Node.prototype._syncParentEnabledState = function () {
  133830. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  133831. if (this._children) {
  133832. this._children.forEach(function (c) {
  133833. c._syncParentEnabledState(); // Force children to update accordingly
  133834. });
  133835. }
  133836. };
  133837. /**
  133838. * Set the enabled state of this node
  133839. * @param value defines the new enabled state
  133840. */
  133841. Node.prototype.setEnabled = function (value) {
  133842. this._isEnabled = value;
  133843. this._syncParentEnabledState();
  133844. };
  133845. /**
  133846. * Is this node a descendant of the given node?
  133847. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  133848. * @param ancestor defines the parent node to inspect
  133849. * @returns a boolean indicating if this node is a descendant of the given node
  133850. */
  133851. Node.prototype.isDescendantOf = function (ancestor) {
  133852. if (this.parent) {
  133853. if (this.parent === ancestor) {
  133854. return true;
  133855. }
  133856. return this.parent.isDescendantOf(ancestor);
  133857. }
  133858. return false;
  133859. };
  133860. /** @hidden */
  133861. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  133862. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  133863. if (!this._children) {
  133864. return;
  133865. }
  133866. for (var index = 0; index < this._children.length; index++) {
  133867. var item = this._children[index];
  133868. if (!predicate || predicate(item)) {
  133869. results.push(item);
  133870. }
  133871. if (!directDescendantsOnly) {
  133872. item._getDescendants(results, false, predicate);
  133873. }
  133874. }
  133875. };
  133876. /**
  133877. * Will return all nodes that have this node as ascendant
  133878. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  133879. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  133880. * @return all children nodes of all types
  133881. */
  133882. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  133883. var results = new Array();
  133884. this._getDescendants(results, directDescendantsOnly, predicate);
  133885. return results;
  133886. };
  133887. /**
  133888. * Get all child-meshes of this node
  133889. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  133890. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  133891. * @returns an array of AbstractMesh
  133892. */
  133893. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  133894. var results = [];
  133895. this._getDescendants(results, directDescendantsOnly, function (node) {
  133896. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  133897. });
  133898. return results;
  133899. };
  133900. /**
  133901. * Get all direct children of this node
  133902. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  133903. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  133904. * @returns an array of Node
  133905. */
  133906. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  133907. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  133908. return this.getDescendants(directDescendantsOnly, predicate);
  133909. };
  133910. /** @hidden */
  133911. Node.prototype._setReady = function (state) {
  133912. if (state === this._isReady) {
  133913. return;
  133914. }
  133915. if (!state) {
  133916. this._isReady = false;
  133917. return;
  133918. }
  133919. if (this.onReady) {
  133920. this.onReady(this);
  133921. }
  133922. this._isReady = true;
  133923. };
  133924. /**
  133925. * Get an animation by name
  133926. * @param name defines the name of the animation to look for
  133927. * @returns null if not found else the requested animation
  133928. */
  133929. Node.prototype.getAnimationByName = function (name) {
  133930. for (var i = 0; i < this.animations.length; i++) {
  133931. var animation = this.animations[i];
  133932. if (animation.name === name) {
  133933. return animation;
  133934. }
  133935. }
  133936. return null;
  133937. };
  133938. /**
  133939. * Creates an animation range for this node
  133940. * @param name defines the name of the range
  133941. * @param from defines the starting key
  133942. * @param to defines the end key
  133943. */
  133944. Node.prototype.createAnimationRange = function (name, from, to) {
  133945. // check name not already in use
  133946. if (!this._ranges[name]) {
  133947. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  133948. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  133949. if (this.animations[i]) {
  133950. this.animations[i].createRange(name, from, to);
  133951. }
  133952. }
  133953. }
  133954. };
  133955. /**
  133956. * Delete a specific animation range
  133957. * @param name defines the name of the range to delete
  133958. * @param deleteFrames defines if animation frames from the range must be deleted as well
  133959. */
  133960. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  133961. if (deleteFrames === void 0) { deleteFrames = true; }
  133962. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  133963. if (this.animations[i]) {
  133964. this.animations[i].deleteRange(name, deleteFrames);
  133965. }
  133966. }
  133967. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  133968. };
  133969. /**
  133970. * Get an animation range by name
  133971. * @param name defines the name of the animation range to look for
  133972. * @returns null if not found else the requested animation range
  133973. */
  133974. Node.prototype.getAnimationRange = function (name) {
  133975. return this._ranges[name];
  133976. };
  133977. /**
  133978. * Gets the list of all animation ranges defined on this node
  133979. * @returns an array
  133980. */
  133981. Node.prototype.getAnimationRanges = function () {
  133982. var animationRanges = [];
  133983. var name;
  133984. for (name in this._ranges) {
  133985. animationRanges.push(this._ranges[name]);
  133986. }
  133987. return animationRanges;
  133988. };
  133989. /**
  133990. * Will start the animation sequence
  133991. * @param name defines the range frames for animation sequence
  133992. * @param loop defines if the animation should loop (false by default)
  133993. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  133994. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  133995. * @returns the object created for this animation. If range does not exist, it will return null
  133996. */
  133997. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  133998. var range = this.getAnimationRange(name);
  133999. if (!range) {
  134000. return null;
  134001. }
  134002. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  134003. };
  134004. /**
  134005. * Serialize animation ranges into a JSON compatible object
  134006. * @returns serialization object
  134007. */
  134008. Node.prototype.serializeAnimationRanges = function () {
  134009. var serializationRanges = [];
  134010. for (var name in this._ranges) {
  134011. var localRange = this._ranges[name];
  134012. if (!localRange) {
  134013. continue;
  134014. }
  134015. var range = {};
  134016. range.name = name;
  134017. range.from = localRange.from;
  134018. range.to = localRange.to;
  134019. serializationRanges.push(range);
  134020. }
  134021. return serializationRanges;
  134022. };
  134023. /**
  134024. * Computes the world matrix of the node
  134025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  134026. * @returns the world matrix
  134027. */
  134028. Node.prototype.computeWorldMatrix = function (force) {
  134029. if (!this._worldMatrix) {
  134030. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  134031. }
  134032. return this._worldMatrix;
  134033. };
  134034. /**
  134035. * Releases resources associated with this node.
  134036. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134037. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134038. */
  134039. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  134040. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  134041. this._isDisposed = true;
  134042. if (!doNotRecurse) {
  134043. var nodes = this.getDescendants(true);
  134044. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  134045. var node = nodes_1[_i];
  134046. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  134047. }
  134048. }
  134049. if (!this.parent) {
  134050. this.removeFromSceneRootNodes();
  134051. }
  134052. else {
  134053. this.parent = null;
  134054. }
  134055. // Callback
  134056. this.onDisposeObservable.notifyObservers(this);
  134057. this.onDisposeObservable.clear();
  134058. // Behaviors
  134059. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  134060. var behavior = _b[_a];
  134061. behavior.detach();
  134062. }
  134063. this._behaviors = [];
  134064. };
  134065. /**
  134066. * Parse animation range data from a serialization object and store them into a given node
  134067. * @param node defines where to store the animation ranges
  134068. * @param parsedNode defines the serialization object to read data from
  134069. * @param scene defines the hosting scene
  134070. */
  134071. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  134072. if (parsedNode.ranges) {
  134073. for (var index = 0; index < parsedNode.ranges.length; index++) {
  134074. var data = parsedNode.ranges[index];
  134075. node.createAnimationRange(data.name, data.from, data.to);
  134076. }
  134077. }
  134078. };
  134079. /** @hidden */
  134080. Node._AnimationRangeFactory = function (name, from, to) {
  134081. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AnimationRange");
  134082. };
  134083. Node._NodeConstructors = {};
  134084. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134085. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  134086. ], Node.prototype, "name", void 0);
  134087. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134088. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  134089. ], Node.prototype, "id", void 0);
  134090. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134091. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  134092. ], Node.prototype, "uniqueId", void 0);
  134093. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134094. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  134095. ], Node.prototype, "state", void 0);
  134096. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134097. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  134098. ], Node.prototype, "metadata", void 0);
  134099. return Node;
  134100. }());
  134101. /***/ }),
  134102. /***/ "./scene.ts":
  134103. /*!******************!*\
  134104. !*** ./scene.ts ***!
  134105. \******************/
  134106. /*! exports provided: Scene */
  134107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134108. "use strict";
  134109. __webpack_require__.r(__webpack_exports__);
  134110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  134111. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  134112. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  134113. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  134114. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  134115. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  134116. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  134117. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  134118. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  134119. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/transformNode */ "./Meshes/transformNode.ts");
  134120. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  134121. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  134122. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  134123. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  134124. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  134125. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  134126. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  134127. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  134128. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  134129. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  134130. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  134131. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  134132. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  134133. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  134134. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  134135. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  134136. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  134137. /* harmony import */ var _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Actions/abstractActionManager */ "./Actions/abstractActionManager.ts");
  134138. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  134139. /** @hidden */
  134140. var ClickInfo = /** @class */ (function () {
  134141. function ClickInfo() {
  134142. this._singleClick = false;
  134143. this._doubleClick = false;
  134144. this._hasSwiped = false;
  134145. this._ignore = false;
  134146. }
  134147. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  134148. get: function () {
  134149. return this._singleClick;
  134150. },
  134151. set: function (b) {
  134152. this._singleClick = b;
  134153. },
  134154. enumerable: true,
  134155. configurable: true
  134156. });
  134157. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  134158. get: function () {
  134159. return this._doubleClick;
  134160. },
  134161. set: function (b) {
  134162. this._doubleClick = b;
  134163. },
  134164. enumerable: true,
  134165. configurable: true
  134166. });
  134167. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  134168. get: function () {
  134169. return this._hasSwiped;
  134170. },
  134171. set: function (b) {
  134172. this._hasSwiped = b;
  134173. },
  134174. enumerable: true,
  134175. configurable: true
  134176. });
  134177. Object.defineProperty(ClickInfo.prototype, "ignore", {
  134178. get: function () {
  134179. return this._ignore;
  134180. },
  134181. set: function (b) {
  134182. this._ignore = b;
  134183. },
  134184. enumerable: true,
  134185. configurable: true
  134186. });
  134187. return ClickInfo;
  134188. }());
  134189. /**
  134190. * Represents a scene to be rendered by the engine.
  134191. * @see http://doc.babylonjs.com/features/scene
  134192. */
  134193. var Scene = /** @class */ (function (_super) {
  134194. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  134195. /**
  134196. * Creates a new Scene
  134197. * @param engine defines the engine to use to render this scene
  134198. * @param options defines the scene options
  134199. */
  134200. function Scene(engine, options) {
  134201. var _this = _super.call(this) || this;
  134202. // Members
  134203. /** @hidden */
  134204. _this._isScene = true;
  134205. /**
  134206. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  134207. */
  134208. _this.autoClear = true;
  134209. /**
  134210. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  134211. */
  134212. _this.autoClearDepthAndStencil = true;
  134213. /**
  134214. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  134215. */
  134216. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  134217. /**
  134218. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  134219. */
  134220. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  134221. _this._forceWireframe = false;
  134222. _this._forcePointsCloud = false;
  134223. /**
  134224. * Gets or sets a boolean indicating if animations are enabled
  134225. */
  134226. _this.animationsEnabled = true;
  134227. _this._animationPropertiesOverride = null;
  134228. /**
  134229. * Gets or sets a boolean indicating if a constant deltatime has to be used
  134230. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  134231. */
  134232. _this.useConstantAnimationDeltaTime = false;
  134233. /**
  134234. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  134235. * Please note that it requires to run a ray cast through the scene on every frame
  134236. */
  134237. _this.constantlyUpdateMeshUnderPointer = false;
  134238. /**
  134239. * Defines the HTML cursor to use when hovering over interactive elements
  134240. */
  134241. _this.hoverCursor = "pointer";
  134242. /**
  134243. * Defines the HTML default cursor to use (empty by default)
  134244. */
  134245. _this.defaultCursor = "";
  134246. /**
  134247. * This is used to call preventDefault() on pointer down
  134248. * in order to block unwanted artifacts like system double clicks
  134249. */
  134250. _this.preventDefaultOnPointerDown = true;
  134251. /**
  134252. * This is used to call preventDefault() on pointer up
  134253. * in order to block unwanted artifacts like system double clicks
  134254. */
  134255. _this.preventDefaultOnPointerUp = true;
  134256. // Metadata
  134257. /**
  134258. * Gets or sets user defined metadata
  134259. */
  134260. _this.metadata = null;
  134261. /**
  134262. * For internal use only. Please do not use.
  134263. */
  134264. _this.reservedDataStore = null;
  134265. /**
  134266. * Use this array to add regular expressions used to disable offline support for specific urls
  134267. */
  134268. _this.disableOfflineSupportExceptionRules = new Array();
  134269. /**
  134270. * An event triggered when the scene is disposed.
  134271. */
  134272. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134273. _this._onDisposeObserver = null;
  134274. /**
  134275. * An event triggered before rendering the scene (right after animations and physics)
  134276. */
  134277. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134278. _this._onBeforeRenderObserver = null;
  134279. /**
  134280. * An event triggered after rendering the scene
  134281. */
  134282. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134283. _this._onAfterRenderObserver = null;
  134284. /**
  134285. * An event triggered before animating the scene
  134286. */
  134287. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134288. /**
  134289. * An event triggered after animations processing
  134290. */
  134291. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134292. /**
  134293. * An event triggered before draw calls are ready to be sent
  134294. */
  134295. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134296. /**
  134297. * An event triggered after draw calls have been sent
  134298. */
  134299. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134300. /**
  134301. * An event triggered when the scene is ready
  134302. */
  134303. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134304. /**
  134305. * An event triggered before rendering a camera
  134306. */
  134307. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134308. _this._onBeforeCameraRenderObserver = null;
  134309. /**
  134310. * An event triggered after rendering a camera
  134311. */
  134312. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134313. _this._onAfterCameraRenderObserver = null;
  134314. /**
  134315. * An event triggered when active meshes evaluation is about to start
  134316. */
  134317. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134318. /**
  134319. * An event triggered when active meshes evaluation is done
  134320. */
  134321. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134322. /**
  134323. * An event triggered when particles rendering is about to start
  134324. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  134325. */
  134326. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134327. /**
  134328. * An event triggered when particles rendering is done
  134329. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  134330. */
  134331. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134332. /**
  134333. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  134334. */
  134335. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134336. /**
  134337. * An event triggered when a camera is created
  134338. */
  134339. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134340. /**
  134341. * An event triggered when a camera is removed
  134342. */
  134343. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134344. /**
  134345. * An event triggered when a light is created
  134346. */
  134347. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134348. /**
  134349. * An event triggered when a light is removed
  134350. */
  134351. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134352. /**
  134353. * An event triggered when a geometry is created
  134354. */
  134355. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134356. /**
  134357. * An event triggered when a geometry is removed
  134358. */
  134359. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134360. /**
  134361. * An event triggered when a transform node is created
  134362. */
  134363. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134364. /**
  134365. * An event triggered when a transform node is removed
  134366. */
  134367. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134368. /**
  134369. * An event triggered when a mesh is created
  134370. */
  134371. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134372. /**
  134373. * An event triggered when a mesh is removed
  134374. */
  134375. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134376. /**
  134377. * An event triggered when a skeleton is created
  134378. */
  134379. _this.onNewSkeletonAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134380. /**
  134381. * An event triggered when a skeleton is removed
  134382. */
  134383. _this.onSkeletonRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134384. /**
  134385. * An event triggered when a material is created
  134386. */
  134387. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134388. /**
  134389. * An event triggered when a material is removed
  134390. */
  134391. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134392. /**
  134393. * An event triggered when a texture is created
  134394. */
  134395. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134396. /**
  134397. * An event triggered when a texture is removed
  134398. */
  134399. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134400. /**
  134401. * An event triggered when render targets are about to be rendered
  134402. * Can happen multiple times per frame.
  134403. */
  134404. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134405. /**
  134406. * An event triggered when render targets were rendered.
  134407. * Can happen multiple times per frame.
  134408. */
  134409. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134410. /**
  134411. * An event triggered before calculating deterministic simulation step
  134412. */
  134413. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134414. /**
  134415. * An event triggered after calculating deterministic simulation step
  134416. */
  134417. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134418. /**
  134419. * An event triggered when the activeCamera property is updated
  134420. */
  134421. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134422. /**
  134423. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  134424. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  134425. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  134426. */
  134427. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134428. /**
  134429. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  134430. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  134431. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  134432. */
  134433. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134434. /**
  134435. * This Observable will when a mesh has been imported into the scene.
  134436. */
  134437. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134438. // Animations
  134439. /** @hidden */
  134440. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  134441. /**
  134442. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  134443. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  134444. */
  134445. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134446. /**
  134447. * Observable event triggered each time an input event is received from the rendering canvas
  134448. */
  134449. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134450. _this._meshPickProceed = false;
  134451. _this._currentPickResult = null;
  134452. _this._previousPickResult = null;
  134453. _this._totalPointersPressed = 0;
  134454. _this._doubleClickOccured = false;
  134455. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  134456. _this.cameraToUseForPointers = null;
  134457. _this._pointerX = 0;
  134458. _this._pointerY = 0;
  134459. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  134460. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  134461. _this._startingPointerTime = 0;
  134462. _this._previousStartingPointerTime = 0;
  134463. _this._pointerCaptures = {};
  134464. // Deterministic lockstep
  134465. _this._timeAccumulator = 0;
  134466. _this._currentStepId = 0;
  134467. _this._currentInternalStep = 0;
  134468. // Keyboard
  134469. /**
  134470. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  134471. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  134472. */
  134473. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134474. /**
  134475. * Observable event triggered each time an keyboard event is received from the hosting window
  134476. */
  134477. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134478. // Coordinates system
  134479. _this._useRightHandedSystem = false;
  134480. // Fog
  134481. _this._fogEnabled = true;
  134482. _this._fogMode = Scene.FOGMODE_NONE;
  134483. /**
  134484. * Gets or sets the fog color to use
  134485. * @see http://doc.babylonjs.com/babylon101/environment#fog
  134486. * (Default is Color3(0.2, 0.2, 0.3))
  134487. */
  134488. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  134489. /**
  134490. * Gets or sets the fog density to use
  134491. * @see http://doc.babylonjs.com/babylon101/environment#fog
  134492. * (Default is 0.1)
  134493. */
  134494. _this.fogDensity = 0.1;
  134495. /**
  134496. * Gets or sets the fog start distance to use
  134497. * @see http://doc.babylonjs.com/babylon101/environment#fog
  134498. * (Default is 0)
  134499. */
  134500. _this.fogStart = 0;
  134501. /**
  134502. * Gets or sets the fog end distance to use
  134503. * @see http://doc.babylonjs.com/babylon101/environment#fog
  134504. * (Default is 1000)
  134505. */
  134506. _this.fogEnd = 1000.0;
  134507. // Lights
  134508. _this._shadowsEnabled = true;
  134509. _this._lightsEnabled = true;
  134510. /** All of the active cameras added to this scene. */
  134511. _this.activeCameras = new Array();
  134512. // Textures
  134513. _this._texturesEnabled = true;
  134514. // Particles
  134515. /**
  134516. * Gets or sets a boolean indicating if particles are enabled on this scene
  134517. */
  134518. _this.particlesEnabled = true;
  134519. // Sprites
  134520. /**
  134521. * Gets or sets a boolean indicating if sprites are enabled on this scene
  134522. */
  134523. _this.spritesEnabled = true;
  134524. // Skeletons
  134525. _this._skeletonsEnabled = true;
  134526. // Lens flares
  134527. /**
  134528. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  134529. */
  134530. _this.lensFlaresEnabled = true;
  134531. // Collisions
  134532. /**
  134533. * Gets or sets a boolean indicating if collisions are enabled on this scene
  134534. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  134535. */
  134536. _this.collisionsEnabled = true;
  134537. /**
  134538. * Defines the gravity applied to this scene (used only for collisions)
  134539. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  134540. */
  134541. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  134542. // Postprocesses
  134543. /**
  134544. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  134545. */
  134546. _this.postProcessesEnabled = true;
  134547. /**
  134548. * The list of postprocesses added to the scene
  134549. */
  134550. _this.postProcesses = new Array();
  134551. // Customs render targets
  134552. /**
  134553. * Gets or sets a boolean indicating if render targets are enabled on this scene
  134554. */
  134555. _this.renderTargetsEnabled = true;
  134556. /**
  134557. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  134558. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  134559. */
  134560. _this.dumpNextRenderTargets = false;
  134561. /**
  134562. * The list of user defined render targets added to the scene
  134563. */
  134564. _this.customRenderTargets = new Array();
  134565. /**
  134566. * Gets the list of meshes imported to the scene through SceneLoader
  134567. */
  134568. _this.importedMeshesFiles = new Array();
  134569. // Probes
  134570. /**
  134571. * Gets or sets a boolean indicating if probes are enabled on this scene
  134572. */
  134573. _this.probesEnabled = true;
  134574. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  134575. // Procedural textures
  134576. /**
  134577. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  134578. */
  134579. _this.proceduralTexturesEnabled = true;
  134580. // Performance counters
  134581. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  134582. /** @hidden */
  134583. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  134584. /** @hidden */
  134585. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  134586. /** @hidden */
  134587. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  134588. /** @hidden */
  134589. _this._animationTime = 0;
  134590. /**
  134591. * Gets or sets a general scale for animation speed
  134592. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  134593. */
  134594. _this.animationTimeScale = 1;
  134595. _this._renderId = 0;
  134596. _this._frameId = 0;
  134597. _this._executeWhenReadyTimeoutId = -1;
  134598. _this._intermediateRendering = false;
  134599. _this._viewUpdateFlag = -1;
  134600. _this._projectionUpdateFlag = -1;
  134601. /** @hidden */
  134602. _this._toBeDisposed = new Array(256);
  134603. _this._activeRequests = new Array();
  134604. /** @hidden */
  134605. _this._pendingData = new Array();
  134606. _this._isDisposed = false;
  134607. /**
  134608. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  134609. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  134610. */
  134611. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  134612. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  134613. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  134614. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  134615. /** @hidden */
  134616. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  134617. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  134618. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  134619. /** @hidden */
  134620. _this._activeAnimatables = new Array();
  134621. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  134622. _this._wheelEventName = "";
  134623. /**
  134624. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  134625. * This is useful if there are more lights that the maximum simulteanous authorized
  134626. */
  134627. _this.requireLightSorting = false;
  134628. /**
  134629. * @hidden
  134630. * Backing store of defined scene components.
  134631. */
  134632. _this._components = [];
  134633. /**
  134634. * @hidden
  134635. * Backing store of defined scene components.
  134636. */
  134637. _this._serializableComponents = [];
  134638. /**
  134639. * List of components to register on the next registration step.
  134640. */
  134641. _this._transientComponents = [];
  134642. /**
  134643. * @hidden
  134644. * Defines the actions happening before camera updates.
  134645. */
  134646. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134647. /**
  134648. * @hidden
  134649. * Defines the actions happening before clear the canvas.
  134650. */
  134651. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134652. /**
  134653. * @hidden
  134654. * Defines the actions when collecting render targets for the frame.
  134655. */
  134656. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134657. /**
  134658. * @hidden
  134659. * Defines the actions happening for one camera in the frame.
  134660. */
  134661. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134662. /**
  134663. * @hidden
  134664. * Defines the actions happening during the per mesh ready checks.
  134665. */
  134666. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134667. /**
  134668. * @hidden
  134669. * Defines the actions happening before evaluate active mesh checks.
  134670. */
  134671. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134672. /**
  134673. * @hidden
  134674. * Defines the actions happening during the evaluate sub mesh checks.
  134675. */
  134676. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134677. /**
  134678. * @hidden
  134679. * Defines the actions happening during the active mesh stage.
  134680. */
  134681. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134682. /**
  134683. * @hidden
  134684. * Defines the actions happening during the per camera render target step.
  134685. */
  134686. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134687. /**
  134688. * @hidden
  134689. * Defines the actions happening just before the active camera is drawing.
  134690. */
  134691. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134692. /**
  134693. * @hidden
  134694. * Defines the actions happening just before a render target is drawing.
  134695. */
  134696. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134697. /**
  134698. * @hidden
  134699. * Defines the actions happening just before a rendering group is drawing.
  134700. */
  134701. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134702. /**
  134703. * @hidden
  134704. * Defines the actions happening just before a mesh is drawing.
  134705. */
  134706. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134707. /**
  134708. * @hidden
  134709. * Defines the actions happening just after a mesh has been drawn.
  134710. */
  134711. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134712. /**
  134713. * @hidden
  134714. * Defines the actions happening just after a rendering group has been drawn.
  134715. */
  134716. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134717. /**
  134718. * @hidden
  134719. * Defines the actions happening just after the active camera has been drawn.
  134720. */
  134721. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134722. /**
  134723. * @hidden
  134724. * Defines the actions happening just after a render target has been drawn.
  134725. */
  134726. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134727. /**
  134728. * @hidden
  134729. * Defines the actions happening just after rendering all cameras and computing intersections.
  134730. */
  134731. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134732. /**
  134733. * @hidden
  134734. * Defines the actions happening when a pointer move event happens.
  134735. */
  134736. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134737. /**
  134738. * @hidden
  134739. * Defines the actions happening when a pointer down event happens.
  134740. */
  134741. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134742. /**
  134743. * @hidden
  134744. * Defines the actions happening when a pointer up event happens.
  134745. */
  134746. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134747. /**
  134748. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  134749. */
  134750. _this.geometriesByUniqueId = null;
  134751. _this._defaultMeshCandidates = {
  134752. data: [],
  134753. length: 0
  134754. };
  134755. _this._defaultSubMeshCandidates = {
  134756. data: [],
  134757. length: 0
  134758. };
  134759. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  134760. _this._activeMeshesFrozen = false;
  134761. /** @hidden */
  134762. _this._allowPostProcessClearColor = true;
  134763. /**
  134764. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  134765. */
  134766. _this.getDeterministicFrameTime = function () {
  134767. return 1000.0 / 60.0; // frame time in ms
  134768. };
  134769. _this._blockMaterialDirtyMechanism = false;
  134770. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_25__["EngineStore"].LastCreatedEngine;
  134771. _this._engine.scenes.push(_this);
  134772. _this._uid = null;
  134773. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_20__["RenderingManager"](_this);
  134774. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_19__["PostProcessManager"]) {
  134775. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_19__["PostProcessManager"](_this);
  134776. }
  134777. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_23__["DomManagement"].IsWindowObjectExist()) {
  134778. _this.attachControl();
  134779. }
  134780. // Uniform Buffer
  134781. _this._createUbo();
  134782. // Default Image processing definition
  134783. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  134784. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]();
  134785. }
  134786. _this.setDefaultCandidateProviders();
  134787. if (options && options.useGeometryUniqueIdsMap === true) {
  134788. _this.geometriesByUniqueId = {};
  134789. }
  134790. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  134791. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  134792. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  134793. return _this;
  134794. }
  134795. /**
  134796. * Factory used to create the default material.
  134797. * @param name The name of the material to create
  134798. * @param scene The scene to create the material for
  134799. * @returns The default material
  134800. */
  134801. Scene.DefaultMaterialFactory = function (scene) {
  134802. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("StandardMaterial");
  134803. };
  134804. /**
  134805. * Factory used to create the a collision coordinator.
  134806. * @returns The collision coordinator
  134807. */
  134808. Scene.CollisionCoordinatorFactory = function () {
  134809. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("DefaultCollisionCoordinator");
  134810. };
  134811. Object.defineProperty(Scene.prototype, "environmentTexture", {
  134812. /**
  134813. * Texture used in all pbr material as the reflection texture.
  134814. * As in the majority of the scene they are the same (exception for multi room and so on),
  134815. * this is easier to reference from here than from all the materials.
  134816. */
  134817. get: function () {
  134818. return this._environmentTexture;
  134819. },
  134820. /**
  134821. * Texture used in all pbr material as the reflection texture.
  134822. * As in the majority of the scene they are the same (exception for multi room and so on),
  134823. * this is easier to set here than in all the materials.
  134824. */
  134825. set: function (value) {
  134826. if (this._environmentTexture === value) {
  134827. return;
  134828. }
  134829. this._environmentTexture = value;
  134830. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_TextureDirtyFlag);
  134831. },
  134832. enumerable: true,
  134833. configurable: true
  134834. });
  134835. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  134836. /**
  134837. * Default image processing configuration used either in the rendering
  134838. * Forward main pass or through the imageProcessingPostProcess if present.
  134839. * As in the majority of the scene they are the same (exception for multi camera),
  134840. * this is easier to reference from here than from all the materials and post process.
  134841. *
  134842. * No setter as we it is a shared configuration, you can set the values instead.
  134843. */
  134844. get: function () {
  134845. return this._imageProcessingConfiguration;
  134846. },
  134847. enumerable: true,
  134848. configurable: true
  134849. });
  134850. Object.defineProperty(Scene.prototype, "forceWireframe", {
  134851. get: function () {
  134852. return this._forceWireframe;
  134853. },
  134854. /**
  134855. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  134856. */
  134857. set: function (value) {
  134858. if (this._forceWireframe === value) {
  134859. return;
  134860. }
  134861. this._forceWireframe = value;
  134862. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  134863. },
  134864. enumerable: true,
  134865. configurable: true
  134866. });
  134867. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  134868. get: function () {
  134869. return this._forcePointsCloud;
  134870. },
  134871. /**
  134872. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  134873. */
  134874. set: function (value) {
  134875. if (this._forcePointsCloud === value) {
  134876. return;
  134877. }
  134878. this._forcePointsCloud = value;
  134879. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  134880. },
  134881. enumerable: true,
  134882. configurable: true
  134883. });
  134884. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  134885. /**
  134886. * Gets or sets the animation properties override
  134887. */
  134888. get: function () {
  134889. return this._animationPropertiesOverride;
  134890. },
  134891. set: function (value) {
  134892. this._animationPropertiesOverride = value;
  134893. },
  134894. enumerable: true,
  134895. configurable: true
  134896. });
  134897. Object.defineProperty(Scene.prototype, "onDispose", {
  134898. /** Sets a function to be executed when this scene is disposed. */
  134899. set: function (callback) {
  134900. if (this._onDisposeObserver) {
  134901. this.onDisposeObservable.remove(this._onDisposeObserver);
  134902. }
  134903. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  134904. },
  134905. enumerable: true,
  134906. configurable: true
  134907. });
  134908. Object.defineProperty(Scene.prototype, "beforeRender", {
  134909. /** Sets a function to be executed before rendering this scene */
  134910. set: function (callback) {
  134911. if (this._onBeforeRenderObserver) {
  134912. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  134913. }
  134914. if (callback) {
  134915. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  134916. }
  134917. },
  134918. enumerable: true,
  134919. configurable: true
  134920. });
  134921. Object.defineProperty(Scene.prototype, "afterRender", {
  134922. /** Sets a function to be executed after rendering this scene */
  134923. set: function (callback) {
  134924. if (this._onAfterRenderObserver) {
  134925. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  134926. }
  134927. if (callback) {
  134928. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  134929. }
  134930. },
  134931. enumerable: true,
  134932. configurable: true
  134933. });
  134934. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  134935. /** Sets a function to be executed before rendering a camera*/
  134936. set: function (callback) {
  134937. if (this._onBeforeCameraRenderObserver) {
  134938. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  134939. }
  134940. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  134941. },
  134942. enumerable: true,
  134943. configurable: true
  134944. });
  134945. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  134946. /** Sets a function to be executed after rendering a camera*/
  134947. set: function (callback) {
  134948. if (this._onAfterCameraRenderObserver) {
  134949. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  134950. }
  134951. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  134952. },
  134953. enumerable: true,
  134954. configurable: true
  134955. });
  134956. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  134957. /**
  134958. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  134959. */
  134960. get: function () {
  134961. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  134962. },
  134963. enumerable: true,
  134964. configurable: true
  134965. });
  134966. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  134967. get: function () {
  134968. return this._useRightHandedSystem;
  134969. },
  134970. /**
  134971. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  134972. */
  134973. set: function (value) {
  134974. if (this._useRightHandedSystem === value) {
  134975. return;
  134976. }
  134977. this._useRightHandedSystem = value;
  134978. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  134979. },
  134980. enumerable: true,
  134981. configurable: true
  134982. });
  134983. /**
  134984. * Sets the step Id used by deterministic lock step
  134985. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  134986. * @param newStepId defines the step Id
  134987. */
  134988. Scene.prototype.setStepId = function (newStepId) {
  134989. this._currentStepId = newStepId;
  134990. };
  134991. /**
  134992. * Gets the step Id used by deterministic lock step
  134993. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  134994. * @returns the step Id
  134995. */
  134996. Scene.prototype.getStepId = function () {
  134997. return this._currentStepId;
  134998. };
  134999. /**
  135000. * Gets the internal step used by deterministic lock step
  135001. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135002. * @returns the internal step
  135003. */
  135004. Scene.prototype.getInternalStep = function () {
  135005. return this._currentInternalStep;
  135006. };
  135007. Object.defineProperty(Scene.prototype, "fogEnabled", {
  135008. get: function () {
  135009. return this._fogEnabled;
  135010. },
  135011. /**
  135012. * Gets or sets a boolean indicating if fog is enabled on this scene
  135013. * @see http://doc.babylonjs.com/babylon101/environment#fog
  135014. * (Default is true)
  135015. */
  135016. set: function (value) {
  135017. if (this._fogEnabled === value) {
  135018. return;
  135019. }
  135020. this._fogEnabled = value;
  135021. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  135022. },
  135023. enumerable: true,
  135024. configurable: true
  135025. });
  135026. Object.defineProperty(Scene.prototype, "fogMode", {
  135027. get: function () {
  135028. return this._fogMode;
  135029. },
  135030. /**
  135031. * Gets or sets the fog mode to use
  135032. * @see http://doc.babylonjs.com/babylon101/environment#fog
  135033. * | mode | value |
  135034. * | --- | --- |
  135035. * | FOGMODE_NONE | 0 |
  135036. * | FOGMODE_EXP | 1 |
  135037. * | FOGMODE_EXP2 | 2 |
  135038. * | FOGMODE_LINEAR | 3 |
  135039. */
  135040. set: function (value) {
  135041. if (this._fogMode === value) {
  135042. return;
  135043. }
  135044. this._fogMode = value;
  135045. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  135046. },
  135047. enumerable: true,
  135048. configurable: true
  135049. });
  135050. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  135051. get: function () {
  135052. return this._shadowsEnabled;
  135053. },
  135054. /**
  135055. * Gets or sets a boolean indicating if shadows are enabled on this scene
  135056. */
  135057. set: function (value) {
  135058. if (this._shadowsEnabled === value) {
  135059. return;
  135060. }
  135061. this._shadowsEnabled = value;
  135062. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_LightDirtyFlag);
  135063. },
  135064. enumerable: true,
  135065. configurable: true
  135066. });
  135067. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  135068. get: function () {
  135069. return this._lightsEnabled;
  135070. },
  135071. /**
  135072. * Gets or sets a boolean indicating if lights are enabled on this scene
  135073. */
  135074. set: function (value) {
  135075. if (this._lightsEnabled === value) {
  135076. return;
  135077. }
  135078. this._lightsEnabled = value;
  135079. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_LightDirtyFlag);
  135080. },
  135081. enumerable: true,
  135082. configurable: true
  135083. });
  135084. Object.defineProperty(Scene.prototype, "activeCamera", {
  135085. /** Gets or sets the current active camera */
  135086. get: function () {
  135087. return this._activeCamera;
  135088. },
  135089. set: function (value) {
  135090. if (value === this._activeCamera) {
  135091. return;
  135092. }
  135093. this._activeCamera = value;
  135094. this.onActiveCameraChanged.notifyObservers(this);
  135095. },
  135096. enumerable: true,
  135097. configurable: true
  135098. });
  135099. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  135100. /** The default material used on meshes when no material is affected */
  135101. get: function () {
  135102. if (!this._defaultMaterial) {
  135103. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  135104. }
  135105. return this._defaultMaterial;
  135106. },
  135107. /** The default material used on meshes when no material is affected */
  135108. set: function (value) {
  135109. this._defaultMaterial = value;
  135110. },
  135111. enumerable: true,
  135112. configurable: true
  135113. });
  135114. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  135115. get: function () {
  135116. return this._texturesEnabled;
  135117. },
  135118. /**
  135119. * Gets or sets a boolean indicating if textures are enabled on this scene
  135120. */
  135121. set: function (value) {
  135122. if (this._texturesEnabled === value) {
  135123. return;
  135124. }
  135125. this._texturesEnabled = value;
  135126. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_TextureDirtyFlag);
  135127. },
  135128. enumerable: true,
  135129. configurable: true
  135130. });
  135131. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  135132. get: function () {
  135133. return this._skeletonsEnabled;
  135134. },
  135135. /**
  135136. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  135137. */
  135138. set: function (value) {
  135139. if (this._skeletonsEnabled === value) {
  135140. return;
  135141. }
  135142. this._skeletonsEnabled = value;
  135143. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_AttributesDirtyFlag);
  135144. },
  135145. enumerable: true,
  135146. configurable: true
  135147. });
  135148. Object.defineProperty(Scene.prototype, "collisionCoordinator", {
  135149. /** @hidden */
  135150. get: function () {
  135151. if (!this._collisionCoordinator) {
  135152. this._collisionCoordinator = Scene.CollisionCoordinatorFactory();
  135153. this._collisionCoordinator.init(this);
  135154. }
  135155. return this._collisionCoordinator;
  135156. },
  135157. enumerable: true,
  135158. configurable: true
  135159. });
  135160. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  135161. /**
  135162. * Gets the list of frustum planes (built from the active camera)
  135163. */
  135164. get: function () {
  135165. return this._frustumPlanes;
  135166. },
  135167. enumerable: true,
  135168. configurable: true
  135169. });
  135170. /**
  135171. * Registers the transient components if needed.
  135172. */
  135173. Scene.prototype._registerTransientComponents = function () {
  135174. // Register components that have been associated lately to the scene.
  135175. if (this._transientComponents.length > 0) {
  135176. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  135177. var component = _a[_i];
  135178. component.register();
  135179. }
  135180. this._transientComponents = [];
  135181. }
  135182. };
  135183. /**
  135184. * @hidden
  135185. * Add a component to the scene.
  135186. * Note that the ccomponent could be registered on th next frame if this is called after
  135187. * the register component stage.
  135188. * @param component Defines the component to add to the scene
  135189. */
  135190. Scene.prototype._addComponent = function (component) {
  135191. this._components.push(component);
  135192. this._transientComponents.push(component);
  135193. var serializableComponent = component;
  135194. if (serializableComponent.addFromContainer) {
  135195. this._serializableComponents.push(serializableComponent);
  135196. }
  135197. };
  135198. /**
  135199. * @hidden
  135200. * Gets a component from the scene.
  135201. * @param name defines the name of the component to retrieve
  135202. * @returns the component or null if not present
  135203. */
  135204. Scene.prototype._getComponent = function (name) {
  135205. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  135206. var component = _a[_i];
  135207. if (component.name === name) {
  135208. return component;
  135209. }
  135210. }
  135211. return null;
  135212. };
  135213. /**
  135214. * Gets a string idenfifying the name of the class
  135215. * @returns "Scene" string
  135216. */
  135217. Scene.prototype.getClassName = function () {
  135218. return "Scene";
  135219. };
  135220. /**
  135221. * @hidden
  135222. */
  135223. Scene.prototype._getDefaultMeshCandidates = function () {
  135224. this._defaultMeshCandidates.data = this.meshes;
  135225. this._defaultMeshCandidates.length = this.meshes.length;
  135226. return this._defaultMeshCandidates;
  135227. };
  135228. /**
  135229. * @hidden
  135230. */
  135231. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  135232. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  135233. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  135234. return this._defaultSubMeshCandidates;
  135235. };
  135236. /**
  135237. * Sets the default candidate providers for the scene.
  135238. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  135239. * and getCollidingSubMeshCandidates to their default function
  135240. */
  135241. Scene.prototype.setDefaultCandidateProviders = function () {
  135242. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  135243. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  135244. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  135245. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  135246. };
  135247. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  135248. /**
  135249. * Gets the mesh that is currently under the pointer
  135250. */
  135251. get: function () {
  135252. return this._pointerOverMesh;
  135253. },
  135254. enumerable: true,
  135255. configurable: true
  135256. });
  135257. Object.defineProperty(Scene.prototype, "pointerX", {
  135258. /**
  135259. * Gets or sets the current on-screen X position of the pointer
  135260. */
  135261. get: function () {
  135262. return this._pointerX;
  135263. },
  135264. set: function (value) {
  135265. this._pointerX = value;
  135266. },
  135267. enumerable: true,
  135268. configurable: true
  135269. });
  135270. Object.defineProperty(Scene.prototype, "pointerY", {
  135271. /**
  135272. * Gets or sets the current on-screen Y position of the pointer
  135273. */
  135274. get: function () {
  135275. return this._pointerY;
  135276. },
  135277. set: function (value) {
  135278. this._pointerY = value;
  135279. },
  135280. enumerable: true,
  135281. configurable: true
  135282. });
  135283. /**
  135284. * Gets the cached material (ie. the latest rendered one)
  135285. * @returns the cached material
  135286. */
  135287. Scene.prototype.getCachedMaterial = function () {
  135288. return this._cachedMaterial;
  135289. };
  135290. /**
  135291. * Gets the cached effect (ie. the latest rendered one)
  135292. * @returns the cached effect
  135293. */
  135294. Scene.prototype.getCachedEffect = function () {
  135295. return this._cachedEffect;
  135296. };
  135297. /**
  135298. * Gets the cached visibility state (ie. the latest rendered one)
  135299. * @returns the cached visibility state
  135300. */
  135301. Scene.prototype.getCachedVisibility = function () {
  135302. return this._cachedVisibility;
  135303. };
  135304. /**
  135305. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  135306. * @param material defines the current material
  135307. * @param effect defines the current effect
  135308. * @param visibility defines the current visibility state
  135309. * @returns true if one parameter is not cached
  135310. */
  135311. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  135312. if (visibility === void 0) { visibility = 1; }
  135313. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  135314. };
  135315. /**
  135316. * Gets the engine associated with the scene
  135317. * @returns an Engine
  135318. */
  135319. Scene.prototype.getEngine = function () {
  135320. return this._engine;
  135321. };
  135322. /**
  135323. * Gets the total number of vertices rendered per frame
  135324. * @returns the total number of vertices rendered per frame
  135325. */
  135326. Scene.prototype.getTotalVertices = function () {
  135327. return this._totalVertices.current;
  135328. };
  135329. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  135330. /**
  135331. * Gets the performance counter for total vertices
  135332. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  135333. */
  135334. get: function () {
  135335. return this._totalVertices;
  135336. },
  135337. enumerable: true,
  135338. configurable: true
  135339. });
  135340. /**
  135341. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  135342. * @returns the total number of active indices rendered per frame
  135343. */
  135344. Scene.prototype.getActiveIndices = function () {
  135345. return this._activeIndices.current;
  135346. };
  135347. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  135348. /**
  135349. * Gets the performance counter for active indices
  135350. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  135351. */
  135352. get: function () {
  135353. return this._activeIndices;
  135354. },
  135355. enumerable: true,
  135356. configurable: true
  135357. });
  135358. /**
  135359. * Gets the total number of active particles rendered per frame
  135360. * @returns the total number of active particles rendered per frame
  135361. */
  135362. Scene.prototype.getActiveParticles = function () {
  135363. return this._activeParticles.current;
  135364. };
  135365. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  135366. /**
  135367. * Gets the performance counter for active particles
  135368. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  135369. */
  135370. get: function () {
  135371. return this._activeParticles;
  135372. },
  135373. enumerable: true,
  135374. configurable: true
  135375. });
  135376. /**
  135377. * Gets the total number of active bones rendered per frame
  135378. * @returns the total number of active bones rendered per frame
  135379. */
  135380. Scene.prototype.getActiveBones = function () {
  135381. return this._activeBones.current;
  135382. };
  135383. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  135384. /**
  135385. * Gets the performance counter for active bones
  135386. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  135387. */
  135388. get: function () {
  135389. return this._activeBones;
  135390. },
  135391. enumerable: true,
  135392. configurable: true
  135393. });
  135394. /**
  135395. * Gets the array of active meshes
  135396. * @returns an array of AbstractMesh
  135397. */
  135398. Scene.prototype.getActiveMeshes = function () {
  135399. return this._activeMeshes;
  135400. };
  135401. /**
  135402. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  135403. * @returns a number
  135404. */
  135405. Scene.prototype.getAnimationRatio = function () {
  135406. return this._animationRatio !== undefined ? this._animationRatio : 1;
  135407. };
  135408. /**
  135409. * Gets an unique Id for the current render phase
  135410. * @returns a number
  135411. */
  135412. Scene.prototype.getRenderId = function () {
  135413. return this._renderId;
  135414. };
  135415. /**
  135416. * Gets an unique Id for the current frame
  135417. * @returns a number
  135418. */
  135419. Scene.prototype.getFrameId = function () {
  135420. return this._frameId;
  135421. };
  135422. /** Call this function if you want to manually increment the render Id*/
  135423. Scene.prototype.incrementRenderId = function () {
  135424. this._renderId++;
  135425. };
  135426. Scene.prototype._updatePointerPosition = function (evt) {
  135427. var canvasRect = this._engine.getRenderingCanvasClientRect();
  135428. if (!canvasRect) {
  135429. return;
  135430. }
  135431. this._pointerX = evt.clientX - canvasRect.left;
  135432. this._pointerY = evt.clientY - canvasRect.top;
  135433. this._unTranslatedPointerX = this._pointerX;
  135434. this._unTranslatedPointerY = this._pointerY;
  135435. };
  135436. Scene.prototype._createUbo = function () {
  135437. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_13__["UniformBuffer"](this._engine, undefined, true);
  135438. this._sceneUbo.addUniform("viewProjection", 16);
  135439. this._sceneUbo.addUniform("view", 16);
  135440. };
  135441. // Pointers handling
  135442. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  135443. if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
  135444. if (!pointerInfo.pickInfo.ray) {
  135445. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  135446. }
  135447. }
  135448. };
  135449. /**
  135450. * Use this method to simulate a pointer move on a mesh
  135451. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  135452. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  135453. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  135454. * @returns the current scene
  135455. */
  135456. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  135457. var evt = new PointerEvent("pointermove", pointerEventInit);
  135458. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERMOVE)) {
  135459. return this;
  135460. }
  135461. return this._processPointerMove(pickResult, evt);
  135462. };
  135463. Scene.prototype._processPointerMove = function (pickResult, evt) {
  135464. var canvas = this._engine.getRenderingCanvas();
  135465. if (!canvas) {
  135466. return this;
  135467. }
  135468. // Restore pointer
  135469. canvas.style.cursor = this.defaultCursor;
  135470. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  135471. if (isMeshPicked) {
  135472. this.setPointerOverMesh(pickResult.pickedMesh);
  135473. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  135474. if (this._pointerOverMesh.actionManager.hoverCursor) {
  135475. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  135476. }
  135477. else {
  135478. canvas.style.cursor = this.hoverCursor;
  135479. }
  135480. }
  135481. }
  135482. else {
  135483. this.setPointerOverMesh(null);
  135484. }
  135485. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  135486. var step = _a[_i];
  135487. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  135488. }
  135489. if (pickResult) {
  135490. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERMOVE;
  135491. if (this.onPointerMove) {
  135492. this.onPointerMove(evt, pickResult, type);
  135493. }
  135494. if (this.onPointerObservable.hasObservers()) {
  135495. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfo"](type, evt, pickResult);
  135496. this._setRayOnPointerInfo(pi);
  135497. this.onPointerObservable.notifyObservers(pi, type);
  135498. }
  135499. }
  135500. return this;
  135501. };
  135502. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  135503. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  135504. if (pickResult) {
  135505. pi.ray = pickResult.ray;
  135506. }
  135507. this.onPrePointerObservable.notifyObservers(pi, type);
  135508. if (pi.skipOnPointerObservable) {
  135509. return true;
  135510. }
  135511. else {
  135512. return false;
  135513. }
  135514. };
  135515. /**
  135516. * Use this method to simulate a pointer down on a mesh
  135517. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  135518. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  135519. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  135520. * @returns the current scene
  135521. */
  135522. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  135523. var evt = new PointerEvent("pointerdown", pointerEventInit);
  135524. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOWN)) {
  135525. return this;
  135526. }
  135527. return this._processPointerDown(pickResult, evt);
  135528. };
  135529. Scene.prototype._processPointerDown = function (pickResult, evt) {
  135530. var _this = this;
  135531. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  135532. this._pickedDownMesh = pickResult.pickedMesh;
  135533. var actionManager = pickResult.pickedMesh.actionManager;
  135534. if (actionManager) {
  135535. if (actionManager.hasPickTriggers) {
  135536. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135537. switch (evt.button) {
  135538. case 0:
  135539. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135540. break;
  135541. case 1:
  135542. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135543. break;
  135544. case 2:
  135545. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135546. break;
  135547. }
  135548. }
  135549. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnLongPressTrigger)) {
  135550. window.setTimeout(function () {
  135551. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, function (mesh) { return (mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnLongPressTrigger) && mesh == _this._pickedDownMesh); }, false, _this.cameraToUseForPointers);
  135552. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  135553. if (_this._totalPointersPressed !== 0 &&
  135554. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  135555. !_this._isPointerSwiping()) {
  135556. _this._startingPointerTime = 0;
  135557. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135558. }
  135559. }
  135560. }, Scene.LongPressDelay);
  135561. }
  135562. }
  135563. }
  135564. else {
  135565. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  135566. var step = _a[_i];
  135567. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  135568. }
  135569. }
  135570. if (pickResult) {
  135571. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOWN;
  135572. if (this.onPointerDown) {
  135573. this.onPointerDown(evt, pickResult, type);
  135574. }
  135575. if (this.onPointerObservable.hasObservers()) {
  135576. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfo"](type, evt, pickResult);
  135577. this._setRayOnPointerInfo(pi);
  135578. this.onPointerObservable.notifyObservers(pi, type);
  135579. }
  135580. }
  135581. return this;
  135582. };
  135583. /**
  135584. * Use this method to simulate a pointer up on a mesh
  135585. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  135586. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  135587. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  135588. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  135589. * @returns the current scene
  135590. */
  135591. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  135592. var evt = new PointerEvent("pointerup", pointerEventInit);
  135593. var clickInfo = new ClickInfo();
  135594. if (doubleTap) {
  135595. clickInfo.doubleClick = true;
  135596. }
  135597. else {
  135598. clickInfo.singleClick = true;
  135599. }
  135600. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERUP)) {
  135601. return this;
  135602. }
  135603. return this._processPointerUp(pickResult, evt, clickInfo);
  135604. };
  135605. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  135606. if (pickResult && pickResult && pickResult.pickedMesh) {
  135607. this._pickedUpMesh = pickResult.pickedMesh;
  135608. if (this._pickedDownMesh === this._pickedUpMesh) {
  135609. if (this.onPointerPick) {
  135610. this.onPointerPick(evt, pickResult);
  135611. }
  135612. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  135613. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERPICK;
  135614. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfo"](type_1, evt, pickResult);
  135615. this._setRayOnPointerInfo(pi);
  135616. this.onPointerObservable.notifyObservers(pi, type_1);
  135617. }
  135618. }
  135619. var actionManager = pickResult.pickedMesh._getActionManagerForTrigger();
  135620. if (actionManager && !clickInfo.ignore) {
  135621. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135622. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  135623. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135624. }
  135625. var doubleClickActionManager = pickResult.pickedMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger);
  135626. if (clickInfo.doubleClick && doubleClickActionManager) {
  135627. doubleClickActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135628. }
  135629. }
  135630. }
  135631. else {
  135632. if (!clickInfo.ignore) {
  135633. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  135634. var step = _a[_i];
  135635. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  135636. }
  135637. }
  135638. }
  135639. if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
  135640. var pickedDownActionManager = this._pickedDownMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickOutTrigger);
  135641. if (pickedDownActionManager) {
  135642. pickedDownActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  135643. }
  135644. }
  135645. var type = 0;
  135646. if (this.onPointerObservable.hasObservers()) {
  135647. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  135648. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP)) {
  135649. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP;
  135650. }
  135651. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP)) {
  135652. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP;
  135653. }
  135654. if (type) {
  135655. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfo"](type, evt, pickResult);
  135656. this._setRayOnPointerInfo(pi);
  135657. this.onPointerObservable.notifyObservers(pi, type);
  135658. }
  135659. }
  135660. if (!clickInfo.ignore) {
  135661. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERUP;
  135662. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfo"](type, evt, pickResult);
  135663. this._setRayOnPointerInfo(pi);
  135664. this.onPointerObservable.notifyObservers(pi, type);
  135665. }
  135666. }
  135667. if (this.onPointerUp && !clickInfo.ignore) {
  135668. this.onPointerUp(evt, pickResult, type);
  135669. }
  135670. return this;
  135671. };
  135672. /**
  135673. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  135674. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  135675. * @returns true if the pointer was captured
  135676. */
  135677. Scene.prototype.isPointerCaptured = function (pointerId) {
  135678. if (pointerId === void 0) { pointerId = 0; }
  135679. return this._pointerCaptures[pointerId];
  135680. };
  135681. /** @hidden */
  135682. Scene.prototype._isPointerSwiping = function () {
  135683. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  135684. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  135685. };
  135686. /**
  135687. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  135688. * @param attachUp defines if you want to attach events to pointerup
  135689. * @param attachDown defines if you want to attach events to pointerdown
  135690. * @param attachMove defines if you want to attach events to pointermove
  135691. */
  135692. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  135693. var _this = this;
  135694. if (attachUp === void 0) { attachUp = true; }
  135695. if (attachDown === void 0) { attachDown = true; }
  135696. if (attachMove === void 0) { attachMove = true; }
  135697. this._initActionManager = function (act, clickInfo) {
  135698. if (!_this._meshPickProceed) {
  135699. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  135700. _this._currentPickResult = pickResult;
  135701. if (pickResult) {
  135702. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh._getActionManagerForTrigger() : null;
  135703. }
  135704. _this._meshPickProceed = true;
  135705. }
  135706. return act;
  135707. };
  135708. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  135709. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  135710. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  135711. btn !== _this._previousButtonPressed) {
  135712. _this._doubleClickOccured = false;
  135713. clickInfo.singleClick = true;
  135714. clickInfo.ignore = false;
  135715. cb(clickInfo, _this._currentPickResult);
  135716. }
  135717. };
  135718. this._initClickEvent = function (obs1, obs2, evt, cb) {
  135719. var clickInfo = new ClickInfo();
  135720. _this._currentPickResult = null;
  135721. var act = null;
  135722. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERPICK)
  135723. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP)
  135724. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP);
  135725. if (!checkPicking && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"]) {
  135726. act = _this._initActionManager(act, clickInfo);
  135727. if (act) {
  135728. checkPicking = act.hasPickTriggers;
  135729. }
  135730. }
  135731. var needToIgnoreNext = false;
  135732. if (checkPicking) {
  135733. var btn = evt.button;
  135734. clickInfo.hasSwiped = _this._isPointerSwiping();
  135735. if (!clickInfo.hasSwiped) {
  135736. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  135737. if (!checkSingleClickImmediately) {
  135738. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP) &&
  135739. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP);
  135740. if (checkSingleClickImmediately && !_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger)) {
  135741. act = _this._initActionManager(act, clickInfo);
  135742. if (act) {
  135743. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger);
  135744. }
  135745. }
  135746. }
  135747. if (checkSingleClickImmediately) {
  135748. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  135749. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  135750. btn !== _this._previousButtonPressed) {
  135751. clickInfo.singleClick = true;
  135752. cb(clickInfo, _this._currentPickResult);
  135753. needToIgnoreNext = true;
  135754. }
  135755. }
  135756. // at least one double click is required to be check and exclusive double click is enabled
  135757. else {
  135758. // wait that no double click has been raised during the double click delay
  135759. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  135760. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  135761. }
  135762. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP) ||
  135763. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP);
  135764. if (!checkDoubleClick && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger)) {
  135765. act = _this._initActionManager(act, clickInfo);
  135766. if (act) {
  135767. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger);
  135768. }
  135769. }
  135770. if (checkDoubleClick) {
  135771. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  135772. if (btn === _this._previousButtonPressed &&
  135773. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  135774. !_this._doubleClickOccured) {
  135775. // pointer has not moved for 2 clicks, it's a double click
  135776. if (!clickInfo.hasSwiped &&
  135777. !_this._isPointerSwiping()) {
  135778. _this._previousStartingPointerTime = 0;
  135779. _this._doubleClickOccured = true;
  135780. clickInfo.doubleClick = true;
  135781. clickInfo.ignore = false;
  135782. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  135783. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  135784. }
  135785. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  135786. cb(clickInfo, _this._currentPickResult);
  135787. }
  135788. // if the two successive clicks are too far, it's just two simple clicks
  135789. else {
  135790. _this._doubleClickOccured = false;
  135791. _this._previousStartingPointerTime = _this._startingPointerTime;
  135792. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  135793. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  135794. _this._previousButtonPressed = btn;
  135795. if (Scene.ExclusiveDoubleClickMode) {
  135796. if (_this._previousDelayedSimpleClickTimeout) {
  135797. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  135798. }
  135799. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  135800. cb(clickInfo, _this._previousPickResult);
  135801. }
  135802. else {
  135803. cb(clickInfo, _this._currentPickResult);
  135804. }
  135805. }
  135806. needToIgnoreNext = true;
  135807. }
  135808. // just the first click of the double has been raised
  135809. else {
  135810. _this._doubleClickOccured = false;
  135811. _this._previousStartingPointerTime = _this._startingPointerTime;
  135812. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  135813. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  135814. _this._previousButtonPressed = btn;
  135815. }
  135816. }
  135817. }
  135818. }
  135819. if (!needToIgnoreNext) {
  135820. cb(clickInfo, _this._currentPickResult);
  135821. }
  135822. };
  135823. this._onPointerMove = function (evt) {
  135824. _this._updatePointerPosition(evt);
  135825. // PreObservable support
  135826. if (_this._checkPrePointerObservable(null, evt, evt.type === _this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERMOVE)) {
  135827. return;
  135828. }
  135829. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  135830. return;
  135831. }
  135832. if (!_this.pointerMovePredicate) {
  135833. _this.pointerMovePredicate = function (mesh) { return (mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || _this.constantlyUpdateMeshUnderPointer || (mesh.actionManager !== null && mesh.actionManager !== undefined)) && (!_this.cameraToUseForPointers || (_this.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0)); };
  135834. }
  135835. // Meshes
  135836. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  135837. _this._processPointerMove(pickResult, evt);
  135838. };
  135839. this._onPointerDown = function (evt) {
  135840. _this._totalPointersPressed++;
  135841. _this._pickedDownMesh = null;
  135842. _this._meshPickProceed = false;
  135843. _this._updatePointerPosition(evt);
  135844. if (_this.preventDefaultOnPointerDown && canvas) {
  135845. evt.preventDefault();
  135846. canvas.focus();
  135847. }
  135848. _this._startingPointerPosition.x = _this._pointerX;
  135849. _this._startingPointerPosition.y = _this._pointerY;
  135850. _this._startingPointerTime = Date.now();
  135851. // PreObservable support
  135852. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOWN)) {
  135853. return;
  135854. }
  135855. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  135856. return;
  135857. }
  135858. _this._pointerCaptures[evt.pointerId] = true;
  135859. if (!_this.pointerDownPredicate) {
  135860. _this.pointerDownPredicate = function (mesh) {
  135861. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (!_this.cameraToUseForPointers || (_this.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
  135862. };
  135863. }
  135864. // Meshes
  135865. _this._pickedDownMesh = null;
  135866. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  135867. _this._processPointerDown(pickResult, evt);
  135868. };
  135869. this._onPointerUp = function (evt) {
  135870. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  135871. return; // So we need to test it the pointer down was pressed before.
  135872. }
  135873. _this._totalPointersPressed--;
  135874. _this._pickedUpMesh = null;
  135875. _this._meshPickProceed = false;
  135876. _this._updatePointerPosition(evt);
  135877. if (_this.preventDefaultOnPointerUp && canvas) {
  135878. evt.preventDefault();
  135879. canvas.focus();
  135880. }
  135881. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  135882. // PreObservable support
  135883. if (_this.onPrePointerObservable.hasObservers()) {
  135884. if (!clickInfo.ignore) {
  135885. if (!clickInfo.hasSwiped) {
  135886. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP)) {
  135887. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP)) {
  135888. return;
  135889. }
  135890. }
  135891. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP)) {
  135892. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP)) {
  135893. return;
  135894. }
  135895. }
  135896. }
  135897. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERUP)) {
  135898. return;
  135899. }
  135900. }
  135901. }
  135902. if (!_this._pointerCaptures[evt.pointerId]) {
  135903. return;
  135904. }
  135905. _this._pointerCaptures[evt.pointerId] = false;
  135906. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  135907. return;
  135908. }
  135909. if (!_this.pointerUpPredicate) {
  135910. _this.pointerUpPredicate = function (mesh) {
  135911. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (!_this.cameraToUseForPointers || (_this.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
  135912. };
  135913. }
  135914. // Meshes
  135915. if (!_this._meshPickProceed && (_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"] && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  135916. _this._initActionManager(null, clickInfo);
  135917. }
  135918. if (!pickResult) {
  135919. pickResult = _this._currentPickResult;
  135920. }
  135921. _this._processPointerUp(pickResult, evt, clickInfo);
  135922. _this._previousPickResult = _this._currentPickResult;
  135923. });
  135924. };
  135925. this._onKeyDown = function (evt) {
  135926. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardEventTypes"].KEYDOWN;
  135927. if (_this.onPreKeyboardObservable.hasObservers()) {
  135928. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardInfoPre"](type, evt);
  135929. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  135930. if (pi.skipOnPointerObservable) {
  135931. return;
  135932. }
  135933. }
  135934. if (_this.onKeyboardObservable.hasObservers()) {
  135935. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardInfo"](type, evt);
  135936. _this.onKeyboardObservable.notifyObservers(pi, type);
  135937. }
  135938. if (_this.actionManager) {
  135939. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNewFromScene(_this, evt));
  135940. }
  135941. };
  135942. this._onKeyUp = function (evt) {
  135943. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardEventTypes"].KEYUP;
  135944. if (_this.onPreKeyboardObservable.hasObservers()) {
  135945. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardInfoPre"](type, evt);
  135946. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  135947. if (pi.skipOnPointerObservable) {
  135948. return;
  135949. }
  135950. }
  135951. if (_this.onKeyboardObservable.hasObservers()) {
  135952. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardInfo"](type, evt);
  135953. _this.onKeyboardObservable.notifyObservers(pi, type);
  135954. }
  135955. if (_this.actionManager) {
  135956. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNewFromScene(_this, evt));
  135957. }
  135958. };
  135959. var engine = this.getEngine();
  135960. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  135961. if (!canvas) {
  135962. return;
  135963. }
  135964. canvas.addEventListener("keydown", _this._onKeyDown, false);
  135965. canvas.addEventListener("keyup", _this._onKeyUp, false);
  135966. });
  135967. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  135968. if (!canvas) {
  135969. return;
  135970. }
  135971. canvas.removeEventListener("keydown", _this._onKeyDown);
  135972. canvas.removeEventListener("keyup", _this._onKeyUp);
  135973. });
  135974. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  135975. var canvas = this._engine.getRenderingCanvas();
  135976. if (!canvas) {
  135977. return;
  135978. }
  135979. if (attachMove) {
  135980. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  135981. // Wheel
  135982. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  135983. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  135984. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  135985. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  135986. }
  135987. if (attachDown) {
  135988. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  135989. }
  135990. if (attachUp) {
  135991. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  135992. }
  135993. canvas.tabIndex = 1;
  135994. };
  135995. /** Detaches all event handlers*/
  135996. Scene.prototype.detachControl = function () {
  135997. var engine = this.getEngine();
  135998. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  135999. var canvas = engine.getRenderingCanvas();
  136000. if (!canvas) {
  136001. return;
  136002. }
  136003. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  136004. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  136005. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  136006. if (this._onCanvasBlurObserver) {
  136007. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  136008. }
  136009. if (this._onCanvasFocusObserver) {
  136010. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  136011. }
  136012. // Wheel
  136013. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  136014. // Keyboard
  136015. canvas.removeEventListener("keydown", this._onKeyDown);
  136016. canvas.removeEventListener("keyup", this._onKeyUp);
  136017. // Cursor
  136018. canvas.style.cursor = this.defaultCursor;
  136019. };
  136020. /**
  136021. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  136022. * Delay loaded resources are not taking in account
  136023. * @return true if all required resources are ready
  136024. */
  136025. Scene.prototype.isReady = function () {
  136026. if (this._isDisposed) {
  136027. return false;
  136028. }
  136029. var index;
  136030. var engine = this.getEngine();
  136031. // Effects
  136032. if (!engine.areAllEffectsReady()) {
  136033. return false;
  136034. }
  136035. // Pending data
  136036. if (this._pendingData.length > 0) {
  136037. return false;
  136038. }
  136039. // Meshes
  136040. for (index = 0; index < this.meshes.length; index++) {
  136041. var mesh = this.meshes[index];
  136042. if (!mesh.isEnabled()) {
  136043. continue;
  136044. }
  136045. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  136046. continue;
  136047. }
  136048. if (!mesh.isReady(true)) {
  136049. return false;
  136050. }
  136051. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  136052. // Is Ready For Mesh
  136053. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  136054. var step = _a[_i];
  136055. if (!step.action(mesh, hardwareInstancedRendering)) {
  136056. return false;
  136057. }
  136058. }
  136059. }
  136060. // Geometries
  136061. for (index = 0; index < this.geometries.length; index++) {
  136062. var geometry = this.geometries[index];
  136063. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].DELAYLOADSTATE_LOADING) {
  136064. return false;
  136065. }
  136066. }
  136067. // Post-processes
  136068. if (this.activeCameras && this.activeCameras.length > 0) {
  136069. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  136070. var camera = _c[_b];
  136071. if (!camera.isReady(true)) {
  136072. return false;
  136073. }
  136074. }
  136075. }
  136076. else if (this.activeCamera) {
  136077. if (!this.activeCamera.isReady(true)) {
  136078. return false;
  136079. }
  136080. }
  136081. // Particles
  136082. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  136083. var particleSystem = _e[_d];
  136084. if (!particleSystem.isReady()) {
  136085. return false;
  136086. }
  136087. }
  136088. return true;
  136089. };
  136090. /** Resets all cached information relative to material (including effect and visibility) */
  136091. Scene.prototype.resetCachedMaterial = function () {
  136092. this._cachedMaterial = null;
  136093. this._cachedEffect = null;
  136094. this._cachedVisibility = null;
  136095. };
  136096. /**
  136097. * Registers a function to be called before every frame render
  136098. * @param func defines the function to register
  136099. */
  136100. Scene.prototype.registerBeforeRender = function (func) {
  136101. this.onBeforeRenderObservable.add(func);
  136102. };
  136103. /**
  136104. * Unregisters a function called before every frame render
  136105. * @param func defines the function to unregister
  136106. */
  136107. Scene.prototype.unregisterBeforeRender = function (func) {
  136108. this.onBeforeRenderObservable.removeCallback(func);
  136109. };
  136110. /**
  136111. * Registers a function to be called after every frame render
  136112. * @param func defines the function to register
  136113. */
  136114. Scene.prototype.registerAfterRender = function (func) {
  136115. this.onAfterRenderObservable.add(func);
  136116. };
  136117. /**
  136118. * Unregisters a function called after every frame render
  136119. * @param func defines the function to unregister
  136120. */
  136121. Scene.prototype.unregisterAfterRender = function (func) {
  136122. this.onAfterRenderObservable.removeCallback(func);
  136123. };
  136124. Scene.prototype._executeOnceBeforeRender = function (func) {
  136125. var _this = this;
  136126. var execFunc = function () {
  136127. func();
  136128. setTimeout(function () {
  136129. _this.unregisterBeforeRender(execFunc);
  136130. });
  136131. };
  136132. this.registerBeforeRender(execFunc);
  136133. };
  136134. /**
  136135. * The provided function will run before render once and will be disposed afterwards.
  136136. * A timeout delay can be provided so that the function will be executed in N ms.
  136137. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  136138. * @param func The function to be executed.
  136139. * @param timeout optional delay in ms
  136140. */
  136141. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  136142. var _this = this;
  136143. if (timeout !== undefined) {
  136144. setTimeout(function () {
  136145. _this._executeOnceBeforeRender(func);
  136146. }, timeout);
  136147. }
  136148. else {
  136149. this._executeOnceBeforeRender(func);
  136150. }
  136151. };
  136152. /** @hidden */
  136153. Scene.prototype._addPendingData = function (data) {
  136154. this._pendingData.push(data);
  136155. };
  136156. /** @hidden */
  136157. Scene.prototype._removePendingData = function (data) {
  136158. var wasLoading = this.isLoading;
  136159. var index = this._pendingData.indexOf(data);
  136160. if (index !== -1) {
  136161. this._pendingData.splice(index, 1);
  136162. }
  136163. if (wasLoading && !this.isLoading) {
  136164. this.onDataLoadedObservable.notifyObservers(this);
  136165. }
  136166. };
  136167. /**
  136168. * Returns the number of items waiting to be loaded
  136169. * @returns the number of items waiting to be loaded
  136170. */
  136171. Scene.prototype.getWaitingItemsCount = function () {
  136172. return this._pendingData.length;
  136173. };
  136174. Object.defineProperty(Scene.prototype, "isLoading", {
  136175. /**
  136176. * Returns a boolean indicating if the scene is still loading data
  136177. */
  136178. get: function () {
  136179. return this._pendingData.length > 0;
  136180. },
  136181. enumerable: true,
  136182. configurable: true
  136183. });
  136184. /**
  136185. * Registers a function to be executed when the scene is ready
  136186. * @param {Function} func - the function to be executed
  136187. */
  136188. Scene.prototype.executeWhenReady = function (func) {
  136189. var _this = this;
  136190. this.onReadyObservable.add(func);
  136191. if (this._executeWhenReadyTimeoutId !== -1) {
  136192. return;
  136193. }
  136194. this._executeWhenReadyTimeoutId = setTimeout(function () {
  136195. _this._checkIsReady();
  136196. }, 150);
  136197. };
  136198. /**
  136199. * Returns a promise that resolves when the scene is ready
  136200. * @returns A promise that resolves when the scene is ready
  136201. */
  136202. Scene.prototype.whenReadyAsync = function () {
  136203. var _this = this;
  136204. return new Promise(function (resolve) {
  136205. _this.executeWhenReady(function () {
  136206. resolve();
  136207. });
  136208. });
  136209. };
  136210. /** @hidden */
  136211. Scene.prototype._checkIsReady = function () {
  136212. var _this = this;
  136213. this._registerTransientComponents();
  136214. if (this.isReady()) {
  136215. this.onReadyObservable.notifyObservers(this);
  136216. this.onReadyObservable.clear();
  136217. this._executeWhenReadyTimeoutId = -1;
  136218. return;
  136219. }
  136220. this._executeWhenReadyTimeoutId = setTimeout(function () {
  136221. _this._checkIsReady();
  136222. }, 150);
  136223. };
  136224. Object.defineProperty(Scene.prototype, "animatables", {
  136225. /**
  136226. * Gets all animatable attached to the scene
  136227. */
  136228. get: function () {
  136229. return this._activeAnimatables;
  136230. },
  136231. enumerable: true,
  136232. configurable: true
  136233. });
  136234. /**
  136235. * Resets the last animation time frame.
  136236. * Useful to override when animations start running when loading a scene for the first time.
  136237. */
  136238. Scene.prototype.resetLastAnimationTimeFrame = function () {
  136239. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  136240. };
  136241. // Matrix
  136242. /**
  136243. * Gets the current view matrix
  136244. * @returns a Matrix
  136245. */
  136246. Scene.prototype.getViewMatrix = function () {
  136247. return this._viewMatrix;
  136248. };
  136249. /**
  136250. * Gets the current projection matrix
  136251. * @returns a Matrix
  136252. */
  136253. Scene.prototype.getProjectionMatrix = function () {
  136254. return this._projectionMatrix;
  136255. };
  136256. /**
  136257. * Gets the current transform matrix
  136258. * @returns a Matrix made of View * Projection
  136259. */
  136260. Scene.prototype.getTransformMatrix = function () {
  136261. return this._transformMatrix;
  136262. };
  136263. /**
  136264. * Sets the current transform matrix
  136265. * @param viewL defines the View matrix to use
  136266. * @param projectionL defines the Projection matrix to use
  136267. * @param viewR defines the right View matrix to use (if provided)
  136268. * @param projectionR defines the right Projection matrix to use (if provided)
  136269. */
  136270. Scene.prototype.setTransformMatrix = function (viewL, projectionL, viewR, projectionR) {
  136271. if (this._viewUpdateFlag === viewL.updateFlag && this._projectionUpdateFlag === projectionL.updateFlag) {
  136272. return;
  136273. }
  136274. this._viewUpdateFlag = viewL.updateFlag;
  136275. this._projectionUpdateFlag = projectionL.updateFlag;
  136276. this._viewMatrix = viewL;
  136277. this._projectionMatrix = projectionL;
  136278. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  136279. // Update frustum
  136280. if (!this._frustumPlanes) {
  136281. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  136282. }
  136283. else {
  136284. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  136285. }
  136286. if (this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo) {
  136287. this._updateMultiviewUbo(viewR, projectionR);
  136288. }
  136289. else if (this._sceneUbo.useUbo) {
  136290. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  136291. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  136292. this._sceneUbo.update();
  136293. }
  136294. };
  136295. /**
  136296. * Gets the uniform buffer used to store scene data
  136297. * @returns a UniformBuffer
  136298. */
  136299. Scene.prototype.getSceneUniformBuffer = function () {
  136300. return this._multiviewSceneUbo ? this._multiviewSceneUbo : this._sceneUbo;
  136301. };
  136302. /**
  136303. * Gets an unique (relatively to the current scene) Id
  136304. * @returns an unique number for the scene
  136305. */
  136306. Scene.prototype.getUniqueId = function () {
  136307. var result = Scene._uniqueIdCounter;
  136308. Scene._uniqueIdCounter++;
  136309. return result;
  136310. };
  136311. /**
  136312. * Add a mesh to the list of scene's meshes
  136313. * @param newMesh defines the mesh to add
  136314. * @param recursive if all child meshes should also be added to the scene
  136315. */
  136316. Scene.prototype.addMesh = function (newMesh, recursive) {
  136317. var _this = this;
  136318. if (recursive === void 0) { recursive = false; }
  136319. this.meshes.push(newMesh);
  136320. newMesh._resyncLightSources();
  136321. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  136322. if (recursive) {
  136323. newMesh.getChildMeshes().forEach(function (m) {
  136324. _this.addMesh(m);
  136325. });
  136326. }
  136327. };
  136328. /**
  136329. * Remove a mesh for the list of scene's meshes
  136330. * @param toRemove defines the mesh to remove
  136331. * @param recursive if all child meshes should also be removed from the scene
  136332. * @returns the index where the mesh was in the mesh list
  136333. */
  136334. Scene.prototype.removeMesh = function (toRemove, recursive) {
  136335. var _this = this;
  136336. if (recursive === void 0) { recursive = false; }
  136337. var index = this.meshes.indexOf(toRemove);
  136338. if (index !== -1) {
  136339. // Remove from the scene if mesh found
  136340. this.meshes[index] = this.meshes[this.meshes.length - 1];
  136341. this.meshes.pop();
  136342. }
  136343. this.onMeshRemovedObservable.notifyObservers(toRemove);
  136344. if (recursive) {
  136345. toRemove.getChildMeshes().forEach(function (m) {
  136346. _this.removeMesh(m);
  136347. });
  136348. }
  136349. return index;
  136350. };
  136351. /**
  136352. * Add a transform node to the list of scene's transform nodes
  136353. * @param newTransformNode defines the transform node to add
  136354. */
  136355. Scene.prototype.addTransformNode = function (newTransformNode) {
  136356. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  136357. this.transformNodes.push(newTransformNode);
  136358. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  136359. };
  136360. /**
  136361. * Remove a transform node for the list of scene's transform nodes
  136362. * @param toRemove defines the transform node to remove
  136363. * @returns the index where the transform node was in the transform node list
  136364. */
  136365. Scene.prototype.removeTransformNode = function (toRemove) {
  136366. var index = toRemove._indexInSceneTransformNodesArray;
  136367. if (index !== -1) {
  136368. if (index !== this.transformNodes.length - 1) {
  136369. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  136370. this.transformNodes[index] = lastNode;
  136371. lastNode._indexInSceneTransformNodesArray = index;
  136372. }
  136373. toRemove._indexInSceneTransformNodesArray = -1;
  136374. this.transformNodes.pop();
  136375. }
  136376. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  136377. return index;
  136378. };
  136379. /**
  136380. * Remove a skeleton for the list of scene's skeletons
  136381. * @param toRemove defines the skeleton to remove
  136382. * @returns the index where the skeleton was in the skeleton list
  136383. */
  136384. Scene.prototype.removeSkeleton = function (toRemove) {
  136385. var index = this.skeletons.indexOf(toRemove);
  136386. if (index !== -1) {
  136387. // Remove from the scene if found
  136388. this.skeletons.splice(index, 1);
  136389. this.onSkeletonRemovedObservable.notifyObservers(toRemove);
  136390. }
  136391. return index;
  136392. };
  136393. /**
  136394. * Remove a morph target for the list of scene's morph targets
  136395. * @param toRemove defines the morph target to remove
  136396. * @returns the index where the morph target was in the morph target list
  136397. */
  136398. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  136399. var index = this.morphTargetManagers.indexOf(toRemove);
  136400. if (index !== -1) {
  136401. // Remove from the scene if found
  136402. this.morphTargetManagers.splice(index, 1);
  136403. }
  136404. return index;
  136405. };
  136406. /**
  136407. * Remove a light for the list of scene's lights
  136408. * @param toRemove defines the light to remove
  136409. * @returns the index where the light was in the light list
  136410. */
  136411. Scene.prototype.removeLight = function (toRemove) {
  136412. var index = this.lights.indexOf(toRemove);
  136413. if (index !== -1) {
  136414. // Remove from meshes
  136415. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  136416. var mesh = _a[_i];
  136417. mesh._removeLightSource(toRemove);
  136418. }
  136419. // Remove from the scene if mesh found
  136420. this.lights.splice(index, 1);
  136421. this.sortLightsByPriority();
  136422. }
  136423. this.onLightRemovedObservable.notifyObservers(toRemove);
  136424. return index;
  136425. };
  136426. /**
  136427. * Remove a camera for the list of scene's cameras
  136428. * @param toRemove defines the camera to remove
  136429. * @returns the index where the camera was in the camera list
  136430. */
  136431. Scene.prototype.removeCamera = function (toRemove) {
  136432. var index = this.cameras.indexOf(toRemove);
  136433. if (index !== -1) {
  136434. // Remove from the scene if mesh found
  136435. this.cameras.splice(index, 1);
  136436. }
  136437. // Remove from activeCameras
  136438. var index2 = this.activeCameras.indexOf(toRemove);
  136439. if (index2 !== -1) {
  136440. // Remove from the scene if mesh found
  136441. this.activeCameras.splice(index2, 1);
  136442. }
  136443. // Reset the activeCamera
  136444. if (this.activeCamera === toRemove) {
  136445. if (this.cameras.length > 0) {
  136446. this.activeCamera = this.cameras[0];
  136447. }
  136448. else {
  136449. this.activeCamera = null;
  136450. }
  136451. }
  136452. this.onCameraRemovedObservable.notifyObservers(toRemove);
  136453. return index;
  136454. };
  136455. /**
  136456. * Remove a particle system for the list of scene's particle systems
  136457. * @param toRemove defines the particle system to remove
  136458. * @returns the index where the particle system was in the particle system list
  136459. */
  136460. Scene.prototype.removeParticleSystem = function (toRemove) {
  136461. var index = this.particleSystems.indexOf(toRemove);
  136462. if (index !== -1) {
  136463. this.particleSystems.splice(index, 1);
  136464. }
  136465. return index;
  136466. };
  136467. /**
  136468. * Remove a animation for the list of scene's animations
  136469. * @param toRemove defines the animation to remove
  136470. * @returns the index where the animation was in the animation list
  136471. */
  136472. Scene.prototype.removeAnimation = function (toRemove) {
  136473. var index = this.animations.indexOf(toRemove);
  136474. if (index !== -1) {
  136475. this.animations.splice(index, 1);
  136476. }
  136477. return index;
  136478. };
  136479. /**
  136480. * Removes the given animation group from this scene.
  136481. * @param toRemove The animation group to remove
  136482. * @returns The index of the removed animation group
  136483. */
  136484. Scene.prototype.removeAnimationGroup = function (toRemove) {
  136485. var index = this.animationGroups.indexOf(toRemove);
  136486. if (index !== -1) {
  136487. this.animationGroups.splice(index, 1);
  136488. }
  136489. return index;
  136490. };
  136491. /**
  136492. * Removes the given multi-material from this scene.
  136493. * @param toRemove The multi-material to remove
  136494. * @returns The index of the removed multi-material
  136495. */
  136496. Scene.prototype.removeMultiMaterial = function (toRemove) {
  136497. var index = this.multiMaterials.indexOf(toRemove);
  136498. if (index !== -1) {
  136499. this.multiMaterials.splice(index, 1);
  136500. }
  136501. return index;
  136502. };
  136503. /**
  136504. * Removes the given material from this scene.
  136505. * @param toRemove The material to remove
  136506. * @returns The index of the removed material
  136507. */
  136508. Scene.prototype.removeMaterial = function (toRemove) {
  136509. var index = toRemove._indexInSceneMaterialArray;
  136510. if (index !== -1 && index < this.materials.length) {
  136511. if (index !== this.materials.length - 1) {
  136512. var lastMaterial = this.materials[this.materials.length - 1];
  136513. this.materials[index] = lastMaterial;
  136514. lastMaterial._indexInSceneMaterialArray = index;
  136515. }
  136516. toRemove._indexInSceneMaterialArray = -1;
  136517. this.materials.pop();
  136518. }
  136519. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  136520. return index;
  136521. };
  136522. /**
  136523. * Removes the given action manager from this scene.
  136524. * @param toRemove The action manager to remove
  136525. * @returns The index of the removed action manager
  136526. */
  136527. Scene.prototype.removeActionManager = function (toRemove) {
  136528. var index = this.actionManagers.indexOf(toRemove);
  136529. if (index !== -1) {
  136530. this.actionManagers.splice(index, 1);
  136531. }
  136532. return index;
  136533. };
  136534. /**
  136535. * Removes the given texture from this scene.
  136536. * @param toRemove The texture to remove
  136537. * @returns The index of the removed texture
  136538. */
  136539. Scene.prototype.removeTexture = function (toRemove) {
  136540. var index = this.textures.indexOf(toRemove);
  136541. if (index !== -1) {
  136542. this.textures.splice(index, 1);
  136543. }
  136544. this.onTextureRemovedObservable.notifyObservers(toRemove);
  136545. return index;
  136546. };
  136547. /**
  136548. * Adds the given light to this scene
  136549. * @param newLight The light to add
  136550. */
  136551. Scene.prototype.addLight = function (newLight) {
  136552. this.lights.push(newLight);
  136553. this.sortLightsByPriority();
  136554. // Add light to all meshes (To support if the light is removed and then readded)
  136555. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  136556. var mesh = _a[_i];
  136557. if (mesh._lightSources.indexOf(newLight) === -1) {
  136558. mesh._lightSources.push(newLight);
  136559. mesh._resyncLightSources();
  136560. }
  136561. }
  136562. this.onNewLightAddedObservable.notifyObservers(newLight);
  136563. };
  136564. /**
  136565. * Sorts the list list based on light priorities
  136566. */
  136567. Scene.prototype.sortLightsByPriority = function () {
  136568. if (this.requireLightSorting) {
  136569. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_14__["Light"].CompareLightsPriority);
  136570. }
  136571. };
  136572. /**
  136573. * Adds the given camera to this scene
  136574. * @param newCamera The camera to add
  136575. */
  136576. Scene.prototype.addCamera = function (newCamera) {
  136577. this.cameras.push(newCamera);
  136578. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  136579. };
  136580. /**
  136581. * Adds the given skeleton to this scene
  136582. * @param newSkeleton The skeleton to add
  136583. */
  136584. Scene.prototype.addSkeleton = function (newSkeleton) {
  136585. this.skeletons.push(newSkeleton);
  136586. this.onNewSkeletonAddedObservable.notifyObservers(newSkeleton);
  136587. };
  136588. /**
  136589. * Adds the given particle system to this scene
  136590. * @param newParticleSystem The particle system to add
  136591. */
  136592. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  136593. this.particleSystems.push(newParticleSystem);
  136594. };
  136595. /**
  136596. * Adds the given animation to this scene
  136597. * @param newAnimation The animation to add
  136598. */
  136599. Scene.prototype.addAnimation = function (newAnimation) {
  136600. this.animations.push(newAnimation);
  136601. };
  136602. /**
  136603. * Adds the given animation group to this scene.
  136604. * @param newAnimationGroup The animation group to add
  136605. */
  136606. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  136607. this.animationGroups.push(newAnimationGroup);
  136608. };
  136609. /**
  136610. * Adds the given multi-material to this scene
  136611. * @param newMultiMaterial The multi-material to add
  136612. */
  136613. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  136614. this.multiMaterials.push(newMultiMaterial);
  136615. };
  136616. /**
  136617. * Adds the given material to this scene
  136618. * @param newMaterial The material to add
  136619. */
  136620. Scene.prototype.addMaterial = function (newMaterial) {
  136621. newMaterial._indexInSceneMaterialArray = this.materials.length;
  136622. this.materials.push(newMaterial);
  136623. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  136624. };
  136625. /**
  136626. * Adds the given morph target to this scene
  136627. * @param newMorphTargetManager The morph target to add
  136628. */
  136629. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  136630. this.morphTargetManagers.push(newMorphTargetManager);
  136631. };
  136632. /**
  136633. * Adds the given geometry to this scene
  136634. * @param newGeometry The geometry to add
  136635. */
  136636. Scene.prototype.addGeometry = function (newGeometry) {
  136637. if (this.geometriesByUniqueId) {
  136638. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  136639. }
  136640. this.geometries.push(newGeometry);
  136641. };
  136642. /**
  136643. * Adds the given action manager to this scene
  136644. * @param newActionManager The action manager to add
  136645. */
  136646. Scene.prototype.addActionManager = function (newActionManager) {
  136647. this.actionManagers.push(newActionManager);
  136648. };
  136649. /**
  136650. * Adds the given texture to this scene.
  136651. * @param newTexture The texture to add
  136652. */
  136653. Scene.prototype.addTexture = function (newTexture) {
  136654. this.textures.push(newTexture);
  136655. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  136656. };
  136657. /**
  136658. * Switch active camera
  136659. * @param newCamera defines the new active camera
  136660. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  136661. */
  136662. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  136663. if (attachControl === void 0) { attachControl = true; }
  136664. var canvas = this._engine.getRenderingCanvas();
  136665. if (!canvas) {
  136666. return;
  136667. }
  136668. if (this.activeCamera) {
  136669. this.activeCamera.detachControl(canvas);
  136670. }
  136671. this.activeCamera = newCamera;
  136672. if (attachControl) {
  136673. newCamera.attachControl(canvas);
  136674. }
  136675. };
  136676. /**
  136677. * sets the active camera of the scene using its ID
  136678. * @param id defines the camera's ID
  136679. * @return the new active camera or null if none found.
  136680. */
  136681. Scene.prototype.setActiveCameraByID = function (id) {
  136682. var camera = this.getCameraByID(id);
  136683. if (camera) {
  136684. this.activeCamera = camera;
  136685. return camera;
  136686. }
  136687. return null;
  136688. };
  136689. /**
  136690. * sets the active camera of the scene using its name
  136691. * @param name defines the camera's name
  136692. * @returns the new active camera or null if none found.
  136693. */
  136694. Scene.prototype.setActiveCameraByName = function (name) {
  136695. var camera = this.getCameraByName(name);
  136696. if (camera) {
  136697. this.activeCamera = camera;
  136698. return camera;
  136699. }
  136700. return null;
  136701. };
  136702. /**
  136703. * get an animation group using its name
  136704. * @param name defines the material's name
  136705. * @return the animation group or null if none found.
  136706. */
  136707. Scene.prototype.getAnimationGroupByName = function (name) {
  136708. for (var index = 0; index < this.animationGroups.length; index++) {
  136709. if (this.animationGroups[index].name === name) {
  136710. return this.animationGroups[index];
  136711. }
  136712. }
  136713. return null;
  136714. };
  136715. /**
  136716. * Get a material using its unique id
  136717. * @param uniqueId defines the material's unique id
  136718. * @return the material or null if none found.
  136719. */
  136720. Scene.prototype.getMaterialByUniqueID = function (uniqueId) {
  136721. for (var index = 0; index < this.materials.length; index++) {
  136722. if (this.materials[index].uniqueId === uniqueId) {
  136723. return this.materials[index];
  136724. }
  136725. }
  136726. return null;
  136727. };
  136728. /**
  136729. * get a material using its id
  136730. * @param id defines the material's ID
  136731. * @return the material or null if none found.
  136732. */
  136733. Scene.prototype.getMaterialByID = function (id) {
  136734. for (var index = 0; index < this.materials.length; index++) {
  136735. if (this.materials[index].id === id) {
  136736. return this.materials[index];
  136737. }
  136738. }
  136739. return null;
  136740. };
  136741. /**
  136742. * Gets a material using its name
  136743. * @param name defines the material's name
  136744. * @return the material or null if none found.
  136745. */
  136746. Scene.prototype.getMaterialByName = function (name) {
  136747. for (var index = 0; index < this.materials.length; index++) {
  136748. if (this.materials[index].name === name) {
  136749. return this.materials[index];
  136750. }
  136751. }
  136752. return null;
  136753. };
  136754. /**
  136755. * Gets a camera using its id
  136756. * @param id defines the id to look for
  136757. * @returns the camera or null if not found
  136758. */
  136759. Scene.prototype.getCameraByID = function (id) {
  136760. for (var index = 0; index < this.cameras.length; index++) {
  136761. if (this.cameras[index].id === id) {
  136762. return this.cameras[index];
  136763. }
  136764. }
  136765. return null;
  136766. };
  136767. /**
  136768. * Gets a camera using its unique id
  136769. * @param uniqueId defines the unique id to look for
  136770. * @returns the camera or null if not found
  136771. */
  136772. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  136773. for (var index = 0; index < this.cameras.length; index++) {
  136774. if (this.cameras[index].uniqueId === uniqueId) {
  136775. return this.cameras[index];
  136776. }
  136777. }
  136778. return null;
  136779. };
  136780. /**
  136781. * Gets a camera using its name
  136782. * @param name defines the camera's name
  136783. * @return the camera or null if none found.
  136784. */
  136785. Scene.prototype.getCameraByName = function (name) {
  136786. for (var index = 0; index < this.cameras.length; index++) {
  136787. if (this.cameras[index].name === name) {
  136788. return this.cameras[index];
  136789. }
  136790. }
  136791. return null;
  136792. };
  136793. /**
  136794. * Gets a bone using its id
  136795. * @param id defines the bone's id
  136796. * @return the bone or null if not found
  136797. */
  136798. Scene.prototype.getBoneByID = function (id) {
  136799. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  136800. var skeleton = this.skeletons[skeletonIndex];
  136801. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  136802. if (skeleton.bones[boneIndex].id === id) {
  136803. return skeleton.bones[boneIndex];
  136804. }
  136805. }
  136806. }
  136807. return null;
  136808. };
  136809. /**
  136810. * Gets a bone using its id
  136811. * @param name defines the bone's name
  136812. * @return the bone or null if not found
  136813. */
  136814. Scene.prototype.getBoneByName = function (name) {
  136815. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  136816. var skeleton = this.skeletons[skeletonIndex];
  136817. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  136818. if (skeleton.bones[boneIndex].name === name) {
  136819. return skeleton.bones[boneIndex];
  136820. }
  136821. }
  136822. }
  136823. return null;
  136824. };
  136825. /**
  136826. * Gets a light node using its name
  136827. * @param name defines the the light's name
  136828. * @return the light or null if none found.
  136829. */
  136830. Scene.prototype.getLightByName = function (name) {
  136831. for (var index = 0; index < this.lights.length; index++) {
  136832. if (this.lights[index].name === name) {
  136833. return this.lights[index];
  136834. }
  136835. }
  136836. return null;
  136837. };
  136838. /**
  136839. * Gets a light node using its id
  136840. * @param id defines the light's id
  136841. * @return the light or null if none found.
  136842. */
  136843. Scene.prototype.getLightByID = function (id) {
  136844. for (var index = 0; index < this.lights.length; index++) {
  136845. if (this.lights[index].id === id) {
  136846. return this.lights[index];
  136847. }
  136848. }
  136849. return null;
  136850. };
  136851. /**
  136852. * Gets a light node using its scene-generated unique ID
  136853. * @param uniqueId defines the light's unique id
  136854. * @return the light or null if none found.
  136855. */
  136856. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  136857. for (var index = 0; index < this.lights.length; index++) {
  136858. if (this.lights[index].uniqueId === uniqueId) {
  136859. return this.lights[index];
  136860. }
  136861. }
  136862. return null;
  136863. };
  136864. /**
  136865. * Gets a particle system by id
  136866. * @param id defines the particle system id
  136867. * @return the corresponding system or null if none found
  136868. */
  136869. Scene.prototype.getParticleSystemByID = function (id) {
  136870. for (var index = 0; index < this.particleSystems.length; index++) {
  136871. if (this.particleSystems[index].id === id) {
  136872. return this.particleSystems[index];
  136873. }
  136874. }
  136875. return null;
  136876. };
  136877. /**
  136878. * Gets a geometry using its ID
  136879. * @param id defines the geometry's id
  136880. * @return the geometry or null if none found.
  136881. */
  136882. Scene.prototype.getGeometryByID = function (id) {
  136883. for (var index = 0; index < this.geometries.length; index++) {
  136884. if (this.geometries[index].id === id) {
  136885. return this.geometries[index];
  136886. }
  136887. }
  136888. return null;
  136889. };
  136890. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  136891. if (this.geometriesByUniqueId) {
  136892. var index_1 = this.geometriesByUniqueId[uniqueId];
  136893. if (index_1 !== undefined) {
  136894. return this.geometries[index_1];
  136895. }
  136896. }
  136897. else {
  136898. for (var index = 0; index < this.geometries.length; index++) {
  136899. if (this.geometries[index].uniqueId === uniqueId) {
  136900. return this.geometries[index];
  136901. }
  136902. }
  136903. }
  136904. return null;
  136905. };
  136906. /**
  136907. * Add a new geometry to this scene
  136908. * @param geometry defines the geometry to be added to the scene.
  136909. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  136910. * @return a boolean defining if the geometry was added or not
  136911. */
  136912. Scene.prototype.pushGeometry = function (geometry, force) {
  136913. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  136914. return false;
  136915. }
  136916. this.addGeometry(geometry);
  136917. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  136918. return true;
  136919. };
  136920. /**
  136921. * Removes an existing geometry
  136922. * @param geometry defines the geometry to be removed from the scene
  136923. * @return a boolean defining if the geometry was removed or not
  136924. */
  136925. Scene.prototype.removeGeometry = function (geometry) {
  136926. var index;
  136927. if (this.geometriesByUniqueId) {
  136928. index = this.geometriesByUniqueId[geometry.uniqueId];
  136929. if (index === undefined) {
  136930. return false;
  136931. }
  136932. }
  136933. else {
  136934. index = this.geometries.indexOf(geometry);
  136935. if (index < 0) {
  136936. return false;
  136937. }
  136938. }
  136939. if (index !== this.geometries.length - 1) {
  136940. var lastGeometry = this.geometries[this.geometries.length - 1];
  136941. this.geometries[index] = lastGeometry;
  136942. if (this.geometriesByUniqueId) {
  136943. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  136944. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  136945. }
  136946. }
  136947. this.geometries.pop();
  136948. this.onGeometryRemovedObservable.notifyObservers(geometry);
  136949. return true;
  136950. };
  136951. /**
  136952. * Gets the list of geometries attached to the scene
  136953. * @returns an array of Geometry
  136954. */
  136955. Scene.prototype.getGeometries = function () {
  136956. return this.geometries;
  136957. };
  136958. /**
  136959. * Gets the first added mesh found of a given ID
  136960. * @param id defines the id to search for
  136961. * @return the mesh found or null if not found at all
  136962. */
  136963. Scene.prototype.getMeshByID = function (id) {
  136964. for (var index = 0; index < this.meshes.length; index++) {
  136965. if (this.meshes[index].id === id) {
  136966. return this.meshes[index];
  136967. }
  136968. }
  136969. return null;
  136970. };
  136971. /**
  136972. * Gets a list of meshes using their id
  136973. * @param id defines the id to search for
  136974. * @returns a list of meshes
  136975. */
  136976. Scene.prototype.getMeshesByID = function (id) {
  136977. return this.meshes.filter(function (m) {
  136978. return m.id === id;
  136979. });
  136980. };
  136981. /**
  136982. * Gets the first added transform node found of a given ID
  136983. * @param id defines the id to search for
  136984. * @return the found transform node or null if not found at all.
  136985. */
  136986. Scene.prototype.getTransformNodeByID = function (id) {
  136987. for (var index = 0; index < this.transformNodes.length; index++) {
  136988. if (this.transformNodes[index].id === id) {
  136989. return this.transformNodes[index];
  136990. }
  136991. }
  136992. return null;
  136993. };
  136994. /**
  136995. * Gets a transform node with its auto-generated unique id
  136996. * @param uniqueId efines the unique id to search for
  136997. * @return the found transform node or null if not found at all.
  136998. */
  136999. Scene.prototype.getTransformNodeByUniqueID = function (uniqueId) {
  137000. for (var index = 0; index < this.transformNodes.length; index++) {
  137001. if (this.transformNodes[index].uniqueId === uniqueId) {
  137002. return this.transformNodes[index];
  137003. }
  137004. }
  137005. return null;
  137006. };
  137007. /**
  137008. * Gets a list of transform nodes using their id
  137009. * @param id defines the id to search for
  137010. * @returns a list of transform nodes
  137011. */
  137012. Scene.prototype.getTransformNodesByID = function (id) {
  137013. return this.transformNodes.filter(function (m) {
  137014. return m.id === id;
  137015. });
  137016. };
  137017. /**
  137018. * Gets a mesh with its auto-generated unique id
  137019. * @param uniqueId defines the unique id to search for
  137020. * @return the found mesh or null if not found at all.
  137021. */
  137022. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  137023. for (var index = 0; index < this.meshes.length; index++) {
  137024. if (this.meshes[index].uniqueId === uniqueId) {
  137025. return this.meshes[index];
  137026. }
  137027. }
  137028. return null;
  137029. };
  137030. /**
  137031. * Gets a the last added mesh using a given id
  137032. * @param id defines the id to search for
  137033. * @return the found mesh or null if not found at all.
  137034. */
  137035. Scene.prototype.getLastMeshByID = function (id) {
  137036. for (var index = this.meshes.length - 1; index >= 0; index--) {
  137037. if (this.meshes[index].id === id) {
  137038. return this.meshes[index];
  137039. }
  137040. }
  137041. return null;
  137042. };
  137043. /**
  137044. * Gets a the last added node (Mesh, Camera, Light) using a given id
  137045. * @param id defines the id to search for
  137046. * @return the found node or null if not found at all
  137047. */
  137048. Scene.prototype.getLastEntryByID = function (id) {
  137049. var index;
  137050. for (index = this.meshes.length - 1; index >= 0; index--) {
  137051. if (this.meshes[index].id === id) {
  137052. return this.meshes[index];
  137053. }
  137054. }
  137055. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  137056. if (this.transformNodes[index].id === id) {
  137057. return this.transformNodes[index];
  137058. }
  137059. }
  137060. for (index = this.cameras.length - 1; index >= 0; index--) {
  137061. if (this.cameras[index].id === id) {
  137062. return this.cameras[index];
  137063. }
  137064. }
  137065. for (index = this.lights.length - 1; index >= 0; index--) {
  137066. if (this.lights[index].id === id) {
  137067. return this.lights[index];
  137068. }
  137069. }
  137070. return null;
  137071. };
  137072. /**
  137073. * Gets a node (Mesh, Camera, Light) using a given id
  137074. * @param id defines the id to search for
  137075. * @return the found node or null if not found at all
  137076. */
  137077. Scene.prototype.getNodeByID = function (id) {
  137078. var mesh = this.getMeshByID(id);
  137079. if (mesh) {
  137080. return mesh;
  137081. }
  137082. var transformNode = this.getTransformNodeByID(id);
  137083. if (transformNode) {
  137084. return transformNode;
  137085. }
  137086. var light = this.getLightByID(id);
  137087. if (light) {
  137088. return light;
  137089. }
  137090. var camera = this.getCameraByID(id);
  137091. if (camera) {
  137092. return camera;
  137093. }
  137094. var bone = this.getBoneByID(id);
  137095. if (bone) {
  137096. return bone;
  137097. }
  137098. return null;
  137099. };
  137100. /**
  137101. * Gets a node (Mesh, Camera, Light) using a given name
  137102. * @param name defines the name to search for
  137103. * @return the found node or null if not found at all.
  137104. */
  137105. Scene.prototype.getNodeByName = function (name) {
  137106. var mesh = this.getMeshByName(name);
  137107. if (mesh) {
  137108. return mesh;
  137109. }
  137110. var transformNode = this.getTransformNodeByName(name);
  137111. if (transformNode) {
  137112. return transformNode;
  137113. }
  137114. var light = this.getLightByName(name);
  137115. if (light) {
  137116. return light;
  137117. }
  137118. var camera = this.getCameraByName(name);
  137119. if (camera) {
  137120. return camera;
  137121. }
  137122. var bone = this.getBoneByName(name);
  137123. if (bone) {
  137124. return bone;
  137125. }
  137126. return null;
  137127. };
  137128. /**
  137129. * Gets a mesh using a given name
  137130. * @param name defines the name to search for
  137131. * @return the found mesh or null if not found at all.
  137132. */
  137133. Scene.prototype.getMeshByName = function (name) {
  137134. for (var index = 0; index < this.meshes.length; index++) {
  137135. if (this.meshes[index].name === name) {
  137136. return this.meshes[index];
  137137. }
  137138. }
  137139. return null;
  137140. };
  137141. /**
  137142. * Gets a transform node using a given name
  137143. * @param name defines the name to search for
  137144. * @return the found transform node or null if not found at all.
  137145. */
  137146. Scene.prototype.getTransformNodeByName = function (name) {
  137147. for (var index = 0; index < this.transformNodes.length; index++) {
  137148. if (this.transformNodes[index].name === name) {
  137149. return this.transformNodes[index];
  137150. }
  137151. }
  137152. return null;
  137153. };
  137154. /**
  137155. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  137156. * @param id defines the id to search for
  137157. * @return the found skeleton or null if not found at all.
  137158. */
  137159. Scene.prototype.getLastSkeletonByID = function (id) {
  137160. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  137161. if (this.skeletons[index].id === id) {
  137162. return this.skeletons[index];
  137163. }
  137164. }
  137165. return null;
  137166. };
  137167. /**
  137168. * Gets a skeleton using a given auto generated unique id
  137169. * @param uniqueId defines the unique id to search for
  137170. * @return the found skeleton or null if not found at all.
  137171. */
  137172. Scene.prototype.getSkeletonByUniqueId = function (uniqueId) {
  137173. for (var index = 0; index < this.skeletons.length; index++) {
  137174. if (this.skeletons[index].uniqueId === uniqueId) {
  137175. return this.skeletons[index];
  137176. }
  137177. }
  137178. return null;
  137179. };
  137180. /**
  137181. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  137182. * @param id defines the id to search for
  137183. * @return the found skeleton or null if not found at all.
  137184. */
  137185. Scene.prototype.getSkeletonById = function (id) {
  137186. for (var index = 0; index < this.skeletons.length; index++) {
  137187. if (this.skeletons[index].id === id) {
  137188. return this.skeletons[index];
  137189. }
  137190. }
  137191. return null;
  137192. };
  137193. /**
  137194. * Gets a skeleton using a given name
  137195. * @param name defines the name to search for
  137196. * @return the found skeleton or null if not found at all.
  137197. */
  137198. Scene.prototype.getSkeletonByName = function (name) {
  137199. for (var index = 0; index < this.skeletons.length; index++) {
  137200. if (this.skeletons[index].name === name) {
  137201. return this.skeletons[index];
  137202. }
  137203. }
  137204. return null;
  137205. };
  137206. /**
  137207. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  137208. * @param id defines the id to search for
  137209. * @return the found morph target manager or null if not found at all.
  137210. */
  137211. Scene.prototype.getMorphTargetManagerById = function (id) {
  137212. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  137213. if (this.morphTargetManagers[index].uniqueId === id) {
  137214. return this.morphTargetManagers[index];
  137215. }
  137216. }
  137217. return null;
  137218. };
  137219. /**
  137220. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  137221. * @param id defines the id to search for
  137222. * @return the found morph target or null if not found at all.
  137223. */
  137224. Scene.prototype.getMorphTargetById = function (id) {
  137225. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  137226. var morphTargetManager = this.morphTargetManagers[managerIndex];
  137227. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  137228. var target = morphTargetManager.getTarget(index);
  137229. if (target.id === id) {
  137230. return target;
  137231. }
  137232. }
  137233. }
  137234. return null;
  137235. };
  137236. /**
  137237. * Gets a boolean indicating if the given mesh is active
  137238. * @param mesh defines the mesh to look for
  137239. * @returns true if the mesh is in the active list
  137240. */
  137241. Scene.prototype.isActiveMesh = function (mesh) {
  137242. return (this._activeMeshes.indexOf(mesh) !== -1);
  137243. };
  137244. Object.defineProperty(Scene.prototype, "uid", {
  137245. /**
  137246. * Return a unique id as a string which can serve as an identifier for the scene
  137247. */
  137248. get: function () {
  137249. if (!this._uid) {
  137250. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  137251. }
  137252. return this._uid;
  137253. },
  137254. enumerable: true,
  137255. configurable: true
  137256. });
  137257. /**
  137258. * Add an externaly attached data from its key.
  137259. * This method call will fail and return false, if such key already exists.
  137260. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  137261. * @param key the unique key that identifies the data
  137262. * @param data the data object to associate to the key for this Engine instance
  137263. * @return true if no such key were already present and the data was added successfully, false otherwise
  137264. */
  137265. Scene.prototype.addExternalData = function (key, data) {
  137266. if (!this._externalData) {
  137267. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  137268. }
  137269. return this._externalData.add(key, data);
  137270. };
  137271. /**
  137272. * Get an externaly attached data from its key
  137273. * @param key the unique key that identifies the data
  137274. * @return the associated data, if present (can be null), or undefined if not present
  137275. */
  137276. Scene.prototype.getExternalData = function (key) {
  137277. if (!this._externalData) {
  137278. return null;
  137279. }
  137280. return this._externalData.get(key);
  137281. };
  137282. /**
  137283. * Get an externaly attached data from its key, create it using a factory if it's not already present
  137284. * @param key the unique key that identifies the data
  137285. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  137286. * @return the associated data, can be null if the factory returned null.
  137287. */
  137288. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  137289. if (!this._externalData) {
  137290. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  137291. }
  137292. return this._externalData.getOrAddWithFactory(key, factory);
  137293. };
  137294. /**
  137295. * Remove an externaly attached data from the Engine instance
  137296. * @param key the unique key that identifies the data
  137297. * @return true if the data was successfully removed, false if it doesn't exist
  137298. */
  137299. Scene.prototype.removeExternalData = function (key) {
  137300. return this._externalData.remove(key);
  137301. };
  137302. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  137303. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  137304. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  137305. var step = _a[_i];
  137306. step.action(mesh, subMesh);
  137307. }
  137308. var material = subMesh.getMaterial();
  137309. if (material !== null && material !== undefined) {
  137310. // Render targets
  137311. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  137312. if (this._processedMaterials.indexOf(material) === -1) {
  137313. this._processedMaterials.push(material);
  137314. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  137315. }
  137316. }
  137317. // Dispatch
  137318. this._activeIndices.addCount(subMesh.indexCount, false);
  137319. this._renderingManager.dispatch(subMesh, mesh, material);
  137320. }
  137321. }
  137322. };
  137323. /**
  137324. * Clear the processed materials smart array preventing retention point in material dispose.
  137325. */
  137326. Scene.prototype.freeProcessedMaterials = function () {
  137327. this._processedMaterials.dispose();
  137328. };
  137329. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  137330. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  137331. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  137332. * when disposing several meshes in a row or a hierarchy of meshes.
  137333. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  137334. */
  137335. get: function () {
  137336. return this._preventFreeActiveMeshesAndRenderingGroups;
  137337. },
  137338. set: function (value) {
  137339. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  137340. return;
  137341. }
  137342. if (value) {
  137343. this.freeActiveMeshes();
  137344. this.freeRenderingGroups();
  137345. }
  137346. this._preventFreeActiveMeshesAndRenderingGroups = value;
  137347. },
  137348. enumerable: true,
  137349. configurable: true
  137350. });
  137351. /**
  137352. * Clear the active meshes smart array preventing retention point in mesh dispose.
  137353. */
  137354. Scene.prototype.freeActiveMeshes = function () {
  137355. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  137356. return;
  137357. }
  137358. this._activeMeshes.dispose();
  137359. if (this.activeCamera && this.activeCamera._activeMeshes) {
  137360. this.activeCamera._activeMeshes.dispose();
  137361. }
  137362. if (this.activeCameras) {
  137363. for (var i = 0; i < this.activeCameras.length; i++) {
  137364. var activeCamera = this.activeCameras[i];
  137365. if (activeCamera && activeCamera._activeMeshes) {
  137366. activeCamera._activeMeshes.dispose();
  137367. }
  137368. }
  137369. }
  137370. };
  137371. /**
  137372. * Clear the info related to rendering groups preventing retention points during dispose.
  137373. */
  137374. Scene.prototype.freeRenderingGroups = function () {
  137375. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  137376. return;
  137377. }
  137378. if (this._renderingManager) {
  137379. this._renderingManager.freeRenderingGroups();
  137380. }
  137381. if (this.textures) {
  137382. for (var i = 0; i < this.textures.length; i++) {
  137383. var texture = this.textures[i];
  137384. if (texture && texture.renderList) {
  137385. texture.freeRenderingGroups();
  137386. }
  137387. }
  137388. }
  137389. };
  137390. /** @hidden */
  137391. Scene.prototype._isInIntermediateRendering = function () {
  137392. return this._intermediateRendering;
  137393. };
  137394. /**
  137395. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  137396. * @returns the current scene
  137397. */
  137398. Scene.prototype.freezeActiveMeshes = function () {
  137399. if (!this.activeCamera) {
  137400. return this;
  137401. }
  137402. if (!this._frustumPlanes) {
  137403. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  137404. }
  137405. this._evaluateActiveMeshes();
  137406. this._activeMeshesFrozen = true;
  137407. for (var _i = 0, _a = this._activeMeshes.data; _i < _a.length; _i++) {
  137408. var mesh = _a[_i];
  137409. mesh._freeze();
  137410. }
  137411. return this;
  137412. };
  137413. /**
  137414. * Use this function to restart evaluating active meshes on every frame
  137415. * @returns the current scene
  137416. */
  137417. Scene.prototype.unfreezeActiveMeshes = function () {
  137418. for (var _i = 0, _a = this._activeMeshes.data; _i < _a.length; _i++) {
  137419. var mesh = _a[_i];
  137420. mesh._unFreeze();
  137421. }
  137422. this._activeMeshesFrozen = false;
  137423. return this;
  137424. };
  137425. Scene.prototype._evaluateActiveMeshes = function () {
  137426. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  137427. var len_1 = this._activeMeshes.length;
  137428. for (var i = 0; i < len_1; i++) {
  137429. var mesh = this._activeMeshes.data[i];
  137430. mesh.computeWorldMatrix();
  137431. }
  137432. return;
  137433. }
  137434. if (!this.activeCamera) {
  137435. return;
  137436. }
  137437. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  137438. this.activeCamera._activeMeshes.reset();
  137439. this._activeMeshes.reset();
  137440. this._renderingManager.reset();
  137441. this._processedMaterials.reset();
  137442. this._activeParticleSystems.reset();
  137443. this._activeSkeletons.reset();
  137444. this._softwareSkinnedMeshes.reset();
  137445. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  137446. var step = _a[_i];
  137447. step.action();
  137448. }
  137449. // Determine mesh candidates
  137450. var meshes = this.getActiveMeshCandidates();
  137451. // Check each mesh
  137452. var len = meshes.length;
  137453. for (var i = 0; i < len; i++) {
  137454. var mesh = meshes.data[i];
  137455. mesh._isActive = false;
  137456. if (mesh.isBlocked) {
  137457. continue;
  137458. }
  137459. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  137460. if (!mesh.isReady() || !mesh.isEnabled()) {
  137461. continue;
  137462. }
  137463. mesh.computeWorldMatrix();
  137464. // Intersections
  137465. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  137466. this._meshesForIntersections.pushNoDuplicate(mesh);
  137467. }
  137468. // Switch to current LOD
  137469. var meshLOD = this.customLODSelector ? this.customLODSelector(mesh, this.activeCamera) : mesh.getLOD(this.activeCamera);
  137470. if (meshLOD === undefined || meshLOD === null) {
  137471. continue;
  137472. }
  137473. // Compute world matrix if LOD is billboard
  137474. if (meshLOD !== mesh && meshLOD.billboardMode !== _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_8__["TransformNode"].BILLBOARDMODE_NONE) {
  137475. meshLOD.computeWorldMatrix();
  137476. }
  137477. mesh._preActivate();
  137478. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  137479. this._activeMeshes.push(mesh);
  137480. this.activeCamera._activeMeshes.push(mesh);
  137481. if (meshLOD !== mesh) {
  137482. meshLOD._activate(this._renderId);
  137483. }
  137484. if (mesh._activate(this._renderId)) {
  137485. mesh._isActive = true;
  137486. this._activeMesh(mesh, meshLOD);
  137487. }
  137488. }
  137489. }
  137490. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  137491. // Particle systems
  137492. if (this.particlesEnabled) {
  137493. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  137494. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  137495. var particleSystem = this.particleSystems[particleIndex];
  137496. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  137497. continue;
  137498. }
  137499. var emitter = particleSystem.emitter;
  137500. if (!emitter.position || emitter.isEnabled()) {
  137501. this._activeParticleSystems.push(particleSystem);
  137502. particleSystem.animate();
  137503. this._renderingManager.dispatchParticles(particleSystem);
  137504. }
  137505. }
  137506. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  137507. }
  137508. };
  137509. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  137510. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  137511. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  137512. mesh.skeleton.prepare();
  137513. }
  137514. if (!mesh.computeBonesUsingShaders) {
  137515. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  137516. }
  137517. }
  137518. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  137519. var step = _a[_i];
  137520. step.action(sourceMesh, mesh);
  137521. }
  137522. if (mesh !== undefined && mesh !== null
  137523. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  137524. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  137525. var len = subMeshes.length;
  137526. for (var i = 0; i < len; i++) {
  137527. var subMesh = subMeshes.data[i];
  137528. this._evaluateSubMesh(subMesh, mesh);
  137529. }
  137530. }
  137531. };
  137532. /**
  137533. * Update the transform matrix to update from the current active camera
  137534. * @param force defines a boolean used to force the update even if cache is up to date
  137535. */
  137536. Scene.prototype.updateTransformMatrix = function (force) {
  137537. if (!this.activeCamera) {
  137538. return;
  137539. }
  137540. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  137541. };
  137542. Scene.prototype._bindFrameBuffer = function () {
  137543. if (this.activeCamera && this.activeCamera._multiviewTexture) {
  137544. this.activeCamera._multiviewTexture._bindFrameBuffer();
  137545. }
  137546. else if (this.activeCamera && this.activeCamera.outputRenderTarget) {
  137547. var useMultiview = this.getEngine().getCaps().multiview && this.activeCamera.outputRenderTarget && this.activeCamera.outputRenderTarget.getViewCount() > 1;
  137548. if (useMultiview) {
  137549. this.activeCamera.outputRenderTarget._bindFrameBuffer();
  137550. }
  137551. else {
  137552. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  137553. if (internalTexture) {
  137554. this.getEngine().bindFramebuffer(internalTexture);
  137555. }
  137556. else {
  137557. _Misc_logger__WEBPACK_IMPORTED_MODULE_24__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  137558. }
  137559. }
  137560. }
  137561. else {
  137562. this.getEngine().restoreDefaultFramebuffer(); // Restore back buffer if needed
  137563. }
  137564. };
  137565. /** @hidden */
  137566. Scene.prototype._renderForCamera = function (camera, rigParent) {
  137567. if (camera && camera._skipRendering) {
  137568. return;
  137569. }
  137570. var engine = this._engine;
  137571. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  137572. this._activeCamera = camera;
  137573. if (!this.activeCamera) {
  137574. throw new Error("Active camera not set");
  137575. }
  137576. // Viewport
  137577. engine.setViewport(this.activeCamera.viewport);
  137578. // Camera
  137579. this.resetCachedMaterial();
  137580. this._renderId++;
  137581. var useMultiview = this.getEngine().getCaps().multiview && camera.outputRenderTarget && camera.outputRenderTarget.getViewCount() > 1;
  137582. if (useMultiview) {
  137583. this.setTransformMatrix(camera._rigCameras[0].getViewMatrix(), camera._rigCameras[0].getProjectionMatrix(), camera._rigCameras[1].getViewMatrix(), camera._rigCameras[1].getProjectionMatrix());
  137584. }
  137585. else {
  137586. this.updateTransformMatrix();
  137587. }
  137588. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  137589. // Meshes
  137590. this._evaluateActiveMeshes();
  137591. // Software skinning
  137592. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  137593. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  137594. mesh.applySkeleton(mesh.skeleton);
  137595. }
  137596. // Render targets
  137597. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  137598. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  137599. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  137600. }
  137601. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  137602. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  137603. }
  137604. // Collects render targets from external components.
  137605. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  137606. var step = _a[_i];
  137607. step.action(this._renderTargets);
  137608. }
  137609. if (this.renderTargetsEnabled) {
  137610. this._intermediateRendering = true;
  137611. var needRebind = false;
  137612. if (this._renderTargets.length > 0) {
  137613. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  137614. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  137615. var renderTarget = this._renderTargets.data[renderIndex];
  137616. if (renderTarget._shouldRender()) {
  137617. this._renderId++;
  137618. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  137619. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  137620. needRebind = true;
  137621. }
  137622. }
  137623. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  137624. this._renderId++;
  137625. }
  137626. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  137627. var step = _c[_b];
  137628. needRebind = needRebind || step.action(this.activeCamera);
  137629. }
  137630. this._intermediateRendering = false;
  137631. // Restore framebuffer after rendering to targets
  137632. if (needRebind) {
  137633. this._bindFrameBuffer();
  137634. }
  137635. }
  137636. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  137637. // Prepare Frame
  137638. if (this.postProcessManager && !camera._multiviewTexture) {
  137639. this.postProcessManager._prepareFrame();
  137640. }
  137641. // Before Camera Draw
  137642. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  137643. var step = _e[_d];
  137644. step.action(this.activeCamera);
  137645. }
  137646. // Render
  137647. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  137648. this._renderingManager.render(null, null, true, true);
  137649. this.onAfterDrawPhaseObservable.notifyObservers(this);
  137650. // After Camera Draw
  137651. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  137652. var step = _g[_f];
  137653. step.action(this.activeCamera);
  137654. }
  137655. // Finalize frame
  137656. if (this.postProcessManager && !camera._multiviewTexture) {
  137657. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  137658. }
  137659. // Reset some special arrays
  137660. this._renderTargets.reset();
  137661. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  137662. };
  137663. Scene.prototype._processSubCameras = function (camera) {
  137664. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_NONE || (camera.outputRenderTarget && camera.outputRenderTarget.getViewCount() > 1 && this.getEngine().getCaps().multiview)) {
  137665. this._renderForCamera(camera);
  137666. return;
  137667. }
  137668. if (camera._useMultiviewToSingleView) {
  137669. this._renderMultiviewToSingleView(camera);
  137670. }
  137671. else {
  137672. // rig cameras
  137673. for (var index = 0; index < camera._rigCameras.length; index++) {
  137674. this._renderForCamera(camera._rigCameras[index], camera);
  137675. }
  137676. }
  137677. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  137678. this._activeCamera = camera;
  137679. this.setTransformMatrix(this._activeCamera.getViewMatrix(), this._activeCamera.getProjectionMatrix());
  137680. };
  137681. Scene.prototype._checkIntersections = function () {
  137682. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  137683. var sourceMesh = this._meshesForIntersections.data[index];
  137684. if (!sourceMesh.actionManager) {
  137685. continue;
  137686. }
  137687. for (var actionIndex = 0; sourceMesh.actionManager && actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  137688. var action = sourceMesh.actionManager.actions[actionIndex];
  137689. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger) {
  137690. var parameters = action.getTriggerParameter();
  137691. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_9__["AbstractMesh"] ? parameters : parameters.mesh;
  137692. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  137693. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  137694. if (areIntersecting && currentIntersectionInProgress === -1) {
  137695. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  137696. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  137697. sourceMesh._intersectionsInProgress.push(otherMesh);
  137698. }
  137699. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger) {
  137700. sourceMesh._intersectionsInProgress.push(otherMesh);
  137701. }
  137702. }
  137703. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  137704. //They intersected, and now they don't.
  137705. //is this trigger an exit trigger? execute an event.
  137706. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger) {
  137707. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  137708. }
  137709. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  137710. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  137711. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_9__["AbstractMesh"] ? parameter : parameter.mesh;
  137712. return otherMesh === parameterMesh;
  137713. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger) {
  137714. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  137715. }
  137716. }
  137717. }
  137718. }
  137719. }
  137720. };
  137721. /** @hidden */
  137722. Scene.prototype._advancePhysicsEngineStep = function (step) {
  137723. // Do nothing. Code will be replaced if physics engine component is referenced
  137724. };
  137725. /** @hidden */
  137726. Scene.prototype._animate = function () {
  137727. // Nothing to do as long as Animatable have not been imported.
  137728. };
  137729. /** Execute all animations (for a frame) */
  137730. Scene.prototype.animate = function () {
  137731. if (this._engine.isDeterministicLockStep()) {
  137732. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  137733. var defaultFPS = (60.0 / 1000.0);
  137734. var defaultFrameTime = this.getDeterministicFrameTime();
  137735. var stepsTaken = 0;
  137736. var maxSubSteps = this._engine.getLockstepMaxSteps();
  137737. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  137738. internalSteps = Math.min(internalSteps, maxSubSteps);
  137739. do {
  137740. this.onBeforeStepObservable.notifyObservers(this);
  137741. // Animations
  137742. this._animationRatio = defaultFrameTime * defaultFPS;
  137743. this._animate();
  137744. this.onAfterAnimationsObservable.notifyObservers(this);
  137745. // Physics
  137746. this._advancePhysicsEngineStep(defaultFrameTime);
  137747. this.onAfterStepObservable.notifyObservers(this);
  137748. this._currentStepId++;
  137749. stepsTaken++;
  137750. deltaTime -= defaultFrameTime;
  137751. } while (deltaTime > 0 && stepsTaken < internalSteps);
  137752. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  137753. }
  137754. else {
  137755. // Animations
  137756. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  137757. this._animationRatio = deltaTime * (60.0 / 1000.0);
  137758. this._animate();
  137759. this.onAfterAnimationsObservable.notifyObservers(this);
  137760. // Physics
  137761. this._advancePhysicsEngineStep(deltaTime);
  137762. }
  137763. };
  137764. /**
  137765. * Render the scene
  137766. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  137767. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  137768. */
  137769. Scene.prototype.render = function (updateCameras, ignoreAnimations) {
  137770. if (updateCameras === void 0) { updateCameras = true; }
  137771. if (ignoreAnimations === void 0) { ignoreAnimations = false; }
  137772. if (this.isDisposed) {
  137773. return;
  137774. }
  137775. this._frameId++;
  137776. // Register components that have been associated lately to the scene.
  137777. this._registerTransientComponents();
  137778. this._activeParticles.fetchNewFrame();
  137779. this._totalVertices.fetchNewFrame();
  137780. this._activeIndices.fetchNewFrame();
  137781. this._activeBones.fetchNewFrame();
  137782. this._meshesForIntersections.reset();
  137783. this.resetCachedMaterial();
  137784. this.onBeforeAnimationsObservable.notifyObservers(this);
  137785. // Actions
  137786. if (this.actionManager) {
  137787. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnEveryFrameTrigger);
  137788. }
  137789. // Animations
  137790. if (!ignoreAnimations) {
  137791. this.animate();
  137792. }
  137793. // Before camera update steps
  137794. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  137795. var step = _a[_i];
  137796. step.action();
  137797. }
  137798. // Update Cameras
  137799. if (updateCameras) {
  137800. if (this.activeCameras.length > 0) {
  137801. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  137802. var camera = this.activeCameras[cameraIndex];
  137803. camera.update();
  137804. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_NONE) {
  137805. // rig cameras
  137806. for (var index = 0; index < camera._rigCameras.length; index++) {
  137807. camera._rigCameras[index].update();
  137808. }
  137809. }
  137810. }
  137811. }
  137812. else if (this.activeCamera) {
  137813. this.activeCamera.update();
  137814. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_NONE) {
  137815. // rig cameras
  137816. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  137817. this.activeCamera._rigCameras[index].update();
  137818. }
  137819. }
  137820. }
  137821. }
  137822. // Before render
  137823. this.onBeforeRenderObservable.notifyObservers(this);
  137824. // Customs render targets
  137825. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  137826. var engine = this.getEngine();
  137827. var currentActiveCamera = this.activeCamera;
  137828. if (this.renderTargetsEnabled) {
  137829. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  137830. this._intermediateRendering = true;
  137831. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  137832. var renderTarget = this.customRenderTargets[customIndex];
  137833. if (renderTarget._shouldRender()) {
  137834. this._renderId++;
  137835. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  137836. if (!this.activeCamera) {
  137837. throw new Error("Active camera not set");
  137838. }
  137839. // Viewport
  137840. engine.setViewport(this.activeCamera.viewport);
  137841. // Camera
  137842. this.updateTransformMatrix();
  137843. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  137844. }
  137845. }
  137846. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  137847. this._intermediateRendering = false;
  137848. this._renderId++;
  137849. }
  137850. // Restore back buffer
  137851. this.activeCamera = currentActiveCamera;
  137852. this._bindFrameBuffer();
  137853. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  137854. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  137855. var step = _c[_b];
  137856. step.action();
  137857. }
  137858. // Clear
  137859. if (this.autoClearDepthAndStencil || this.autoClear) {
  137860. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  137861. }
  137862. // Collects render targets from external components.
  137863. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  137864. var step = _e[_d];
  137865. step.action(this._renderTargets);
  137866. }
  137867. // Multi-cameras?
  137868. if (this.activeCameras.length > 0) {
  137869. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  137870. if (cameraIndex > 0) {
  137871. this._engine.clear(null, false, true, true);
  137872. }
  137873. this._processSubCameras(this.activeCameras[cameraIndex]);
  137874. }
  137875. }
  137876. else {
  137877. if (!this.activeCamera) {
  137878. throw new Error("No camera defined");
  137879. }
  137880. this._processSubCameras(this.activeCamera);
  137881. }
  137882. // Intersection checks
  137883. this._checkIntersections();
  137884. // Executes the after render stage actions.
  137885. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  137886. var step = _g[_f];
  137887. step.action();
  137888. }
  137889. // After render
  137890. if (this.afterRender) {
  137891. this.afterRender();
  137892. }
  137893. this.onAfterRenderObservable.notifyObservers(this);
  137894. // Cleaning
  137895. if (this._toBeDisposed.length) {
  137896. for (var index = 0; index < this._toBeDisposed.length; index++) {
  137897. var data = this._toBeDisposed[index];
  137898. if (data) {
  137899. data.dispose();
  137900. }
  137901. }
  137902. this._toBeDisposed = [];
  137903. }
  137904. if (this.dumpNextRenderTargets) {
  137905. this.dumpNextRenderTargets = false;
  137906. }
  137907. this._activeBones.addCount(0, true);
  137908. this._activeIndices.addCount(0, true);
  137909. this._activeParticles.addCount(0, true);
  137910. };
  137911. /**
  137912. * Freeze all materials
  137913. * A frozen material will not be updatable but should be faster to render
  137914. */
  137915. Scene.prototype.freezeMaterials = function () {
  137916. for (var i = 0; i < this.materials.length; i++) {
  137917. this.materials[i].freeze();
  137918. }
  137919. };
  137920. /**
  137921. * Unfreeze all materials
  137922. * A frozen material will not be updatable but should be faster to render
  137923. */
  137924. Scene.prototype.unfreezeMaterials = function () {
  137925. for (var i = 0; i < this.materials.length; i++) {
  137926. this.materials[i].unfreeze();
  137927. }
  137928. };
  137929. /**
  137930. * Releases all held ressources
  137931. */
  137932. Scene.prototype.dispose = function () {
  137933. this.beforeRender = null;
  137934. this.afterRender = null;
  137935. this.skeletons = [];
  137936. this.morphTargetManagers = [];
  137937. this._transientComponents = [];
  137938. this._isReadyForMeshStage.clear();
  137939. this._beforeEvaluateActiveMeshStage.clear();
  137940. this._evaluateSubMeshStage.clear();
  137941. this._activeMeshStage.clear();
  137942. this._cameraDrawRenderTargetStage.clear();
  137943. this._beforeCameraDrawStage.clear();
  137944. this._beforeRenderTargetDrawStage.clear();
  137945. this._beforeRenderingGroupDrawStage.clear();
  137946. this._beforeRenderingMeshStage.clear();
  137947. this._afterRenderingMeshStage.clear();
  137948. this._afterRenderingGroupDrawStage.clear();
  137949. this._afterCameraDrawStage.clear();
  137950. this._afterRenderTargetDrawStage.clear();
  137951. this._afterRenderStage.clear();
  137952. this._beforeCameraUpdateStage.clear();
  137953. this._beforeClearStage.clear();
  137954. this._gatherRenderTargetsStage.clear();
  137955. this._gatherActiveCameraRenderTargetsStage.clear();
  137956. this._pointerMoveStage.clear();
  137957. this._pointerDownStage.clear();
  137958. this._pointerUpStage.clear();
  137959. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  137960. var component = _a[_i];
  137961. component.dispose();
  137962. }
  137963. this.importedMeshesFiles = new Array();
  137964. this.stopAllAnimations();
  137965. this.resetCachedMaterial();
  137966. // Smart arrays
  137967. if (this.activeCamera) {
  137968. this.activeCamera._activeMeshes.dispose();
  137969. this.activeCamera = null;
  137970. }
  137971. this._activeMeshes.dispose();
  137972. this._renderingManager.dispose();
  137973. this._processedMaterials.dispose();
  137974. this._activeParticleSystems.dispose();
  137975. this._activeSkeletons.dispose();
  137976. this._softwareSkinnedMeshes.dispose();
  137977. this._renderTargets.dispose();
  137978. this._registeredForLateAnimationBindings.dispose();
  137979. this._meshesForIntersections.dispose();
  137980. this._toBeDisposed = [];
  137981. // Abort active requests
  137982. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  137983. var request = _c[_b];
  137984. request.abort();
  137985. }
  137986. // Events
  137987. this.onDisposeObservable.notifyObservers(this);
  137988. this.onDisposeObservable.clear();
  137989. this.onBeforeRenderObservable.clear();
  137990. this.onAfterRenderObservable.clear();
  137991. this.onBeforeRenderTargetsRenderObservable.clear();
  137992. this.onAfterRenderTargetsRenderObservable.clear();
  137993. this.onAfterStepObservable.clear();
  137994. this.onBeforeStepObservable.clear();
  137995. this.onBeforeActiveMeshesEvaluationObservable.clear();
  137996. this.onAfterActiveMeshesEvaluationObservable.clear();
  137997. this.onBeforeParticlesRenderingObservable.clear();
  137998. this.onAfterParticlesRenderingObservable.clear();
  137999. this.onBeforeDrawPhaseObservable.clear();
  138000. this.onAfterDrawPhaseObservable.clear();
  138001. this.onBeforeAnimationsObservable.clear();
  138002. this.onAfterAnimationsObservable.clear();
  138003. this.onDataLoadedObservable.clear();
  138004. this.onBeforeRenderingGroupObservable.clear();
  138005. this.onAfterRenderingGroupObservable.clear();
  138006. this.onMeshImportedObservable.clear();
  138007. this.onBeforeCameraRenderObservable.clear();
  138008. this.onAfterCameraRenderObservable.clear();
  138009. this.onReadyObservable.clear();
  138010. this.onNewCameraAddedObservable.clear();
  138011. this.onCameraRemovedObservable.clear();
  138012. this.onNewLightAddedObservable.clear();
  138013. this.onLightRemovedObservable.clear();
  138014. this.onNewGeometryAddedObservable.clear();
  138015. this.onGeometryRemovedObservable.clear();
  138016. this.onNewTransformNodeAddedObservable.clear();
  138017. this.onTransformNodeRemovedObservable.clear();
  138018. this.onNewMeshAddedObservable.clear();
  138019. this.onMeshRemovedObservable.clear();
  138020. this.onNewSkeletonAddedObservable.clear();
  138021. this.onSkeletonRemovedObservable.clear();
  138022. this.onNewMaterialAddedObservable.clear();
  138023. this.onMaterialRemovedObservable.clear();
  138024. this.onNewTextureAddedObservable.clear();
  138025. this.onTextureRemovedObservable.clear();
  138026. this.onPrePointerObservable.clear();
  138027. this.onPointerObservable.clear();
  138028. this.onPreKeyboardObservable.clear();
  138029. this.onKeyboardObservable.clear();
  138030. this.onActiveCameraChanged.clear();
  138031. this.detachControl();
  138032. // Detach cameras
  138033. var canvas = this._engine.getRenderingCanvas();
  138034. if (canvas) {
  138035. var index;
  138036. for (index = 0; index < this.cameras.length; index++) {
  138037. this.cameras[index].detachControl(canvas);
  138038. }
  138039. }
  138040. // Release animation groups
  138041. while (this.animationGroups.length) {
  138042. this.animationGroups[0].dispose();
  138043. }
  138044. // Release lights
  138045. while (this.lights.length) {
  138046. this.lights[0].dispose();
  138047. }
  138048. // Release meshes
  138049. while (this.meshes.length) {
  138050. this.meshes[0].dispose(true);
  138051. }
  138052. while (this.transformNodes.length) {
  138053. this.transformNodes[0].dispose(true);
  138054. }
  138055. // Release cameras
  138056. while (this.cameras.length) {
  138057. this.cameras[0].dispose();
  138058. }
  138059. // Release materials
  138060. if (this.defaultMaterial) {
  138061. this.defaultMaterial.dispose();
  138062. }
  138063. while (this.multiMaterials.length) {
  138064. this.multiMaterials[0].dispose();
  138065. }
  138066. while (this.materials.length) {
  138067. this.materials[0].dispose();
  138068. }
  138069. // Release particles
  138070. while (this.particleSystems.length) {
  138071. this.particleSystems[0].dispose();
  138072. }
  138073. // Release postProcesses
  138074. while (this.postProcesses.length) {
  138075. this.postProcesses[0].dispose();
  138076. }
  138077. // Release textures
  138078. while (this.textures.length) {
  138079. this.textures[0].dispose();
  138080. }
  138081. // Release UBO
  138082. this._sceneUbo.dispose();
  138083. if (this._multiviewSceneUbo) {
  138084. this._multiviewSceneUbo.dispose();
  138085. }
  138086. // Post-processes
  138087. this.postProcessManager.dispose();
  138088. // Remove from engine
  138089. index = this._engine.scenes.indexOf(this);
  138090. if (index > -1) {
  138091. this._engine.scenes.splice(index, 1);
  138092. }
  138093. this._engine.wipeCaches(true);
  138094. this._isDisposed = true;
  138095. };
  138096. Object.defineProperty(Scene.prototype, "isDisposed", {
  138097. /**
  138098. * Gets if the scene is already disposed
  138099. */
  138100. get: function () {
  138101. return this._isDisposed;
  138102. },
  138103. enumerable: true,
  138104. configurable: true
  138105. });
  138106. /**
  138107. * Call this function to reduce memory footprint of the scene.
  138108. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  138109. */
  138110. Scene.prototype.clearCachedVertexData = function () {
  138111. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  138112. var mesh = this.meshes[meshIndex];
  138113. var geometry = mesh.geometry;
  138114. if (geometry) {
  138115. geometry._indices = [];
  138116. for (var vbName in geometry._vertexBuffers) {
  138117. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  138118. continue;
  138119. }
  138120. geometry._vertexBuffers[vbName]._buffer._data = null;
  138121. }
  138122. }
  138123. }
  138124. };
  138125. /**
  138126. * This function will remove the local cached buffer data from texture.
  138127. * It will save memory but will prevent the texture from being rebuilt
  138128. */
  138129. Scene.prototype.cleanCachedTextureBuffer = function () {
  138130. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  138131. var baseTexture = _a[_i];
  138132. var buffer = baseTexture._buffer;
  138133. if (buffer) {
  138134. baseTexture._buffer = null;
  138135. }
  138136. }
  138137. };
  138138. /**
  138139. * Get the world extend vectors with an optional filter
  138140. *
  138141. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  138142. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  138143. */
  138144. Scene.prototype.getWorldExtends = function (filterPredicate) {
  138145. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  138146. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  138147. filterPredicate = filterPredicate || (function () { return true; });
  138148. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  138149. mesh.computeWorldMatrix(true);
  138150. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  138151. return;
  138152. }
  138153. var boundingInfo = mesh.getBoundingInfo();
  138154. var minBox = boundingInfo.boundingBox.minimumWorld;
  138155. var maxBox = boundingInfo.boundingBox.maximumWorld;
  138156. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  138157. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  138158. });
  138159. return {
  138160. min: min,
  138161. max: max
  138162. };
  138163. };
  138164. // Picking
  138165. /**
  138166. * Creates a ray that can be used to pick in the scene
  138167. * @param x defines the x coordinate of the origin (on-screen)
  138168. * @param y defines the y coordinate of the origin (on-screen)
  138169. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  138170. * @param camera defines the camera to use for the picking
  138171. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  138172. * @returns a Ray
  138173. */
  138174. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  138175. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  138176. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138177. };
  138178. /**
  138179. * Creates a ray that can be used to pick in the scene
  138180. * @param x defines the x coordinate of the origin (on-screen)
  138181. * @param y defines the y coordinate of the origin (on-screen)
  138182. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  138183. * @param result defines the ray where to store the picking ray
  138184. * @param camera defines the camera to use for the picking
  138185. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  138186. * @returns the current scene
  138187. */
  138188. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  138189. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  138190. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138191. };
  138192. /**
  138193. * Creates a ray that can be used to pick in the scene
  138194. * @param x defines the x coordinate of the origin (on-screen)
  138195. * @param y defines the y coordinate of the origin (on-screen)
  138196. * @param camera defines the camera to use for the picking
  138197. * @returns a Ray
  138198. */
  138199. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  138200. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138201. };
  138202. /**
  138203. * Creates a ray that can be used to pick in the scene
  138204. * @param x defines the x coordinate of the origin (on-screen)
  138205. * @param y defines the y coordinate of the origin (on-screen)
  138206. * @param result defines the ray where to store the picking ray
  138207. * @param camera defines the camera to use for the picking
  138208. * @returns the current scene
  138209. */
  138210. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  138211. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138212. };
  138213. /** Launch a ray to try to pick a mesh in the scene
  138214. * @param x position on screen
  138215. * @param y position on screen
  138216. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  138217. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  138218. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  138219. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  138220. * @returns a PickingInfo
  138221. */
  138222. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  138223. // Dummy info if picking as not been imported
  138224. var pi = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_15__["PickingInfo"]();
  138225. pi._pickingUnavailable = true;
  138226. return pi;
  138227. };
  138228. /** Use the given ray to pick a mesh in the scene
  138229. * @param ray The ray to use to pick meshes
  138230. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  138231. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  138232. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  138233. * @returns a PickingInfo
  138234. */
  138235. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  138236. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138237. };
  138238. /**
  138239. * Launch a ray to try to pick a mesh in the scene
  138240. * @param x X position on screen
  138241. * @param y Y position on screen
  138242. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  138243. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  138244. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  138245. * @returns an array of PickingInfo
  138246. */
  138247. Scene.prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  138248. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138249. };
  138250. /**
  138251. * Launch a ray to try to pick a mesh in the scene
  138252. * @param ray Ray to use
  138253. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  138254. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  138255. * @returns an array of PickingInfo
  138256. */
  138257. Scene.prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  138258. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138259. };
  138260. /**
  138261. * Force the value of meshUnderPointer
  138262. * @param mesh defines the mesh to use
  138263. */
  138264. Scene.prototype.setPointerOverMesh = function (mesh) {
  138265. if (this._pointerOverMesh === mesh) {
  138266. return;
  138267. }
  138268. var actionManager;
  138269. if (this._pointerOverMesh) {
  138270. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPointerOutTrigger);
  138271. if (actionManager) {
  138272. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(this._pointerOverMesh));
  138273. }
  138274. }
  138275. this._pointerOverMesh = mesh;
  138276. if (this._pointerOverMesh) {
  138277. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPointerOverTrigger);
  138278. if (actionManager) {
  138279. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(this._pointerOverMesh));
  138280. }
  138281. }
  138282. };
  138283. /**
  138284. * Gets the mesh under the pointer
  138285. * @returns a Mesh or null if no mesh is under the pointer
  138286. */
  138287. Scene.prototype.getPointerOverMesh = function () {
  138288. return this._pointerOverMesh;
  138289. };
  138290. // Misc.
  138291. /** @hidden */
  138292. Scene.prototype._rebuildGeometries = function () {
  138293. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  138294. var geometry = _a[_i];
  138295. geometry._rebuild();
  138296. }
  138297. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  138298. var mesh = _c[_b];
  138299. mesh._rebuild();
  138300. }
  138301. if (this.postProcessManager) {
  138302. this.postProcessManager._rebuild();
  138303. }
  138304. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  138305. var component = _e[_d];
  138306. component.rebuild();
  138307. }
  138308. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  138309. var system = _g[_f];
  138310. system.rebuild();
  138311. }
  138312. };
  138313. /** @hidden */
  138314. Scene.prototype._rebuildTextures = function () {
  138315. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  138316. var texture = _a[_i];
  138317. texture._rebuild();
  138318. }
  138319. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_TextureDirtyFlag);
  138320. };
  138321. // Tags
  138322. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  138323. if (tagsQuery === undefined) {
  138324. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  138325. return list;
  138326. }
  138327. var listByTags = [];
  138328. forEach = forEach || (function (item) { return; });
  138329. for (var i in list) {
  138330. var item = list[i];
  138331. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  138332. listByTags.push(item);
  138333. forEach(item);
  138334. }
  138335. }
  138336. return listByTags;
  138337. };
  138338. /**
  138339. * Get a list of meshes by tags
  138340. * @param tagsQuery defines the tags query to use
  138341. * @param forEach defines a predicate used to filter results
  138342. * @returns an array of Mesh
  138343. */
  138344. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  138345. return this._getByTags(this.meshes, tagsQuery, forEach);
  138346. };
  138347. /**
  138348. * Get a list of cameras by tags
  138349. * @param tagsQuery defines the tags query to use
  138350. * @param forEach defines a predicate used to filter results
  138351. * @returns an array of Camera
  138352. */
  138353. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  138354. return this._getByTags(this.cameras, tagsQuery, forEach);
  138355. };
  138356. /**
  138357. * Get a list of lights by tags
  138358. * @param tagsQuery defines the tags query to use
  138359. * @param forEach defines a predicate used to filter results
  138360. * @returns an array of Light
  138361. */
  138362. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  138363. return this._getByTags(this.lights, tagsQuery, forEach);
  138364. };
  138365. /**
  138366. * Get a list of materials by tags
  138367. * @param tagsQuery defines the tags query to use
  138368. * @param forEach defines a predicate used to filter results
  138369. * @returns an array of Material
  138370. */
  138371. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  138372. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  138373. };
  138374. /**
  138375. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  138376. * This allowed control for front to back rendering or reversly depending of the special needs.
  138377. *
  138378. * @param renderingGroupId The rendering group id corresponding to its index
  138379. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  138380. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  138381. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  138382. */
  138383. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  138384. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  138385. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  138386. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  138387. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  138388. };
  138389. /**
  138390. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  138391. *
  138392. * @param renderingGroupId The rendering group id corresponding to its index
  138393. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  138394. * @param depth Automatically clears depth between groups if true and autoClear is true.
  138395. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  138396. */
  138397. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  138398. if (depth === void 0) { depth = true; }
  138399. if (stencil === void 0) { stencil = true; }
  138400. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  138401. };
  138402. /**
  138403. * Gets the current auto clear configuration for one rendering group of the rendering
  138404. * manager.
  138405. * @param index the rendering group index to get the information for
  138406. * @returns The auto clear setup for the requested rendering group
  138407. */
  138408. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  138409. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  138410. };
  138411. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  138412. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  138413. get: function () {
  138414. return this._blockMaterialDirtyMechanism;
  138415. },
  138416. set: function (value) {
  138417. if (this._blockMaterialDirtyMechanism === value) {
  138418. return;
  138419. }
  138420. this._blockMaterialDirtyMechanism = value;
  138421. if (!value) { // Do a complete update
  138422. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_AllDirtyFlag);
  138423. }
  138424. },
  138425. enumerable: true,
  138426. configurable: true
  138427. });
  138428. /**
  138429. * Will flag all materials as dirty to trigger new shader compilation
  138430. * @param flag defines the flag used to specify which material part must be marked as dirty
  138431. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  138432. */
  138433. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  138434. if (this._blockMaterialDirtyMechanism) {
  138435. return;
  138436. }
  138437. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  138438. var material = _a[_i];
  138439. if (predicate && !predicate(material)) {
  138440. continue;
  138441. }
  138442. material.markAsDirty(flag);
  138443. }
  138444. };
  138445. /** @hidden */
  138446. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  138447. var _this = this;
  138448. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  138449. this._activeRequests.push(request);
  138450. request.onCompleteObservable.add(function (request) {
  138451. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  138452. });
  138453. return request;
  138454. };
  138455. /** @hidden */
  138456. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  138457. var _this = this;
  138458. return new Promise(function (resolve, reject) {
  138459. _this._loadFile(url, function (data) {
  138460. resolve(data);
  138461. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  138462. reject(exception);
  138463. });
  138464. });
  138465. };
  138466. // Statics
  138467. Scene._uniqueIdCounter = 0;
  138468. /** The fog is deactivated */
  138469. Scene.FOGMODE_NONE = 0;
  138470. /** The fog density is following an exponential function */
  138471. Scene.FOGMODE_EXP = 1;
  138472. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  138473. Scene.FOGMODE_EXP2 = 2;
  138474. /** The fog density is following a linear function. */
  138475. Scene.FOGMODE_LINEAR = 3;
  138476. /**
  138477. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  138478. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  138479. */
  138480. Scene.MinDeltaTime = 1.0;
  138481. /**
  138482. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  138483. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  138484. */
  138485. Scene.MaxDeltaTime = 1000.0;
  138486. /** The distance in pixel that you have to move to prevent some events */
  138487. Scene.DragMovementThreshold = 10; // in pixels
  138488. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  138489. Scene.LongPressDelay = 500; // in milliseconds
  138490. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  138491. Scene.DoubleClickDelay = 300; // in milliseconds
  138492. /** If you need to check double click without raising a single click at first click, enable this flag */
  138493. Scene.ExclusiveDoubleClickMode = false;
  138494. return Scene;
  138495. }(_abstractScene__WEBPACK_IMPORTED_MODULE_11__["AbstractScene"]));
  138496. /***/ }),
  138497. /***/ "./sceneComponent.ts":
  138498. /*!***************************!*\
  138499. !*** ./sceneComponent.ts ***!
  138500. \***************************/
  138501. /*! exports provided: SceneComponentConstants, Stage */
  138502. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  138503. "use strict";
  138504. __webpack_require__.r(__webpack_exports__);
  138505. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  138506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  138507. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  138508. /**
  138509. * Groups all the scene component constants in one place to ease maintenance.
  138510. * @hidden
  138511. */
  138512. var SceneComponentConstants = /** @class */ (function () {
  138513. function SceneComponentConstants() {
  138514. }
  138515. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  138516. SceneComponentConstants.NAME_LAYER = "Layer";
  138517. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  138518. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  138519. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  138520. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  138521. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  138522. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  138523. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  138524. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  138525. SceneComponentConstants.NAME_SPRITE = "Sprite";
  138526. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  138527. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  138528. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  138529. SceneComponentConstants.NAME_OCTREE = "Octree";
  138530. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  138531. SceneComponentConstants.NAME_AUDIO = "Audio";
  138532. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  138533. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  138534. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  138535. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  138536. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  138537. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  138538. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  138539. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  138540. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  138541. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  138542. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  138543. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  138544. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  138545. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  138546. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  138547. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  138548. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  138549. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  138550. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  138551. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  138552. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  138553. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  138554. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  138555. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  138556. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  138557. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  138558. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  138559. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  138560. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  138561. return SceneComponentConstants;
  138562. }());
  138563. /**
  138564. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  138565. * @hidden
  138566. */
  138567. var Stage = /** @class */ (function (_super) {
  138568. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  138569. /**
  138570. * Hide ctor from the rest of the world.
  138571. * @param items The items to add.
  138572. */
  138573. function Stage(items) {
  138574. return _super.apply(this, items) || this;
  138575. }
  138576. /**
  138577. * Creates a new Stage.
  138578. * @returns A new instance of a Stage
  138579. */
  138580. Stage.Create = function () {
  138581. return Object.create(Stage.prototype);
  138582. };
  138583. /**
  138584. * Registers a step in an ordered way in the targeted stage.
  138585. * @param index Defines the position to register the step in
  138586. * @param component Defines the component attached to the step
  138587. * @param action Defines the action to launch during the step
  138588. */
  138589. Stage.prototype.registerStep = function (index, component, action) {
  138590. var i = 0;
  138591. var maxIndex = Number.MAX_VALUE;
  138592. for (; i < this.length; i++) {
  138593. var step = this[i];
  138594. maxIndex = step.index;
  138595. if (index < maxIndex) {
  138596. break;
  138597. }
  138598. }
  138599. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  138600. };
  138601. /**
  138602. * Clears all the steps from the stage.
  138603. */
  138604. Stage.prototype.clear = function () {
  138605. this.length = 0;
  138606. };
  138607. return Stage;
  138608. }(Array));
  138609. /***/ })
  138610. /******/ });
  138611. });
  138612. //# sourceMappingURL=babylon.max.js.map